namespace VRTK.Prefabs.Interactions.Interactables.Grab.Provider { using UnityEngine; using System.Collections.Generic; using Malimbe.XmlDocumentationAttribute; using Malimbe.PropertySerializationAttribute; using Zinnia.Event.Proxy; using Zinnia.Extension; using Zinnia.Data.Attribute; using VRTK.Prefabs.Interactions.Interactors; /// /// Processes a received grab event and passes it over to the appropriate grab actions. /// public abstract class GrabInteractableInteractorProvider : MonoBehaviour { #region Input Settings /// /// The input for the grab action. /// [Serialized] [field: Header("Input Settings"), DocumentedByXml, Restricted] public GameObjectEventProxyEmitter InputGrabReceived { get; protected set; } /// /// The input for the ungrab action. /// [Serialized] [field: DocumentedByXml, Restricted] public GameObjectEventProxyEmitter InputUngrabReceived { get; protected set; } #endregion #region Primary Output Settings /// /// The output for the primary grab action. /// [Serialized] [field: Header("Primary Output Settings"), DocumentedByXml, Restricted] public GameObjectEventProxyEmitter OutputPrimaryGrabAction { get; protected set; } /// /// The output for the primary grab setup on secondary action. /// [Serialized] [field: DocumentedByXml, Restricted] public GameObjectEventProxyEmitter OutputPrimaryGrabSetupOnSecondaryAction { get; protected set; } /// /// The output for the primary ungrab action. /// [Serialized] [field: DocumentedByXml, Restricted] public GameObjectEventProxyEmitter OutputPrimaryUngrabAction { get; protected set; } /// /// The output for the primary ungrab reset on secondary action. /// [Serialized] [field: DocumentedByXml, Restricted] public GameObjectEventProxyEmitter OutputPrimaryUngrabResetOnSecondaryAction { get; protected set; } #endregion #region Secondary Output Settings /// /// The output for the secondary grab action. /// [Serialized] [field: Header("Secondary Output Settings"), DocumentedByXml, Restricted] public GameObjectEventProxyEmitter OutputSecondaryGrabAction { get; protected set; } /// /// The output for the Secondary ungrab action. /// [Serialized] [field: DocumentedByXml, Restricted] public GameObjectEventProxyEmitter OutputSecondaryUngrabAction { get; protected set; } #endregion /// /// Gets the available grabbing Interactors from the provider. /// /// A collection of Interactors that are currently grabbing the Interactable. public abstract IReadOnlyList GrabbingInteractors { get; } /// /// A reusable collection to hold the returned grabbing interactors. /// protected readonly List grabbingInteractors = new List(); /// /// Gets the Grabbing Interactors stored in the given collection. /// /// The collection to retrieve the Grabbing Interactors from. /// A collection of Grabbing Interactors. protected virtual IReadOnlyList GetGrabbingInteractors(IEnumerable elements) { grabbingInteractors.Clear(); if (elements == null) { return grabbingInteractors; } foreach (GameObject element in elements) { InteractorFacade interactor = element.TryGetComponent(true, true); if (interactor != null) { grabbingInteractors.Add(interactor); } } return grabbingInteractors; } } }