docs
Systems
Infrastructure
UpdateSystem
Key Components

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 updateables list and the currently bound UpdateAdapter.
  • SetUpdateAdapter binds an adapter and gives it the manager's tick method.
  • ProcessCommand handles Register commands by calling AddUpdateable.
  • AddUpdateable adds an object only if it is not already in the list.
  • The private Tick method calls OnUpdate on each object.

UpdateFlowController

The bridge from the command bus to the manager. It inherits FlowController and owns the Domain.Update domain.

  • Init registers the command handler through base.Init(), then creates the manager and the Unity adapter.
  • HandleCommand checks for UpdateKeys.UpdateableObject and forwards matching commands to ProcessCommand.

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.UpdateableObject holds the string name of the key.
  • UpdateKeys.UpdateableObject is the typed ParamKey<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.Update is the routing value used by UpdateCommandFactory and returned by UpdateFlowController.Domain.
  • Command and ICommand (Commands). The factory creates commands with Command.Create. UpdateFlowController and UpdateManager receive them as ICommand.
  • ParamKey<T>, Params (Params). UpdateKeys builds on ParamKey<IUpdateable>. The factory sets the value and the flow controller and manager read it with Has and Get.
  • FlowController (Flow). UpdateFlowController extends it and implements HandleCommand.
  • BusUtility (Bus). UpdateCommandFactory.RegisterUpdatable sends each command through BusUtility.Send.

Component interaction summary

ComponentCalls or is called byPurpose
UpdateCommandFactoryBusUtilityBuilds and sends Register commands
UpdateFlowControllerFlowController base, UpdateManagerRoutes Update-domain commands to the manager
UpdateManagerUpdateFlowController, IUpdateAdapterOwns the registry and the tick
UnityUpdateAdapterUpdateManager via IUpdateAdapterConnects the tick to the Update phase
UpdateServiceUnityUpdateAdapterApplies the injected node to the PlayerLoop
UpdateUtilityUpdateServiceFinds the target phase and appends the node