예제 #1
0
        public bool attemptResolve()
        {
            FactionFC factionfc = Find.World.GetComponent <FactionFC>();

            if (PaymentUtil.getSilver() >= -1 * this.taxes.silverAmount || this.taxes.silverAmount >= 0)
            { //if have enough silver on the current map to pay  & map belongs to player
                FCEventMaker.createTaxEvent(this);
                if (this.taxes.researchCompleted != 0)
                {
                    factionfc.researchPointPool += this.taxes.researchCompleted;
                    Messages.Message(TranslatorFormattedStringExtensions.Translate("PointsAddedToResearchPool", this.taxes.researchCompleted), MessageTypeDefOf.PositiveEvent);
                }

                if (this.taxes.electricityAllotted != 0)
                {
                    factionfc.powerPool += this.taxes.electricityAllotted;
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        public bool resolve()
        {
            FactionFC factionfc = Find.World.GetComponent <FactionFC>();

            if (PaymentUtil.getSilver() >= -1 * taxes.silverAmount || taxes.silverAmount >= 0)
            { //if have enough silver on the current map to pay  & map belongs to player
                FCEventMaker.createTaxEvent(this);
                if (taxes.researchCompleted != 0)
                {
                    factionfc.researchPointPool += taxes.researchCompleted;
                    Messages.Message("PointsAddedToResearchPool".Translate(taxes.researchCompleted), MessageTypeDefOf.PositiveEvent);
                }

                if (taxes.electricityAllotted != 0)
                {
                    factionfc.powerPool += taxes.electricityAllotted;
                }

                return(true);
            }

            string messageString = "NotEnoughSilverForBill".Translate() + " " + settlement.name + ". " + "ConfiscatedTithes".Translate() + "." + " " + "UnpaidTitheEffect".Translate();

            settlement.GainUnrestWithReason(new Message(messageString, MessageTypeDefOf.NegativeEvent), 10d);
            settlement.GainHappiness(-10d);
            factionfc.Bills.Remove(this);
            return(false);
        }
예제 #3
0
        public bool resolve()
        {
            FactionFC factionfc = Find.World.GetComponent <FactionFC>();

            if (PaymentUtil.getSilver() >= -1 * taxes.silverAmount || taxes.silverAmount >= 0)
            { //if have enough silver on the current map to pay  & map belongs to player
                FCEventMaker.createTaxEvent(this);
                if (taxes.researchCompleted != 0)
                {
                    factionfc.researchPointPool += taxes.researchCompleted;
                    Messages.Message("PointsAddedToResearchPool".Translate(taxes.researchCompleted), MessageTypeDefOf.PositiveEvent);
                }

                if (taxes.electricityAllotted != 0)
                {
                    factionfc.powerPool += taxes.electricityAllotted;
                }

                return(true);
            }

            Messages.Message("NotEnoughSilverForBill".Translate() + " " + settlement.name + ". " + "ConfiscatedTithes".Translate() + "." + " " + "UnpaidTitheEffect".Translate(), MessageTypeDefOf.NegativeEvent);
            settlement.unrest    += 10 * TraitUtilsFC.cycleTraits(new double(), "unrestGainedMultiplier", settlement.traits, "multiply") * TraitUtilsFC.cycleTraits(new double(), "unrestGainedMultiplier", factionfc.traits, "multiply");
            settlement.happiness -= 10 * TraitUtilsFC.cycleTraits(new double(), "happinessLostMultiplier", settlement.traits, "multiply") * TraitUtilsFC.cycleTraits(new double(), "happinessLostMultiplier", factionfc.traits, "multiply");
            factionfc.Bills.Remove(this);
            return(false);
        }
        /// <summary>
        /// Attempts to create an upgrading <c>FCEvent</c> for a <c>SettlementFC</c>.
        /// </summary>
        /// <returns>A message describing if the process was successful or not, including a reason in case it was not</returns>
        private Message UpgradeSettlement()
        {
            //failure reasons
            if (settlement.IsBeingUpgraded)
            {
                return(new Message("AlreadyUpgradeSettlement".Translate(), MessageTypeDefOf.RejectInput));
            }
            if (settlement.isUnderAttack)
            {
                return(new Message("SettlementUnderAttack".Translate(), MessageTypeDefOf.RejectInput));
            }
            if (PaymentUtil.getSilver() < settlementUpgradeCost)
            {
                return(new Message("NotEnoughSilverUpgrade".Translate(), MessageTypeDefOf.RejectInput));
            }

            //on success
            PaymentUtil.paySilver(settlementUpgradeCost);
            FCEvent tmp = new FCEvent(true)
            {
                def             = FCEventDefOf.upgradeSettlement,
                location        = settlement.mapLocation,
                planetName      = settlement.planetName,
                timeTillTrigger = Find.TickManager.TicksGame + (settlement.settlementLevel + 1) * 60000 * (factionfc.hasPolicy(FCPolicyDefOf.isolationist) ? 1 : 2)
            };

            Find.World.GetComponent <FactionFC>().addEvent(tmp);

            //Close this window and update the SettlementWindowFc
            Find.WindowStack.TryRemove(this);
            Find.WindowStack.WindowOfType <SettlementWindowFc>().windowUpdateFc();

            return(new Message("StartUpgradeSettlement".Translate(), MessageTypeDefOf.NeutralEvent));
        }
예제 #5
0
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;



            //Settlement Tax Collection Header
            Text.Anchor = TextAnchor.MiddleLeft;
            Text.Font   = GameFont.Medium;
            Widgets.DrawMenuSection(new Rect(0, 0, 544, 150));
            Widgets.Label(new Rect(10, 0, 500, 60), header);
            Widgets.DrawLineHorizontal(0, 155, 544);



            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font   = GameFont.Tiny;
            Widgets.Label(new Rect(20, 60, 470, 90), desc);


            Text.Anchor = TextAnchor.MiddleLeft;
            Text.Font   = GameFont.Tiny;



            for (int i = 0; i < options.Count(); i++)
            {
                if (Widgets.ButtonTextSubtle(new Rect(xoffset, yoffset + (i * (height + yspacing)), length, height), ""))
                {
                    if (PaymentUtil.getSilver() >= options[i].silverCost)
                    {
                        PaymentUtil.paySilver(options[i].silverCost);

                        FCEventMaker.calculateSuccess(options[i], parentEvent);
                        //Log.Message(options[i].label);


                        Find.WindowStack.TryRemove(this);
                    }
                    else
                    {
                        Messages.Message("You do not have enough silver on the map to pay for that option", MessageTypeDefOf.RejectInput);
                    }
                }

                //label
                Widgets.Label(new Rect(xoffset + 5, yoffset + 5 + (i * (height + yspacing)), length - 10, height - 10), options[i].label);
            }
            //Widgets.DrawBox(new Rect(xoffset, yoffset - yspacing, length, height - yspacing * 2));

            //reset anchor/font
            Text.Font   = fontBefore;
            Text.Anchor = anchorBefore;
        }
예제 #6
0
        private bool PlayerHasEnoughSilver(StringBuilder reason)
        {
            if (PaymentUtil.getSilver() >= settlementCreationCost)
            {
                return(true);
            }

            reason?.Append("NotEnoughSilverToSettle".Translate() + "!");
            return(false);
        }
예제 #7
0
 public FCWindow_Pay_Silver(SettlementFC settlement)
 {
     this.forcePause          = false;
     this.draggable           = true;
     this.doCloseX            = true;
     this.preventCameraMotion = false;
     this.silverCount         = PaymentUtil.getSilver();
     this.settlement          = settlement;
     this.selectedSilver      = 0;
 }
 public FCWindow_Pay_Silver_Loyalty(SettlementFC settlement) : base(settlement)
 {
     this.forcePause          = false;
     this.draggable           = true;
     this.doCloseX            = true;
     this.preventCameraMotion = false;
     this.silverCount         = PaymentUtil.getSilver();
     this.settlement          = settlement;
     this.selectedSilver      = 0;
     this.stringEffect        = "SettlementGainsXLoyalty";
 }
예제 #9
0
        public override void DrawTab(Rect rect)
        {
            Rect SettlementBox  = new Rect(5, 45, 535, settlementHeight);
            Rect SettlementName = new Rect(SettlementBox.x + 5, SettlementBox.y + 5, 250, 25);
            Rect MilitaryLevel  = new Rect(SettlementName.x, SettlementName.y + 30, 250, 25);
            Rect AssignedSquad  = new Rect(MilitaryLevel.x, MilitaryLevel.y + 30, 250, 25);
            Rect isBusy         = new Rect(AssignedSquad.x, AssignedSquad.y + 30, 250, 25);

            Rect buttonSetSquad  = new Rect(SettlementBox.x + SettlementBox.width - 265, SettlementBox.y + 5, 100, 25);
            Rect buttonViewSquad = new Rect(buttonSetSquad.x, buttonSetSquad.y + 3 + buttonSetSquad.height,
                                            buttonSetSquad.width, buttonSetSquad.height);
            Rect buttonDeploySquad = new Rect(buttonViewSquad.x, buttonViewSquad.y + 3 + buttonViewSquad.height,
                                              buttonSetSquad.width, buttonSetSquad.height);
            Rect buttonResetPawns = new Rect(buttonDeploySquad.x, buttonDeploySquad.y + 3 + buttonDeploySquad.height,
                                             buttonSetSquad.width, buttonSetSquad.height);
            Rect buttonOrderFireSupport = new Rect(buttonSetSquad.x + 125 + 5, SettlementBox.y + 5, 125, 25);


            //set text anchor and font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;


            int count = 0;

            foreach (SettlementFC settlement in Find.World.GetComponent <FactionFC>().settlements)
            {
                Text.Font = GameFont.Small;

                Widgets.DrawMenuSection(new Rect(SettlementBox.x,
                                                 SettlementBox.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                                 SettlementBox.width, SettlementBox.height));

                //click on settlement name
                if (Widgets.ButtonTextSubtle(
                        new Rect(SettlementName.x,
                                 SettlementName.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                 SettlementName.width, SettlementName.height), settlement.name))
                {
                    Find.WindowStack.Add(new SettlementWindowFc(settlement));
                }

                Widgets.Label(
                    new Rect(MilitaryLevel.x,
                             MilitaryLevel.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                             MilitaryLevel.width, MilitaryLevel.height * 2),
                    "Mil Level: " + settlement.settlementMilitaryLevel + " - Max Squad Cost: " +
                    FactionColonies.calculateMilitaryLevelPoints(settlement.settlementMilitaryLevel));
                if (settlement.militarySquad != null)
                {
                    if (settlement.militarySquad.outfit != null)
                    {
                        Widgets.Label(
                            new Rect(AssignedSquad.x,
                                     AssignedSquad.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                     AssignedSquad.width, AssignedSquad.height),
                            "Assigned Squad: " +
                            settlement.militarySquad.outfit.name); //settlement.militarySquad.name);
                    }
                    else
                    {
                        Widgets.Label(
                            new Rect(AssignedSquad.x,
                                     AssignedSquad.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                     AssignedSquad.width, AssignedSquad.height),
                            "No assigned Squad"); //settlement.militarySquad.name);
                    }
                }
                else
                {
                    Widgets.Label(
                        new Rect(AssignedSquad.x,
                                 AssignedSquad.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                 AssignedSquad.width, AssignedSquad.height), "No assigned Squad");
                }


                Widgets.Label(
                    new Rect(isBusy.x, isBusy.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                             isBusy.width, isBusy.height), "Available: " + (!settlement.isMilitaryBusySilent()));

                Text.Font = GameFont.Tiny;

                //Set Squad Button
                if (Widgets.ButtonText(
                        new Rect(buttonSetSquad.x,
                                 buttonSetSquad.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                 buttonSetSquad.width, buttonSetSquad.height), "Set Squad"))
                {
                    //check null
                    if (util.squads == null)
                    {
                        util.resetSquads();
                    }

                    List <FloatMenuOption> squads = new List <FloatMenuOption>();

                    squads.AddRange(util.squads
                                    .Select(squad => new FloatMenuOption(squad.name + " - Total Equipment Cost: " +
                                                                         squad.equipmentTotalCost, delegate
                    {
                        //Unit is selected
                        util.attemptToAssignSquad(settlement, squad);
                    })));

                    if (!squads.Any())
                    {
                        squads.Add(new FloatMenuOption("No Available Squads", null));
                    }

                    FloatMenu selection = new FloatMenuSearchable(squads);
                    Find.WindowStack.Add(selection);
                }

                //View Squad
                if (Widgets.ButtonText(
                        new Rect(buttonViewSquad.x,
                                 buttonViewSquad.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                 buttonViewSquad.width, buttonViewSquad.height), "View Squad"))
                {
                    Messages.Message("This is currently not implemented.", MessageTypeDefOf.RejectInput);
                }


                //Deploy Squad
                if (Widgets.ButtonText(
                        new Rect(buttonDeploySquad.x,
                                 buttonDeploySquad.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                 buttonDeploySquad.width, buttonDeploySquad.height), "Deploy Squad"))
                {
                    if (!(settlement.isMilitaryBusy()) && settlement.isMilitarySquadValid())
                    {
                        Find.WindowStack.Add(new FloatMenu(DeploymentOptions(settlement)));
                    }
                    else if (settlement.isMilitaryBusy() && settlement.isMilitarySquadValid() &&
                             faction.hasPolicy(FCPolicyDefOf.militaristic))
                    {
                        if ((faction.traitMilitaristicTickLastUsedExtraSquad + GenDate.TicksPerDay * 5) <=
                            Find.TickManager.TicksGame)
                        {
                            int cost = (int)Math.Round(settlement.militarySquad.outfit.updateEquipmentTotalCost() *
                                                       .2);
                            List <FloatMenuOption> options = new List <FloatMenuOption>();

                            options.Add(new FloatMenuOption("Deploy Secondary Squad - $" + cost + " silver",
                                                            delegate
                            {
                                if (PaymentUtil.getSilver() >= cost)
                                {
                                    List <FloatMenuOption> deploymentOptions = new List <FloatMenuOption>();

                                    deploymentOptions.Add(new FloatMenuOption("Walk into map", delegate
                                    {
                                        FactionColonies.CallinAlliedForces(settlement, false, cost);
                                        Find.WindowStack.currentlyDrawnWindow.Close();
                                    }));
                                    //check if medieval only
                                    bool medievalOnly = LoadedModManager.GetMod <FactionColoniesMod>()
                                                        .GetSettings <FactionColonies>().medievalTechOnly;
                                    if (!medievalOnly && (DefDatabase <ResearchProjectDef>
                                                          .GetNamed("TransportPod", false)?.IsFinished ?? false))
                                    {
                                        deploymentOptions.Add(new FloatMenuOption("Drop-Pod", delegate
                                        {
                                            FactionColonies.CallinAlliedForces(settlement, true, cost);
                                            Find.WindowStack.currentlyDrawnWindow.Close();
                                        }));
                                    }

                                    Find.WindowStack.Add(new FloatMenu(deploymentOptions));
                                }
                                else
                                {
                                    Messages.Message("NotEnoughSilverToDeploySquad".Translate(),
                                                     MessageTypeDefOf.RejectInput);
                                }
                            }));

                            Find.WindowStack.Add(new FloatMenu(options));
                        }
                        else
                        {
                            Messages.Message(
                                "XDaysToRedeploy".Translate(Math.Round(
                                                                ((faction.traitMilitaristicTickLastUsedExtraSquad + GenDate.TicksPerDay * 5) -
                                                                 Find.TickManager.TicksGame).TicksToDays(), 1)), MessageTypeDefOf.RejectInput);
                        }
                    }
                }

                //Reset Squad
                if (Widgets.ButtonText(
                        new Rect(buttonResetPawns.x,
                                 buttonResetPawns.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                 buttonResetPawns.width, buttonResetPawns.height), "Reset Pawns"))
                {
                    FloatMenuOption confirm = new FloatMenuOption("Are you sure? Click to confirm", delegate
                    {
                        if (settlement.militarySquad != null)
                        {
                            Messages.Message("Pawns have been regenerated for the squad",
                                             MessageTypeDefOf.NeutralEvent);
                            settlement.militarySquad.initiateSquad();
                        }
                        else
                        {
                            Messages.Message("There is no pawns to reset. Assign a squad first.",
                                             MessageTypeDefOf.RejectInput);
                        }
                    });

                    List <FloatMenuOption> list = new List <FloatMenuOption>();
                    list.Add(confirm);
                    Find.WindowStack.Add(new FloatMenu(list));
                }

                //Order Fire Support
                if (Widgets.ButtonText(
                        new Rect(buttonOrderFireSupport.x,
                                 buttonOrderFireSupport.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                 buttonOrderFireSupport.width, buttonOrderFireSupport.height), "Order Fire Support"))
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();


                    foreach (MilitaryFireSupport support in util.fireSupportDefs)
                    {
                        float           cost   = support.returnTotalCost();
                        FloatMenuOption option = new FloatMenuOption(support.name + " - $" + cost, delegate
                        {
                            if (support.returnTotalCost() <=
                                FactionColonies.calculateMilitaryLevelPoints(settlement.settlementMilitaryLevel))
                            {
                                if (settlement.buildings.Contains(BuildingFCDefOf.artilleryOutpost))
                                {
                                    if (settlement.artilleryTimer <= Find.TickManager.TicksGame)
                                    {
                                        if (PaymentUtil.getSilver() >= cost)
                                        {
                                            FactionColonies.FireSupport(settlement, support);
                                            Find.WindowStack.TryRemove(typeof(MilitaryCustomizationWindowFc));
                                        }
                                        else
                                        {
                                            Messages.Message(
                                                "You lack the required amount of silver to use that firesupport option!",
                                                MessageTypeDefOf.RejectInput);
                                        }
                                    }
                                    else
                                    {
                                        Messages.Message(
                                            "That firesupport option is on cooldown for another " +
                                            (settlement.artilleryTimer - Find.TickManager.TicksGame)
                                            .ToStringTicksToDays(), MessageTypeDefOf.RejectInput);
                                    }
                                }
                                else
                                {
                                    Messages.Message(
                                        "The settlement requires an artillery outpost to be built to use that firesupport option",
                                        MessageTypeDefOf.RejectInput);
                                }
                            }
                            else
                            {
                                Messages.Message(
                                    "The settlement requires a higher military level to use that fire support!",
                                    MessageTypeDefOf.RejectInput);
                            }
                        });
                        list.Add(option);
                    }

                    if (!list.Any())
                    {
                        list.Add(new FloatMenuOption("No fire supports currently made. Make one", delegate { }));
                    }

                    FloatMenu menu = new FloatMenuSearchable(list);
                    Find.WindowStack.Add(menu);
                }

                count++;
            }

            //Reset Text anchor and font
            Text.Font   = fontBefore;
            Text.Anchor = anchorBefore;

            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y, settlementMaxScroll);
            }
        }
