A class in Root.Township, Alta.Logic.
Holds the shared data records for logic components (switches, wires and so on), keyed by id, and saves them. One is the global manager; others can act as a saving context for a group of components.
Constructors
| Member | What it is |
|---|
GlobalLogicManager() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
7 private and internal fields
| Member | What it is |
|---|
private static Stack<GlobalLogicManager> contextStack | Static stack of managers pushed as saving contexts. Its top is Current, or Global when empty. |
private Dictionary<uint, ILogicValueData> dataMap | Logic value data by identifier. Filled by GetData and replaced on load, saved in full. |
private NonHashedData defaultSetData | Saved data loaded into the entity on server start when nothing has been loaded yet. |
private static GlobalLogicManager instance | Backing field for Global. |
private bool isGlobal | Whether this manager registers itself as Global in Awake. Defaults to true. |
private static Logger logger | NLog logger for this class. |
private uint nextId | Next identifier GetData hands out to data that has none. Saved, and only raised on load. |
Properties
| Member | What it is |
|---|
static GlobalLogicManager Current { get; } | The manager on top of the saving context stack, or the global one if the stack is empty. |
static GlobalLogicManager Global { get; } | The manager marked as global, set when it wakes. |
Methods
| Member | What it is |
|---|
TData GetData<TData>(ref uint identifier) | Gets a record by id. The generic form assigns a new id if 0 and creates missing records; the plain form returns null. |
ILogicValueData GetData(uint identifier) | Gets a record by id. The generic form assigns a new id if 0 and creates missing records; the plain form returns null. |
override void InitializeAsServer(SpawnData spawnData) | Server: loads the default data set into its entity if it has no records yet. |
void Restore<TData>(ref TData saveData) | On load: keeps the existing record for an id if there is one, otherwise stores the loaded one. |
3 private and internal methods
| Member | What it is |
|---|
private void Awake() | Registers this manager as Global when isGlobal is set. |
private void ISavingContext.PopContext() | Explicit ISavingContext method: pops this manager off the context stack, logging an error if it wasn't on top. |
private void ISavingContext.PushContext() | Explicit ISavingContext method: pushes this manager so it becomes Current while its children load or save. |
Used in
Members of other types that take, return or hold a GlobalLogicManager:
Chunk.logicManager, Chunk.LogicManager, ILogicComponent.EditorPreSave, LogicValueReceiver<TSenderInput>.EditorPreSave, LogicValueReceiver<TSenderInput>.LogicManager, LogicValueReceiverArray<TSenderInput>.EditorPreSave, LogicValueReceiverArray<TSenderInput>.LogicManager, LogicValueSender.EditorPreSave, LogicValueSender.LogicManager, LogicValueSender<TData>.EditorPreSave, SenderInput.Manager, SenderInput<TSender, TData>.Load.