Skip to content

Commit

Permalink
chore: underchores
Browse files Browse the repository at this point in the history
  • Loading branch information
SilasPeters committed Apr 29, 2024
1 parent bba93e2 commit 9fd9ed0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions aplib.net-demo/Assets/Scripts/Teleporter/Teleporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ public class Teleporter : MonoBehaviour
/// </summary>
[Header("Parameters")]
[SerializeField]
private float teleportWindUpTime = 2f;
private float _teleportWindUpTime = 2f;

/// <summary>
/// An offset from this teleporter's position, on which the player will be teleported to when teleporting to this
/// teleporter.
/// </summary>
[SerializeField]
private Vector3 landingPointOffset = new(0, 1, 0);
private Vector3 _landingPointOffset = new(0, 1, 0);

/// <summary>
/// A reference to the FX parent gameobject, containing all special effects of the teleporter to be
/// activated during wind up.
/// </summary>
[Header("References")]
[SerializeField]
private GameObject FX;
private GameObject _FX;

/// <summary>
/// The teleporter to which the player must be teleported. This is a one-directional link. To be bidirectional,
Expand All @@ -40,7 +40,7 @@ public class Teleporter : MonoBehaviour
/// <summary>
/// The absolute position to which the player will be teleported to when teleporting to this teleporter.
/// </summary>
public Vector3 LandingPoint => transform.position + landingPointOffset;
public Vector3 LandingPoint => transform.position + _landingPointOffset;

/// <summary>
/// A simple reference to the player's transform, for performance reasons.
Expand Down Expand Up @@ -82,7 +82,7 @@ private void OnTriggerEnter(Collider other)
return;
}

FX.SetActive(true);
_FX.SetActive(true);
_waitThenTeleportCoroutine = StartCoroutine(WaitThenTeleport()); // Store reference to be able to stop it prematurely
}

Expand All @@ -95,18 +95,18 @@ private void OnTriggerExit(Collider other)
{
if (!other.CompareTag("Player")) return; // Only trigger for player

FX.SetActive(false);
_FX.SetActive(false);
if (_waitThenTeleportCoroutine != null) // Can be null when player gets teleported to this teleporter
StopCoroutine(_waitThenTeleportCoroutine); // Stop coroutine prematurely when player exits during wind up time
}

/// <summary>
/// Waits for <see cref="teleportWindUpTime"/>, then starts the teleport. This allows the FX to play.
/// Waits for <see cref="_teleportWindUpTime"/>, then starts the teleport. This allows the FX to play.
/// </summary>
/// <returns>IEnumerator representing coroutine</returns>
private IEnumerator WaitThenTeleport()
{
yield return new WaitForSeconds(teleportWindUpTime);
yield return new WaitForSeconds(_teleportWindUpTime);

// Teleport the player
targetTeleporter.TeleportReceive(_playerTransform);
Expand Down

0 comments on commit 9fd9ed0

Please sign in to comment.