namespace VRTK.Prefabs.Locomotion.Teleporters
{
using UnityEngine;
using Malimbe.MemberChangeMethod;
using Malimbe.MemberClearanceMethod;
using Malimbe.XmlDocumentationAttribute;
using Malimbe.PropertySerializationAttribute;
using Zinnia.Rule;
using Zinnia.Data.Type;
using Zinnia.Data.Attribute;
using Zinnia.Tracking.Modification;
///
/// The public interface into the Teleporter Prefab.
///
public class TeleporterFacade : MonoBehaviour
{
///
/// The type of offset to apply when teleporting.
///
public enum OffsetType
{
///
/// Updates the teleported position with the affecting the position but the destination rotation has no effect on the teleported rotation.
///
OffsetAlwaysIgnoreDestinationRotation,
///
/// Updates the teleported position with the affecting the position and the destination rotation affecting the teleported rotation.
///
OffsetAlwaysWithDestinationRotation,
///
/// Updates the teleported position but only uses the when affecting the floor snap position but the destination rotation has no effect on the teleported rotation.
///
OffsetFloorSnapOnlyIgnoreDestinationRotation
}
#region Teleporter Settings
///
/// The target to move to the teleported position.
///
[Serialized, Cleared]
[field: Header("Teleporter Settings"), DocumentedByXml]
public GameObject Target { get; set; }
///
/// The offset to compensate the teleported target position by for both floor snapping and position movement.
///
[Serialized, Cleared]
[field: DocumentedByXml]
public GameObject Offset { get; set; }
///
/// Determines how to use the when calculating the teleport location.
///
[Serialized]
[field: DocumentedByXml]
public OffsetType OffsetUsage { get; set; }
///
/// Determines if the teleport destination will be applied to the .
///
[Serialized]
[field: DocumentedByXml]
public bool ApplyDestinationRotation { get; set; } = true;
///
/// The of scene s to apply a fade to.
///
[Serialized, Cleared]
[field: DocumentedByXml]
public RuleContainer CameraValidity { get; set; }
///
/// Allows to optionally determine targets based on the set rules.
///
[Serialized, Cleared]
[field: DocumentedByXml]
public RuleContainer TargetValidity { get; set; }
#endregion
#region Teleporter Events
///
/// Emitted when the teleporting is about to initiate.
///
[Header("Teleporter Events"), DocumentedByXml]
public TransformPropertyApplier.UnityEvent Teleporting = new TransformPropertyApplier.UnityEvent();
///
/// Emitted when the teleporting has completed.
///
[DocumentedByXml]
public TransformPropertyApplier.UnityEvent Teleported = new TransformPropertyApplier.UnityEvent();
#endregion
#region Reference Settings
///
/// The linked Internal Setup.
///
[Serialized, Cleared]
[field: Header("Reference Settings"), DocumentedByXml, Restricted]
public TeleporterConfigurator Configuration { get; protected set; }
#endregion
///
/// Attempts to teleport the .
///
/// The location to attempt to teleport to.
public virtual void Teleport(TransformData destination)
{
Configuration.Teleport(destination);
}
///
/// Sets .
///
/// The index of the .
public virtual void SetOffsetUsage(int offsetTypeIndex)
{
OffsetUsage = (OffsetType)Mathf.Clamp(offsetTypeIndex, 0, System.Enum.GetValues(typeof(OffsetType)).Length);
}
///
/// Called after has been changed.
///
[CalledAfterChangeOf(nameof(Target))]
protected virtual void OnAfterTargetChange()
{
Configuration.ConfigureTransformPropertyAppliers();
}
///
/// Called after has been changed.
///
[CalledAfterChangeOf(nameof(Offset))]
protected virtual void OnAfterOffsetChange()
{
Configuration.ConfigureSurfaceLocatorAliases();
Configuration.ConfigureTransformPropertyAppliers();
}
///
/// Called after has been changed.
///
[CalledAfterChangeOf(nameof(OffsetUsage))]
protected virtual void OnAfterOffsetUsageChange()
{
Configuration.ConfigureTransformPropertyAppliers();
}
///
/// Called after has been changed.
///
[CalledAfterChangeOf(nameof(ApplyDestinationRotation))]
protected virtual void OnAfterApplyDestinationRotationChange()
{
Configuration.ConfigureRotationAbility(ApplyDestinationRotation);
}
///
/// Called after has been changed.
///
[CalledAfterChangeOf(nameof(CameraValidity))]
protected virtual void OnAfterCameraValidityChange()
{
Configuration.ConfigureCameraColorOverlays();
}
///
/// Called after has been changed.
///
[CalledAfterChangeOf(nameof(TargetValidity))]
protected virtual void OnAfterTargetValidityChange()
{
Configuration.ConfigureSurfaceLocatorRules();
}
}
}