feat: GameObject Register Actions Added

This commit is contained in:
Syntriax 2024-01-23 12:08:50 +03:00
parent fdb5936573
commit d08495afbb
1 changed files with 12 additions and 7 deletions

View File

@ -11,6 +11,9 @@ namespace Syntriax.Engine.Core;
public class GameManager : IEntity, IEnumerable<IGameObject>
{
public Action<GameManager>? OnCameraChanged { get; set; } = null;
public Action<GameManager, IGameObject>? OnGameObjectRegistered { get; set; } = null;
public Action<GameManager, IGameObject>? OnGameObjectUnRegistered { get; set; } = null;
public Action<IInitialize>? OnInitialized { get; set; } = null;
public Action<IInitialize>? OnFinalized { get; set; } = null;
public Action<IAssignable>? OnUnassigned { get; set; } = null;
@ -149,18 +152,20 @@ public class GameManager : IEntity, IEnumerable<IGameObject>
/////////////////////////////////////////////////////////////////
private void Unregister(IGameObject gameObject)
{
gameObject.OnFinalized -= OnGameObjectFinalize;
_gameObjects.Remove(gameObject);
}
private void Register(IGameObject gameObject)
{
gameObject.OnFinalized += OnGameObjectFinalize;
_gameObjects.Add(gameObject);
OnGameObjectRegistered?.Invoke(this, gameObject);
}
private void Unregister(IGameObject gameObject)
{
gameObject.OnFinalized -= OnGameObjectFinalize;
_gameObjects.Remove(gameObject);
OnGameObjectUnRegistered?.Invoke(this, gameObject);
}
private void OnGameObjectFinalize(IInitialize initialize)