Skip to main content

LogicDisplay

A class in Root.Township, the global namespace.

Networked logic display: when a LogicBoolReceiver changes on the server, it syncs the value to clients and fires active or inactive Unity events (on clients, and on the server if enabled).

Constructors​

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

Fields​

6 private and internal fields
MemberWhat it is
private UnityEvent activeEvent fired when the value turns true.
private UnityEvent inactiveEvent fired when the value turns false.
private bool isRunningOnClientWhether clients get the value and fire the events (default true).
private bool isRunningOnServerWhether the server also fires the events.
private LogicBoolReceiver receiverThe logic bool input being shown.
private MethodSync syncMethod sync for the value; null when not running on clients.

Methods​

MemberWhat it is
override void Initialize()Creates the sync if the display runs on clients.
override void InitializeAsServer(SpawnData spawnData)Server: subscribes to the receiver's Changed event.
override void OnConnected(Player player)Server: sends the current value to a joining player.
3 private and internal methods
MemberWhat it is
private void HandleChange(bool value)Server: sends the new value to the chunks and fires the events locally if running on the server or in a local test.
private void Sync(IPlayer player, Stream stream)Server to client: writes the receiver's state, and on the client fires the matching event.
private void Trigger(bool isEnabled)Fires active for true, inactive for false.