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.
- Listed in Global namespace: T to X
- Inherits or implements
NetworkEntityBehaviour
Constructors
| Member | What it is |
|---|---|
TeleporterPlatform() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
18 private and internal fields
| Member | What it is |
|---|---|
private float duration | Seconds a player must stand on the platform. |
private float fadeDuration | Seconds for the visual progress to fall back to zero. |
private CharacterControllerEvent finished | Event raised with the player controller when the timer completes. |
private bool isLocalPressing | True while the local player is on the platform. |
private bool isNetworked | True once initialized as a network entity; then a local player is required. |
private bool isProgressing | True while anyone is pressing. |
private bool isRemotePressing | Last pressing state received over the network. |
private PlayerController localCharacter | The local player standing on the platform. |
private float localEndTime | Time the local player's wait completes. |
private HashSet<IPlayer> pressing | Server: players currently on the platform. |
private FloatEvent progressChanged | Event raised with the curved progress value each update. |
private AnimationCurve progressCurve | Curve that maps progress to the value sent to progressChanged. |
private BoolEvent progressingChanged | Event raised when the platform starts or stops progressing. |
private MethodSync syncFinish | Method sync for finishing. |
private MethodSync syncPressing | Method sync for the pressing state. |
private TriggerShape trigger | Trigger shape players stand in. |
private IUnityUpdateMethod update | Registered update method while progress is moving. |
private float visualProgress | Progress from 0 to 1 shown to the player. |
Methods
| Member | What 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
| Member | What 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. |