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
| Member | What it is |
|---|
LogicDisplay() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
6 private and internal fields
| Member | What it is |
|---|
private UnityEvent active | Event fired when the value turns true. |
private UnityEvent inactive | Event fired when the value turns false. |
private bool isRunningOnClient | Whether clients get the value and fire the events (default true). |
private bool isRunningOnServer | Whether the server also fires the events. |
private LogicBoolReceiver receiver | The logic bool input being shown. |
private MethodSync sync | Method sync for the value; null when not running on clients. |
Methods
| Member | What 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
| Member | What 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. |