namespace VRTK.Prefabs.Locomotion.Movement.SpatialManipulation { using UnityEngine; using Malimbe.MemberClearanceMethod; using Malimbe.XmlDocumentationAttribute; using Malimbe.PropertySerializationAttribute; using Zinnia.Action; using Zinnia.Process; /// /// Provides a basis for manipulating an spatial object. /// public abstract class SpatialManipulator : MonoBehaviour, IProcessable { #region Object Settings /// /// The primary source to track positional and rotational data on to apply to the manipulator. /// [Serialized, Cleared] [field: Header("Object Settings"), DocumentedByXml] public GameObject PrimarySource { get; set; } /// /// The secondary source to track positional and rotational data on to apply to the manipulator. /// [Serialized, Cleared] [field: DocumentedByXml] public GameObject SecondarySource { get; set; } /// /// The target to apply the spatial manipulation to. /// [Serialized, Cleared] [field: DocumentedByXml] public GameObject Target { get; set; } /// /// An optional offset to take into consideration when manipulating the target. /// [Serialized, Cleared] [field: DocumentedByXml] public GameObject Offset { get; set; } /// /// Multiplies the result of the manupulation operation. /// [Serialized] [field: DocumentedByXml] public float Multiplier { get; set; } = 1f; #endregion #region Activation Settings /// /// The action that will enable the activation state. /// [Serialized, Cleared] [field: Header("Activation Settings"), DocumentedByXml] public BooleanAction ActivationAction { get; set; } /// /// The minimum value required to be considered active. /// [Serialized] [field: DocumentedByXml] public float ActivationThreshold { get; set; } #endregion /// /// Determines whether the manipulator was activated last frame. /// protected bool wasActivated; /// /// Processes the manipulation operation. /// public abstract void Process(); /// /// Determines if the given object is valid. /// /// The object to check. /// Whether the object is valid. protected virtual bool IsObjectValid(GameObject source) { return source != null && source.activeInHierarchy; } /// /// Gets the local position of the given source. /// /// The source to get the local position for. /// The local position. protected virtual Vector3 GetLocalPosition(GameObject source) { return IsObjectValid(source) ? source.transform.localPosition : Vector3.zero; } } }