triggersystem.h
来自「C人工智能游戏开发的一些实例源代码 C Game development in 」· C头文件 代码 · 共 64 行
H
64 行
#ifndef __TRIGGER_SYSTEM_H__
#define __TRIGGER_SYSTEM_H__
#include "Vector.h"
#pragma warning(disable:4786)
#include <Map>
enum EnumTriggerType
{
kTrig_None = 0,
kTrig_Explosion = (1 << 0),
kTrig_EnemyNear = (1 << 1),
kTrig_Gunfire = (1 << 2),
};
struct TriggerRecordStruct
{
TriggerRecordStruct(EnumTriggerType _eTriggerType,
unsigned long _idSource, const Vector& _vPos,
float _fRadius, float _fDuration, bool _bDynamicSourcePos);
EnumTriggerType eTriggerType; // Type of trigger.
unsigned long nTriggerID; // Registration ID assigned by the TriggerSystem.
unsigned long idSource; // ID of source of trigger.
Vector vPos; // Position in world of trigger.
float fRadius; // Distance from source that trigger affects.
unsigned long nTimeStamp; // When trigger occured.
unsigned long nExpirationTime; // When trigger expires.
bool bDynamicSourcePos; // Lookup position of trigger source every update.
static unsigned long s_nNextTriggerID; // Next unique Registration ID for trigger.
};
typedef std::multimap<unsigned short /*nPriority*/, TriggerRecordStruct*, std::greater<unsigned short> > TRIGGER_MAP;
class CTriggerSystem
{
public :
CTriggerSystem();
~CTriggerSystem();
unsigned long RegisterTrigger(EnumTriggerType _eTriggerType, unsigned long _nPriority,
unsigned long _idSource, const Vector& _vPos, float _fRadius,
float _fDuration, bool _bDynamicSourcePos);
void RemoveTrigger(unsigned long nTriggerID);
void Update();
private :
TRIGGER_MAP m_mapTriggerMap; // List of existing triggers, sorted by priority.
bool m_bTriggerCriticalSection;
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?