What is the best way of replacing JobGiver_Haul in Animal ThinkTreeDefs?
I have thought of the following options:
- Do the detour thing with JobGiver_Haul.TryGiveJob(), the only method it has.
- Do the detour thing with JobGiver_Haul.TryGiveJob(), BUT always give null job. Make a SubTree with insertTab Animal_PreWander to handle hauling.
- Make a SubTree thing with insertTag Animal_PreMain, make its treeRoot class to always give true and then subNodes are the same thing following the modder hook Animal_PreMain in Animal ThinkTreeDefs until after <!-- Trained behavior: Haul--> and just replace the class in our SubTree. Look at my prototype here: http://pastebin.com/QVKYYyDn
Edit: alternatively to 3, do the same thing but make each a separate SubTree instead of subNodes.
I think detouring the jobgiver directly (so that would be #1?) is probably the simplest/best way to do it.
Detours should be avoided unless all other, better options (and all other options are better) have been exhausted.
Detours are intended to be a "last resort, nothing else can achieve the goal I am aiming for."
If using some XML to fix it doesn't work (and you may need to clone the entire sub-tree to do it) then it's time to start looking at other solutions.
Final note, there are two mods already which will allow you to control the animal hauling.
If you use XML to override the ThinkTree you're doing something inherently incompatible while overriding a specific job is compatible with mods that do change the ThinkTree for broader purposes... I'm sure CCL offers a good solution to this.
CCL adds additional injection points in the think trees as well as a mechanic to detour methods. That being said, I still advocate avoiding detours unless no other option exists.
hooks are not last resort, you do not need to limit yourself.
just do what you want in way you like, don't waste time on "better solutions".
when (if) some issue appear later, in form of compatability or stability issue, you will fix it later.
trying to make everything "perfect" initially will have "bad" results.