namespace VRTK.Prefabs.Interactions.Interactables.Grab.Action { using UnityEngine; using Malimbe.XmlDocumentationAttribute; using Malimbe.PropertySerializationAttribute; using Zinnia.Data.Attribute; using Zinnia.Data.Collection.List; using Zinnia.Tracking.Modification; /// /// Describes an action that allows the Interactable to point in the direction of a given Interactor. /// public class GrabInteractableControlDirectionAction : GrabInteractableAction { #region Interactable Settings /// /// A collection to enable/disabled as part of the direction control process. /// [Serialized] [field: Header("Interactable Settings"), DocumentedByXml, Restricted] public GameObjectObservableList LinkedObjects { get; protected set; } /// /// The to process the direction control. /// [Serialized] [field: DocumentedByXml, Restricted] public DirectionModifier DirectionModifier { get; protected set; } #endregion /// /// Enables the state of each of the items in the collection. /// public virtual void EnableLinkedObjects() { ToggleLinkedObjectState(true); } /// /// Disables the state of each of the items in the collection. /// public virtual void DisableLinkedObjects() { ToggleLinkedObjectState(false); } /// /// Toggles the state of each of the items in the collection. /// /// The state to set the active state to. protected virtual void ToggleLinkedObjectState(bool state) { foreach (GameObject linkedObject in LinkedObjects.NonSubscribableElements) { linkedObject.SetActive(state); } } /// protected override void OnAfterGrabSetupChange() { DirectionModifier.Target = GrabSetup.Facade.ConsumerContainer; } } }