126 lines
		
	
	
		
			6.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			126 lines
		
	
	
		
			6.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System.Collections.Generic;
 | 
						|
 | 
						|
namespace Engine.Core;
 | 
						|
 | 
						|
/// <summary>
 | 
						|
/// Represents an <see cref="IEntity"/> that can enter and exit a universe within the <see cref="IUniverse"/> 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.
 | 
						|
/// </summary>
 | 
						|
public interface IUniverseObject : IEntity, IActive, INameable, IHasBehaviourController
 | 
						|
{
 | 
						|
    /// <summary>
 | 
						|
    /// Event triggered when the <see cref="IUniverseObject"/> enters the universe.
 | 
						|
    /// </summary>
 | 
						|
    Event<IUniverseObject, EnteredUniverseArguments> OnEnteredUniverse { get; }
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Event triggered when the <see cref="IUniverseObject"/> exits the universe.
 | 
						|
    /// </summary>
 | 
						|
    Event<IUniverseObject, ExitedUniverseArguments> OnExitedUniverse { get; }
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Event triggered when the <see cref="Parent"/> of the <see cref="IUniverseObject"/> changes. The second parameter is the old <see cref="IUniverseObject"/>.
 | 
						|
    /// </summary>
 | 
						|
    Event<IUniverseObject, ParentChangedArguments> OnParentChanged { get; }
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Event triggered when a new <see cref="IUniverseObject"/> is added to the <see cref="Children"/>.
 | 
						|
    /// </summary>
 | 
						|
    Event<IUniverseObject, ChildrenAddedArguments> OnChildrenAdded { get; }
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Event triggered when an <see cref="IUniverseObject"/> is removed from the <see cref="Children"/>.
 | 
						|
    /// </summary>
 | 
						|
    Event<IUniverseObject, ChildrenRemovedArguments> OnChildrenRemoved { get; }
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Gets the <see cref="IUniverse"/> this <see cref="IUniverseObject"/> is connected to, if any.
 | 
						|
    /// </summary>
 | 
						|
    IUniverse Universe { get; }
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Indicates whether the <see cref="IUniverseObject"/> is currently in the universe.
 | 
						|
    /// </summary>
 | 
						|
    bool IsInUniverse { get; }
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// The parent <see cref="IUniverseObject"/> of the <see cref="IUniverseObject"/>.
 | 
						|
    /// </summary>
 | 
						|
    IUniverseObject? Parent { get; set; }
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// The <see cref="IUniverseObject"/>s that have this <see cref="IUniverseObject"/> as their <see cref="Parent"/>.
 | 
						|
    /// </summary>
 | 
						|
    IReadOnlyList<IUniverseObject> Children { get; }
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Internal method to handle entering the universe.
 | 
						|
    /// This should be called by the system to properly manage universe states.
 | 
						|
    /// </summary>
 | 
						|
    /// <param name="universe">The <see cref="IUniverse"/> that is managing this universe.</param>
 | 
						|
    /// <returns>
 | 
						|
    /// <see cref="true"/> if the <see cref="IUniverseObject"/> successfully entered the universe; 
 | 
						|
    /// <see cref="false"/> if it failed to do so.
 | 
						|
    /// </returns>
 | 
						|
    internal bool EnterUniverse(IUniverse universe);
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Internal method to handle exiting the universe.
 | 
						|
    /// This should be called by the system to properly manage universe states.
 | 
						|
    /// </summary>
 | 
						|
    /// <returns>
 | 
						|
    /// <see cref="true"/> if the <see cref="IUniverseObject"/> successfully exited the universe; 
 | 
						|
    /// <see cref="false"/> if it failed to do so.
 | 
						|
    /// </returns>
 | 
						|
    internal bool ExitUniverse();
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Adds a child <see cref="IUniverseObject"/> to this <see cref="IUniverseObject"/>.
 | 
						|
    /// </summary>
 | 
						|
    /// <param name="universeObject">The child <see cref="IUniverseObject"/> to add.</param>
 | 
						|
    void AddChild(IUniverseObject universeObject);
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Removes a child <see cref="IUniverseObject"/> from this <see cref="IUniverseObject"/>.
 | 
						|
    /// </summary>
 | 
						|
    /// <param name="universeObject">The child <see cref="IUniverseObject"/> to remove.</param>
 | 
						|
    void RemoveChild(IUniverseObject universeObject);
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Arguments for the event triggered when the <see cref="IUniverseObject"/> enters the universe of a <see cref="IUniverse">.
 | 
						|
    /// </summary>
 | 
						|
    /// <param name="sender">The <see cref="IUniverseObject"/> that entered the universe.</param>
 | 
						|
    /// <param name="universe">The <see cref="IUniverse"/> that the <see cref="IUniverseObject"/> has entered it's universe.</param>
 | 
						|
    readonly record struct EnteredUniverseArguments(IUniverse Universe);
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Arguments for the event triggered when the <see cref="IUniverseObject"/> exits the universe of a <see cref="IUniverse">.
 | 
						|
    /// </summary>
 | 
						|
    /// <param name="sender">The <see cref="IUniverseObject"/> that exited the universe.</param>
 | 
						|
    /// <param name="universe">The <see cref="IUniverse"/> that the <see cref="IUniverseObject"/> has exited it's universe.</param>
 | 
						|
    readonly record struct ExitedUniverseArguments(IUniverse Universe);
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Arguments for the event triggered when the <see cref="IUniverseObject"/>'s parent changes.
 | 
						|
    /// </summary>
 | 
						|
    /// <param name="sender">The <see cref="IUniverseObject"/> that the parent has changed.</param>
 | 
						|
    /// <param name="previousParent">The previous <see cref="IUniverseObject"/> the sender was a child of.</param>
 | 
						|
    /// <param name="newParent">The new and current <see cref="IUniverseObject"/> the sender is a child of.</param>
 | 
						|
    readonly record struct ParentChangedArguments(IUniverseObject? PreviousParent, IUniverseObject? CurrentParent);
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Arguments for the event triggered when a new <see cref="IUniverseObject"/> added as a child.
 | 
						|
    /// </summary>
 | 
						|
    /// <param name="sender">The parent <see cref="IUniverseObject"/> this event is being called from.</param>
 | 
						|
    /// <param name="childrenAdded">The <see cref="IUniverseObject"/> that got removed as a children of the sender <see cref="IUniverseObject"/>.</param>
 | 
						|
    readonly record struct ChildrenAddedArguments(IUniverseObject ChildrenAdded);
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Delegate for the event triggered when a new <see cref="IUniverseObject"/> removed from being a child.
 | 
						|
    /// </summary>
 | 
						|
    /// <param name="sender">The parent <see cref="IUniverseObject"/> this event is being called from.</param>
 | 
						|
    /// <param name="childrenAdded">The <see cref="IUniverseObject"/> that got removed as a children of the sender <see cref="IUniverseObject"/>.</param>
 | 
						|
    readonly record struct ChildrenRemovedArguments(IUniverseObject ChildrenRemoved);
 | 
						|
}
 |