BREAKING CHANGE: Added IHierarchObject with Hierarchy Enter & Exit
This commit is contained in:
62
Engine.Core/Abstract/Assignable/IHierarchyObject.cs
Normal file
62
Engine.Core/Abstract/Assignable/IHierarchyObject.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an <see cref="IEntity"/> that can enter and exit a hierarchy within the <see cref="IGameManager"/> system.
|
||||
/// This interface allows for tracking the object's presence in the hierarchy and provides events
|
||||
/// for notifying when the see enters or exits the hierarchy.
|
||||
/// </summary>
|
||||
public interface IHierarchyObject : IEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="IEntity"/> enters the hierarchy.
|
||||
/// </summary>
|
||||
event OnEnteredHierarchyDelegate? OnEnteredHierarchy;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="IEntity"/> exits the hierarchy.
|
||||
/// </summary>
|
||||
event OnExitedHierarchyDelegate? OnExitedHierarchy;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IGameManager"/> associated with this <see cref="IEntity"/> , if any.
|
||||
/// </summary>
|
||||
IGameManager? GameManager { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the <see cref="IEntity"/> is currently in the hierarchy.
|
||||
/// </summary>
|
||||
bool IsInHierarchy { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Internal method to handle entering the hierarchy.
|
||||
/// This should be called by the system to properly manage hierarchy states.
|
||||
/// </summary>
|
||||
/// <param name="gameManager">The game manager that is managing this hierarchy.</param>
|
||||
/// <returns>
|
||||
/// <see cref="true"/> if the <see cref="IEntity"/> successfully entered the hierarchy;
|
||||
/// <see cref="false"/> if it failed to do so.
|
||||
/// </returns>
|
||||
internal bool EnterHierarchy(IGameManager gameManager);
|
||||
|
||||
/// <summary>
|
||||
/// Internal method to handle exiting the hierarchy.
|
||||
/// This should be called by the system to properly manage hierarchy states.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <see cref="true"/> if the <see cref="IEntity"/> successfully exited the hierarchy;
|
||||
/// <see cref="false"/> if it failed to do so.
|
||||
/// </returns>
|
||||
internal bool ExitHierarchy();
|
||||
|
||||
/// <summary>
|
||||
/// Delegate type for the event triggered when the <see cref="IEntity"/> enters the hierarchy.
|
||||
/// </summary>
|
||||
/// <param name="sender">The <see cref="IEntity"/> that entered the hierarchy.</param>
|
||||
delegate void OnEnteredHierarchyDelegate(IHierarchyObject sender);
|
||||
|
||||
/// <summary>
|
||||
/// Delegate type for the event triggered when the <see cref="IEntity"/> exits the hierarchy.
|
||||
/// </summary>
|
||||
/// <param name="sender">The <see cref="IEntity"/> that exited the hierarchy.</param>
|
||||
delegate void OnExitedHierarchyDelegate(IHierarchyObject sender);
|
||||
}
|
@@ -17,11 +17,26 @@ public interface IGameManager : IEntity, IEnumerable<IGameObject>
|
||||
/// </summary>
|
||||
event OnGameObjectUnRegisteredDelegate? OnGameObjectUnRegistered;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when a <see cref="IHierarchyObject"/> is registered to the <see cref="IGameManager"/>.
|
||||
/// </summary>
|
||||
event OnHierarchyObjectRegisteredDelegate? OnHierarchyObjectRegistered;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when a <see cref="IHierarchyObject"/> is unregistered from the <see cref="IGameManager"/>.
|
||||
/// </summary>
|
||||
event OnHierarchyObjectUnRegisteredDelegate? OnHierarchyObjectUnRegistered;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a read-only list of <see cref="IGameObject"/>s managed by the <see cref="IGameManager"/>.
|
||||
/// </summary>
|
||||
IReadOnlyList<IGameObject> GameObjects { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a read-only list of <see cref="IHierarchyObject"/>s managed by the <see cref="IGameManager"/>.
|
||||
/// </summary>
|
||||
IReadOnlyList<IHierarchyObject> HierarchyObjects { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Registers a <see cref="IGameObject"/> to the <see cref="IGameManager"/>.
|
||||
/// </summary>
|
||||
@@ -56,4 +71,6 @@ public interface IGameManager : IEntity, IEnumerable<IGameObject>
|
||||
|
||||
delegate void OnGameObjectRegisteredDelegate(IGameManager sender, IGameObject gameObjectRegistered);
|
||||
delegate void OnGameObjectUnRegisteredDelegate(IGameManager sender, IGameObject gameObjectUnregistered);
|
||||
delegate void OnHierarchyObjectRegisteredDelegate(IGameManager sender, IHierarchyObject hierarchyObjectRegistered);
|
||||
delegate void OnHierarchyObjectUnRegisteredDelegate(IGameManager sender, IHierarchyObject hierarchyObjectUnregistered);
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ namespace Syntriax.Engine.Core.Abstract;
|
||||
/// <summary>
|
||||
/// Represents a game object with various properties and functionalities.
|
||||
/// </summary>
|
||||
public interface IGameObject : IEntity, IAssignableGameManager, IAssignableTransform, IAssignableBehaviourController, INameable, IInitialize
|
||||
public interface IGameObject : IEntity, IHierarchyObject, IAssignableTransform, IAssignableBehaviourController, INameable, IInitialize
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="Update"/> method is called.
|
||||
|
Reference in New Issue
Block a user