SafePositionSetter
A class in Root.Township, the global namespace.
A networked marker that, when triggered, sets a player's fall-recovery safe position to its target point. Only one is current per client; becoming current or not fires events and animates a 0 to 1 progress.
- Listed in Global namespace: S
- Inherits or implements
NetworkEntityBehaviour,ISavable<SafePositionSetterData>,ISavableSave<SafePositionSetterData>,ISavableSaveBase - Derived types
SafePositionSetterData
Constructors
| Member | What it is |
|---|---|
SafePositionSetter() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
11 private and internal fields
| Member | What it is |
|---|---|
private float animationDuration | Seconds the progress animation takes. Default 2. |
private FloatEvent animationUpdate | Float event fired with the progress value during the animation. |
private static SafePositionSetter currentSafePositionSetter | The setter that last set the local player's safe position, if still active. |
private AltaEvent onBecameActive | Event fired when this becomes the current setter. |
private AltaEvent onBecameInactive | Event fired when this stops being the current setter. |
private float progress | Current animation progress from 0 to 1. |
private Coroutine progressAnimation | The running Animate coroutine, if any. |
private MethodSync syncActivated | Method sync the server uses to tell a client to apply the safe position. |
private MethodSync syncPosition | Method sync for the target's offset. |
private Transform target | Transform marking the safe position. Its local position is saved and synced. |
private float targetProgress | Progress the animation is heading to: 1 when current, 0 when not. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Creates the activation and position method syncs. |
override void OnConnected(Player player) | Server: sends the target's offset to a joining player. |
void SetSafePosition(IPlayer player) | For a remote player the server tells their client to run it. For the local player, sets their smooth locomotion safe position to the target if the chunk allows it. |
7 private and internal methods
| Member | What it is |
|---|---|
private IEnumerator Animate() (iterator) | Client: coroutine that moves progress toward targetProgress over animationDuration and fires animationUpdate each frame. |
private void CheckForDisable(LocationChunk obj) | When the local player changes chunk and the chunk no longer overrides the safe position, makes this setter inactive. |
private void OnDestroy() | If this is the current setter, marks it inactive and clears the static current setter. |
private void OnDrawGizmos() | Editor: draws a line and sphere to the target point. |
private void SyncActivated(IPlayer player, Stream stream) | Client: on receiving the activation message, sets the safe position for the local player. |
private void SyncPosition(IPlayer player, Stream stream) | Syncs the target's local position, within 10 units on each axis. |
private void UpdateAsCurrent(bool isCurrent, bool withAnimation = true) | Makes this the current setter or clears it, fires the matching event and starts the progress animation. |