// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #pragma once #ifndef NDK_WORLD_HPP #define NDK_WORLD_HPP #include #include #include #include #include #include #include #include #include namespace Ndk { class NDK_API World : NzNonCopyable { friend Entity; public: using EntityList = std::vector; inline World(bool addDefaultSystems = true); ~World(); void AddDefaultSystems(); inline BaseSystem& AddSystem(std::unique_ptr&& system); template SystemType& AddSystem(Args&&... args); const EntityHandle& CreateEntity(); inline EntityList CreateEntities(unsigned int count); void Clear(); const EntityHandle& GetEntity(EntityId id); inline const EntityList& GetEntities(); inline BaseSystem& GetSystem(SystemIndex index); template SystemType& GetSystem(); inline bool HasSystem(SystemIndex index) const; template bool HasSystem() const; void KillEntity(Entity* entity); inline void KillEntities(const EntityList& list); inline bool IsEntityValid(const Entity* entity) const; inline bool IsEntityIdValid(EntityId id) const; inline void RemoveAllSystems(); inline void RemoveSystem(SystemIndex index); template void RemoveSystem(); void Update(); inline void Update(float elapsedTime); private: inline void Invalidate(); inline void Invalidate(EntityId id); struct EntityBlock { EntityBlock(Entity&& e) : entity(std::move(e)) { } EntityBlock(EntityBlock&& block) = default; Entity entity; unsigned int aliveIndex; }; std::vector> m_systems; std::vector m_entities; std::vector m_freeIdList; EntityList m_aliveEntities; NzBitset m_dirtyEntities; NzBitset m_killedEntities; }; } #include #endif // NDK_WORLD_HPP