[1.5] Better Pawn Control (v2.7)

Started by VouLT, October 04, 2016, 07:20:22 PM

Previous topic - Next topic

Oblitus

Found a bug. When you set an area in Inspect window, then open Animals tab, change from Inspect is discarded.

Also, looks like you are overriding Pawn_PlayerSettings.AreaRestriction since with BPC my postfix patch to set_AreaRestriction does not work. I'm trying to make animals react immediately to restriction changes. Any idea how to make it work together? Or just include it in BPC if you think it would fit in.

        // Try to find allowed area immediately after restrictions are changed
        protected static FieldInfo Pawn_PlayerSettings_pawn = null;
        protected static FieldInfo Pawn_PlayerSettings_areaAllowedInt = null;
        protected static JobGiver_SeekAllowedArea thinkNode_JobGiver = null;

        [HarmonyPatch(typeof(Pawn_PlayerSettings), "set_AreaRestriction", new Type[] { typeof(Area) })]
        static class Pawn_PlayerSettings_set_AreaRestriction_Patch
        {
            static void Postfix(ref Pawn_PlayerSettings __instance)
            {
                if (Pawn_PlayerSettings_pawn == null)
                    Pawn_PlayerSettings_pawn = typeof(Pawn_PlayerSettings).GetField("pawn", BindingFlags.NonPublic | BindingFlags.Instance);
                if (Pawn_PlayerSettings_areaAllowedInt == null)
                    Pawn_PlayerSettings_areaAllowedInt = typeof(Pawn_PlayerSettings).GetField("areaAllowedInt", BindingFlags.NonPublic | BindingFlags.Instance);

                Pawn p = (Pawn)Pawn_PlayerSettings_pawn.GetValue(__instance);
                Area a = (Area)Pawn_PlayerSettings_areaAllowedInt.GetValue(__instance);
               
                if (ForbidUtility.InAllowedArea(p.Position, p))
                {
                    return;
                }
               
                if (p.CurJob != null && !p.CurJob.def.casualInterruptible)
                {
                    return;
                }

                if (thinkNode_JobGiver == null)
                    thinkNode_JobGiver = (JobGiver_SeekAllowedArea)Activator.CreateInstance(typeof(JobGiver_SeekAllowedArea));
                ThinkResult thinkResult = thinkNode_JobGiver.TryIssueJobPackage(p, default(JobIssueParams));

                if (thinkResult.Job != null)
                {
                    p.jobs.StopAll();
                    p.jobs.StartJob(thinkResult.Job, JobCondition.None, null, false, true, null, null);
                }
            }
        }

Oblitus

It also messes up master assignments. Master is no more auto-assigned (sometimes?), and master is saved per policy.

VouLT

Hi Oblitus,

You can check the code of the mod on git hub. Link on the 1st page. The mod doesn't overriding Pawn_PlayerSettings.AreaRestriction. It only changes pawn settings accordingly with the policy. This also means my mod should be compatible with yours.

Oblitus

Yes, apparently that is not the problem.

Still, you are force overriding all settings made from Inspector, Training tab or another source in MainTabWindow_Restrict_Policies.PreOpen. I'm not sure it is a good idea to do so - IMO any change should be applied to the current policy.

VouLT

Hi Oblitus,

I don't follow your point. This mod expands on the vanilla mechanisms which means the assignments are done when the user opens the tabs. Changes are applied to the current policy and saved if the users changes policies. It is no different from Vanilla. Please take a closer look to the code. I also advice you to ask your questions on the RimworldMod discord server since there is a lot of people that might be able to help you. You'll need to ask Skullywag to be invited.

Oblitus

#80
Quote from: VouLT on August 12, 2017, 05:31:57 AM
Hi Oblitus,

I don't follow your point. This mod expands on the vanilla mechanisms which means the assignments are done when the user opens the tabs. Changes are applied to the current policy and saved if the users changes policies. It is no different from Vanilla. Please take a closer look to the code. I also advice you to ask your questions on the RimworldMod discord server since there is a lot of people that might be able to help you. You'll need to ask Skullywag to be invited.

The point is:

Animal is unrestricted.
I'm selecting it and setting it to be restricted to home area.
Then I open Animals tab and it becomes unrestricted again (just because tab is opened, not because policy is changed), because you don't handle input from Inspector pane, only from Animals tab.

Animal got trained to Obedience and got trainer as master.
Then I open Animals tab and it becomes masterless again, because... etc.

VouLT

Ah, I understand now. You're right! I'm not handling the input from the inspect window. I'm surprised no one has raised it yet. I personally never use it. I would need to expand the mod to take that input and update the current policy.  Added this task to my todo list! Thank you!

kaptain_kavern

Quote from: Oblitus on August 12, 2017, 05:44:18 AM
Animal is unrestricted.
I'm selecting it and setting it to be restricted to home area.
Then I open Animals tab and it becomes unrestricted again (just because tab is opened, not because policy is changed), because you don't handle input from Inspector pane, only from Animals tab.

Animal got trained to Obedience and got trainer as master.
Then I open Animals tab and it becomes masterless again, because... etc.

Ah so I'm not crazy, I was sensing something strange with my animals lately. This happened to me. Not a big deal, anyhow

blubFisch

I don't know how anyone is supposed to play Rimworld without this mod, well done!

Here's a tiny problem that might've been mentioned just before: There are some other ways to assign restrictions or loadouts to colonists, for example if you select a colonist, you can directly set his restricted area in his window. Or create a loadout from within the colonist's gear tab. In both cases, when you switch to the restrict/assign tab, this mod will override the settings done by the user, which is probably not intended behavior. I use it to set temporary restrictions, its very handy for that :-P


Kori

I'm using this mod with Animals Tab, and the new animal policy buttons are overlapping the Sort By Name button, so when I want to change the policy it always changes the sort by name order instead, and it usually takes a few clicks until the policy selection dropdown finally opens.

I tried both, loading Animals Tab before and after Better Pawn Control, but it doesn't help.

Aren't they compatible anymore, or am I doing something wrong?  :-\

Boundir


Kori

Quote from: Boundir on September 16, 2017, 03:38:39 AM
Shift click will do the trick ;)

Great, thank you very much!  :)
So this is normal behavior?

VouLT

No, it is not a normal behaviour.  I'm still checking compatibility with Animal tab. At the moment, one option is to move the two buttons way down on the tab, below the animal list.. Still analysing.

Kori

Quote from: VouLT on September 18, 2017, 05:07:13 PM
No, it is not a normal behaviour.  I'm still checking compatibility with Animal tab. At the moment, one option is to move the two buttons way down on the tab, below the animal list.. Still analysing.

thank you! :)

Kori

While the overlapping button is only an minor inconvencience, I just noticed that Animal Tab's Filter-button is completely gone, too. Making the cool filter feature unavailable. :(

Until you've found a solution for compatibility, can I somrehow deactivate only BPC's animal functionality, so that I can keep all the other features at least?