84 lines
3.8 KiB
C#
84 lines
3.8 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace Syntriax.Engine.Core;
|
|
|
|
/// <summary>
|
|
/// Represents a controller for managing <see cref="IBehaviour"/>s. Connected to an <see cref="IUniverseObject"/>.
|
|
/// </summary>
|
|
public interface IBehaviourController : IEntity, IHasUniverseObject
|
|
{
|
|
/// <summary>
|
|
/// Event triggered when a <see cref="IBehaviour"/> is added to the <see cref="IBehaviourController"/>.
|
|
/// </summary>
|
|
Event<IBehaviourController, BehaviourAddedArguments> OnBehaviourAdded { get; }
|
|
|
|
/// <summary>
|
|
/// Event triggered when a <see cref="IBehaviour"/> is removed from the <see cref="IBehaviourController"/>.
|
|
/// </summary>
|
|
Event<IBehaviourController, BehaviourRemovedArguments> OnBehaviourRemoved { get; }
|
|
|
|
/// <summary>
|
|
/// Amount of <see cref="IBehaviour"/> collected.
|
|
/// </summary>
|
|
int Count { get; }
|
|
|
|
/// <summary>
|
|
/// Get a <see cref="IBehaviour"/> collected by it's index.
|
|
/// </summary>
|
|
IBehaviour this[System.Index index] { get; }
|
|
|
|
/// <summary>
|
|
/// Adds a <see cref="IBehaviour"/> to the <see cref="IBehaviourController"/>.
|
|
/// </summary>
|
|
/// <typeparam name="T">The type of <see cref="IBehaviour"/> to add.</typeparam>
|
|
/// <param name="behaviour">The <see cref="IBehaviour"/> to add.</param>
|
|
/// <returns>The added <see cref="IBehaviour"/>.</returns>
|
|
T AddBehaviour<T>(T behaviour) where T : class, IBehaviour;
|
|
|
|
/// <summary>
|
|
/// Adds a <see cref="IBehaviour"/> of the specified type to the <see cref="IBehaviourController"/>.
|
|
/// </summary>
|
|
/// <typeparam name="T">The type of <see cref="IBehaviour"/> to add.</typeparam>
|
|
/// <param name="args">Construction parameters for the <see cref="IBehaviour"/>.</param>
|
|
/// <returns>The added <see cref="IBehaviour"/>.</returns>
|
|
T AddBehaviour<T>(params object?[]? args) where T : class, IBehaviour;
|
|
|
|
/// <summary>
|
|
/// Gets a <see cref="IBehaviour"/> of the specified type.
|
|
/// </summary>
|
|
/// <typeparam name="T">The type of <see cref="IBehaviour"/> to get.</typeparam>
|
|
/// <returns>The <see cref="IBehaviour"/> of the specified type if found; otherwise, <see cref="null"/>.</returns>
|
|
T? GetBehaviour<T>();
|
|
|
|
/// <summary>
|
|
/// Gets all <see cref="IBehaviour"/>s of the specified type.
|
|
/// </summary>
|
|
/// <typeparam name="T">The type of <see cref="IBehaviour"/>s to get.</typeparam>
|
|
/// <returns>A list of <see cref="IBehaviour"/>s of the specified type.</returns>
|
|
IReadOnlyList<T> GetBehaviours<T>();
|
|
|
|
/// <summary>
|
|
/// Gets all <see cref="IBehaviour"/>s of the specified type and stores them in the provided list.
|
|
/// </summary>
|
|
/// <typeparam name="T">The type of <see cref="IBehaviour"/>s to get.</typeparam>
|
|
/// <param name="results">The list to store the <see cref="IBehaviour"/>s.</param>
|
|
void GetBehaviours<T>(IList<T> results);
|
|
|
|
/// <summary>
|
|
/// Removes <see cref="IBehaviour"/>s of the specified type from the <see cref="IBehaviourController"/>.
|
|
/// </summary>
|
|
/// <typeparam name="T">The type of <see cref="IBehaviour"/>s to remove.</typeparam>
|
|
/// <param name="removeAll">A flag indicating whether to remove all <see cref="IBehaviour"/>s of the specified type.</param>
|
|
void RemoveBehaviour<T>(bool removeAll = false) where T : class, IBehaviour;
|
|
|
|
/// <summary>
|
|
/// Removes the specified <see cref="IBehaviour"/> from the <see cref="IBehaviourController"/>.
|
|
/// </summary>
|
|
/// <typeparam name="T">The type of <see cref="IBehaviour"/> to remove.</typeparam>
|
|
/// <param name="behaviour">The <see cref="IBehaviour"/> to remove.</param>
|
|
void RemoveBehaviour<T>(T behaviour) where T : class, IBehaviour;
|
|
|
|
readonly record struct BehaviourAddedArguments(IBehaviour BehaviourAdded);
|
|
readonly record struct BehaviourRemovedArguments(IBehaviour BehaviourRemoved);
|
|
}
|