-
Notifications
You must be signed in to change notification settings - Fork 2
Funeral Framework Worker Classes
I'm going to preface this with this is doing more then it should. Something I realized fairly late is that I could just create my own Lordjob_Ritual Derived class, and save myself many harmony patches and hacks inside this behavior. I'm planning on doing just that but it requires a fair bit of rewrite and this all works fine for now.
Currently this serves 2 purposes, handles the start, and running parts of the ritual. Including handling additional effecters/sound. 2. Acts as an extra exposable home for a few key fields. That can be easily reached by my other workers. This 2nd part is the part that should go into its own Lordjob.
Most are just self explanatory but few relevant ones.
Called after the Dialog_BeingRitual is confirmed
- Overrides the base behavior to better handle the fact we have just shoved a corpse into the assignments.
- Checks the selected corpse against the obligations to make sure we are creating the ritual for the right obligation.
- Saves the selected corpse here, so to be able to access it again easily after a save/load. Because all vanilla expose datas will not save the reference to it as the pawn is considered destroyed.
- Checks that the corpse is indeed still around, and can be buried.
- Overrides base to not return false cause of the dead pawn.
- This ticks the effecter and sound tied to this behavior. Which is only set by Action triggers.
- Removes the sounds, effects, and any Things that were used for special effects by another action
- Pawn corpse - This is the assigned corpse that will be saved and used later.
- List spawnEffectThings - These are things spawned by an action for effects. Stored here to be sure they get cleaned up.
- Sustainer soundPlaying - assigned by action
- Effecter effecter - assigned by action
- Pawn effecterpawn - assigned by action, not used at all.
- ThingDef stuffToUse - Assigned by the selection on ritual UI for what stuff to use when it comes to item spawning.
- int stuffCount - same as above.
This handles all of the effects of the rituals, expanding the functionality. There's a lot that could be overridden in this class, I only do ApplyExtraOutcome then call my methods.
All the derived classes from this are specific to the ritual in question so I wont document them. But essentially they are just modifying one of the methods called via ApplyExtraOutcome to do specific things.
This calls all the subsequent methods to handle the various outcomes. Is called by base Apply.
- pawn here is the roleToSpawn on extension. Which is corpse unless specificed otherwise
- Calls all the outcome spawners to build a list of things to spawn, as well as destroy an requisite material
Allows for an extra description about best or worse result. Tagged strings from the def extension.
Handles Striping corpse if true on extension, the spawning of the items, destroying the corpse after.
Just a simple method to find out if it's the worst result in the ritual. Base game only has a check for best result so this is just doing that in reverse.
This worker basically just exists because the Precept_Ritual doesn't have the targetfilter as a list. List of filters defined by the mod extension. Then through harmony, after the initial pattern fill. It will create and initialize those filters.
Called through harmony is creates the instance of the filters and fills in ritual. These get exposed as well.
Enumerable of all the subfilters results
- Creates a concatenated string of all the reasons it cant be used from the subfilters.
- Also checks the validCorpse of the extension to see if that's a fail reason.
- General warning about this method (not unique to this class). It actually gets called constantly when targeting things when there's active obligations. So be careful with what you are checking. It's once per frame as part of the show gizmo I believe. - Update, its worse then 1 per frame. its minimum 2 per frame if it returns success. if it fails its will run x*activeobligations per ritual. Which with many funerals allowed all making obligations. It got very out of hand fast. Use BehaviorWorker CanStart for anything even remotely heavy its not called nearly as often. If you need specific obligation info and specific target info, then utilize some caching.
- Called in the ritual foundation/reformation UI. As well as when the obligations are made.
- obligation is null for when its getting called via the UI part. So just be aware of that if you want to make a tagged string return.
- Creates a concatenated string of all the requirements.
This is the only other Target worker I'll describe in detail. As most of them are specific, or clear enough what they'll do.
- Builds a string of missing materials using the spawners in the outcome effect def extension.
- This is one where the fact it gets called constantly is very relevant. As doing potentially multiple searches on the resource counter per frame could get costly.
- To counteract this, the spawners cache a found stuff and only recheck against resource counter that specific stuff. But unfortunately, if stuff cant be found it will be checking a lot.
- Builds a string of all required stuff from the outcome extension spawners.
Basically the same as Requires stuff. But for things. I might combine them if/when I redo ThingstoSpawn.
Self explanatory, for things with power comp.