using System.Collections.Generic;
namespace Syntriax.Engine.Core.Abstract;
///
/// Represents an that can enter and exit a hierarchy within the 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.
///
public interface IHierarchyObject : IEntity, IActive, INameable, IHasBehaviourController, IEnumerable
{
///
/// Event triggered when the enters the hierarchy.
///
event EnteredHierarchyEventHandler? OnEnteredHierarchy;
///
/// Event triggered when the exits the hierarchy.
///
event ExitedHierarchyEventHandler? OnExitedHierarchy;
///
/// Event triggered when the of the changes. The second parameter is the old .
///
event ParentChangedEventHandler? OnParentChanged;
///
/// Event triggered when a new is added to the .
///
event ChildrenAddedEventHandler? OnChildrenAdded;
///
/// Event triggered when an is removed from the .
///
event ChildrenRemovedEventHandler? OnChildrenRemoved;
///
/// Gets the this is connected to, if any.
///
IGameManager GameManager { get; }
///
/// Indicates whether the is currently in the hierarchy.
///
bool IsInHierarchy { get; }
///
/// The parent of the .
///
IHierarchyObject? Parent { get; }
///
/// The s that have this as their .
///
IReadOnlyList Children { get; }
///
/// Internal method to handle entering the hierarchy.
/// This should be called by the system to properly manage hierarchy states.
///
/// The that is managing this hierarchy.
///
/// if the successfully entered the hierarchy;
/// if it failed to do so.
///
internal bool EnterHierarchy(IGameManager gameManager);
///
/// Internal method to handle exiting the hierarchy.
/// This should be called by the system to properly manage hierarchy states.
///
///
/// if the successfully exited the hierarchy;
/// if it failed to do so.
///
internal bool ExitHierarchy();
///
/// Sets the parent of this .
///
/// The parent to set.
void SetParent(IHierarchyObject? hierarchyObject);
///
/// Adds a child to this .
///
/// The child to add.
void AddChild(IHierarchyObject hierarchyObject);
///
/// Removes a child from this .
///
/// The child to remove.
void RemoveChild(IHierarchyObject hierarchyObject);
///
/// EventHandler delegate for the event triggered when the enters the hierarchy of a .
///
/// The that entered the hierarchy.
/// The that the has entered it's hierarchy.
delegate void EnteredHierarchyEventHandler(IHierarchyObject sender, IGameManager gameManager);
///
/// EventHandler delegate for the event triggered when the exits the hierarchy of a .
///
/// The that exited the hierarchy.
/// The that the has exited it's hierarchy.
delegate void ExitedHierarchyEventHandler(IHierarchyObject sender, IGameManager gameManager);
///
/// Delegate for the event triggered when the 's parent changes.
///
/// The that the parent has changed.
/// The previous the sender was a child of.
/// The new and current the sender is a child of.
delegate void ParentChangedEventHandler(IHierarchyObject sender, IHierarchyObject? previousParent, IHierarchyObject? newParent);
///
/// Delegate for the event triggered when a new added as a child.
///
/// The parent this event is being called from.
/// The that got removed as a children of the sender .
delegate void ChildrenAddedEventHandler(IHierarchyObject sender, IHierarchyObject childrenAdded);
///
/// Delegate for the event triggered when a new removed from being a child.
///
/// The parent this event is being called from.
/// The that got removed as a children of the sender .
delegate void ChildrenRemovedEventHandler(IHierarchyObject sender, IHierarchyObject childrenRemoved);
}