Skip to main content

PlayerUnlockStation

A class in Root.Township, the global namespace.

A station in a climbing challenge (PlayerUnlock): start, orb checkpoint, completion, or a permanent unlock. Server side; touching it sets the player's checkpoint and adds its orb.

Constructors​

MemberWhat it is
PlayerUnlockStation()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

17 private and internal fields
MemberWhat it is
private IAnalyticsService analyticsServiceInjected analytics service.
private PlayerUnlock climbingUnlockThe PlayerUnlock (challenge) this station belongs to.
private float cooldownSeconds between interactions with the station. Defaults to 1.
private float cooldownEndTimeTime the cooldown ends.
private HandHoverPoint handHoverHand hover point the player charges to use the station; its activation calls Interact on the server.
private Interactable interactableInteractable whose filter decides who can use the station.
private float interactionDelaySeconds the server waits after activation before handling it.
private readonly Logger loggerNLog logger for this class.
private int orbIndexBacking field for OrbIndex; -1 for no orb.
private Transform orbParentWhere the orb model is placed.
private PlayerUnlockStation.UnlockStationType stationTypeBacking field for StationType.
private MethodSyncStruct<PlayerUnlockStation.NetworkEffect> syncEffectMethod sync for station effects.
private MethodSyncStruct<PlayerUnlockStation.InteractionInfo> syncInteractionInfoToClientMethod sync for interaction results.
private MethodSync syncSaveDataToClientMethod sync for the station setup.
private AltaEvent triggeredCancelledEvent played when a challenge is cancelled.
private AltaEvent triggeredCompleteEvent played when a challenge is completed.
private AltaEvent triggeredUnlockEvent played when an orb is collected.

Properties​

MemberWhat it is
int OrbIndex { get; }Orb this station gives, or -1. Normal stations need the previous orb before you can use them.
PlayerUnlockStation.UnlockStationType StationType { get; }Normal, Start, Completion or Unlock.

Methods​

MemberWhat it is
override void Initialize()Sets up sync messages and the interaction filter. Clients set up the hand hover hint.
override void InitializeAsServer(SpawnData spawnData)Server: spawns the orb visual and handles the hand hover activation.
void Inject(IAnalyticsService newAnalyticsService)Receives the analytics service.
async void Interact(IPlayer player)Server: with a cooldown and optional delay, runs the station for the player (start, checkpoint and orb, or completion) and sends the result to them.
override void OnConnected(Player player)Server: sends the station's unlock, orb index and type to a joining player.
bool PlayerHasAllOrbs(IPlayer player)True if the player has this station's orb. On a completion station that orb index stands for the last one.
18 private and internal methods
MemberWhat it is
private void AddOrb(IPlayer player)Server: gives the player this station's orb and plays the unlock effect for the chunk.
private void CancelUnlock(IPlayer player, PlayerUnlockStation.NetworkEffect effect)Server: ends the player's current challenge and plays an effect (complete or cancelled) for the chunk.
private bool CanInteractWithUnlockStation(IPlayer player)True if the player has a challenge running and already holds the previous orb (index minus 1).
private void FilterStationInteraction(Interactor interactor, Interactable interactable, ref bool result)Blocks the hand hover on normal and unlock stations for players who can't use them yet.
private bool HandHoverHasContent()Client attracting check: start and completion stations always attract; others only when the local player can use them.
private void InitializeHandHoverAttractingState(PlayerController _)Gives the hand hover point its attracting check.
private void InteractWithCompletionStation(IPlayer player)If the player holds the final orb, takes all orbs and completes the challenge.
private void InteractWithStartStation(IPlayer player)Starts this station's challenge for the player and clears their orbs.
private void InteractWithStation(IPlayer player)Runs the start or unlock behaviour for the station type; normal stations do nothing extra.
private void InteractWithUnlockStation(IPlayer player)Gives the player this station's unlock permanently.
private void RemoveOrbs(IPlayer player)Takes every orb from the player.
private void SendAnalyticsEvent(PlayerUnlockStation.InteractionInfo interactionInfo)Client: sends a challenge completed or checkpoint reached analytics event.
private void SetCheckpoint(IPlayer player)Sets the player's challenge checkpoint to their feet position.
private void SetupHandHoverAttractingState()Client: sets up the attracting check once the local player exists.
private void SpawnOrb()Client: places this station's orb model under orbParent.
private void SyncEffect(IPlayer player, Stream stream, PlayerUnlockStation.NetworkEffect arguments)Plays the unlock, complete or cancelled event on remote clients.
private void SyncInteractionInfoToClient(IPlayer player, Stream stream, PlayerUnlockStation.InteractionInfo interactionInfo)Sends the interaction result to the player, whose client turns it into an analytics event.
private void SyncSaveDataToClient(IPlayer player, Stream stream)Sends the unlock, orb index and station type to a client, which then spawns the orb.

Used in​

Members of other types that take, return or hold a PlayerUnlockStation: