feat: GameObject Register Actions Added
This commit is contained in:
parent
fdb5936573
commit
d08495afbb
|
@ -11,6 +11,9 @@ namespace Syntriax.Engine.Core;
|
||||||
public class GameManager : IEntity, IEnumerable<IGameObject>
|
public class GameManager : IEntity, IEnumerable<IGameObject>
|
||||||
{
|
{
|
||||||
public Action<GameManager>? OnCameraChanged { get; set; } = null;
|
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>? OnInitialized { get; set; } = null;
|
||||||
public Action<IInitialize>? OnFinalized { get; set; } = null;
|
public Action<IInitialize>? OnFinalized { get; set; } = null;
|
||||||
public Action<IAssignable>? OnUnassigned { 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)
|
private void Register(IGameObject gameObject)
|
||||||
{
|
{
|
||||||
gameObject.OnFinalized += OnGameObjectFinalize;
|
gameObject.OnFinalized += OnGameObjectFinalize;
|
||||||
|
|
||||||
_gameObjects.Add(gameObject);
|
_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)
|
private void OnGameObjectFinalize(IInitialize initialize)
|
||||||
|
|
Loading…
Reference in New Issue