示例#1
0
 static void Postfix(StaffMenu __instance, StaffDefinition.Type staffType, StaffMenu.StaffMenuSettings ____staffMenuSettings, WorldState ____worldState, List <JobDescription>[] ____jobs, CharacterManager ____characterManager)
 {
     if (!Main.enabled)
     {
         return;
     }
     try
     {
         int num = 0;
         foreach (object obj in ____staffMenuSettings.JobsListContainer)
         {
             Transform      transform = (Transform)obj;
             JobDescription job       = ____jobs[(int)staffType][num];
             TMP_Text       component = UnityEngine.Object.Instantiate <GameObject>(____staffMenuSettings.TitleText.gameObject).GetComponent <TMP_Text>();
             component.rectTransform.SetParent(transform);
             int staffCount = ____characterManager.StaffMembers.Count((Staff s) => !s.HasResigned() && !s.HasBeenFired() && job.IsSuitable(s) && !s.JobExclusions.Contains(job));
             int roomCount  = 0;
             if (job is JobRoomDescription)
             {
                 roomCount      = ____worldState.AllRooms.Count((Room x) => x.Definition == ((JobRoomDescription)job).Room);
                 component.text = staffCount.ToString() + "/" + roomCount.ToString();
                 StaffJobIcon[] componentsInChildren = ____staffMenuSettings.JobsListContainer.gameObject.GetComponentsInChildren <StaffJobIcon>();
                 if (componentsInChildren != null && num < componentsInChildren.Length)
                 {
                     componentsInChildren[num].Tooltip.SetDataProvider(delegate(Tooltip tooltip)
                     {
                         tooltip.Text = string.Concat(new string[]
                         {
                             job.GetJobAssignmentTooltipString(),
                             "\n\nSatff Assigned: ",
                             staffCount.ToString(),
                             "\nRooms Built: ",
                             roomCount.ToString()
                         });
                     });
                 }
             }
             else if (job is JobItemDescription)
             {
                 component.text = staffCount.ToString();
                 StaffJobIcon[] componentsInChildren2 = ____staffMenuSettings.JobsListContainer.gameObject.GetComponentsInChildren <StaffJobIcon>();
                 if (componentsInChildren2 != null && num < componentsInChildren2.Length)
                 {
                     componentsInChildren2[num].Tooltip.SetDataProvider(delegate(Tooltip tooltip)
                     {
                         tooltip.Text = job.GetJobAssignmentTooltipString() + "\n\nSatff Assigned: " + staffCount.ToString();
                     });
                 }
             }
             else if (job is JobMaintenanceDescription)
             {
                 string text      = staffCount.ToString();
                 int    itemCount = (from mj in ____worldState.GetRoomItemsWithMaintenanceDescription(((JobMaintenanceDescription)job).Description)
                                     where mj.Definition.Interactions.Count((InteractionDefinition inter) => inter.Type == InteractionAttributeModifier.Type.Maintain) > 0
                                     select mj).Count <RoomItem>();
                 text           = text + "/" + itemCount.ToString();
                 component.text = text;
                 StaffJobIcon[] componentsInChildren3 = ____staffMenuSettings.JobsListContainer.gameObject.GetComponentsInChildren <StaffJobIcon>();
                 if (componentsInChildren3 != null && num < componentsInChildren3.Length)
                 {
                     componentsInChildren3[num].Tooltip.SetDataProvider(delegate(Tooltip tooltip)
                     {
                         tooltip.Text = string.Concat(new string[]
                         {
                             job.GetJobAssignmentTooltipString(),
                             "\n\nSatff Assigned: ",
                             staffCount.ToString(),
                             "\nMaintenance Items: ",
                             itemCount.ToString()
                         });
                     });
                 }
             }
             else if (job is JobUpgradeDescription)
             {
                 int    upgradeCount       = 0;
                 string machinesForUpgarde = "";
                 foreach (Room room in ____worldState.AllRooms)
                 {
                     foreach (RoomItem roomItem in room.FloorPlan.Items)
                     {
                         RoomItemUpgradeDefinition nextUpgrade = roomItem.Definition.GetNextUpgrade(roomItem.UpgradeLevel);
                         if (nextUpgrade != null && roomItem.Level.Metagame.HasUnlocked(nextUpgrade) && roomItem.GetComponent <RoomItemUpgradeComponent>() == null)
                         {
                             upgradeCount++;
                             machinesForUpgarde = machinesForUpgarde + "\n" + roomItem.Name;
                         }
                     }
                 }
                 if (!string.IsNullOrEmpty(machinesForUpgarde))
                 {
                     StaffJobIcon[] componentsInChildren4 = ____staffMenuSettings.JobsListContainer.gameObject.GetComponentsInChildren <StaffJobIcon>();
                     if (componentsInChildren4 != null && num < componentsInChildren4.Length)
                     {
                         componentsInChildren4[num].Tooltip.SetDataProvider(delegate(Tooltip tooltip)
                         {
                             tooltip.Text = string.Concat(new string[]
                             {
                                 job.GetJobAssignmentTooltipString(),
                                 "\n\nSatff Assigned: ",
                                 staffCount.ToString(),
                                 "\n",
                                 machinesForUpgarde
                             });
                         });
                     }
                 }
                 component.text = staffCount.ToString() + "/" + upgradeCount;
             }
             else
             {
                 if (!(job is JobGhostDescription) && !(job is JobFireDescription))
                 {
                     continue;
                 }
                 component.text = staffCount.ToString();
             }
             component.enableAutoSizing   = false;
             component.fontSize           = 18f;
             component.enableWordWrapping = false;
             component.overflowMode       = 0;
             component.alignment          = TextAlignmentOptions.Midline;
             component.color                          = Color.white;
             component.outlineColor                   = Color.black;
             component.outlineWidth                   = 1f;
             component.rectTransform.anchorMin        = new Vector2(0.5f, 0f);
             component.rectTransform.anchorMax        = new Vector2(0.5f, 1f);
             component.rectTransform.anchoredPosition = new Vector2(0f, -15f);
             component.rectTransform.sizeDelta        = transform.GetComponent <RectTransform>().sizeDelta;
             num++;
         }
     }
     catch (Exception ex)
     {
         Main.Logger.Error(ex.ToString() + ": " + ex.StackTrace.ToString());
     }
 }