RimWorldCCLTeam / CommunityCoreLibrary

For full details see the official Ludeon Forums thread.
https://ludeon.com/forums/index.php?topic=16599.0
The Unlicense
60 stars 27 forks source link

Alpha 15 - Pawns Will Social Relax with any drug, including luciferium #179

Closed Zhentar closed 8 years ago

Zhentar commented 8 years ago

Running the Alpha 15 branch head, pawns will take luciferium as a social relax drug (and I believe any other drug as well).

Zhentar commented 8 years ago

Oh, drug policy is ignored, as well.

ForsakenShell commented 8 years ago

Thanks for spotting, I still need to do the final check on the detours. Right now the focus is on finishing the injector refactors and squashing existing bugs. Once done I'll do a final round on the detours to verify their logic.

Kelnor277 commented 8 years ago

https://github.com/RimWorldCCLTeam/CommunityCoreLibrary/pull/183 Submitted an initial PR with the fix for when you get around to it. Some additional work will be needed for Automated Factories. I don't understand them enough to do that at this time.

Sidenote, I think scheduled drug policies are still ignored, but that seems to be a different problem from the social relaxing issue. Documentation is in the PR comments.

ForsakenShell commented 8 years ago

The factories work like two different buildings depending on how they are configured. They work similar to Building_WorkTable except they don't need a pawn to manually craft or they work similarily in concept to Building_NutrientPasteDispenser in that they only produce when a pawn explicitly uses the machine.

The new drug system I don't think will work with the factories any more as there isn't enough information passed to the functions that need it for the factories to "know" whether food or a drug is being requested. Some investigation into how the new drug system works and some possible refactoring of the factories with respect to this may need to be done.

As to scheduling, I haven't looked at the drug system at all and only went through the detours enough to make sure they compile. I have not yet done the comparisons to the A15 functions which are being detoured to make sure the logic is consistent. Currently the logic in CCLs detours is that of A14 and they all need to be checked and updated.

Kelnor277 commented 8 years ago

I can investigate the factories and the drug system if you want. See if I can find a way to implement it. I made the mistake of not branching first so I'll close this pr and branch to keep my fork's alpha15 synced. If I find something that works I'll resubmit. That ok?

ForsakenShell commented 8 years ago

Sounds good.

Kelnor277 commented 8 years ago

Here's an update. https://github.com/Kelnor277/CommunityCoreLibrary/tree/issue179 Fixes the issue, however automated factories still don't work.

Modified TakeDrugFromSynthesizer to only dispense drugs on pawn's policy (Unless binging) The commented code in JoyGiver_SocialRelax lines (125-126) detects if a factory can dispense the desired drug and sets the factory as a possible target. However this breaks everything. Cast class exceptions start spamming on any future job assignment.

Looks like assigning the factory as TargetC on the job is the problem. With that code commented out it's fine. Seems like the social relax job needs to be modified to allow taking from dispensers, but I'm new to Rimworld and CCL so I'm not sure yet. I can check more tomorrow.

ForsakenShell commented 8 years ago

At my end what I have done is commented all factory related code from the drugs side. Factories for food should still work but I am yet to fully test that at the time of writing this. It's in my current to do list, however.

Kelnor277 commented 8 years ago

I got it working with factories. I just need to confirm I didn't break anything else first. Then I'll make a pull request..

Kelnor277 commented 8 years ago

PR: https://github.com/RimWorldCCLTeam/CommunityCoreLibrary/pull/184 Fixes the social_relax job with Automated factories and disallowed drugs.

Automated factories with Meals is still broken. Looks like in JobGiver_GetFood.TryGiveJob() puts the building in foodDef instead of the food. This breaks the FoodUtility.WillIngestStackCountOf call when it tries to get foodDef.ingestible and it's null because it's a building and not food.

ForsakenShell commented 8 years ago

That means that FoodUtility.WillIngestStackCountOf needs to be detoured to properly handle having a npd/factory passed to it.

Kelnor277 commented 8 years ago

Yeah, I think detours might also be a better way of handling some of the hackey stuff I had to do for the drug factory. I'll look over your detours and see if there's a way to clean that up.

ForsakenShell commented 8 years ago

I've been looking over your last PR, I left a few comments. It's looking good so far though. I also did a commit where I simply commented most of the drug related code out. You'll need to do a local merge in your local repo and basically discard my changes (related to drugs).

Kelnor277 commented 8 years ago

Merge complete, looks good and tests out well.

ForsakenShell commented 8 years ago

Sounds good, I will close this issue and wait for the PR with the complete set of changes.