Skip to main content

Door

An abstract class in Root.Township, the global namespace.

Base for networked doors with a saved open/closed state that the server syncs to players. Subclasses implement HandleChange to animate it.

Constructors​

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

Fields​

2 private and internal fields
MemberWhat it is
private bool isOpenBacking field for IsOpen; also the saved value.
private MethodSync syncMethod sync used for the open state.

Properties​

MemberWhat it is
bool IsOpen { get; }Whether the door is currently open.

Methods​

MemberWhat it is
override void Initialize()Creates the method sync for the open state.
override void OnConnected(Player player)Sends the current open state to a joining player.
void SetOpen(bool isOpen)Server: sets the open state, syncs it to the chunks and calls HandleChange if it changed.
protected abstract void HandleChange()Called when the open state changes, on the server in SetOpen and on clients when a sync arrives.
1 private and internal method
MemberWhat it is
private void Sync(IPlayer player, Stream stream)Reads or writes the open state and calls HandleChange when a read changes it.