MMatchNPCObject.h
00001 #ifndef _MMATCHNPCOBJECT_H 00002 #define _MMATCHNPCOBJECT_H 00003 00004 00005 #include "MVector3.h" 00006 #include "MBaseQuest.h" 00007 #include "MUID.h" 00008 #include "MQuestDropTable.h" 00009 #include <map> 00010 using namespace std; 00011 00012 class MMatchStage; 00013 struct MQuestPlayerInfo; 00014 00016 enum NPCOBJECT_FLAG 00017 { 00018 NOF_NONE = 0, 00019 00020 }; 00021 00022 00024 class MMatchNPCObject 00025 { 00026 private: 00027 MUID m_UID; 00028 MQUEST_NPC m_nType; 00029 MUID m_uidController; 00030 MVector3 m_Pos; 00031 unsigned long int m_nFlags; 00032 MQuestDropItem m_DropItem; 00033 public: 00038 MMatchNPCObject(MUID& uid, MQUEST_NPC nType, unsigned long int nFlags=0); 00040 ~MMatchNPCObject() { } 00043 void AssignControl(MUID& uidPlayer); 00045 void ReleaseControl(); 00048 void SetDropItem(MQuestDropItem* pDropItem); 00049 00050 // gets 00051 MUID GetUID() { return m_UID; } 00052 MQUEST_NPC GetType() { return m_nType; } 00053 MUID& GetController() { return m_uidController; } 00054 MQuestDropItem* GetDropItem() { return &m_DropItem; } 00055 00056 inline void SetFlag(unsigned int nFlag, bool bValue); 00057 inline bool CheckFlag(unsigned int nFlag); 00058 inline void SetFlags(unsigned int nFlags); 00059 inline unsigned long GetFlags(); 00060 inline bool HasDropItem(); 00061 00062 }; 00063 00064 typedef map<MUID, MMatchNPCObject*> MMatchNPCObjectMap; 00065 00066 00067 class MQuestPlayerManager; 00068 00070 class MMatchNPCManager 00071 { 00072 private: 00073 // var 00074 MMatchStage* m_pStage; 00075 MQuestPlayerManager* m_pPlayerManager; 00076 MMatchNPCObjectMap m_NPCObjectMap; 00077 00078 unsigned long int m_nLastSpawnTime; // for test 00079 00080 int m_nNPCCount[MNST_END]; // 스폰타입별 살아있는 NPC수 00081 00082 // func 00083 MUID NewUID(); 00084 bool AssignControl(MUID& uidNPC, MUID& uidPlayer); 00085 bool Spawn(MUID& uidNPC, MUID& uidController, unsigned char nSpawnPositionIndex); 00086 void Clear(); 00087 bool FindSuitableController(MUID& out, MQuestPlayerInfo* pSender); 00088 00089 void SetNPCObjectToControllerInfo(MUID& uidChar, MMatchNPCObject* pNPCObject); 00090 void DelNPCObjectToControllerInfo(MUID& uidChar, MMatchNPCObject* pNPCObject); 00091 public: 00093 MMatchNPCManager(); 00095 ~MMatchNPCManager(); 00099 void Create(MMatchStage* pStage, MQuestPlayerManager* pPlayerManager); 00101 void Destroy(); 00103 void ClearNPC(); 00107 MMatchNPCObject* CreateNPCObject(MQUEST_NPC nType, unsigned char nSpawnPositionIndex); 00111 bool DestroyNPCObject(MUID& uidNPC, MQuestDropItem& outItem); 00114 MMatchNPCObject* GetNPCObject(MUID& uidNPC); 00117 void OnDelPlayer(MUID& uidPlayer); 00121 bool IsControllersNPC(MUID& uidChar, MUID& uidNPC); 00123 int GetNPCObjectCount(); 00126 int GetNPCObjectCount(MQuestNPCSpawnType nSpawnType); 00127 }; 00128 00129 00130 00131 // inlines ////////////////////////////////////////////////////////////////////////////////// 00132 inline void MMatchNPCObject::SetFlags(unsigned int nFlags) 00133 { 00134 if (m_nFlags != nFlags) 00135 { 00136 m_nFlags = nFlags; 00137 } 00138 } 00139 00140 inline void MMatchNPCObject::SetFlag(unsigned int nFlag, bool bValue) 00141 { 00142 if (bValue) m_nFlags |= nFlag; 00143 else m_nFlags &= ~nFlag; 00144 } 00145 00146 inline bool MMatchNPCObject::CheckFlag(unsigned int nFlag) 00147 { 00148 return ((m_nFlags & nFlag) != 0); 00149 } 00150 00151 inline unsigned long MMatchNPCObject::GetFlags() 00152 { 00153 return m_nFlags; 00154 } 00155 00156 inline int MMatchNPCManager::GetNPCObjectCount() 00157 { 00158 return (int)m_NPCObjectMap.size(); 00159 } 00160 00161 inline bool MMatchNPCObject::HasDropItem() 00162 { 00163 return (m_DropItem.nDropItemType != QDIT_NA); 00164 } 00165 00166 00167 inline int MMatchNPCManager::GetNPCObjectCount(MQuestNPCSpawnType nSpawnType) 00168 { 00169 return m_nNPCCount[nSpawnType]; 00170 } 00171 00172 00173 #endif
MAIET entertainment