📄 msg.h.svn-base
字号:
/* Copyright (C) Steve Rabin, 2000. * All rights reserved worldwide. * * This software is provided "as is" without express or implied * warranties. You may freely copy and compile this source into * applications you distribute provided that the copyright text * below is included in the resulting source code, for example: * "Portions Copyright (C) Steve Rabin, 2000" */////////////////////////////////////////////////////////////////// Filename: msg.h//// Author: Steve Rabin// E-mail: stevera@noa.nintendo.com// From the book "Game Programming Gems"// From the article "Designing a General Robust AI Engine"//// Brief Disclaimer:// This code is free to use for commercial use and is in the// public domain. You may distribute, copy, modify, or use as// is as long as this information is present. This code makes// no guarantees written or implied and is provided solely as// an example. Have a nice day!//// Purpose:// This file contains the definition of a message along with// an enumerated type of all messages within the game.////////////////////////////////////////////////////////////////#ifndef _MSG_H#define _MSG_H#include "../gamedata/Structs.h"//定义各种消息类型。是否要像这样全都放到一起我不是很清楚。typedef enum { MSG_NULL, MSG_RESERVED_Enter, //Don't send this message - the system sends this when a state is first entered - Use OnInitialize to listen for it MSG_RESERVED_Exit, //Don't send this message - the system sends this when a state is exited - Use OnExit to listen for it MSG_RESERVED_Update, //Don't send this message - the system sends this when a game tick goes by - Use OnUpdate to listen for it MSG_CalcNewPos, //通知各个人物让他们计算自己的新位置,好进行碰撞检测 MSG_Timeout, //超时 MSG_ChangeState, //目前没用到 MSG_Rotate, //目前没用到 MSG_Stand, //好像是没用到,不记得了 MSG_Run, //开始跑 MSG_Move, //目前没用到 MSG_Attack, //开始进攻,用没用到不记得了 MSG_Damage, //受到伤害,即,被火球击中时 MSG_GameStart, //开始进入游戏 MSG_GamePause, //暂停游戏,目前没用到 MSG_GameExcuteScript, //开始执行脚本动画 MSG_GamePlayerDie, //player死了 MSG_GameBossSeen, //看见boss了,目前好像没用到 MSG_GameBossDie, //boss死了 MSG_CameraWithPlayer, //摄像机跟随player MSG_CameraFree, //摄像机自由移动 MSG_CameraSetLookAt, //设置摄像机看的位置 MSG_CameraSetPosition, //设置摄像机的位置 MSG_CameraSetUp, //设置摄像机的头顶的方向 MSG_CameraAuto, //摄像机转为auto模式 MSG_CameraSetDest, //设置摄像机的目的地 MSG_ScriptSetDest, //设置脚本动画中人物的目的地 MSG_ScriptSetPosition, //设置脚本动画中人物的位置 MSG_ScriptSetDirection //设置脚本动画中人物的方向} MsgName;//每种消息可能携带不同的信息,原本是要定义为union,后来由于奇怪的编译原因改为struct。typedef struct { float rotY; //设置方向时用到 struct Vertex pos; //设置位置时用到 unsigned long time; //设置时间时用到 float damage; //设置伤害值时用到} extra_data;//消息对象,所有的消息的格式是统一的,不同的消息可能携带不同类型的ex,这个目前就是硬记住的,怎么改进还没想好。typedef struct{ MsgName name; //name of message (an enumerated type works well) unsigned int sender_id; //unique id of sender unsigned int receiver_id; //unique id of receiver unsigned int delivery_time; //deliver message at this time unsigned int state; // 此消息只针对这个state有效 extra_data ex; //其他信息 //Note that the sender_id and receiver_id are not pointers to game objects. //Since messages can be delayed, the sender or receiver may get removed //from the game and a pointer would become dangerously invalid. //You can add right here any data you want to be passed //along with every message - sometimes it's helpful to let //messages convey more info by using extra data. //For example, a damaged message could carry with it the amount of damage} MsgObject;#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -