fix creating new component index on every set
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
98955f3048
commit
ffc052ded3
|
@ -50,10 +50,13 @@ namespace Encompass
|
||||||
|
|
||||||
private unsafe void InternalSet(int entityID, TComponent component)
|
private unsafe void InternalSet(int entityID, TComponent component)
|
||||||
{
|
{
|
||||||
var index = _idManager.NextID();
|
if (!indices.ContainsKey(entityID))
|
||||||
|
{
|
||||||
|
indices[entityID] = _idManager.NextID();
|
||||||
|
}
|
||||||
|
|
||||||
var ptr = Unsafe.AsPointer(ref component);
|
var ptr = Unsafe.AsPointer(ref component);
|
||||||
indices[entityID] = index;
|
components[indices[entityID]] = Unsafe.AsRef<TComponent>(ptr);
|
||||||
components[index] = Unsafe.AsRef<TComponent>(ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Remove(int entityID, int priority)
|
public override bool Remove(int entityID, int priority)
|
||||||
|
@ -84,6 +87,10 @@ namespace Encompass
|
||||||
|
|
||||||
public override void Clear()
|
public override void Clear()
|
||||||
{
|
{
|
||||||
|
foreach (var entityID in indices.Keys)
|
||||||
|
{
|
||||||
|
_idManager.Free(entityID);
|
||||||
|
}
|
||||||
indices.Clear();
|
indices.Clear();
|
||||||
priorities.Clear();
|
priorities.Clear();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue