[C#] How to Map a Job to a WorkGiver?

Started by maarx1337, March 07, 2017, 07:34:25 PM

Previous topic - Next topic

maarx1337

I can look at Pawn.CurJob to know what he is doing right now.

I can look at Pawn.WorkGiversInOrderNormal or Pawn.WorkGiversInOrderEmergency to understand overall how his WorkGiver priorities are set.

But how do I map from one to the other? How do I determine where his current Job falls on the spectrum of his current WorkGivers? I do not see any obvious relationship between the objects, neither has a pointer to the other, nor does either seem to have any common/shared reference.

RawCode


maarx1337

For example one of the mods I am working on right now sometimes calls "pawn.jobs.StopAll(...)" to reset a pawn if the mod suspects the pawn is currently doing something low-priority/dumb when it should be doing another job that is higher-priority that has probably only recently became available (as one example, doctor is crafting when a treatment job has just become available).

But if the pawn's current job is actually higher in the WorkGivers list than what the mod wants it to do, then there is no point calling StopAll() because the pawn still won't do what we want.

So I need to determine where the pawn's current Job falls in the ordered list of WorkGivers to decide whether player has configured it to treat other thing at higher priority before I bother to call StopAll().

RawCode

if your mod already knows what pawn should do, what about just forcing pawn to do that thing without stopping and relying on vanilla work enumerator?