EntityManager.h 823 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. #include <map>
  3. #include <mutex>
  4. #include "Entity.h"
  5. #include "IEntityFilter.h"
  6. namespace cheat::game {
  7. class EntityManager {
  8. public:
  9. static EntityManager& getInstance();
  10. Entity* entity(app::BaseEntity*);
  11. Entity* entity(uint32_t runtimeID, bool unsafe = false);
  12. Entity* avatar();
  13. std::vector<app::BaseEntity*> rawEntities();
  14. std::vector<Entity*> entities();
  15. std::vector<Entity*> entities(const IEntityFilter& filter);
  16. typedef bool (*Validator)(game::Entity* entity);
  17. std::vector<Entity*> entities(Validator validator);
  18. app::CameraEntity* mainCamera();
  19. private:
  20. EntityManager();
  21. std::mutex m_EntityCacheLock;
  22. std::map<app::BaseEntity*, std::pair<Entity*, uint32_t>> m_EntityCache;
  23. Entity m_AvatarEntity;
  24. inline static Entity* s_EmptyEntity = new Entity(nullptr);
  25. };
  26. }