Exemple #1
0
        public override string GetInspectString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(base.GetInspectString());
            if (stringBuilder.Length != 0)
            {
                stringBuilder.AppendLine();
            }
            if (this.Next is null)
            {
                stringBuilder.Append("Goal");
            }
            else
            {
                stringBuilder.Append("RoadsOfTheRim_siteInspectString".Translate(this.GetSite().roadDef.label, string.Format("{0:0.0}", this.GetSite().roadDef.movementCostMultiplier)));

                float totalCostModifier = 0f;
                stringBuilder.Append(WorldObjectComp_ConstructionSite.CostModifersDescription(this.Tile, this.Next.Tile, ref totalCostModifier));

                // Show costs
                WorldObjectComp_ConstructionSite SiteComp = this.GetSite().GetComponent <WorldObjectComp_ConstructionSite>();
                foreach (string resourceName in DefModExtension_RotR_RoadDef.allResourcesAndWork)
                {
                    if (SiteComp.GetCost(resourceName) > 0)
                    {
                        // The cost modifier doesn't affect some advanced resources, as defined in static DefModExtension_RotR_RoadDef.allResourcesWithoutModifiers
                        // TO DO : COuld this be combined with WorldObjectComp_ConstructionSite.setCosts() ? shares a lot in common except rebates. Can we really calcualte rebate on a leg ?
                        float costModifierForThisResource = ((DefModExtension_RotR_RoadDef.allResourcesWithoutModifiers.Contains(resourceName)) ? 1 : totalCostModifier);
                        stringBuilder.AppendLine();
                        stringBuilder.Append((int)SiteComp.GetCost(resourceName) * costModifierForThisResource + " " + resourceName);
                    }
                }
            }

            return(stringBuilder.ToString());
        }
Exemple #2
0
        public string progressDescription()
        {
            RoadConstructionSite parentSite    = this.parent as RoadConstructionSite;
            StringBuilder        stringBuilder = new StringBuilder();

            stringBuilder.Append("RoadsOfTheRim_ConstructionSiteDescription_Main".Translate(String.Format("{0:P1}", GetPercentageDone("Work"))));

            // Description of ally's help, if any
            if (parentSite.helpFromFaction != null)
            {
                stringBuilder.Append("RoadsOfTheRim_ConstructionSiteDescription_Help".Translate(parentSite.helpFromFaction.Name, (int)parentSite.helpAmount, String.Format("{0:0.0}", parentSite.helpWorkPerTick)));
                if (parentSite.helpFromTick > Find.TickManager.TicksGame)
                {
                    stringBuilder.Append("RoadsOfTheRim_ConstructionSiteDescription_HelpStartsWhen".Translate(String.Format("{0:0.00}", (float)(parentSite.helpFromTick - Find.TickManager.TicksGame) / (float)GenDate.TicksPerDay)));
                }
            }

            // Show total cost modifiers
            float totalCostModifier = 0f;

            stringBuilder.Append(WorldObjectComp_ConstructionSite.CostModifersDescription(parentSite.Tile, parentSite.GetNextLeg().Tile, ref totalCostModifier));

            List <Caravan> AllCaravansHere = new List <Caravan>();

            Find.WorldObjects.GetPlayerControlledCaravansAt(parentSite.Tile, AllCaravansHere);
            int ISR2G = 0;

            foreach (Caravan c in AllCaravansHere)
            {
                int caravanISR2G = c.GetComponent <WorldObjectComp_Caravan>().useISR2G();
                if (caravanISR2G > ISR2G)
                {
                    ISR2G = caravanISR2G;
                }
            }

            // Per resource : show costs & how much is left to do
            foreach (string resourceName in DefModExtension_RotR_RoadDef.allResourcesAndWork)
            {
                if (GetCost(resourceName) > 0)
                {
                    stringBuilder.AppendLine();
                    string ISR2Gmsg = "";
                    if (ISR2G > 0)
                    {
                        if (resourceName == "Work")
                        {
                            ISR2Gmsg = (ISR2G == 1 ? "RoadsOfTheRim_ConstructionSiteDescription_ISR2Gwork".Translate() : "RoadsOfTheRim_ConstructionSiteDescription_AISR2Gwork".Translate());
                        }
                        else if (DefModExtension_RotR_RoadDef.GetInSituModifier(resourceName, ISR2G))
                        {
                            ISR2Gmsg = (ISR2G == 1 ? "RoadsOfTheRim_ConstructionSiteDescription_ISR2GFree".Translate() : "RoadsOfTheRim_ConstructionSiteDescription_AISR2GFree".Translate());
                        }
                    }
                    stringBuilder.Append("RoadsOfTheRim_ConstructionSiteDescription_Resource".Translate(
                                             resourceName,
                                             String.Format((resourceName == "Work" ? "{0:##.00}" : "{0:##}"), GetLeft(resourceName)), // Only Work should be shown with 2 decimals
                                             (int)GetCost(resourceName),
                                             ISR2Gmsg
                                             ));
                }
            }

            return(stringBuilder.ToString());
        }