A class in Root.Township, the global namespace.
A named list of update callbacks that UnityUpdateManager runs once per frame in a given UpdateSegment, so many objects can share one update loop. A callback that throws is logged and removed from the list.
Constructors
| Member | What it is |
|---|
UpdateModule(string name, UpdateSegment segment, bool includeInServerProfiling = false) | Creates an UpdateModule from name, segment and includeInServerProfiling. |
Fields
| Member | What it is |
|---|
protected Action<UpdateModule.MethodNode, Func<UpdateModule.MethodNode, bool>> checkedIterationMethod | The loop used by subclasses that stop early when a check fails. |
protected AverageNumber duration | Rolling average of how long Update takes, in milliseconds. |
protected UpdateModule.MethodNode first | Head of the callback list. New callbacks are added here, so they run first. |
protected Action<UpdateModule.MethodNode> iterationMethod | The loop Update uses, set by SetProfiling. |
protected static Stopwatch timer | Shared stopwatch used to time updates. |
3 private and internal fields
| Member | What it is |
|---|
private static Logger logger | NLog logger for this class. |
private static Dictionary<UpdateModule.MethodNode, MethodInfo> methodsPerNode | Profiler builds only: the method each node runs. |
private static Dictionary<MethodInfo, string> profilingStrings | Profiler builds only: cached profiler labels, one per method. |
Properties
| Member | What it is |
|---|
bool IncludeInServerProfiling { get; } | Whether this module is listed in server profiling output. |
UpdateModuleInfo ModuleInfo { get; } | Registered count and average run time, for profiling displays. |
string Name { get; } | The module's name, used in logs and profiling. |
Methods
| Member | What it is |
|---|
int ActualCount() | Counts the registered callbacks by walking the list. |
static void DeregisterMethod(ref IUnityUpdateMethod methodNode) | Static: removes a callback using the handle RegisterMethod gave you, and clears the handle. Safe to call with null. |
virtual IUnityUpdateMethod RegisterMethod(Action method) | Adds a callback to the front of the list and returns a handle to deregister it later. Returns null for a null callback. |
void SetProfiling(bool isProfiling) | Switches between the plain and profiling loops. In this build they behave the same. |
virtual void Update() | Runs every registered callback once and records how long it took. |
protected virtual void DeregisterMethod(UpdateModule.MethodNode node) | Static: removes a callback using the handle RegisterMethod gave you, and clears the handle. Safe to call with null. |
8 private and internal methods
| Member | What it is |
|---|
private void AddMethodToProfiling(UpdateModule.MethodNode node) | Profiler builds only (compiled out otherwise): remembers which method a node runs, for profiler labels. |
private void CheckedIterateOverLinkedList(UpdateModule.MethodNode startNode, Func<UpdateModule.MethodNode, bool> check) | Runs each registered method in order while the check passes. A method that throws is logged and deregistered for good. |
private void CheckedIterateOverLinkedListWithProfiling(UpdateModule.MethodNode startNode, Func<UpdateModule.MethodNode, bool> check) | Same as CheckedIterateOverLinkedList in this build; used when profiling is on. |
private void IterateOverLinkedList(UpdateModule.MethodNode startNode) | Runs every registered method once, newest first. A method that throws is logged and deregistered for good. |
private void IterateOverLinkedListWithProfiling(UpdateModule.MethodNode startNode) | Same as IterateOverLinkedList in this build; used when profiling is on. |
private void RemoveMethodFromProfiling(UpdateModule.MethodNode node) | Profiler builds only (compiled out otherwise): forgets a node's profiler entry. |
private void StartProfilingForNode(UpdateModule.MethodNode node) | Profiler builds only (compiled out otherwise): builds the profiler label for a node's method. |
private void StopProfilingForNode() | Profiler builds only; empty. |
Used in
Members of other types that take, return or hold a UpdateModule:
Recycler.updateModule, GenericAssemblyStation.updateModule, GenericCraftingStation.updateModule, HeatArea.updateModule, HeatSourceBase.heatUpdateModule, DelayedImpactResolver.updateModule, ImpactTool.updateModule, ActiveCrawl.updateModule, AgentRollUpInPlace.updateModule, AgentUpdater.updateAgents, FaceTarget.updateModule, FireBug.updateModule, HookAction.updateModule, LiquidSurfaceVisual.updateModule, NetworkManager.receivingModule, NetworkManager.sendingModule, NetworkRigidbody.updateModule, IndependentWalker.updateModule, BoundsPopulationItem.distanceCheckUpdateModule, RadialPopulationItem.distanceCheckUpdateModule, CameraStabilization.updateModule, StatAffectingArea.updateModule, ChunkDetector.chunkUpdateModule, DepthCheckLocoCheck.updateModule, EmberComposer.HeatPointCollectionHandler.updateModule, HandInteractor.updateModule, HeatPointTriggerCollector.updateModule, LerpFollowBase<T>.staticUpdateModule, LockedRotationHandle.updateModule, PlayerToolBasedSkillHelper.updateModule, RoomRotator.updateModule, ScriptedRotation.updateModule, SimpleNetworkedPivot.updateModule, SkillsStructureRotator.updateModule, SmoothLocomotion.unownedHeightCheck, SmoothLocomotion.updateModule, SpacePoint.updateModule, SwipeInteractionController.SwipeTracker.updateModule, UnityUpdateManager.AllModules, UnityUpdateManager.FixedUpdateModule, UnityUpdateManager.fixedUpdateModules, UnityUpdateManager.LateUpdateModule, UnityUpdateManager.lateUpdateModules, UnityUpdateManager.RegisterModule, UnityUpdateManager.RegisterModuleToList, UnityUpdateManager.UpdateModule, UnityUpdateManager.updateModules, UnityUpdateManager.ModuleRegistration.Module, UpdateModule.MethodNode.Module.