Files
RebootKit/Runtime/Engine/Code/Services/Simulation/Interactors/IInteractor.cs
2025-05-26 17:04:33 +02:00

33 lines
1.0 KiB
C#
Executable File

using System.Collections.Generic;
using System.Threading;
using Cysharp.Threading.Tasks;
namespace RebootKit.Engine.Services.Simulation.Interactors {
public interface IInteractorAsync<in TInteractable> {
UniTask Interact(TInteractable target, CancellationToken cancellationToken);
}
public interface IInteractor<in TInteractable> {
void Interact(TInteractable target);
}
public class GroupInteractor<TInteractable> : IInteractor<TInteractable> {
readonly List<IInteractor<TInteractable>> m_Interactors = new();
public void Interact(TInteractable target) {
foreach (IInteractor<TInteractable> interactor in m_Interactors) interactor.Interact(target);
}
public void Add(IInteractor<TInteractable> interactor) {
m_Interactors.Add(interactor);
}
public void Remove(IInteractor<TInteractable> interactor) {
m_Interactors.Remove(interactor);
}
public void RemoveAll() {
m_Interactors.Clear();
}
}
}