namespace Tilia.Interactions.PointerInteractors { using UnityEngine; using Zinnia.Action; using Zinnia.Cast; using Zinnia.Data.Attribute; using Zinnia.Extension; using Zinnia.Rule; using Zinnia.Tracking.Velocity; /// /// The public interface into the PointerGrabber Prefab. /// public class PointerGrabberFacade : MonoBehaviour { #region Pointer Settings [Header("Pointer Settings")] [Tooltip("The source to get the internal pointer to follow.")] [SerializeField] private GameObject followSource; /// /// The source to get the internal pointer to follow. /// public GameObject FollowSource { get { return followSource; } set { followSource = value; if (this.IsMemberChangeAllowed()) { OnAfterFollowSourceChange(); } } } [Tooltip("The Action to enable and disable the pointer with.")] [SerializeField] private BooleanAction activationAction; /// /// The Action to enable and disable the pointer with. /// public BooleanAction ActivationAction { get { return activationAction; } set { activationAction = value; if (this.IsMemberChangeAllowed()) { OnAfterActivationActionChange(); } } } [Tooltip("The Action to attempt to get the pointer interactor to grab.")] [SerializeField] private BooleanAction grabAction; /// /// The Action to attempt to get the pointer interactor to grab. /// public BooleanAction GrabAction { get { return grabAction; } set { grabAction = value; if (this.IsMemberChangeAllowed()) { OnAfterGrabActionChange(); } } } [Tooltip("The Action control the fixed pointer length.")] [SerializeField] private FloatAction lengthAxisAction; /// /// The Action control the fixed pointer length. /// public FloatAction LengthAxisAction { get { return lengthAxisAction; } set { lengthAxisAction = value; if (this.IsMemberChangeAllowed()) { OnAfterLengthAxisActionChange(); } } } [Tooltip("The multiplier value of the given length axis input to increase or reduce the speed of the pointer length change.")] [SerializeField] private float lengthAxisMultiplier = 1f; /// /// The multiplier value of the given length axis input to increase or reduce the speed of the pointer length change. /// public float LengthAxisMultiplier { get { return lengthAxisMultiplier; } set { lengthAxisMultiplier = value; if (this.IsMemberChangeAllowed()) { OnAfterLengthAxisMultiplierChange(); } } } [Tooltip("An optional VelocityTracker to use when applying velocity to the Interactor.\n\nIf one is not provided then a default VelocityTracker will be used that tracks the pointer cursor.")] [SerializeField] private VelocityTracker velocityTracker; /// /// An optional to use when applying velocity to the Interactor. /// /// /// If one is not provided then a default will be used that tracks the pointer cursor. /// public VelocityTracker VelocityTracker { get { return velocityTracker; } set { velocityTracker = value; if (this.IsMemberChangeAllowed()) { OnAfterVelocityTrackerChange(); } } } [Tooltip("Whether to attempt to automatically grab upon the pointer entering a valid target.")] [SerializeField] private bool autoGrabOnEnter; /// /// Whether to attempt to automatically grab upon the pointer entering a valid target. /// public bool AutoGrabOnEnter { get { return autoGrabOnEnter; } set { autoGrabOnEnter = value; if (this.IsMemberChangeAllowed()) { OnAfterAutoGrabOnEnterChange(); } } } #endregion #region Rule Settings [Header("Rule Settings")] [Tooltip("Determines which targets are valid to the pointer.")] [SerializeField] private RuleContainer targetValidity; /// /// Determines which targets are valid to the pointer. /// public RuleContainer TargetValidity { get { return targetValidity; } set { targetValidity = value; if (this.IsMemberChangeAllowed()) { OnAfterTargetValidityChange(); } } } [Tooltip("Determines the rules for the pointer RayCast.")] [SerializeField] private PhysicsCast raycastRules; /// /// Determines the rules for the pointer RayCast. /// public PhysicsCast RaycastRules { get { return raycastRules; } set { raycastRules = value; if (this.IsMemberChangeAllowed()) { OnAfterRaycastRulesChange(); } } } #endregion #region Reference Settings [Header("Reference Settings")] [Tooltip("The linked Internal Setup.")] [SerializeField] [Restricted] private PointerGrabberConfigurator configuration; /// /// The linked Internal Setup. /// public PointerGrabberConfigurator Configuration { get { return configuration; } set { configuration = value; } } #endregion /// /// Called after has been changed. /// protected virtual void OnAfterFollowSourceChange() { Configuration.ConfigurePointer(); } /// /// Called after has been changed. /// protected virtual void OnAfterActivationActionChange() { Configuration.ConfigurePointer(); } /// /// Called after has been changed. /// protected virtual void OnAfterGrabActionChange() { Configuration.ConfigureInteractor(); } /// /// Called after has been changed. /// protected virtual void OnAfterLengthAxisActionChange() { Configuration.ConfigurePointer(); } /// /// Called after has been changed. /// protected virtual void OnAfterLengthAxisMultiplierChange() { Configuration.ConfigurePointer(); } /// /// Called after has been changed. /// protected virtual void OnAfterVelocityTrackerChange() { Configuration.ConfigureInteractor(); } /// /// Called after has been changed. /// protected virtual void OnAfterAutoGrabOnEnterChange() { Configuration.ConfigureGrabOnEnter(); } /// /// Called after has been changed. /// protected virtual void OnAfterTargetValidityChange() { Configuration.ConfigurePointerRules(); } /// /// Called after has been changed. /// protected virtual void OnAfterRaycastRulesChange() { Configuration.ConfigurePointerRules(); } } }