DrawBridgeRangeLogic
A class in Root.Township, the global namespace.
Networked drawbridge that sets a target transform's Z angle between two saved angles from a 0 to 1 progress value, optionally easing towards it. The server syncs the progress.
- Listed in Global namespace: C to D
- Inherits or implements
NetworkEntityBehaviour,ISavable<DrawBridgeRangeLogicSaveData>,ISavableSave<DrawBridgeRangeLogicSaveData>,ISavableSaveBase,IPointTowards - Derived types
DrawBridgeRangeLogicSaveData
Constructors
| Member | What it is |
|---|---|
DrawBridgeRangeLogic() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
8 private and internal fields
| Member | What it is |
|---|---|
private float currentProgress | Progress currently shown. |
private bool isLerping | Whether progress eases towards the target instead of jumping. |
private IUnityUpdateMethod lerpingRotation | Handle of the registered per-frame lerp, null when not easing. |
private float lerpSpeed | Progress per second when easing. |
private DrawBridgeRangeLogicSaveData saved | Save data holding the two angles. |
private MethodSync sync | Method sync for the target progress. |
private Transform target | Transform that is rotated. |
private float targetProgress | Progress to reach, set by SetProgress or a sync. |
Properties
| Member | What it is |
|---|---|
float Angle0 { get; set; } | Angle in degrees at progress 0, stored in the save data. |
float Angle1 { get; set; } | Angle in degrees at progress 1, stored in the save data. |
1 private and internal property
Methods
| Member | What it is |
|---|---|
override void Initialize() | Creates the method sync for the progress. |
override void OnConnected(Player player) | Sends the target progress to a joining player. |
void SetProgress(float progress) | Sets the target progress, applies it now or starts easing, and on the server syncs it to the chunks. |
5 private and internal methods
| Member | What it is |
|---|---|
private void LerpRotation() | Per-frame update that moves the current progress towards the target and stops when close. |
private void OnDestroy() | Removes the per-frame lerp update. |
private void IPointTowards.PointTowards(Vector3 target) | Sets Angle0 so the target points at a world position and applies the rotation. |
private void SetRotation() | Applies the current progress as a rotation around local Z on the target. |
private void Sync(IPlayer player, Stream stream) | Sends the target progress from the server only, packed as a 0 to 1 float. |