using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace Syntriax.Engine.Core.Abstract; /// /// Represents a controller for managing s and notify them accordingly about the engine's updates. Connected to an . /// public interface IBehaviourController : IInitialize, IAssignableGameObject, IEnumerable { /// /// Event triggered before the update of s. /// event OnPreUpdateEventHandler? OnPreUpdate; /// /// Event triggered during the update of s. /// event OnUpdateEventHandler? OnUpdate; /// /// Event triggered before the drawing phase. /// event OnPreDrawEventHandler? OnPreDraw; /// /// Event triggered when a is added to the . /// event OnBehaviourAddedEventHandler? OnBehaviourAdded; /// /// Event triggered when a is removed from the . /// event OnBehaviourRemovedEventHandler? OnBehaviourRemoved; /// /// Adds a to the . /// /// The type of to add. /// The to add. /// The added . T AddBehaviour(T behaviour) where T : class, IBehaviour; /// /// Adds a of the specified type to the . /// /// The type of to add. /// Construction parameters for the . /// The added . T AddBehaviour(params object?[]? args) where T : class, IBehaviour; /// /// Gets a of the specified type. /// /// The type of to get. /// The of the specified type if found; otherwise, . T? GetBehaviour(); /// /// Tries to get a of the specified type. /// /// The type of to get. /// When this method returns, contains the of the specified type, if found; otherwise, see. /// if a of the specified type was found; otherwise, . bool TryGetBehaviour([NotNullWhen(returnValue: true)] out T? behaviour); /// /// Gets all s of the specified type. /// /// The type of s to get. /// A list of s of the specified type. IList GetBehaviours(); /// /// Gets all s of the specified type and stores them in the provided list. /// /// The type of s to get. /// The list to store the s. void GetBehaviours(IList results); /// /// Removes s of the specified type from the . /// /// The type of s to remove. /// A flag indicating whether to remove all s of the specified type. void RemoveBehaviour(bool removeAll = false) where T : class, IBehaviour; /// /// Removes the specified from the . /// /// The type of to remove. /// The to remove. void RemoveBehaviour(T behaviour) where T : class, IBehaviour; /// /// Updates all s in the . /// void Update(); /// /// Performs pre-draw operations. /// void UpdatePreDraw(); delegate void OnPreUpdateEventHandler(IBehaviourController sender); delegate void OnUpdateEventHandler(IBehaviourController sender); delegate void OnPreDrawEventHandler(IBehaviourController sender); delegate void OnBehaviourAddedEventHandler(IBehaviourController sender, IBehaviour behaviourAdded); delegate void OnBehaviourRemovedEventHandler(IBehaviourController sender, IBehaviour behaviourRemoved); }