Clone of PhatAC @ https://github.com/floaterxk/PhatAC

LandBlock.h 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #pragma once
  2. //
  3. #include "PhysicsObj.h"
  4. #include "Monster.h"
  5. #include "Player.h"
  6. typedef stdext::hash_map<DWORD, CPhysicsObj *> EntityMap;
  7. typedef std::vector<CPhysicsObj *> EntityVector;
  8. typedef stdext::hash_map<DWORD, CBasePlayer *> PlayerMap;
  9. typedef std::vector<CBasePlayer *> PlayerVector;
  10. //
  11. class CWorld;
  12. #ifdef _DEBUG
  13. #define DELETE_ENTITY(x) OutputDebugString(csprintf("Delete Entity %u(%08X) @ %s:%u\r\n", pEntity->m_dwGUID, (DWORD)pEntity, __FUNCTION__)); delete pEntity
  14. #else
  15. #define DELETE_ENTITY(x) delete pEntity
  16. #endif
  17. //
  18. class CLandBlock
  19. {
  20. public:
  21. CLandBlock(CWorld *pWorld, WORD wHeader);
  22. ~CLandBlock();
  23. WORD GetHeader();
  24. BOOL Think();
  25. void SetEntityLive(CPhysicsObj *pEntity);
  26. void ClearSpawns();
  27. void Insert(CPhysicsObj *pEntity, WORD wOld = 0, BOOL bNew = FALSE);
  28. void Destroy(CPhysicsObj *pEntity);
  29. void Release(CPhysicsObj *pEntity);
  30. void ExchangePVS(CPhysicsObj *pSource, WORD wOld);
  31. void ExchangeData(CPhysicsObj *pSource);
  32. CBasePlayer* FindPlayer(DWORD dwGUID);
  33. CPhysicsObj* FindEntity(DWORD dwGUID);
  34. void Broadcast(void *_data, DWORD _len, WORD _group, DWORD ignore_ent, BOOL _game_event);
  35. DWORD PlayerCount() { return (DWORD)m_vPlayers.size(); }
  36. DWORD LiveCount() { return (DWORD)m_vLiveEnts.size(); }
  37. DWORD DormantCount() { return (DWORD)m_vDormantEnts.size(); }
  38. void EnumNearby(CPhysicsObj *pSource, float fRange, std::list<CPhysicsObj *> *pResults);
  39. protected:
  40. CWorld* m_pWorld;
  41. WORD m_wHeader;
  42. PlayerMap m_mPlayers;
  43. EntityMap m_mEntities;
  44. PlayerVector m_vPlayers; //Players, used for message broadcasting.
  45. EntityVector m_vSpawnEnts;
  46. EntityVector m_vLiveEnts;
  47. EntityVector m_vDormantEnts; //Entities that do not think are "DEAD"
  48. BOOL m_bThinking;
  49. double m_fDeathTime;
  50. };