fix bug where priorities were not cleared at end of frame
parent
6f00191258
commit
3ef34d37ae
|
@ -124,6 +124,14 @@ namespace Encompass
|
||||||
Lookup<TComponent>().Clear();
|
Lookup<TComponent>().Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void ClearAllPriorities()
|
||||||
|
{
|
||||||
|
foreach (var store in Stores.Values)
|
||||||
|
{
|
||||||
|
store.ClearPriorities();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void ClearAll()
|
public virtual void ClearAll()
|
||||||
{
|
{
|
||||||
ComponentBitSet.Clear();
|
ComponentBitSet.Clear();
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace Encompass
|
||||||
public abstract bool Remove(int entity, int priority);
|
public abstract bool Remove(int entity, int priority);
|
||||||
public abstract void ForceRemove(int entity);
|
public abstract void ForceRemove(int entity);
|
||||||
public abstract void Clear();
|
public abstract void Clear();
|
||||||
|
public abstract void ClearPriorities();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class TypedComponentStore<TComponent> : TypedComponentStore where TComponent : struct, IComponent
|
internal class TypedComponentStore<TComponent> : TypedComponentStore where TComponent : struct, IComponent
|
||||||
|
@ -73,6 +74,11 @@ namespace Encompass
|
||||||
priorities.Clear();
|
priorities.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void ClearPriorities()
|
||||||
|
{
|
||||||
|
priorities.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<(TComponent, int)> All()
|
public IEnumerable<(TComponent, int)> All()
|
||||||
{
|
{
|
||||||
foreach (var kvp in store)
|
foreach (var kvp in store)
|
||||||
|
|
|
@ -55,6 +55,8 @@ namespace Encompass
|
||||||
internal void WriteComponents()
|
internal void WriteComponents()
|
||||||
{
|
{
|
||||||
existingComponentStore.UpdateUsing(replayStore);
|
existingComponentStore.UpdateUsing(replayStore);
|
||||||
|
existingComponentStore.ClearAllPriorities();
|
||||||
|
upToDateComponentStore.ClearAllPriorities();
|
||||||
immediateComponentStore.ClearAll();
|
immediateComponentStore.ClearAll();
|
||||||
replayStore.ClearAll();
|
replayStore.ClearAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,6 @@ namespace Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Reads(typeof(MockComponent))]
|
[Reads(typeof(MockComponent))]
|
||||||
[WritesImmediate(typeof(MockComponent))]
|
|
||||||
[Writes(typeof(MockComponent))]
|
[Writes(typeof(MockComponent))]
|
||||||
class OverwriteEngine : Engine
|
class OverwriteEngine : Engine
|
||||||
{
|
{
|
||||||
|
@ -106,12 +105,11 @@ namespace Tests
|
||||||
{
|
{
|
||||||
foreach (var (mockComponent, entity) in ReadComponentsIncludingEntity<MockComponent>())
|
foreach (var (mockComponent, entity) in ReadComponentsIncludingEntity<MockComponent>())
|
||||||
{
|
{
|
||||||
SetComponent(entity, new MockComponent { myInt = 420 });
|
SetComponent(entity, new MockComponent { myInt = mockComponent.myInt + 1 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ReadsImmediate(typeof(MockComponent))]
|
|
||||||
[Reads(typeof(MockComponent))]
|
[Reads(typeof(MockComponent))]
|
||||||
class ReadMockComponentEngine : Engine
|
class ReadMockComponentEngine : Engine
|
||||||
{
|
{
|
||||||
|
@ -129,12 +127,20 @@ namespace Tests
|
||||||
worldBuilder.AddEngine(new ReadMockComponentEngine());
|
worldBuilder.AddEngine(new ReadMockComponentEngine());
|
||||||
|
|
||||||
var entity = worldBuilder.CreateEntity();
|
var entity = worldBuilder.CreateEntity();
|
||||||
worldBuilder.SetComponent(entity, new MockComponent { });
|
worldBuilder.SetComponent(entity, new MockComponent { myInt = 420 });
|
||||||
|
|
||||||
var world = worldBuilder.Build();
|
var world = worldBuilder.Build();
|
||||||
world.Update(0.01);
|
world.Update(0.01);
|
||||||
|
|
||||||
Assert.That(gottenMockComponent.myInt, Is.EqualTo(420));
|
Assert.That(gottenMockComponent.myInt, Is.EqualTo(420));
|
||||||
|
|
||||||
|
world.Update(0.01);
|
||||||
|
|
||||||
|
Assert.That(gottenMockComponent.myInt, Is.EqualTo(421));
|
||||||
|
|
||||||
|
world.Update(0.01);
|
||||||
|
|
||||||
|
Assert.That(gottenMockComponent.myInt, Is.EqualTo(422));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Reads(typeof(MockComponent))]
|
[Reads(typeof(MockComponent))]
|
||||||
|
|
Loading…
Reference in New Issue