MObject.h
00001 #ifndef MOBJECT_H 00002 #define MOBJECT_H 00003 00004 #include "MUID.h" 00005 //#include "RTypes.h" 00006 #include "MGridMap.h" 00007 #include "MObjectTypes.h" 00008 00009 using namespace std; 00010 #include <algorithm> 00011 00012 class MMap; 00013 class MObject; 00014 00015 typedef MGridMap<MObject*> MObjectGridMap; 00016 00017 00019 #define DECLARE_RTTI() public: static const char* _m_RTTI_szClassName; virtual const char* GetClassName(void){ return _m_RTTI_szClassName; } 00020 00021 #define IMPLEMENT_RTTI(_Class) const char* _Class::_m_RTTI_szClassName = #_Class; 00022 00023 #define ISEQUALCLASS(_Class, _InstancePointer) (_Class::_m_RTTI_szClassName==(_InstancePointer)->GetClassName()) // 포인터 비교 00024 00025 //#define SAFECAST(_Class, _InstancePointer) _InstancePointer- 00026 /* 00028 struct MOBJECTPATH{ 00029 unsigned long int nTime; ///< 해당 시간 00030 rvector Pos; ///< 해당 위치 00031 int nPathNode; ///< Path Node ID 00032 }; 00033 #define MOBJECTMOVE MOBJECTPATH // 임시, 나중에 이름을 다 바꿔준다. 00034 */ 00035 class MObject; 00036 enum OBJECTCACHESTATE { OBJECTCACHESTATE_KEEP, OBJECTCACHESTATE_NEW, OBJECTCACHESTATE_EXPIRE }; 00037 class MObjectCacheNode { 00038 public: 00039 MObject* m_pObject; 00040 OBJECTCACHESTATE m_CacheState; 00041 }; 00042 class MObjectCache : public list<MObjectCacheNode*> { 00043 int m_nUpdateCount; // New, Expire만 카운트 00044 public: 00045 int GetUpdateCount() { return m_nUpdateCount; } 00046 MObjectCacheNode* FindCacheNode(MObject* pObj); 00047 void Invalidate(); 00048 void Update(MObject* pObject); 00049 void RemoveExpired(); 00050 }; 00051 00052 00054 class MObject{ 00055 protected: 00056 MUID m_UID; 00057 00058 MObjectType m_ObjectType; 00059 private: 00060 //rvector m_Pos; ///< 위치 00061 //rvector m_StartPos, m_EndPos, m_Pos; 00062 //unsigned long int m_nStartTime, m_nEndTime; 00063 00064 // vector<MOBJECTPATH> m_Path; ///< 패스 00065 // rvector m_Pos; ///< 현재 위치 00066 // int m_nSpawnID; 00067 00068 //protected: 00069 // MMap* m_pMap; ///< 현재 속해있는 맵 00070 // MObjectGridMap::HREF m_hRef; ///< 맵에서의 위치 핸들 00071 00072 00073 public: 00074 MObjectCache m_ObjectCache; 00075 list<MUID> m_CommListener; 00076 00077 /* 00078 protected: 00079 void UpdateObjectCache(void); 00080 */ 00081 00082 protected: 00084 // rvector GetPos(unsigned long int nTime); 00085 00086 public: 00087 MObject(); 00088 // MObject(MUID& uid, MMap* pMap, rvector& Pos); // Map Navication Object 00089 MObject(const MUID& uid); // No Map Object 00090 virtual ~MObject(void) {}; 00091 00092 const MUID GetUID(void) const; 00093 00095 // void SetPos(rvector& Pos){ SetPos(0, 0, Pos, Pos); } 00097 // void SetPos(unsigned long int nStartTime, unsigned long int nEndTime, rvector& StartPos, rvector& EndPos); 00099 // void SetPath(MOBJECTPATH* p, int nCount); 00101 // const rvector GetPos(void){ return m_Pos; } 00103 // int GetSpawnID() { return m_nSpawnID; } 00104 // void SetSpawnID(int nSpawnID) { m_nSpawnID = nSpawnID; } 00105 00106 void SetObjectType(MObjectType type) { m_ObjectType = type; } 00107 MObjectType GetObjectType() { return m_ObjectType; } 00108 00109 virtual bool CheckDestroy(int nTime) { return false; } 00110 00112 virtual void Tick(unsigned long int nTime) {} 00113 00115 // void SetMap(MMap* pMap){ m_pMap = pMap; } 00117 // MMap* GetMap(void){ return m_pMap; } 00118 00119 00120 void AddCommListener(MUID ListenerUID); 00121 void RemoveCommListener(MUID ListenerUID); 00122 bool IsCommListener(MUID ListenerUID); 00123 bool HasCommListener() { if (m_CommListener.size() > 0) return true; else return false; } 00124 const MUID GetCommListener() { 00125 if (HasCommListener()) 00126 return *m_CommListener.begin(); 00127 else 00128 return MUID(0,0); 00129 } 00130 00131 void InvalidateObjectCache() { m_ObjectCache.Invalidate(); } 00132 void UpdateObjectCache(MObject* pObject) { m_ObjectCache.Update(pObject); } 00133 void ExpireObjectCache(MObject* pObject) { 00134 MObjectCacheNode* pNode = m_ObjectCache.FindCacheNode(pObject); 00135 if (pNode == NULL) return; 00136 pNode->m_CacheState = OBJECTCACHESTATE_EXPIRE; 00137 } 00138 void RemoveObjectCacheExpired() { m_ObjectCache.RemoveExpired(); } 00139 int GetObjectCacheUpdateCount() { return m_ObjectCache.GetUpdateCount(); } 00140 00141 DECLARE_RTTI() 00142 }; 00143 00144 /* 00146 class MObjectVisible : public MObject{ 00147 public: 00148 MObjectVisible(MUID& uid) : MObject(uid) {} 00149 virtual ~MObjectVisible(void){} 00150 00151 DECLARE_RTTI() 00152 }; 00153 */ 00154 00155 00156 /* 00158 struct MOBJECTBASICINFO{ 00159 MUID uid; 00160 float x, y, z; 00161 }; 00162 00164 struct MOBJECTCACHEINFO{ 00165 MUID uid; 00166 float x, y, z; 00167 00168 MObjectType nObjectType; // 오브젝트 타입 - Character, Item 00169 // union { // 오브젝트 타입에 따라서 달라질 수 있다. 00170 // MCharacterType nChrType; // 캐릭터 타입 - Player, NPC 00171 // }; 00172 00173 OBJECTCACHESTATE nState; 00174 }; 00175 00177 struct MCharacterAttrBasicInfo{ 00178 MUID uid; 00179 int nHP; 00180 int nEN; 00181 }; 00182 00183 00185 unsigned long int MGetTimeToWalk(rvector& Distance); 00187 unsigned long int MGetTimeToTurn(rvector& Dir1, rvector& Dir2); 00188 */ 00189 #endif
MAIET entertainment