diff --git a/Engine.Core/Abstract/IGameManager.cs b/Engine.Core/Abstract/IGameManager.cs index 5918b64..277f69e 100644 --- a/Engine.Core/Abstract/IGameManager.cs +++ b/Engine.Core/Abstract/IGameManager.cs @@ -7,6 +7,16 @@ namespace Syntriax.Engine.Core.Abstract; /// public interface IGameManager : IEntity, IEnumerable { + /// + /// Event triggered when is called on the . + /// + event OnUpdateDelegate? OnUpdate; + + /// + /// Event triggered when is called on the . + /// + event OnPreDawDelegate? OnPreDraw; + /// /// Event triggered when a is registered to the . /// @@ -69,6 +79,9 @@ public interface IGameManager : IEntity, IEnumerable /// void PreDraw(); + delegate void OnUpdateDelegate(IGameManager sender, EngineTime time); + delegate void OnPreDawDelegate(IGameManager sender); + delegate void OnGameObjectRegisteredDelegate(IGameManager sender, IGameObject gameObjectRegistered); delegate void OnGameObjectUnRegisteredDelegate(IGameManager sender, IGameObject gameObjectUnregistered); delegate void OnHierarchyObjectRegisteredDelegate(IGameManager sender, IHierarchyObject hierarchyObjectRegistered); diff --git a/Engine.Core/GameManager.cs b/Engine.Core/GameManager.cs index a2a6326..50f2af4 100644 --- a/Engine.Core/GameManager.cs +++ b/Engine.Core/GameManager.cs @@ -11,6 +11,9 @@ namespace Syntriax.Engine.Core; [System.Diagnostics.DebuggerDisplay("GameObject Count: {_gameObjects.Count}")] public class GameManager : BaseEntity, IGameManager { + public event IGameManager.OnUpdateDelegate? OnUpdate = null; + public event IGameManager.OnPreDawDelegate? OnPreDraw = null; + public event IGameManager.OnGameObjectRegisteredDelegate? OnGameObjectRegistered = null; public event IGameManager.OnGameObjectUnRegisteredDelegate? OnGameObjectUnRegistered = null; public event IGameManager.OnHierarchyObjectRegisteredDelegate? OnHierarchyObjectRegistered = null; @@ -94,12 +97,16 @@ public class GameManager : BaseEntity, IGameManager Time.SetTime(time); for (int i = 0; i < GameObjects.Count; i++) GameObjects[i].BehaviourController.Update(); + + OnUpdate?.Invoke(this, time); } public void PreDraw() { for (int i = 0; i < GameObjects.Count; i++) GameObjects[i].BehaviourController.UpdatePreDraw(); + + OnPreDraw?.Invoke(this); } /////////////////////////////////////////////////////////////////