public static void InitPrefix(ProfessionDetailPanel __instance, ProfessionType type)
        {
            //We don't add this panel for Soldier or NoJob
            if (type != ProfessionType.Soldier && type != ProfessionType.NoJob)
            {
                //Checks if we already initialized the Specialization Panel.  If so, do nothing
                SpecializationPanel p = __instance.GetComponentInChildren <SpecializationPanel>(true);
                if (p != null)
                {
                    return;
                }

                //Get the parent of the original panel
                GameObject parent = __instance.specializationTogglePanel.transform.parent.gameObject;

                //Create our own panel
                GameObject newSpecPanel = GameObject.Instantiate(ModHandler.mods.gameObjects["SpecializationPanelModded"], parent.transform);
                p = newSpecPanel.GetComponent <SpecializationPanel>();
                p.Init(type, AbsoluteProfessionPrioritiesMod.GetSpecializationDescriptors()[type].Values.ToList());

                //For the collapse button to work, we need to add our panel to the accordion
                //We also remove the original panel from it
                AccordionPanel aPanel = __instance.GetComponent <AccordionPanel>();
                aPanel.accordionObjects.Add(newSpecPanel);
                aPanel.accordionObjects.Remove(__instance.specializationTogglePanel.gameObject);

                //Removing the original panel from the UI would cause bugs so instead we just disable it
                __instance.specializationTogglePanel.gameObject.SetActive(false);
            }
        }
        public static void SetHumanPostFix(ProfessionDetailPanel __instance, HumanAI human)
        {
            //Get our new panel
            SpecializationPanel p = __instance.GetComponentInChildren <SpecializationPanel>(true);

            //If it exists (depends on the stage of the lifecycle of the UI)
            //If it does, call SetHuman on our panel
            if (p != null)
            {
                p.SetHuman(human);
            }
        }
示例#3
0
        public static bool HigherPriorityLoop_Prefix(ProfessionDetailPanel __instance)
        {
            HumanAI        human = __instance.GetFieldValue <HumanAI>("human");
            ProfessionType type  = __instance.GetPropertyValue <ProfessionType>("type");

            int prio = human.professionManager.GetProfession(type).priority + 1;

            human.professionManager.SetPriority(type, prio, human);
            __instance.InvokeMethod("UpdatePriority");

            return(false);
        }
示例#4
0
        public static void UpdatePriority_Postfix(ProfessionDetailPanel __instance)
        {
            HumanAI        human         = __instance.GetFieldValue <HumanAI>("human");
            ProfessionType type          = __instance.GetPropertyValue <ProfessionType>("type");
            Image          priorityImage = __instance.GetFieldValue <Image>("priorityImage");

            Sprite starsFour = ModHandler.mods.sprites["starsFour"];

            int priority = human.professionManager.GetProfession(type).priority;

            if (priority == 4)
            {
                priorityImage.sprite = starsFour;
            }

            __instance.priorityHigherButton.SetIsPressable(priority < MaxPriority);
        }