From 94875dceb13b18499ebd5ca1552ecaf1ad2fe16c Mon Sep 17 00:00:00 2001 From: Pixeye Date: Sun, 23 Jun 2019 20:00:15 +0200 Subject: [PATCH] Update --- Runtime/LibEcs/Entity.Handle.Delayed.cs | 1 + Runtime/LibProcessors/ProcessorEntities.cs | 38 +++++++++++++++------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Runtime/LibEcs/Entity.Handle.Delayed.cs b/Runtime/LibEcs/Entity.Handle.Delayed.cs index df20f60a..5fe89b24 100644 --- a/Runtime/LibEcs/Entity.Handle.Delayed.cs +++ b/Runtime/LibEcs/Entity.Handle.Delayed.cs @@ -30,6 +30,7 @@ public enum Action : byte Remove, Kill, KillFinalize, + Empty, Activate, Deactivate, Unbind, diff --git a/Runtime/LibProcessors/ProcessorEntities.cs b/Runtime/LibProcessors/ProcessorEntities.cs index 7c787533..8c5d8efb 100644 --- a/Runtime/LibProcessors/ProcessorEntities.cs +++ b/Runtime/LibProcessors/ProcessorEntities.cs @@ -206,21 +206,37 @@ public void Tick(float delta) ref var components = ref Entity.components[entityID]; components.Remove(operation.arg); - // if (components.amount == 0) - // { - // if (Entity.transforms.Length > entityID && Entity.transforms[entityID] != null) - // { - // Entity.transforms[entityID].gameObject.Release(Entity.cache[entityID].isPooled ? Pool.Entities : 0); - // Entity.transforms[entityID] = null; - // } - // - // Entity.tags[entityID].Clear(); - // EntityOperations.Set(operation.entity, 0, EntityOperations.Action.KillFinalize); - // } + if (components.amount == 0) + { + EntityOperations.Set(operation.entity, 0, EntityOperations.Action.Empty); + } break; } + case EntityOperations.Action.Empty: + { + + if (!operation.entity.Exist) continue; + + ref var components = ref Entity.components[entityID]; + + if (Entity.transforms.Length > entityID && Entity.transforms[entityID] != null) + { + Entity.transforms[entityID].gameObject.Release(Entity.cache[entityID].isPooled ? Pool.Entities : 0); + Entity.transforms[entityID] = null; + } + + Entity.tags[entityID].Clear(); + Entity.cache[entityID].isAlive = false; + Entity.Count--; + + EntityOperations.Set(operation.entity, 0, EntityOperations.Action.KillFinalize); + + + break; + } + case EntityOperations.Action.ChangeTag: { if (!Entity.cache[entityID].isAlive) continue;