using System.Collections.Generic; namespace Syntriax.Engine.Core.Abstract; /// /// Represents an that can enter and exit a universe within the system. /// This interface allows for tracking the object's presence in the universe and provides events /// for notifying when the see enters or exits the universe. /// public interface IUniverseObject : IEntity, IActive, INameable, IHasBehaviourController, IEnumerable { /// /// Event triggered when the enters the universe. /// event EnteredUniverseEventHandler? OnEnteredUniverse; /// /// Event triggered when the exits the universe. /// event ExitedUniverseEventHandler? OnExitedUniverse; /// /// 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. /// IUniverse Universe { get; } /// /// Indicates whether the is currently in the universe. /// bool IsInUniverse { get; } /// /// The parent of the . /// IUniverseObject? Parent { get; } /// /// The s that have this as their . /// IReadOnlyList Children { get; } /// /// Internal method to handle entering the universe. /// This should be called by the system to properly manage universe states. /// /// The that is managing this universe. /// /// if the successfully entered the universe; /// if it failed to do so. /// internal bool EnterUniverse(IUniverse universe); /// /// Internal method to handle exiting the universe. /// This should be called by the system to properly manage universe states. /// /// /// if the successfully exited the universe; /// if it failed to do so. /// internal bool ExitUniverse(); /// /// Sets the parent of this . /// /// The parent to set. void SetParent(IUniverseObject? universeObject); /// /// Adds a child to this . /// /// The child to add. void AddChild(IUniverseObject universeObject); /// /// Removes a child from this . /// /// The child to remove. void RemoveChild(IUniverseObject universeObject); /// /// EventHandler delegate for the event triggered when the enters the universe of a . /// /// The that entered the universe. /// The that the has entered it's universe. delegate void EnteredUniverseEventHandler(IUniverseObject sender, IUniverse universe); /// /// EventHandler delegate for the event triggered when the exits the universe of a . /// /// The that exited the universe. /// The that the has exited it's universe. delegate void ExitedUniverseEventHandler(IUniverseObject sender, IUniverse universe); /// /// 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(IUniverseObject sender, IUniverseObject? previousParent, IUniverseObject? 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(IUniverseObject sender, IUniverseObject 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(IUniverseObject sender, IUniverseObject childrenRemoved); }