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 override void Start() { Instance = this; if (this.ColonistsData == null) { this.ColonistsData = new Dictionary <long, Dictionary <ProfessionType, Dictionary <string, Specialization> > >(); } //Get all of the IDs of the current colonists HumanManager humanManager = WorldScripts.Instance.humanManager; List <HumanAI> colonists = humanManager.colonyFaction.GetLivingHumanoids().ToList(); //Remove all of the saved IDs that are not in the colony anymore foreach (var removedId in this.ColonistsData.Keys.Where(x => !colonists.Any(y => y.GetID() == x)).ToArray()) { this.ColonistsData.Remove(removedId); } //Init all of the IDs foreach (var colonist in colonists) { InitColonist(colonist); } MaxTreeWoodAmount = ModHandler.mods.furnitures.Values .Where(x => x.modules.ContainsKey("resource")) .Select(x => x.GetCachedModule <ResourceModule>()) .Where(x => x.GetResource() == Resource.Wood).Max(x => x.resourcesPerRound); }