Point lights
This commit is contained in:
@@ -15,7 +15,7 @@ class IHydraComponentArray
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class HydraComponentArray : public IHydraComponentArray
|
||||
class HydraComponentArray : public IHydraComponentArray, HydraObject
|
||||
{
|
||||
private:
|
||||
std::array<T, MAX_ACTORS> m_components;
|
||||
@@ -28,11 +28,12 @@ class HydraComponentArray : public IHydraComponentArray
|
||||
void RemoveComponent(HydraID entity_id)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
if(m_entity_to_component.find(entity_id) == m_entity_to_component.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DebugLog("COMPONENT DELETED:" + std::to_string(entity_id) + "\n");
|
||||
HydraID component_index = m_entity_to_component[entity_id];
|
||||
HydraID last_component_index = m_component_count -1;
|
||||
HydraID last_entity_id = m_component_to_entity[last_component_index];
|
||||
@@ -41,15 +42,21 @@ class HydraComponentArray : public IHydraComponentArray
|
||||
{
|
||||
m_components[component_index] = m_components[last_component_index];
|
||||
m_entity_to_component[last_entity_id] = component_index;
|
||||
m_component_to_entity.erase(last_component_index);
|
||||
m_component_to_entity[component_index] = last_entity_id;
|
||||
m_components[last_component_index] = {};
|
||||
DebugLog("COMPONENT MOVED:" + std::to_string(last_entity_id) + "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_components[component_index] = {};
|
||||
m_components[last_component_index] = {};
|
||||
m_entity_to_component.erase(entity_id);
|
||||
m_component_to_entity.erase(last_component_index);
|
||||
}
|
||||
|
||||
m_entity_to_component.erase(entity_id);
|
||||
m_component_to_entity.erase(component_index);
|
||||
|
||||
|
||||
m_component_count--;
|
||||
|
||||
}
|
||||
|
||||
@@ -85,6 +92,10 @@ class HydraComponentArray : public IHydraComponentArray
|
||||
{
|
||||
RemoveComponent(entity_id);
|
||||
}
|
||||
T const * const GetComponents()
|
||||
{
|
||||
return &m_components[0];
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* HYDRACOMPONENTARRAY */
|
||||
|
||||
Reference in New Issue
Block a user