Overview
The system has three layers: a pure C# core (UpdateManager), Unity-specific infrastructure (UnityUpdateAdapter, UpdateService, UpdateUtility), and a bus-facing entry point (UpdateFlowController, UpdateCommandFactory). Shared keys and verbs (UpdateKeys, UpdateKeyNames, UpdateCommandVerb) and the IUpdateable and IUpdateAdapter interfaces connect the layers.
Core and coordination
UpdateManager
Owns the registry and runs the tick loop.
- Holds the
updateableslist and the currently boundUpdateAdapter. SetUpdateAdapterbinds an adapter and gives it the manager's tick method.ProcessCommandhandlesRegistercommands by callingAddUpdateable.AddUpdateableadds an object only if it is not already in the list.- The private
Tickmethod callsOnUpdateon each object.
UpdateFlowController
The bridge from the command bus to the manager. It inherits FlowController and owns the Domain.Update domain.
Initregisters the command handler throughbase.Init(), then creates the manager and the Unity adapter.HandleCommandchecks forUpdateKeys.UpdateableObjectand forwards matching commands toProcessCommand.
The class does not show how the manager is shut down. Its summary mentions managing the lifespan of the infrastructure, but the code has no teardown method.
UpdateCommandFactory
A static factory that the rest of the codebase uses to register objects without referencing the manager. RegisterUpdatable builds a Register command, sets the payload, and sends it through BusUtility.
Engine bridge
UpdateAdapter
Abstract base for adapters. Initialize checks for a null callback and then calls the abstract OnInitialized hook.
UnityUpdateAdapter
Concrete adapter for Unity. OnInitialized calls UpdateService.InjectToPlayerLoop with UnityEngine.PlayerLoop.Update as the target phase.
UpdateService
Static entry point that wraps a tick action in a PlayerLoopSystem and applies it to the global PlayerLoop. The changes persist until the loop is reset or the application restarts.
UpdateUtility
Static helper that searches the PlayerLoop tree for a phase by type and appends a child node. UpdateService calls it.
Contracts and data
IUpdateable
Consumer contract. Any class that implements OnUpdate can be registered and will receive a call each tick.
IUpdateAdapter
Provider contract. Any class that implements Initialize(Action) can supply the heartbeat.
UpdateKeys and UpdateKeyNames
UpdateKeyNames.UpdateableObjectholds the string name of the key.UpdateKeys.UpdateableObjectis the typedParamKey<IUpdateable>used to store and read the payload.
UpdateCommandVerb
Enum with one value, Register. It is the verb carried by Update-domain commands.
Interaction with other systems
Domain(Contracts).Domain.Updateis the routing value used byUpdateCommandFactoryand returned byUpdateFlowController.Domain.CommandandICommand(Commands). The factory creates commands withCommand.Create.UpdateFlowControllerandUpdateManagerreceive them asICommand.ParamKey<T>,Params(Params).UpdateKeysbuilds onParamKey<IUpdateable>. The factory sets the value and the flow controller and manager read it withHasandGet.FlowController(Flow).UpdateFlowControllerextends it and implementsHandleCommand.BusUtility(Bus).UpdateCommandFactory.RegisterUpdatablesends each command throughBusUtility.Send.
Component interaction summary
| Component | Calls or is called by | Purpose |
|---|---|---|
UpdateCommandFactory | BusUtility | Builds and sends Register commands |
UpdateFlowController | FlowController base, UpdateManager | Routes Update-domain commands to the manager |
UpdateManager | UpdateFlowController, IUpdateAdapter | Owns the registry and the tick |
UnityUpdateAdapter | UpdateManager via IUpdateAdapter | Connects the tick to the Update phase |
UpdateService | UnityUpdateAdapter | Applies the injected node to the PlayerLoop |
UpdateUtility | UpdateService | Finds the target phase and appends the node |