This commit is contained in:
2025-05-30 16:05:49 +03:00
committed by Syntriax
parent 846aa75dd5
commit b5140a94de
57 changed files with 437 additions and 462 deletions

View File

@@ -5,7 +5,7 @@ namespace Syntriax.Engine.Core.Serialization;
public class EntityRegistry
{
public event EntityRegisteredEventHandler? OnEntityRegistered = null!;
public Event<EntityRegistry, EntityRegisteredArguments> OnEntityRegistered = null!;
private readonly Dictionary<string, Action<IEntity>?> assignCallbacks = [];
private readonly Dictionary<string, IEntity> registeredEntities = [];
@@ -14,7 +14,7 @@ public class EntityRegistry
public void Add(IEntity entity)
{
if (registeredEntities.TryAdd(entity.Id, entity))
OnEntityRegistered?.Invoke(this, entity);
OnEntityRegistered?.Invoke(this, new(entity));
}
public void QueueAssign(string id, Action<IEntity> setMethod)
@@ -35,5 +35,5 @@ public class EntityRegistry
registeredEntities.Clear();
}
public delegate void EntityRegisteredEventHandler(EntityRegistry sender, IEntity entity);
public readonly record struct EntityRegisteredArguments(IEntity Entity);
}