namespace VRTK.Prefabs.Locomotion.DestinationLocations { using UnityEngine; using Malimbe.BehaviourStateRequirementMethod; using Zinnia.Extension; using Zinnia.Data.Type; /// /// Handles receiving and dispatching appropriate actions to the relevant . /// public class ActionDispatcher : MonoBehaviour { /// /// The currently selected . /// public DestinationLocation SelectedLocation { get; protected set; } /// /// Handles potentially entering a . /// /// The potential interaction of something entering a . [RequiresBehaviourState] public void Enter(SurfaceData data) { DestinationLocation location = GetLocation(data); if (location == null) { return; } location.Enter(data); } /// /// Handles potentially exiting a . /// /// The potential interaction of something exiting a . [RequiresBehaviourState] public void Exit(SurfaceData data) { DestinationLocation location = GetLocation(data); if (location == null) { return; } location.Exit(data); } /// /// Handles potentially making a selection on a . /// /// The potential interaction of something selecting a . [RequiresBehaviourState] public void Select(SurfaceData data) { if (SelectedLocation != null && data != null) { SelectedLocation.Deselect(); } DestinationLocation location = GetLocation(data); if (location == null) { return; } location.Select(data); SelectedLocation = location; } /// /// Gets a if one exists in the given colliding transform or parent. /// /// The data to check. /// The found . protected virtual DestinationLocation GetLocation(SurfaceData data) { if (data == null || data.CollisionData.transform == null) { return null; } return data.CollisionData.transform.gameObject.TryGetComponent(false, true); } } }