namespace VRTK.Prefabs.Interactions.Haptics
{
using UnityEngine;
using Malimbe.MemberChangeMethod;
using Malimbe.XmlDocumentationAttribute;
using Malimbe.PropertySerializationAttribute;
using Zinnia.Data.Attribute;
using Zinnia.Data.Collection.List;
using VRTK.Prefabs.Interactions.Interactors;
public class InteractorHapticsFacade : MonoBehaviour
{
#region Haptics Settings
///
/// The intensity of the haptic rumble.
///
[Serialized]
[field: Header("Haptics Settings"), DocumentedByXml]
public float Intensity { get; set; } = 1f;
///
/// Whether to only apply haptics on the active interacting .
///
[Serialized]
[field: DocumentedByXml]
public bool OnlyRumbleActiveInteractor { get; set; } = true;
#endregion
#region Interactor Settings
///
/// The interactors that are considered part of the left controller.
///
[Serialized]
[field: Header("Interactor Settings"), DocumentedByXml]
public UnityObjectObservableList LeftInteractors { get; set; }
///
/// The interactors that are considered part of the right controller.
///
[Serialized]
[field: DocumentedByXml]
public UnityObjectObservableList RightInteractors { get; set; }
#endregion
#region Reference Settings
///
/// The linked Interactor Haptics Internal Setup.
///
[Serialized]
[field: Header("Reference Settings"), DocumentedByXml, Restricted]
public InteractorHapticsConfigurator Configuration { get; protected set; }
#endregion
///
/// Applies the defined rules.
///
/// The source to match the rule against.
public virtual void ApplyRules(object source)
{
Configuration.RulesToMatch.Match(source);
}
///
/// Starts the haptics process.
///
public virtual void Begin()
{
Configuration.BeginHaptics.Receive();
}
///
/// Cancels the haptics process.
///
public virtual void Cancel()
{
Configuration.CancelHaptics.Receive();
}
///
/// Called after has been changed.
///
[CalledAfterChangeOf(nameof(Intensity))]
protected virtual void OnAfterIntensityChange()
{
Configuration.LeftHapicPuliser.Intensity = Intensity;
Configuration.RightHapicPuliser.Intensity = Intensity;
}
///
/// Called after has been changed.
///
[CalledAfterChangeOf(nameof(OnlyRumbleActiveInteractor))]
protected virtual void OnAfterOnlyRumbleActiveInteractorChange()
{
Configuration.RulesToMatch.gameObject.SetActive(OnlyRumbleActiveInteractor);
}
}
}