//Drawing public override void DoWindowContents(Rect inRect) { FactionFC faction = Find.World.GetComponent <FactionFC>(); faction.roadBuilder.displayPaths(); if (Find.WorldSelector.selectedTile != -1 && Find.WorldSelector.selectedTile != currentTileSelected) { currentTileSelected = Find.WorldSelector.selectedTile; //Log.Message("Current: " + currentTileSelected + ", Selected: " + Find.WorldSelector.selectedTile); currentBiomeSelected = DefDatabase <BiomeResourceDef> .GetNamed(Find.WorldGrid.tiles[currentTileSelected].biome.ToString(), false); //default biome if (currentBiomeSelected == default(BiomeResourceDef)) { //Log Modded Biome currentBiomeSelected = BiomeResourceDefOf.defaultBiome; } currentHillinessSelected = DefDatabase <BiomeResourceDef> .GetNamed(Find.WorldGrid.tiles[currentTileSelected].hilliness.ToString()); if (currentBiomeSelected.canSettle == true && currentHillinessSelected.canSettle == true && currentTileSelected != 1) { timeToTravel = FactionColonies.ReturnTicksToArrive(Find.World.GetComponent <FactionFC>().capitalLocation, currentTileSelected); } else { timeToTravel = 0; } } //grab before anchor/font GameFont fontBefore = Text.Font; TextAnchor anchorBefore = Text.Anchor; int silverToCreateSettlement = (int)(traitUtilsFC.cycleTraits(new double(), "createSettlementMultiplier", Find.World.GetComponent <FactionFC>().traits, "multiply") * (FactionColonies.silverToCreateSettlement + (500 * (Find.World.GetComponent <FactionFC>().settlements.Count() + Find.World.GetComponent <FactionFC>().settlementCaravansList.Count())) + (traitUtilsFC.cycleTraits(new double(), "createSettlementBaseCost", Find.World.GetComponent <FactionFC>().traits, "add")))); //Draw Label Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(0, 0, 268, 40), "SettleANewColony".Translate()); //hori line Widgets.DrawLineHorizontal(0, 40, 300); //Upper menu Widgets.DrawMenuSection(new Rect(5, 45, 258, 220)); DrawLabelBox(10, 50, 100, 100, "TravelTime".Translate(), GenDate.ToStringTicksToDays(timeToTravel)); DrawLabelBox(153, 50, 100, 100, "InitialCost".Translate(), silverToCreateSettlement + " " + "Silver".Translate()); //Lower Menu label Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(0, 270, 268, 40), "BaseProductionStats".Translate()); //Lower menu Widgets.DrawMenuSection(new Rect(5, 310, 258, 220)); //Draw production Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; //Production headers Widgets.Label(new Rect(40, 310, 60, 25), "Base".Translate()); Widgets.Label(new Rect(110, 310, 60, 25), "Modifier".Translate()); Widgets.Label(new Rect(180, 310, 60, 25), "Final".Translate()); if (currentTileSelected != -1) { for (int i = 0; i < Find.World.GetComponent <FactionFC>().returnNumberResource(); i++) { int height = 15; if (Widgets.ButtonImage(new Rect(20, 335 + i * (5 + height), height, height), faction.returnResourceByInt(i).getIcon())) { Find.WindowStack.Add(new descWindowFC("SettlementProductionOf".Translate() + ": " + faction.returnResourceByInt(i).label, char.ToUpper(faction.returnResourceByInt(i).label[0]) + faction.returnResourceByInt(i).label.Substring(1))); } Widgets.Label(new Rect(40, 335 + i * (5 + height), 60, height + 2), (currentBiomeSelected.BaseProductionAdditive[i] + currentHillinessSelected.BaseProductionAdditive[i]).ToString()); Widgets.Label(new Rect(110, 335 + i * (5 + height), 60, height + 2), (currentBiomeSelected.BaseProductionMultiplicative[i] * currentHillinessSelected.BaseProductionMultiplicative[i]).ToString()); Widgets.Label(new Rect(180, 335 + i * (5 + height), 60, height + 2), ((currentBiomeSelected.BaseProductionAdditive[i] + currentHillinessSelected.BaseProductionAdditive[i]) * (currentBiomeSelected.BaseProductionMultiplicative[i] * currentHillinessSelected.BaseProductionMultiplicative[i])).ToString()); } } //Settle button Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; int buttonLength = 130; if (Widgets.ButtonText(new Rect((InitialSize.x - 32 - buttonLength) / 2f, 535, buttonLength, 32), "Settle".Translate() + ": (" + silverToCreateSettlement + ")")) //add inital cost { //if click button to settle if (PaymentUtil.getSilver() >= silverToCreateSettlement) //if have enough monies to make new settlement { StringBuilder reason = new StringBuilder(); if (!TileFinder.IsValidTileForNewSettlement(currentTileSelected, reason) || currentTileSelected == -1 || Find.World.GetComponent <FactionFC>().checkSettlementCaravansList(currentTileSelected.ToString())) { //Alert Error to User Messages.Message(reason.ToString() ?? "CaravanOnWay".Translate() + "!", MessageTypeDefOf.NegativeEvent); } else { //Else if valid tile PaymentUtil.paySilver(silverToCreateSettlement); //if PROCESS MONEY HERE //create settle event FCEvent tmp = FCEventMaker.MakeEvent(FCEventDefOf.settleNewColony); tmp.location = currentTileSelected; tmp.planetName = Find.World.info.name; tmp.timeTillTrigger = Find.TickManager.TicksGame + timeToTravel; tmp.source = Find.World.GetComponent <FactionFC>().capitalLocation; Find.World.GetComponent <FactionFC>().addEvent(tmp); Find.World.GetComponent <FactionFC>().settlementCaravansList.Add(tmp.location.ToString()); Messages.Message("CaravanSentToLocation".Translate() + " " + GenDate.ToStringTicksToDays((tmp.timeTillTrigger - Find.TickManager.TicksGame)) + "!", MessageTypeDefOf.PositiveEvent); // when event activate FactionColonies.createPlayerColonySettlement(currentTileSelected); } } else { //if don't have enough monies to make settlement Messages.Message("NotEnoughSilverToSettle".Translate() + "!", MessageTypeDefOf.NeutralEvent); } } //reset anchor/font Text.Font = fontBefore; Text.Anchor = anchorBefore; }
private void DrawFactionResourceIcons(Rect inRect, int x, int y, int resourceSize) //Used to draw a list of resources from the faction { Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; int k; int j; float resourcesPerRow = 7; int ySpacing = 30; for (int i = 0; i < faction.returnNumberResource(); i++) { k = (int)Math.Floor(i / resourcesPerRow); j = (int)(i % resourcesPerRow); if (Widgets.ButtonImage(new Rect(5 + x + (j * (resourceSize + 5)), y - 5 + ySpacing * k, resourceSize, resourceSize), faction.returnResourceByInt(i).getIcon())) { Find.WindowStack.Add(new descWindowFC("TotalFactionProduction".Translate() + ": " + faction.returnResourceByInt(i).name, char.ToUpper(faction.returnResourceByInt(i).name[0]) + faction.returnResourceByInt(i).name.Substring(1))); } Widgets.Label(new Rect(5 + x + (j * (resourceSize + 5)), y + resourceSize - 10 + ySpacing * k, resourceSize, resourceSize), faction.returnResourceByInt(i).amount.ToString()); } }