Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - Adil

#1
Help / Optimizations of frequently called checks
January 27, 2018, 07:29:25 AM
I've been playing around with buttons recently. I've added the following harmony patch to the game:
           
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?
#2
Releases / [1.0] Assign Prisoner Beds
January 26, 2018, 09:36:52 PM
This mod reuses code from animal logic to add "assign owner" button to prison beds. This should allow moving prisoners from cell to cell.



There are still problems with it however.

If a prisoner cannot reach the assigned bed on his own but can reach another free prison bed, he will switch ownership to the latter.  Also, if prisoner is in bed already and cannot reach the new bed any assignments will be cancelled.

This is actually vanilla behavior for all colony pawns. Wardens sometimes move prisoners to their assigned rooms. Or if you allow prisoner to wander outside his cell, then you can use drafted colonists to arrest them into new bed.



To improve that behavior, one will have to plunge rather deep into vanilla behavior code. I currently lack and am unlikely to obtain such knowledge anytime soon. Still in its current state, the using the mod seems to be more convenient than vanilla tricks for moving prisoners. So I'm calling this a release. If someone is willing to finish the job, you have my blessing.



Download link
google drive
googleDrive_b18

mod requires hugslib.



[attachment deleted by admin: too old]