-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathentitymanager.inl
More file actions
28 lines (23 loc) · 1.25 KB
/
entitymanager.inl
File metadata and controls
28 lines (23 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
template<class DataType>
const DataType& EntityManager::getAttribute(const EntityId id, const std::string& attribute) const
{
FEA_ASSERT(mEntities.find(id) != mEntities.end(), "Trying to get the attribute '" + attribute + "' on entity entity ID '" + std::to_string(id) + "' but such an entity doesn't exist!");
return mStorage.getData<DataType>(id, attribute);
}
template<class DataType>
DataType& EntityManager::getAttribute(const EntityId id, const std::string& attribute)
{
FEA_ASSERT(mEntities.find(id) != mEntities.end(), "Trying to get the attribute '" + attribute + "' on entity entity ID '" + std::to_string(id) + "' but such an entity doesn't exist!");
return mStorage.getData<DataType>(id, attribute);
}
template<class DataType>
void EntityManager::setAttribute(const EntityId id, const std::string& attribute, DataType attributeData)
{
FEA_ASSERT(mEntities.find(id) != mEntities.end(), "Trying to get the attribute '" + attribute + "' on entity entity ID '" + std::to_string(id) + "' but such an entity doesn't exist!");
mStorage.setData(id, attribute, std::move(attributeData));
}
template<class DataType>
void EntityManager::registerAttribute(const std::string& attribute)
{
mStorage.registerAttribute<DataType>(attribute);
}