//\Assets\SteamVR\InteractionSystem\Teleport\Scripts\
//Purpose: Handles all the teleport logic.(立钻哥哥:用途:处理所有的传送逻辑.)
using UnityEngine;
using UnityEngine.Events;
using System.Collections;
namespace Valve.VR.InteractionSystem{
public class Teleport : MonoBehaviour{
public SteamVR_Action_Boolean teleportAction = SteamVR_Input.GetAction<SteamVR_Action_Boolean>(“Teleport”);
public LayerMask traceLayerMask;
public LayerMask floorFixupTraceLayerMask;
public float floorFixupMaximumTraceDistance = 1.0f;
public Material areaVisibleMaterial;
public Material areaLockedMaterial;
public Material areaHighlightedMaterial;
public Material pointVisibleMaterial;
public Material pointLockedMaterial;
public Material pointHighlightedMaterial;
public Transform destinationReticleTransform;
public Transform invalidReticleTransform;
public GameObject playAreaPreviewCorner;
public GameObject playAreaPreviewSide;
public Color pointerValidColor;
public Color pointerInvalidColor;
public Color pointerLockedColor;
public bool showPlayAreaMarker = true;
public float teleportFadeTime = 0.1f;
public float meshFadeTime = 0.2f;
public float arcDistance = 10.0f;
[Header(“Effects(立钻哥哥:效果)”)]
public Transform onActivateObjectTransform;
public Transform onDeactivateObjectTransform;
public float activateObjectTime = 1.0f;
public float deactivateObjectTime = 1.0f;
[Header(“Audio Sources(立钻哥哥:声音来源)”)]
public AudioSource pointerAudioSource;
public AudioSource loopingAudioSource;
public AudioSource headAudioSource;
public AudioSource reticleAudioSource;
[Header(“Sounds(立钻哥哥:音效)”)]
public AudioClip teleportSound;
public AudioClip pointerStartSound;
public AudioClip pointerLoopSound;
public AudioClip pointerStopSound;
public AudioClip goodHighlightSound;
public AudioClip badHighlightSound;
[Header(“Debug(立钻哥哥:调试)”)]
public bool debugFloor = false;
public bool showOffsetReticle = false;
public Transform offsetReticleTransform;
public MeshRenderer floorDebugSphere;
public LineRenderer floorDebugLine;
private LineRenderer pointerLineRenderer;
private GameObject teleportPointerObject;
private Transform pointerStartTransform;
private Hand pointerHand = null;
private Player player = null;
private TeleportArc teleportArc = null;
private bool visible = false;
private TeleportMarkerBase[] teleportMarkers;
private TeleportMarkerBase pointedAtTeleportMarker;
private TeleportMarkerBase teleportingToMarker;
private Vector3 pointedAtPosition;
private Vector3 prevPointedAtPosition;
private bool teleporting = false;
private float currentFadeTime = 0.0f;
private float meshAlphaPercent = 1.0f;
private float pointerShowStartTime = 0.0f;
private float pointerHideStartTime = 0.0f;
private bool meshFading = false;
private float fullTintAlpha;
private float invalidReticleMinScale = 0.2f;
private float invalidReticleMaxScale = 1.0f;
private float invalidReticleMinScaleDistance = 0.4f;
private float invalidReticleMaxScaleDistance = 2.0f;
private Vector3 invalidReticleScale = Vector3.one;
private Quaternion invalidReticleTargetRotation = Quaternion.identity;
private Transform playAreaPreviewTransform;
private Transform[] playAreaPreviewCorners;
private Transform[] playAreaPreviewSides;
private float loopingAudioMaxVolume = 0.0f;
private Coroutine hintCoroutine = null;
private bool originalHoverLockState = false;
private Interactable originalHoveringInteractable = null;
private AllowTeleportWhileAttachedToHand allowTeleportWhileAttached = null;
private Vector3 startingFeetOffset = Vector3.zero;
private bool movedFeetFarEnough = false;
SteamVR_Events.Action chaperoneInfoInitializedAction;
//Events(立钻哥哥:事件)
public static SteamVR_Events.Event<float> ChangeState = new SteamVR_Events.Event<float>();
public static SteamVR_Events.Action<float> ChangeSceneAction(UnityAction<float> action){};
public static SteamVR_Events.Event<TeleportMarkderBase> Player = new SteamVR_Events.Event<TeleportMarkerBase>();
public static SteamVR_Events.Action<TeleportMarkerBase> PlayerAction(UnityAction<TeleportMarkerBase> actionsss){}
public static SteamVR_Events.Event<TeleportMarkerBase> PlayerPre = new SteamVR_Events.Event<TeleportMarkerBase>();
public static SteamVR_Events.Action<TeleportMarkerBase> PlayerPreAction(UnityAction<TeleportMarkerBase> action){}
private static Teleport _instance;
public static Teleport instance{}
void Awake(){
_instance = this;
chaperoneInfoInitializedAction = ChaperoneInfo.InitializedAction(OnChaperoneInfoInitialized);
pointerLineRenderer = GetComponentInChildren<LineRenderer>();
teleportPointerObject = pointerLineRenderer.gameObject;
int tintColorID = Shader.PropertyToID(“_TintColor”);
fullTintAlpha = pointVisibleMaterial.GetColor(tintColorID).a;
teleportArc = GetComponent<TeleportArc>();
teleportArc.traceLayerMask = traceLayerMask;
loopingAudioMaxVolue = loopingAudioSource.volume;
playAreaPreviewCorner.SetActive(false);
playAreaPreviewSide.SetActive(false);
float invalidReticleStartingScale = invalidReticleTransform.localScale.x;
invalidReticleMinScale *= invalidReticleStartingScale;
invalidReticleMaxScale *= invalidReticleStartingScale;
} //立钻哥哥:void Awake(){}
void Start(){
teleportMarkers = GameObject.FindObjectsOfType<TeleportMarkerBase>();
HidePointer();
player = InteractionSystem.Player.instance;
if(player == null){
(“<b>立钻哥哥:[SteamVR Interaction]</b> Teleport: No Player instance found in map.”);
Destroy(this.gameObject);
return;
}
CheckForSpawnPoint();
Invoke(“ShowTeleportHint”, 5.0f);
} //立钻哥哥:void Start(){}
void OnEnable(){
chaperoneInfoInitializedAction.enabled = true;
OnChaperoneInfoInitialized();
}
void OnDisable(){
chaperoneInfoInitializedAction.enabled = false;
HidePointer();
}
private void CheckForSpawnPoint(){}
pubic void HideTeleportPointer(){}
void Update(){}
private void UpdatePointer(){}
void FixedUpdate(){}
private void OnChaperoneInfoInitialized(){}
private void HidePointer(){}
private void ShowPointer(Hand newPointerHand, Hand oldPointerHand){}
private void UpdateTeleportColors(){}
private void PlayAudioClip(AudioSource source, AudioClip clip){}
private void PlayPointerHaptic(bool validLocation){}
private void TryTeleportPlayer(){}
private void InitiateTeleportFade(){}
private void TeleportPlayer(){}
private void HighlightSelected(TeleportMarkerBase hitTeleportMarker){}
public void ShowTeleportHint(){}
public void CancelTeleportHint(){}
private IEnumerator TeleportHintCoroutine(){}
public bool IsEligibleForTeleport(Hand hand){}
private bool ShouldOverrideHoverLock(){}
private bool WasTeleportButtonReleased(Hand hand){}
private bool IsTeleportButtonDown(Hand hand){}
private bool WasTeleportButtonPressed(Hand hand){}
private Transform GetPointerStartTransform(Hand hand){}
} //立钻哥哥:public class Teleport:MonoBehaviour{}
} //立钻哥哥:namespace {}