Skip to main content

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.

Constructors​

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

Fields​

8 private and internal fields
MemberWhat it is
private float currentProgressProgress currently shown.
private bool isLerpingWhether progress eases towards the target instead of jumping.
private IUnityUpdateMethod lerpingRotationHandle of the registered per-frame lerp, null when not easing.
private float lerpSpeedProgress per second when easing.
private DrawBridgeRangeLogicSaveData savedSave data holding the two angles.
private MethodSync syncMethod sync for the target progress.
private Transform targetTransform that is rotated.
private float targetProgressProgress to reach, set by SetProgress or a sync.

Properties​

MemberWhat 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
MemberWhat it is
private Vector3 IPointTowards.Origin { get; }World position of the rotated target.

Methods​

MemberWhat 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
MemberWhat 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.