namespace Zinnia.Process.Component { using System; using UnityEngine; using UnityEngine.Events; using Zinnia.Data.Collection.List; using Zinnia.Extension; using Zinnia.Rule; /// /// A that specifically processes a . /// public abstract class GameObjectSourceTargetProcessor : SourceTargetProcessor { /// /// Defines the event with the . /// [Serializable] public class GameObjectUnityEvent : UnityEvent { } #region Processor Settings [Header("Entity Settings")] [Tooltip("A GameObject collection of sources to apply data from.")] [SerializeField] private GameObjectObservableList sources; /// /// A collection of sources to apply data from. /// public GameObjectObservableList Sources { get { return sources; } set { sources = value; } } [Tooltip("Allows to optionally determine which sources should be processed based on the set rules.")] [SerializeField] private RuleContainer sourceValidity; /// /// Allows to optionally determine which sources should be processed based on the set rules. /// public RuleContainer SourceValidity { get { return sourceValidity; } set { sourceValidity = value; } } [Tooltip("A GameObject collection of targets to apply data to.")] [SerializeField] private GameObjectObservableList targets; /// /// A collection of targets to apply data to. /// public GameObjectObservableList Targets { get { return targets; } set { targets = value; } } [Tooltip("Allows to optionally determine which targets should be processed based on the set rules.")] [SerializeField] private RuleContainer targetValidity; /// /// Allows to optionally determine which targets should be processed based on the set rules. /// public RuleContainer TargetValidity { get { return targetValidity; } set { targetValidity = value; } } #endregion /// /// Clears . /// public virtual void ClearSourceValidity() { if (!this.IsValidState()) { return; } SourceValidity = default; } /// /// Clears . /// public virtual void ClearTargetValidity() { if (!this.IsValidState()) { return; } TargetValidity = default; } /// public override void Process() { if (!this.IsValidState()) { return; } ApplySourcesToTargets(Sources.NonSubscribableElements, Targets.NonSubscribableElements); } /// protected override void SetCurrentIndices(int sourceIndex, int targetIndex) { Sources.CurrentIndex = sourceIndex; Targets.CurrentIndex = targetIndex; } /// protected override bool IsSourceValid(GameObject source) { return base.IsSourceValid(source) && SourceValidity.Accepts(source); } /// protected override bool IsTargetValid(GameObject target) { return base.IsTargetValid(target) && TargetValidity.Accepts(target); } } }