예제 #10
0
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;



            //Settlement Tax Collection Header
            Text.Anchor = TextAnchor.MiddleLeft;
            Text.Font   = GameFont.Medium;
            Widgets.Label(new Rect(2, 0, 300, 60), header);



            //settlement buttons

            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font   = GameFont.Tiny;

            //0 tithe total string
            //1 source - -1
            //2 due/delivery date
            //3 Silver (- || +)
            //4 tithe

            if (settlement.settlementLevel < LoadedModManager.GetMod <FactionColoniesMod>().GetSettings <FactionColonies>().settlementMaxLevel)           //if settlement is not max level
            {
                if (Widgets.ButtonText(new Rect(xoffset + ((335 - 150) / 2), height + 10, 150, 40), "UpgradeSettlement".Translate() + ": " + settlementUpgradeCost))
                {                                                                                                                                       //if upgrade button clicked
                    //if max level
                    if (settlement.settlementLevel < LoadedModManager.GetMod <FactionColoniesMod>().GetSettings <FactionColonies>().settlementMaxLevel) //if below max level
                    {
                        if (PaymentUtil.getSilver() > settlementUpgradeCost)                                                                            //if have enough monies to pay
                        {
                            foreach (FCEvent evt in Find.World.GetComponent <FactionFC>().events)
                            {
                                if (evt.def == FCEventDefOf.upgradeSettlement && evt.location == settlement.mapLocation)
                                {                                 //if already existing event
                                    Messages.Message("AlreadyUpgradeSettlement".Translate(), MessageTypeDefOf.RejectInput);
                                    return;
                                }
                            }
                            PaymentUtil.paySilver(settlementUpgradeCost);
                            //settlement.upgradeSettlement();
                            FCEvent tmp = new FCEvent(true);
                            tmp.def             = FCEventDefOf.upgradeSettlement;
                            tmp.location        = settlement.mapLocation;
                            tmp.timeTillTrigger = Find.TickManager.TicksGame + (settlement.settlementLevel + 1) * 60000 * 2;
                            //Log.Message(list[i].enactDuration.ToString());
                            //Log.Message(tmp.timeTillTrigger.ToString());
                            Find.World.GetComponent <FactionFC>().addEvent(tmp);
                            Find.WindowStack.TryRemove(this);
                            Find.WindowStack.WindowOfType <settlementWindowFC>().WindowUpdateFC();
                            Messages.Message("StartUpgradeSettlement".Translate(), MessageTypeDefOf.NeutralEvent);
                        }
                        else
                        {                         //if don't have enough monies
                            Messages.Message("NotEnoughSilverUpgrade".Translate(), MessageTypeDefOf.RejectInput);
                        }
                    }
                    else
                    {
                        Messages.Message(settlement.name + " " + "AlreadyMaxLevel".Translate() + "!", MessageTypeDefOf.RejectInput);
                    }
                }
            }
            else               //if settlement is max level
            {
                desc = "CannotBeUpgradedPastMax".Translate() + ": " + LoadedModManager.GetMod <FactionColoniesMod>().GetSettings <FactionColonies>().settlementMaxLevel;
            }

            Widgets.Label(new Rect(xoffset + 2, yoffset - yspacing + 2, length - 4, height - 4 + yspacing * 2), desc);
            Widgets.DrawBox(new Rect(xoffset, yoffset - yspacing, length, height - yspacing * 2));



            //reset anchor/font
            Text.Font   = fontBefore;
            Text.Anchor = anchorBefore;
        }
