Skip to main content

TeleporterPlatform

A class in Root.Township, the global namespace.

Platform that fires finished after a player stands on it for duration seconds, with progress events for visuals. The local client times it and tells the server, which relays to others.

Constructors​

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

Fields​

18 private and internal fields
MemberWhat it is
private float durationSeconds a player must stand on the platform.
private float fadeDurationSeconds for the visual progress to fall back to zero.
private CharacterControllerEvent finishedEvent raised with the player controller when the timer completes.
private bool isLocalPressingTrue while the local player is on the platform.
private bool isNetworkedTrue once initialized as a network entity; then a local player is required.
private bool isProgressingTrue while anyone is pressing.
private bool isRemotePressingLast pressing state received over the network.
private PlayerController localCharacterThe local player standing on the platform.
private float localEndTimeTime the local player's wait completes.
private HashSet<IPlayer> pressingServer: players currently on the platform.
private FloatEvent progressChangedEvent raised with the curved progress value each update.
private AnimationCurve progressCurveCurve that maps progress to the value sent to progressChanged.
private BoolEvent progressingChangedEvent raised when the platform starts or stops progressing.
private MethodSync syncFinishMethod sync for finishing.
private MethodSync syncPressingMethod sync for the pressing state.
private TriggerShape triggerTrigger shape players stand in.
private IUnityUpdateMethod updateRegistered update method while progress is moving.
private float visualProgressProgress from 0 to 1 shown to the player.

Methods​

MemberWhat it is
override void Initialize()Sets up the pressing and finished method syncs and marks the platform as networked.
override void OnConnected(Player player)Server: tells a joining player the platform is pressed, if anyone is on it.
9 private and internal methods
MemberWhat it is
private void Awake()Subscribes to the trigger's enter and exit events.
private void Entered(Collider collider)When the local player steps on, starts the timer and tells the server they're pressing.
private void Exited(Collider collider)When the local player steps off, stops the timer and tells the server.
private void OnDestroy()Unsubscribes from players and stops updating.
private void OnProgressingChanged()Raises progressingChanged when anyone starts or stops pressing and starts the progress update.
private void RemovePlayer(NetworkEntity entity, bool isUnload)Drops a destroyed player from the pressing set.
private void SyncFinished(IPlayer player, Stream stream)Server: on a finish from a pressing player, raises finished and relays. Clients raise finished with null.
private void SyncPressing(IPlayer player, Stream stream)Sends whether this side is pressing; the server tracks which players are on the platform.
private void UpdateProgress()Each frame: finishes the local timer when it runs out, moves the visual progress up or down and raises progressChanged.