All types are in the SaffronLibrary.Prime.Systems.Update namespace, except the interfaces, which are in SaffronLibrary.Prime.Systems.Update.Interfaces.
IUpdateable
Implemented by any object that should receive a call every frame.
public interface IUpdateable
{
void OnUpdate();
}OnUpdate: called once per tick, during Unity's Update phase, while the object is registered.
IUpdateAdapter
Implemented by adapters that connect an engine's heartbeat to the UpdateManager.
public interface IUpdateAdapter
{
void Initialize(Action onTick);
}Initialize: receives the callback to invoke on every tick.
UpdateAdapter
Abstract base for adapters. Implements IUpdateAdapter.
public abstract class UpdateAdapter : IUpdateAdapter
{
public void Initialize(Action onTick);
public abstract void OnInitialized(Action onTick);
}Initialize: ignores a null callback. Otherwise callsOnInitialized.OnInitialized: implemented by each adapter to connect the callback to its engine.
UnityUpdateAdapter
The Unity adapter. Extends UpdateAdapter.
public class UnityUpdateAdapter : UpdateAdapter
{
public override void OnInitialized(Action onTick);
}OnInitialized: injects the callback into Unity's PlayerLoop Update phase throughUpdateService.
UpdateManager
Plain C# class that holds the registered objects and ticks them.
public class UpdateManager
{
public IUpdateAdapter UpdateAdapter;
public List<IUpdateable> updateables;
public void SetUpdateAdapter(IUpdateAdapter updateAdapter);
public void ProcessCommand(ICommand cmd);
public void AddUpdateable(IUpdateable updateable);
}UpdateAdapter: the adapter currently connected to the manager.updateables: every registered object, in registration order.SetUpdateAdapter: stores the adapter and passes it the manager's tick. Null is ignored.ProcessCommand: handlesRegistercommands by readingUpdateKeys.UpdateableObjectand callingAddUpdateable. Other verbs are ignored.AddUpdateable: adds the object. Null and duplicate references are ignored.
The tick itself is private. On each tick, OnUpdate is called on every registered object in order.
UpdateFlowController
The flow controller for Domain.Update. Extends FlowController.
public class UpdateFlowController : FlowController
{
protected override Domain Domain { get; }
public override void Init();
protected override void HandleCommand(ICommand cmd);
}Domain: returnsDomain.Update.Init: callsbase.Init(), then creates theUpdateManager, and connects it to aUnityUpdateAdapter.HandleCommand: forwards commands that carryUpdateKeys.UpdateableObjectto the manager.
UpdateCommandFactory
Builds and sends Update-domain commands.
public static class UpdateCommandFactory
{
public static void RegisterUpdatable(IUpdateable updateable);
}RegisterUpdatable: sends aRegistercommand carrying the object underUpdateKeys.UpdateableObject.
UpdateCommandVerb
public enum UpdateCommandVerb
{
Register,
}Register: registers anIUpdateableto receive a call every tick.
UpdateKeys
public static class UpdateKeys
{
public static readonly ParamKey<IUpdateable> UpdateableObject;
}UpdateableObject: carries the object to register in an Update command's params.
UpdateKeyNames
public static class UpdateKeyNames
{
public const string UpdateableObject;
}UpdateableObject: the key namecore.update.updateable.object.
UpdateService
Injects actions into Unity's PlayerLoop.
public static class UpdateService
{
public static void InjectToPlayerLoop<TSystem, TPhase>(Action tickAction) where TPhase : struct;
}InjectToPlayerLoop: wrapstickActionin a PlayerLoop system identified byTSystem, and adds it to theTPhasephase. The change applies to the global PlayerLoop until it is reset or the application restarts.
UpdateUtility
Helpers for modifying the PlayerLoop tree.
public static class UpdateUtility
{
public static bool TryInsertSystem<TTargetPhase>(ref PlayerLoopSystem currentRoot, PlayerLoopSystem nodeToInsert);
}TryInsertSystem: searches the tree for theTTargetPhasephase, and appendsnodeToInsertto it. Returns true if the phase was found.