Skip to main content

LogicValueReceiver<TSenderInput>

An abstract class in Root.Township, Alta.Logic.

Base for a logic component that listens to one logic value sender and reacts when the value changes. Server side; subclasses implement ValueUpdated.

Constructors​

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

Fields​

MemberWhat it is
protected TSenderInput senderBacking field for Sender, set in the inspector.

Properties​

MemberWhat it is
GlobalLogicManager LogicManager { get; private set; }The logic manager this receiver belongs to: one in a parent, or the global one.
TSenderInput Sender { get; }The sender input this receiver reads from.

Methods​

MemberWhat it is
void EditorPreSave(GlobalLogicManager manager)Editor: sets the logic manager and points the sender input at it before saving.
override void InitializeAsServer(SpawnData spawnData)Server: subscribes to the sender, finds the logic manager (parent or global) and calls ValueUpdated once.
protected void LoadContext()Sets LogicManager to GlobalLogicManager.Current.
protected virtual void OnDestroy()Cleans up the sender input subscription.
protected virtual void OnDrawGizmos()Draws the link to the sender in the editor.
protected abstract void ValueUpdated()Called when the sender's value changes, and once at server start. Implement the reaction here.
2 private and internal methods
MemberWhat it is
private bool Alta.Logic.ILogicValueLinkReceiver.AttemptLink(LogicValueSender sender)Explicit ILogicValueLinkReceiver method; passes the sender to Sender.AttemptLink and returns whether it linked.
private void FindLogicManager()Sets LogicManager to the nearest GlobalLogicManager in the parents, or the global one, if not already set. Called from InitializeAsServer.