Skip to main content

LogicValueReceiverArray<TSenderInput>

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

Base for logic receivers that listen to a list of senders and react when any of them changes, such as gates and sums. Server side.

Constructors​

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

Fields​

1 private and internal field
MemberWhat it is
private List<TSenderInput> sendersBacking field for Senders, the list of linked inputs set in the inspector.

Properties​

MemberWhat it is
GlobalLogicManager LogicManager { get; private set; }The GlobalLogicManager holding the sender values.
List<TSenderInput> Senders { get; protected set; }The sender inputs this receiver listens to. New links are added here.

Methods​

MemberWhat it is
void EditorPreSave(GlobalLogicManager manager)Editor: sets the logic manager and points every sender input at it.
override void InitializeAsServer(SpawnData spawnData)Server: subscribes to every sender, finds the logic manager (a parent one or the global one), then calls ValueUpdated once.
protected void LoadContext()Sets the logic manager to GlobalLogicManager.Current.
protected virtual void OnDestroy()Destroys every sender input.
protected virtual void OnDrawGizmos()Editor: draws each sender link.
protected abstract void ValueUpdated()Called when any sender's value changes. Subclasses work out their result here.
2 private and internal methods
MemberWhat it is
private bool Alta.Logic.ILogicValueLinkReceiver.AttemptLink(LogicValueSender sender)Explicit ILogicValueLinkReceiver method; makes a new input and adds it to Senders if it links to the given sender.
private void FindLogicManager()Sets LogicManager to the nearest GlobalLogicManager in the parents, or the global one, if not already set. Called from InitializeAsServer.