Syntriax.Engine/Engine.Core/Abstract/IBehaviourCollector.cs

36 lines
1.7 KiB
C#
Raw Normal View History

using System.Collections.Generic;
namespace Syntriax.Engine.Core.Abstract;
/// <summary>
/// Represents a collector for the class type of <typeparamref name="T"/>.
/// Provides mechanisms for tracking additions and removals, and notifies subscribers when such events occur on the assigned <see cref="IGameManager"/>.
/// </summary>
/// <typeparam name="T">The type of objects tracked by the collector.</typeparam>
public interface IBehaviourCollector<T> : IAssignableGameManager, IEnumerable<T> where T : class
{
/// <summary>
/// Event triggered when an object of type <typeparamref name="T"/> is added to the collector.
/// </summary>
event OnCollectedEventHandler? OnCollected;
/// <summary>
/// Event triggered when an object of type <typeparamref name="T"/> is removed from the collector.
/// </summary>
event OnRemovedEventHandler? OnRemoved;
/// <summary>
/// Delegate for handling the <see cref="OnCollected"/> event.
/// </summary>
/// <param name="sender">The instance of the <see cref="BehaviourCollector{T}"/> that triggered the event.</param>
/// <param name="behaviourCollected">The object of type <typeparamref name="T"/> that was added to the collector.</param>
public delegate void OnCollectedEventHandler(BehaviourCollector<T> sender, T behaviourCollected);
/// <summary>
/// Delegate for handling the <see cref="OnRemoved"/> event.
/// </summary>
/// <param name="sender">The instance of the <see cref="BehaviourCollector{T}"/> that triggered the event.</param>
/// <param name="behaviourRemoved">The object of type <typeparamref name="T"/> that was removed from the collector.</param>
public delegate void OnRemovedEventHandler(BehaviourCollector<T> sender, T behaviourRemoved);
}