ClimbingTowerTeleporterNode
A class in Root.Township, Features.Gameplay.ClimbingTower.
Climbing tower teleporter. The root node at the tower base sends a player to the highest child node they hold the orb for; child nodes send them back to the root; the outside node sends them out of the tower. Teleports run on the server.
- Listed in ATT, Features and other game namespaces
- Inherits or implements
NetworkEntityBehaviour,ISavable<ClimbingTowerTeleporterNodeSaveData>,ISavableSave<ClimbingTowerTeleporterNodeSaveData>,ISavableSaveBase - Derived types
ClimbingTowerTeleporterNodeSaveData
Constructors
| Member | What it is |
|---|---|
ClimbingTowerTeleporterNode() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
13 private and internal fields
| Member | What it is |
|---|---|
private readonly List<ClimbingTowerTeleporterNode> childTeleporterNodes | The root node's child nodes, filled from its children on the server and from the sync on clients. |
private Interactable interactable | The interactable that starts the teleport. |
private bool isOutsideTowerTeleporterNode | Marks the end teleporter that sends players out of the tower. |
private bool isRootTeleporterNode | Marks the tower's start node. |
private static readonly Logger logger | NLog logger for this class. |
private uint orbIndexToActivateTeleporterNode | The orb a player needs to use this node, or to be sent to it. |
private PlayerUnlock playerUnlock | Inspector unlock field. Not used by this class's code. |
private static ClimbingTowerTeleporterNode rootTeleporterNode | Static, so shared by every tower: the most recently set root node. |
private MethodSync syncSaveDataToClient | Method sync for the orb index and child list. |
private TeleportDefinition teleportDefinition | Teleport effect used to move the player. |
private float teleportDelayInSeconds | Wait before teleporting, default 3 seconds. |
private Vector3 teleportOffset | Local offset of the arrival point at this node. |
private PlayerUnlockStation unlockStation | Optional unlock station checked for the no-delay completion case. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Adds the interaction filter (except on the outside node) and creates the save-data method sync on SyncC. |
override void InitializeAsServer(SpawnData spawnData) | Server: makes the entity pick its location chunk by position, and records itself as the root if it is one. |
override void OnConnected(Player player) | Server: collects references and sends the orb index and child node list to the joining player. |
void Teleport(Interactable interactable) | Teleports the last player who used the interactable, after the delay. Hooked up from the scene. |
async void TeleportAsync(PlayerController player, float delayInSeconds) | Server: finds the destination, sets a checkpoint when leaving the root, waits the delay, then teleports and turns the player. |
15 private and internal methods
| Member | What it is |
|---|---|
private float CalculateTeleportDelay(PlayerController player) | No delay if the player is at a completion station without all orbs, otherwise teleportDelayInSeconds. |
private bool CanPlayerTeleportToChildNode(PlayerController player, out int childNodeIndex) | Finds the last child node whose orb the player has, returning its index. |
private bool CanPlayerTeleportToRootNode(PlayerController player) | True if the player has this node's orb. |
private bool CanSetCheckpointToChildNode(PlayerController player) | True on the root node when the player has at least one orb. |
private void FilterTeleporterInteraction(Interactor interactor, Interactable interactable, ref bool result) | Interaction filter: only lets a player use the teleporter if it has somewhere to send them. |
private bool GetTeleportLocationForChildNode(PlayerController player, out PositionAndRotationTarget target) | Gets the offset position of the highest child node the player can reach. |
private bool GetTeleportLocationForCompletionNode(PlayerController player, out PositionAndRotationTarget target) | Picks a random spot in the OutsideTower spawn area if the player has this node's orb, otherwise in TowerCP2. |
private bool GetTeleportLocationForRootNode(PlayerController player, out PositionAndRotationTarget target) | Gets the root node's offset position, if the player has this node's orb. |
private bool GetTeleportPositionAndRotation(PlayerController player, out PositionAndRotationTarget target) | Picks the destination based on whether this is the outside, root or a child node. |
private Vector3 GetTeleportTarget() | World position of this node with teleportOffset applied. |
private void InitializeReferences() | On the root node, collects child nodes from its direct children and points them at this root. |
private void OnDrawGizmos() | Draws a red sphere at the teleport offset in the editor. |
private bool PlayerCompletedChallengeWithoutAllOrbs(PlayerController player) | True if the unlock station is a completion station and the player lacks some orbs. |
private void SetRootNode(ClimbingTowerTeleporterNode newRootNode) | Sets the root node reference. |
private void SyncSaveDataToClient(IPlayer player, Stream stream) | Server to client: sends the orb index and the child nodes' entity IDs, which the client resolves into childTeleporterNodes. |