From 7029b9f52e50995b0a3efb923d033eb461449557 Mon Sep 17 00:00:00 2001 From: Evan Hemsley Date: Mon, 23 Dec 2019 20:15:01 -0800 Subject: [PATCH] tightening up component write logic --- encompass-cs/ComponentUpdateManager.cs | 17 ++++++++++++++--- encompass-cs/UberEngine.cs | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/encompass-cs/ComponentUpdateManager.cs b/encompass-cs/ComponentUpdateManager.cs index a2d9849..db166d2 100644 --- a/encompass-cs/ComponentUpdateManager.cs +++ b/encompass-cs/ComponentUpdateManager.cs @@ -59,13 +59,24 @@ namespace Encompass internal bool RemoveImmediate(Entity entity, int priority) where TComponent : struct, IComponent { - UpToDateComponentStore.Remove(entity.ID, priority); - return immediateComponentStore.Remove(entity.ID, priority); + if (immediateComponentStore.Remove(entity.ID, priority)) + { + UpToDateComponentStore.Remove(entity.ID, priority); + return true; + } + + return false; } internal bool Remove(Entity entity, int priority) where TComponent : struct, IComponent { - return UpToDateComponentStore.Remove(entity.ID, priority); + if (existingComponentStore.Remove(entity.ID, priority)) + { + UpToDateComponentStore.Remove(entity.ID, priority); + return true; + } + + return false; } private void RegisterExistingOrImmediateComponentMessage(Entity entity, TComponent component) where TComponent : struct, IComponent diff --git a/encompass-cs/UberEngine.cs b/encompass-cs/UberEngine.cs index 96a74b7..7f8259d 100644 --- a/encompass-cs/UberEngine.cs +++ b/encompass-cs/UberEngine.cs @@ -47,9 +47,9 @@ namespace Encompass CallGenericMethod(type, "GetComponent", new Type[] { typeof(Entity) }, new object[] { Entity }); CallGenericMethod(type, "HasComponent", new Type[] { typeof(Entity) }, new object[] { Entity }); CallGenericMethod(type, "SomeComponent", null); - CallGenericMethod(type, "RemoveComponent", new Type[] { typeof(Entity) }, new object[] { Entity }); CallGenericMethod(type, "DestroyWith", null); CallGenericMethod(type, "DestroyAllWith", null); + CallGenericMethod(type, "RemoveComponent", new Type[] { typeof(Entity) }, new object[] { Entity }); } foreach (var type in _messageTypes)