Fix acronym naming standard
- Now follow standard that acronyms should only capitalize the first letter
This commit is contained in:
@@ -16,12 +16,12 @@ namespace Copium
|
||||
std::vector<Component> components;
|
||||
|
||||
public:
|
||||
ComponentPool(EntityID entity, const Component& component)
|
||||
ComponentPool(EntityId entity, const Component& component)
|
||||
{
|
||||
Emplace(entity, component);
|
||||
}
|
||||
|
||||
Component& Emplace(EntityID entity, const Component& component)
|
||||
Component& Emplace(EntityId entity, const Component& component)
|
||||
{
|
||||
components.push_back(component);
|
||||
entities.Emplace(entity);
|
||||
@@ -34,7 +34,7 @@ namespace Copium
|
||||
entities.Pop();
|
||||
}
|
||||
|
||||
bool Erase(EntityID entity)
|
||||
bool Erase(EntityId entity)
|
||||
{
|
||||
size_t index = entities.Find(entity);
|
||||
if (!entities.Erase(entity))
|
||||
@@ -48,12 +48,12 @@ namespace Copium
|
||||
return operator[](index);
|
||||
}
|
||||
|
||||
size_t Find(EntityID entity)
|
||||
size_t Find(EntityId entity)
|
||||
{
|
||||
return entities.Find(entity);
|
||||
}
|
||||
|
||||
Component* FindComponent(EntityID entity)
|
||||
Component* FindComponent(EntityId entity)
|
||||
{
|
||||
size_t index = Find(entity);
|
||||
if (index < Size())
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
std::vector<EntityID>& ComponentPoolBase::GetEntities()
|
||||
std::vector<EntityId>& ComponentPoolBase::GetEntities()
|
||||
{
|
||||
return entities.GetList();
|
||||
}
|
||||
|
||||
const std::vector<EntityID>& ComponentPoolBase::GetEntities() const
|
||||
const std::vector<EntityId>& ComponentPoolBase::GetEntities() const
|
||||
{
|
||||
return entities.GetList();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace Copium
|
||||
|
||||
virtual size_t Size() = 0;
|
||||
virtual void Pop() = 0;
|
||||
virtual bool Erase(EntityID entity) = 0;
|
||||
std::vector<EntityID>& GetEntities();
|
||||
const std::vector<EntityID>& GetEntities() const;
|
||||
virtual bool Erase(EntityId entity) = 0;
|
||||
std::vector<EntityId>& GetEntities();
|
||||
const std::vector<EntityId>& GetEntities() const;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
using EntityID = uint32_t;
|
||||
using EntityId = uint32_t;
|
||||
const static uint32_t MAX_NUM_ENTITIES = std::numeric_limits<uint32_t>::max();
|
||||
const static uint32_t INVALID_ENTITY = 0;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Copium
|
||||
return entities.size();
|
||||
}
|
||||
|
||||
EntityID ECSManager::CreateEntity()
|
||||
EntityId ECSManager::CreateEntity()
|
||||
{
|
||||
CP_ASSERT(currentEntityId != MAX_NUM_ENTITIES, "No more entities available");
|
||||
entities.emplace(currentEntityId);
|
||||
@@ -35,7 +35,7 @@ namespace Copium
|
||||
return currentEntityId - 1;
|
||||
}
|
||||
|
||||
void ECSManager::DestroyEntity(EntityID entity)
|
||||
void ECSManager::DestroyEntity(EntityId entity)
|
||||
{
|
||||
auto it = entities.find(entity);
|
||||
CP_ASSERT(it != entities.end(), "Entity does not exist in ECSManager (entity=%u)", entity);
|
||||
@@ -46,12 +46,12 @@ namespace Copium
|
||||
}
|
||||
}
|
||||
|
||||
bool ECSManager::ValidEntity(EntityID entity)
|
||||
bool ECSManager::ValidEntity(EntityId entity)
|
||||
{
|
||||
return entities.find(entity) != entities.end();
|
||||
}
|
||||
|
||||
void ECSManager::Each(std::function<void(EntityID)> function)
|
||||
void ECSManager::Each(std::function<void(EntityId)> function)
|
||||
{
|
||||
for (auto e : entities)
|
||||
function(e);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Copium
|
||||
class ECSManager final
|
||||
{
|
||||
private:
|
||||
std::unordered_set<EntityID> entities;
|
||||
std::unordered_set<EntityId> entities;
|
||||
std::map<std::type_index, ComponentPoolBase*> componentPool;
|
||||
|
||||
std::unique_ptr<SystemPool> systemPool;
|
||||
@@ -34,26 +34,26 @@ namespace Copium
|
||||
|
||||
void UpdateSystems();
|
||||
|
||||
EntityID CreateEntity();
|
||||
void DestroyEntity(EntityID entity);
|
||||
EntityId CreateEntity();
|
||||
void DestroyEntity(EntityId entity);
|
||||
size_t GetEntityCount() const;
|
||||
bool ValidEntity(EntityID entity);
|
||||
void Each(std::function<void(EntityID)> function);
|
||||
bool ValidEntity(EntityId entity);
|
||||
void Each(std::function<void(EntityId)> function);
|
||||
|
||||
template <typename... Components>
|
||||
std::tuple<Components&...> AddComponents(EntityID entity, Components&&... components)
|
||||
std::tuple<Components&...> AddComponents(EntityId entity, Components&&... components)
|
||||
{
|
||||
return std::forward_as_tuple(AddComponent(entity, Components(components))...);
|
||||
}
|
||||
|
||||
template <typename Component, typename... Args>
|
||||
Component& AddComponent(EntityID entity, Args&&... args)
|
||||
Component& AddComponent(EntityId entity, Args&&... args)
|
||||
{
|
||||
return AddComponent(entity, Component{args...});
|
||||
}
|
||||
|
||||
template <typename Component>
|
||||
Component& AddComponent(EntityID entity, const Component& component)
|
||||
Component& AddComponent(EntityId entity, const Component& component)
|
||||
{
|
||||
auto pool = GetComponentPool<Component>();
|
||||
|
||||
@@ -71,20 +71,20 @@ namespace Copium
|
||||
}
|
||||
|
||||
template <typename Component>
|
||||
void RemoveComponent(EntityID entity)
|
||||
void RemoveComponent(EntityId entity)
|
||||
{
|
||||
auto pool = GetComponentPoolAssure<Component>();
|
||||
CP_ASSERT(pool->Erase(entity), "Entity did not contain component (entity=%u, Component=%s)", entity, typeid(Component).name());
|
||||
}
|
||||
|
||||
template <typename... Components>
|
||||
void RemoveComponents(EntityID entity)
|
||||
void RemoveComponents(EntityId entity)
|
||||
{
|
||||
(RemoveComponent<Components>(entity), ...);
|
||||
}
|
||||
|
||||
template <typename Component>
|
||||
Component& GetComponent(EntityID entity)
|
||||
Component& GetComponent(EntityId entity)
|
||||
{
|
||||
auto pool = GetComponentPoolAssure<Component>();
|
||||
Component* component = pool->FindComponent(entity);
|
||||
@@ -93,7 +93,7 @@ namespace Copium
|
||||
}
|
||||
|
||||
template <typename Component>
|
||||
bool HasComponent(EntityID entity)
|
||||
bool HasComponent(EntityId entity)
|
||||
{
|
||||
auto pool = GetComponentPool<Component>();
|
||||
if (pool)
|
||||
@@ -102,13 +102,13 @@ namespace Copium
|
||||
}
|
||||
|
||||
template <typename... Components>
|
||||
bool HasComponents(EntityID entity)
|
||||
bool HasComponents(EntityId entity)
|
||||
{
|
||||
return (HasComponent<Components>(entity) && ...);
|
||||
}
|
||||
|
||||
template <typename... Components>
|
||||
bool HasAnyComponent(EntityID entity)
|
||||
bool HasAnyComponent(EntityId entity)
|
||||
{
|
||||
return (HasComponent<Components>(entity) || ...);
|
||||
}
|
||||
@@ -132,7 +132,7 @@ namespace Copium
|
||||
}
|
||||
|
||||
template <typename Component>
|
||||
void Each(std::function<void(EntityID, Component&)> function)
|
||||
void Each(std::function<void(EntityId, Component&)> function)
|
||||
{
|
||||
auto pool = GetComponentPool<Component>();
|
||||
if (pool)
|
||||
@@ -147,7 +147,7 @@ namespace Copium
|
||||
}
|
||||
|
||||
template <typename Component, typename... Components, typename Func>
|
||||
EntityID Find(Func function)
|
||||
EntityId Find(Func function)
|
||||
{
|
||||
auto pool = GetComponentPool<Component>();
|
||||
if (pool)
|
||||
@@ -167,7 +167,7 @@ namespace Copium
|
||||
}
|
||||
|
||||
template <typename Component>
|
||||
EntityID Find(std::function<bool(EntityID, Component&)> function)
|
||||
EntityId Find(std::function<bool(EntityId, Component&)> function)
|
||||
{
|
||||
auto pool = GetComponentPool<Component>();
|
||||
if (pool)
|
||||
|
||||
@@ -10,16 +10,16 @@ namespace Copium
|
||||
: manager{manager}, id{INVALID_ENTITY}
|
||||
{}
|
||||
|
||||
Entity::Entity(ECSManager* manager, EntityID id)
|
||||
Entity::Entity(ECSManager* manager, EntityId id)
|
||||
: manager{manager}, id{id}
|
||||
{}
|
||||
|
||||
Entity::operator EntityID() const
|
||||
Entity::operator EntityId() const
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
void Entity::operator=(EntityID entityId)
|
||||
void Entity::operator=(EntityId entityId)
|
||||
{
|
||||
id = entityId;
|
||||
}
|
||||
@@ -54,12 +54,12 @@ namespace Copium
|
||||
manager->DestroyEntity(id);
|
||||
}
|
||||
|
||||
void Entity::SetID(EntityID aId)
|
||||
void Entity::SetId(EntityId entityId)
|
||||
{
|
||||
id = aId;
|
||||
id = entityId;
|
||||
}
|
||||
|
||||
EntityID Entity::GetID() const
|
||||
EntityId Entity::GetId() const
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -11,23 +11,23 @@ namespace Copium
|
||||
|
||||
private:
|
||||
ECSManager* manager;
|
||||
EntityID id;
|
||||
EntityId id;
|
||||
|
||||
public:
|
||||
Entity();
|
||||
Entity(ECSManager* manager);
|
||||
Entity(ECSManager* manager, EntityID id);
|
||||
Entity(ECSManager* manager, EntityId id);
|
||||
|
||||
operator EntityID() const;
|
||||
void operator=(EntityID entityId);
|
||||
operator EntityId() const;
|
||||
void operator=(EntityId entityId);
|
||||
bool operator==(const Entity& entity);
|
||||
bool operator!=(const Entity& entity);
|
||||
operator bool() const;
|
||||
|
||||
void Invalidate();
|
||||
void Destroy();
|
||||
void SetID(EntityID aId);
|
||||
EntityID GetID() const;
|
||||
void SetId(EntityId entityId);
|
||||
EntityId GetId() const;
|
||||
ECSManager* GetManager() const;
|
||||
|
||||
static Entity Create(ECSManager* manager);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
bool EntitySet::Emplace(EntityID entity)
|
||||
bool EntitySet::Emplace(EntityId entity)
|
||||
{
|
||||
auto res = entitiesMap.emplace(entity, entitiesList.size());
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Copium
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EntitySet::Erase(EntityID entity)
|
||||
bool EntitySet::Erase(EntityId entity)
|
||||
{
|
||||
auto it = entitiesMap.find(entity);
|
||||
if (it == entitiesMap.end())
|
||||
@@ -42,7 +42,7 @@ namespace Copium
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t EntitySet::Find(EntityID entity)
|
||||
size_t EntitySet::Find(EntityId entity)
|
||||
{
|
||||
auto it = entitiesMap.find(entity);
|
||||
if (it == entitiesMap.end())
|
||||
@@ -55,9 +55,9 @@ namespace Copium
|
||||
return entitiesList.size();
|
||||
}
|
||||
|
||||
std::vector<EntityID>& EntitySet::GetList() { return entitiesList; }
|
||||
const std::vector<EntityID>& EntitySet::GetList() const { return entitiesList; }
|
||||
std::vector<EntityId>& EntitySet::GetList() { return entitiesList; }
|
||||
const std::vector<EntityId>& EntitySet::GetList() const { return entitiesList; }
|
||||
|
||||
std::vector<EntityID>::iterator EntitySet::begin() { return entitiesList.begin(); }
|
||||
std::vector<EntityID>::iterator EntitySet::end() { return entitiesList.end(); }
|
||||
std::vector<EntityId>::iterator EntitySet::begin() { return entitiesList.begin(); }
|
||||
std::vector<EntityId>::iterator EntitySet::end() { return entitiesList.end(); }
|
||||
}
|
||||
|
||||
@@ -10,18 +10,18 @@ namespace Copium
|
||||
class EntitySet
|
||||
{
|
||||
private:
|
||||
std::vector<EntityID> entitiesList;
|
||||
std::unordered_map<EntityID, size_t> entitiesMap; // Maps the entity id to a component index
|
||||
std::vector<EntityId> entitiesList;
|
||||
std::unordered_map<EntityId, size_t> entitiesMap; // Maps the entity id to a component index
|
||||
public:
|
||||
bool Emplace(EntityID entity);
|
||||
bool Erase(EntityID entity);
|
||||
bool Emplace(EntityId entity);
|
||||
bool Erase(EntityId entity);
|
||||
bool Pop();
|
||||
size_t Find(EntityID entity);
|
||||
size_t Find(EntityId entity);
|
||||
size_t Size() const;
|
||||
std::vector<EntityID>& GetList();
|
||||
const std::vector<EntityID>& GetList() const;
|
||||
std::vector<EntityId>& GetList();
|
||||
const std::vector<EntityId>& GetList() const;
|
||||
|
||||
std::vector<EntityID>::iterator begin();
|
||||
std::vector<EntityID>::iterator end();
|
||||
std::vector<EntityId>::iterator begin();
|
||||
std::vector<EntityId>::iterator end();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Copium
|
||||
public:
|
||||
void Run() override
|
||||
{
|
||||
manager->Each<Components...>([&](EntityID entityId, Components&... components) { RunEntity(Entity{manager, entityId}, components...); });
|
||||
manager->Each<Components...>([&](EntityId entityId, Components&... components) { RunEntity(Entity{manager, entityId}, components...); });
|
||||
}
|
||||
|
||||
virtual void RunEntity(Entity entity, Components&... components) = 0;
|
||||
|
||||
Reference in New Issue
Block a user