tightening up component write logic

pull/5/head
Evan Hemsley 2019-12-23 20:15:01 -08:00
parent bd17a86dec
commit 7029b9f52e
2 changed files with 15 additions and 4 deletions

View File

@ -58,14 +58,25 @@ namespace Encompass
} }
internal bool RemoveImmediate<TComponent>(Entity entity, int priority) where TComponent : struct, IComponent internal bool RemoveImmediate<TComponent>(Entity entity, int priority) where TComponent : struct, IComponent
{
if (immediateComponentStore.Remove<TComponent>(entity.ID, priority))
{ {
UpToDateComponentStore.Remove<TComponent>(entity.ID, priority); UpToDateComponentStore.Remove<TComponent>(entity.ID, priority);
return immediateComponentStore.Remove<TComponent>(entity.ID, priority); return true;
}
return false;
} }
internal bool Remove<TComponent>(Entity entity, int priority) where TComponent : struct, IComponent internal bool Remove<TComponent>(Entity entity, int priority) where TComponent : struct, IComponent
{ {
return UpToDateComponentStore.Remove<TComponent>(entity.ID, priority); if (existingComponentStore.Remove<TComponent>(entity.ID, priority))
{
UpToDateComponentStore.Remove<TComponent>(entity.ID, priority);
return true;
}
return false;
} }
private void RegisterExistingOrImmediateComponentMessage<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent private void RegisterExistingOrImmediateComponentMessage<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent

View File

@ -47,9 +47,9 @@ namespace Encompass
CallGenericMethod(type, "GetComponent", new Type[] { typeof(Entity) }, new object[] { Entity }); CallGenericMethod(type, "GetComponent", new Type[] { typeof(Entity) }, new object[] { Entity });
CallGenericMethod(type, "HasComponent", new Type[] { typeof(Entity) }, new object[] { Entity }); CallGenericMethod(type, "HasComponent", new Type[] { typeof(Entity) }, new object[] { Entity });
CallGenericMethod(type, "SomeComponent", null); CallGenericMethod(type, "SomeComponent", null);
CallGenericMethod(type, "RemoveComponent", new Type[] { typeof(Entity) }, new object[] { Entity });
CallGenericMethod(type, "DestroyWith", null); CallGenericMethod(type, "DestroyWith", null);
CallGenericMethod(type, "DestroyAllWith", null); CallGenericMethod(type, "DestroyAllWith", null);
CallGenericMethod(type, "RemoveComponent", new Type[] { typeof(Entity) }, new object[] { Entity });
} }
foreach (var type in _messageTypes) foreach (var type in _messageTypes)