I've been playing around with buttons recently. I've added the following harmony patch to the game:
This code is run every time after the vanilla GetGizmos is performed on a building.
With the code above, one gets a single log message on every tick even if nothing happens to the building (even on pause).
Is it presence of Log.Message() that forces function rerun, or is it vanilla behavior to rerun all the checks regardless of absence of change?
The code in question was quite short and checks were simple, so not much time is lost there, probably. Not in this particular case but, say, in PawnCapacityWorker (or JobGiver or Comp) routines some more complex calculations may be desired, and those seem to get called often too.
What would be optimization tricks for those?
Code Select
static class Building_Bed_GetGizmos_Patch
{
static void Postfix(ref IEnumerable<Gizmo> __result, ref Building_Bed __instance)
{
Log.Message("Prisoner bed patch run ")
...
}
}
This code is run every time after the vanilla GetGizmos is performed on a building.
With the code above, one gets a single log message on every tick even if nothing happens to the building (even on pause).
Is it presence of Log.Message() that forces function rerun, or is it vanilla behavior to rerun all the checks regardless of absence of change?
The code in question was quite short and checks were simple, so not much time is lost there, probably. Not in this particular case but, say, in PawnCapacityWorker (or JobGiver or Comp) routines some more complex calculations may be desired, and those seem to get called often too.
What would be optimization tricks for those?