This commit is contained in:
CortexCore 2024-06-25 13:47:32 +08:00
parent cda86975a0
commit 4b8586110e
1 changed files with 3 additions and 1 deletions

View File

@ -130,7 +130,7 @@ public class UnityEntitiesService : MonoBehaviour,IEntitiesService
public static event Action<IEntity> OnAdd;
public static event Action<IEntity> OnRemove;
IEntity[] IEntitiesService.Entities => Entities;
public static IEntity[] Entities => Dictionary.Values.ToArray();
public static IEntity[] Entities { get; private set; }
bool IEntitiesService.Register(IEntity entity) => Register(entity);
bool IEntitiesService.UnRegister(IEntity entity) => UnRegister(entity);
@ -141,12 +141,14 @@ public class UnityEntitiesService : MonoBehaviour,IEntitiesService
if (Dictionary.TryRemove(entity.Id))
{
OnRemove?.Invoke(entity);
Entities = Dictionary.Values.ToArray();
}
}
while (RegisterQueue.TryDequeue(out var entity))
{
Dictionary.GetOrAdd(entity.Id,entity);
OnAdd?.Invoke(entity);
Entities = Dictionary.Values.ToArray();
}
}