Ejemplo n.º 1
0
        static void Postfix(SGSystemViewPopulator __instance, List <LocalizableText> ___SystemDescriptionFields)
        {
            Mod.Log.Debug?.Write("Updating system description with scarcity");

            StarSystem     selectedSystem = ModState.SimGameState.Starmap.CurSelected.System;
            PlanetScarcity scarcity       = selectedSystem.GetScarcityForPlanet();

            StringBuilder sb = new StringBuilder(selectedSystem.Def.Description.Details);

            sb.Append("\n");

            if (scarcity.MechWarriors.Upper > 0)
            {
                Mod.Log.Debug?.Write($"  MechWarriors lowerBound: {scarcity.MechWarriors.Lower}  upperBound: {scarcity.MechWarriors.Upper}");
                string mechWarriorsBoundsText = new Text(Mod.LocalizedText.PlanetStrings[ModText.PT_MW_BOUNDS],
                                                         new object[] { scarcity.MechWarriors.Lower, scarcity.MechWarriors.Upper }).ToString();
                sb.Append("\n");
                sb.Append(mechWarriorsBoundsText);
            }

            if (Mod.Config.HiringHall.VehicleCrews.Enabled && scarcity.Vehicles.Lower > 0)
            {
                Mod.Log.Debug?.Write($"  Vehicles lowerBound: {scarcity.Vehicles.Lower}  upperBound: {scarcity.Vehicles.Upper}");
                string vehicleCrewBoundsText = new Text(Mod.LocalizedText.PlanetStrings[ModText.PT_VEHICLE_BOUNDS],
                                                        new object[] { scarcity.Vehicles.Lower, scarcity.Vehicles.Upper }).ToString();
                sb.Append("\n");
                sb.Append(vehicleCrewBoundsText);
            }

            if (Mod.Config.HiringHall.AerospaceWings.Enabled && scarcity.Aerospace.Lower > 0)
            {
                Mod.Log.Debug?.Write($"  Aerospace lowerBound: {scarcity.Aerospace.Lower}  upperBound: {scarcity.Aerospace.Upper}");
                string mechTechBoundsText = new Text(Mod.LocalizedText.PlanetStrings[ModText.PT_AERO_BOUNDS],
                                                     new object[] { scarcity.Aerospace.Lower, scarcity.Aerospace.Upper }).ToString();
                sb.Append("\n");
                sb.Append(mechTechBoundsText);
            }

            if (Mod.Config.HiringHall.MechTechCrews.Enabled && scarcity.MechTechs.Lower > 0)
            {
                Mod.Log.Debug?.Write($"  MechTechs lowerBound: {scarcity.MechTechs.Lower}  upperBound: {scarcity.MechTechs.Upper}");
                string mechTechBoundsText = new Text(Mod.LocalizedText.PlanetStrings[ModText.PT_MECH_TECH_BOUNDS],
                                                     new object[] { scarcity.MechTechs.Lower, scarcity.MechTechs.Upper }).ToString();
                sb.Append("\n");
                sb.Append(mechTechBoundsText);
            }

            if (Mod.Config.HiringHall.MedTechCrews.Enabled && scarcity.MedTechs.Lower > 0)
            {
                Mod.Log.Debug?.Write($"  MedTechs lowerBound: {scarcity.MedTechs.Lower}  upperBound: {scarcity.MedTechs.Upper}");
                string medTechBoundsText = new Text(Mod.LocalizedText.PlanetStrings[ModText.PT_MED_TECH_BOUNDS],
                                                    new object[] { scarcity.MedTechs.Lower, scarcity.MedTechs.Upper }).ToString();
                sb.Append("\n");
                sb.Append(medTechBoundsText);
            }

            __instance.SetField(___SystemDescriptionFields, sb.ToString());
        }
Ejemplo n.º 2
0
 static void Postfix(SGSystemViewPopulator __instance, StarSystem ___starSystem, SimGameState ___simState)
 {
     try {
         if (GameObject.Find("COMPANYNAMES") == null)
         {
             GameObject old = GameObject.Find("uixPrfPanl_NAV_systemStats-Element-MANAGED");
             if (old != null)
             {
                 GameObject newwidget = GameObject.Instantiate(old);
                 newwidget.transform.SetParent(old.transform.parent, false);
                 newwidget.name         = "COMPANYNAMES";
                 old.transform.position = new Vector3(old.transform.position.x, 311, old.transform.position.z);
                 old.transform.FindRecursive("dotgrid").gameObject.SetActive(false);
                 old.transform.FindRecursive("crossLL").gameObject.SetActive(false);
                 newwidget.transform.position = new Vector3(old.transform.position.x, 106, old.transform.position.z);
                 newwidget.transform.FindRecursive("stats_factionsAndClimate").gameObject.SetActive(false);
                 newwidget.transform.FindRecursive("owner_icon").gameObject.SetActive(false);
                 newwidget.transform.FindRecursive("uixPrfIndc_SIM_Reputation-MANAGED").gameObject.SetActive(false);
                 newwidget.transform.FindRecursive("crossUL").gameObject.SetActive(false);
                 GameObject ownerPanel = newwidget.transform.FindRecursive("owner_detailsPanel").gameObject;
                 ownerPanel.transform.GetComponent <HorizontalLayoutGroup>().childAlignment = TextAnchor.UpperLeft;
                 RectTransform ownerRect = ownerPanel.GetComponent <RectTransform>();
                 ownerRect.sizeDelta = new Vector2(ownerRect.sizeDelta.x, 145);
                 TextMeshProUGUI title = newwidget.transform.FindRecursive("ownerTitle_text").GetComponent <TextMeshProUGUI>();
                 title.SetText("COMPANIES");
                 TextMeshProUGUI text = newwidget.transform.FindRecursive("txt-owner").GetComponent <TextMeshProUGUI>();
                 text.alignment          = TextAlignmentOptions.TopLeft;
                 text.enableWordWrapping = false;
             }
         }
         GameObject companyObject = GameObject.Find("COMPANYNAMES");
         if (companyObject != null && Fields.currentMap != null)
         {
             TextMeshProUGUI         companietext = companyObject.transform.FindRecursive("txt-owner").GetComponent <TextMeshProUGUI>();
             PersistentMapAPI.System system       = Fields.currentMap.systems.FirstOrDefault(x => x.name.Equals(___starSystem.Name));
             if (system != null && companietext != null)
             {
                 List <string> companyNames = new List <string>();
                 foreach (Company company in system.companies)
                 {
                     companyNames.Add("(" + Helper.GetFactionShortName(company.Faction, ___simState.DataManager) + ") " + company.Name);
                 }
                 companietext.SetText(string.Join(Environment.NewLine, companyNames.ToArray()));
             }
             else
             {
                 companietext.SetText("");
             }
         }
     }
     catch (Exception e) {
         PersistentMapClient.Logger.LogError(e);
     }
 }