예제 #11
0
        //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;
        }
예제 #12
0
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;

            //top label
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;

            //build outline
            Widgets.DrawMenuSection(billsBox);


            //loop through each bill
            //GoTo Here if change
Reset:

            int i = 0;

            Text.Anchor = TextAnchor.MiddleCenter;
            foreach (BillFC bill in bills)
            {
                i++;
                Rect settlement = new Rect();
                Rect date       = new Rect();
                Rect amount     = new Rect();
                Rect tithe      = new Rect();
                Rect resolve    = new Rect();
                Rect highlight  = new Rect();


                settlement = billNameBase;
                date       = billDescBase;
                amount     = billLocationBase;
                tithe      = billTimeRemaining;
                resolve    = billResolveBase;

                settlement.y = scroll + billHeight * i;
                date.y       = scroll + billHeight * i;
                amount.y     = scroll + billHeight * i;
                tithe.y      = scroll + billHeight * i;
                resolve.y    = scroll + billHeight * i;

                highlight = new Rect(settlement.x, settlement.y, resolve.x + resolve.width, billHeight);



                if (i % 2 == 0)
                {
                    Widgets.DrawHighlight(highlight);
                }
                String settlementName;
                if (bill.settlement != null)
                {
                    settlementName = bill.settlement.name;
                }
                else
                {
                    settlementName = "Null";
                }
                if (Widgets.ButtonText(settlement, settlementName))
                {
                    if (bill.settlement != null)
                    {
                        Find.WindowStack.Add(new settlementWindowFC(bill.settlement));
                    }
                }
                //
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(date, GenDate.ToStringTicksToDays(bill.dueTick - Find.TickManager.TicksGame));

                //
                Widgets.Label(amount, bill.taxes.silverAmount.ToString());
                //
                bool bul;
                bul = (bill.taxes.itemTithes.Count > 0);
                Widgets.Checkbox(new Vector2(tithe.x + tithe.width / 2 - 12, tithe.y), ref bul);

                if (Widgets.ButtonText(resolve, "ResolveBill".Translate()))
                {
                    if (PaymentUtil.getSilver() >= -1 * (bill.taxes.silverAmount) || bill.taxes.silverAmount >= 0)
                    { //if have enough silver on the current map to pay  & map belongs to player
                        FCEventMaker.createTaxEvent(bill);
                        if (bill.taxes.researchCompleted != 0)
                        {
                            faction.researchPointPool += bill.taxes.researchCompleted;
                            Messages.Message(TranslatorFormattedStringExtensions.Translate("PointsAddedToResearchPool", bill.taxes.researchCompleted), MessageTypeDefOf.PositiveEvent);
                        }
                        if (bill.taxes.electricityAllotted != 0)
                        {
                            faction.powerPool += bill.taxes.electricityAllotted;
                        }
                        goto Reset;
                    }
                    else
                    {
                        Messages.Message("NotEnoughSilverOnMapToPayBill".Translate() + "!", MessageTypeDefOf.RejectInput);
                    }
                }
            }



            //Top label
            Widgets.ButtonTextSubtle(billNameBase, "Settlement".Translate());
            Widgets.ButtonTextSubtle(billDescBase, "DueFC".Translate());
            Widgets.ButtonTextSubtle(billLocationBase, "Amount".Translate());
            Widgets.ButtonTextSubtle(billTimeRemaining, "HasTithe".Translate());
            if (Widgets.ButtonTextSubtle(billResolveBase, "Auto-Resolve"))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();

                FloatMenuOption option = new FloatMenuOption("Auto-Resolving : " + faction.autoResolveBills, delegate
                {
                    faction.autoResolveBills = !faction.autoResolveBills;
                    switch (faction.autoResolveBills)
                    {
                    case true:
                        Messages.Message("Bills are now autoresolving!", MessageTypeDefOf.NeutralEvent);
                        PaymentUtil.autoresolveBills(bills);
                        break;

                    case false:
                        Messages.Message("Bills are now not autoresolving.", MessageTypeDefOf.NeutralEvent);
                        break;
                    }
                });
                list.Add(option);


                FloatMenu menu = new FloatMenu(list);
                Find.WindowStack.Add(menu);
            }
            Widgets.Checkbox(new Vector2(billResolveBase.x + billResolveBase.width - 30, billResolveBase.y + 3), ref faction.autoResolveBills, 24, true);

            //Menu Outline
            Widgets.DrawBox(billsBox);


            //reset anchor/font
            Text.Font   = fontBefore;
            Text.Anchor = anchorBefore;


            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y);
            }
        }