Closed LecrisUT closed 4 years ago
Tracked it down to xpath patches. E.g.: https://github.com/Jellypowered/SurvivalTools/blob/fbd81a25528da30b2ebe71638bc29a71faa60af8/1.1/Patches/Core/WorkGiverDefs/WorkGivers.xml#L17-L26
It patches jobs and their children. Hmm how to change the patching?
I'm thinking of calculating whether the tool really changes the work speed of the WorkGiver
. But I haven't tracked down how SurvivalTools
changes the work speed itself. Can you point to the part of code that does so?
Ok, here is what I've got. It requires a lot of work to decode the rest but I think I have a way to make it more safe: Current method:
WorkDef
/WorkType
have changed statsWork
is assigned than check if there are equipped toolsThis creates a problem when a Haul WorkDef
is a child of Construction WorkDef
.
New method:
WorkGiver
JobDef
or JobDefDriver
is in the list of Jobs that have been patchedWorkGiver
to list of jobs requiring toolWhy go this way? The JobDefDriver
have to be patched in order to degrade the tools and add harvest yield or workspeed. Don't know about the latter.
Naturally Haul
jobs are not patched so it would not be affected.
What I have also learned while digging:
Rand.Value > actor.GetStatValue(StatDefOf.PlantHarvestYield, true)
Problem: There are at least 2 other mods which mess with this: Fertile fields
and Harvest yield patch
. So the redefinition is basically nullified.
I like your idea of rewriting how the checks are handled. In the future we should keep the possibility of adding other jobs not otherwise defined in the base, (Say if we wanted a "wheelbarrow" or "hand truck" for boosting carry capacity/hauling efficiency.)
Ok. I'll update when I got something.
Tools for haulers will be tricky.
We'll revisit this after I've implemented the job searching method. @Jellypowered, do you know of any mod that patches in WorkGivers, preferably as a mod dependency?
@Jellypowered. I have found a problem with the automatic patching method.
Right now the method can be like:
jobdriver
database for stats: e.g. constructionSpeed
. Save a list of drivers. workgivers
-> used jobdefs
-> used jobdrivers
. Require tools for those jobs.Problems:
seed extraction
would also require tools, although it wouldn't make sense. What we could do is:
Which method do you prefer?
What would be less work? If you keep the current manual patching but implement an exception for construction work givers, you'd have to add more checks for building.
An exception list for job driver/status seems like a lot more code.
I'd probably lean more towards adding an exception to the construction workgivers?
In the long run the automatic method is less work. I'm at the final stage of implementing work givers.
Right now I have it xml exposed so anyone can change it later. Will need some feedback on the naming.
I think there is another bug related to the manual patching were builders do nothing. Hopefully this also fixes it
Update: The implementation of automatic patching works almost as intended. Adding jobs that are not affected by the workspeed are not counted towards the workgivers so will not require tools.
I still need to test if the patches are actually working as intended, clean up the code and will add a pull request. Good news is that it should work with any modded jobs now without having to create custom patches anymore (mostly).
While digging into the code I found: https://github.com/Jellypowered/SurvivalTools/blob/fbd81a25528da30b2ebe71638bc29a71faa60af8/Source/SurvivalTools/SurvivalToolUtility.cs#L230-L239
As far as I understand it checks if using the tool actually improves performance: in the case of supply jobs, it does not. Need to check why it does not do so