Ejemplo n.º 1
0
        private void GetTileData()
        {
            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 && currentHillinessSelected.canSettle && currentTileSelected != 1)
                {
                    timeToTravel = FactionColonies.ReturnTicksToArrive(faction.capitalLocation, currentTileSelected);
                }
                else
                {
                    timeToTravel = 0;
                }
            }
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
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;



            Text.Anchor = TextAnchor.MiddleLeft;

            int i = 0;

            foreach (FCPrisoner prisoner in prisoners)
            {
                Rect Box;
                Rect PawnIcon;
                Rect PawnName;
                Rect PawnHealth;
                Rect PawnUnrest;
                Rect PawnWorkload;
                Rect ButtonInfo;
                Rect ButtonAction;

                Box          = optionBox;
                PawnIcon     = optionPawnIcon;
                PawnName     = optionPawnName;
                PawnHealth   = optionPawnHealth;
                PawnUnrest   = optionPawnUnrest;
                PawnWorkload = optionPawnWorkload;
                ButtonInfo   = optionButtonInfo;
                ButtonAction = optionButtonAction;

                Box.y          += scroll + optionHeight * i;
                PawnIcon.y     += scroll + optionHeight * i;
                PawnName.y     += scroll + optionHeight * i;
                PawnHealth.y   += scroll + optionHeight * i;
                PawnUnrest.y   += scroll + optionHeight * i;
                PawnWorkload.y += scroll + optionHeight * i;
                ButtonInfo.y   += scroll + optionHeight * i;
                ButtonAction.y += scroll + optionHeight * i;


                //display stuff now
                Widgets.DrawMenuSection(Box);
                //on every other box
                if (i % 2 == 0)
                {
                    Widgets.DrawHighlight(Box);
                }

                //show pawn;
                Widgets.ThingIcon(PawnIcon, prisoner.prisoner);
                //Pawn Name
                Widgets.Label(PawnName, prisoner.prisoner.Name.ToString());
                //Pawn Health
                Widgets.Label(PawnHealth, "Health".Translate().CapitalizeFirst() + " " + prisoner.health);
                //Pawn Unrest
                //Widgets.Label(PawnUnrest, "Unrest".Translate().CapitalizeFirst() + " " + prisoner.unrest);



                //Pawn Workload
                string workload;
                switch (prisoner.workload)
                {
                case FCWorkLoad.Heavy:
                    workload = "FCHeavy".Translate().CapitalizeFirst();
                    break;

                case FCWorkLoad.Medium:
                    workload = "FCMedium".Translate().CapitalizeFirst();
                    break;

                case FCWorkLoad.Light:
                    workload = "FCLight".Translate().CapitalizeFirst();
                    break;

                default:
                    workload = "null";
                    break;
                }
                if (Widgets.ButtonText(PawnWorkload, "FCWorkload".Translate().CapitalizeFirst() + ": " + workload))
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();
                    list.Add(new FloatMenuOption("FCHeavy".Translate().CapitalizeFirst() + " - " + "FCHeavyExplanation".Translate(), delegate
                    {
                        prisoner.workload = FCWorkLoad.Heavy;
                    }));
                    list.Add(new FloatMenuOption("FCMedium".Translate().CapitalizeFirst() + " - " + "FCMediumExplanation".Translate(), delegate
                    {
                        prisoner.workload = FCWorkLoad.Medium;
                    }));
                    list.Add(new FloatMenuOption("FCLight".Translate().CapitalizeFirst() + " - " + "FCLightExplanation".Translate(), delegate
                    {
                        prisoner.workload = FCWorkLoad.Light;
                    }));
                    FloatMenu menu = new FloatMenu(list);
                    Find.WindowStack.Add(menu);
                }

                //Info Button
                if (Widgets.ButtonTextSubtle(ButtonInfo, "ViewInfo".Translate()))
                {
                    Pawn pawn = new Pawn();
                    pawn = prisoner.prisoner;

                    if (prisoner.healthTracker != null)
                    {
                        prisoner.prisoner.health = prisoner.healthTracker;
                    }
                    else
                    {
                        prisoner.prisoner.health = new Pawn_HealthTracker(prisoner.prisoner);
                        prisoner.healthTracker   = new Pawn_HealthTracker(prisoner.prisoner);
                    }

                    pawn.health = prisoner.healthTracker;


                    Find.WindowStack.Add(new Dialog_InfoCard(pawn));
                }

                //Action button
                if (Widgets.ButtonTextSubtle(ButtonAction, "Actions".Translate()))
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();

                    list.Add(new FloatMenuOption("SellPawn".Translate() + " $" + prisoner.prisoner.MarketValue + " " + "SellPawnInfo".Translate(), delegate

                    {
                        settlement.addSilverIncome(prisoner.prisoner.MarketValue);

                        //reset window
                        prisoners.Remove(prisoner);
                        WindowUpdate();
                        return;
                    }));

                    list.Add(new FloatMenuOption("ReturnToPlayer".Translate(), delegate
                    {
                        if (prisoner.healthTracker != null)
                        {
                            prisoner.prisoner.health = prisoner.healthTracker;
                        }
                        else
                        {
                            prisoner.prisoner.health = new Pawn_HealthTracker(prisoner.prisoner);
                            prisoner.healthTracker   = new Pawn_HealthTracker(prisoner.prisoner);
                        }

                        if (!HealthUtility.TryAnesthetize(prisoner.prisoner))
                        {
                            HealthUtility.DamageUntilDowned(prisoner.prisoner, false);
                        }

                        if (prisoner.prisoner.guest == null)
                        {
                            prisoner.prisoner.guest = new Pawn_GuestTracker();
                        }
                        prisoner.prisoner.guest.guestStatusInt = GuestStatus.Prisoner;
                        FieldInfo hostFaction = typeof(Pawn_GuestTracker).GetField("hostFactionInt", BindingFlags.NonPublic | BindingFlags.Instance);
                        hostFaction.SetValue(prisoner.prisoner.guest, Find.FactionManager.OfPlayer);

                        DeliveryEvent.CreateDeliveryEvent(new FCEvent
                        {
                            location   = Find.AnyPlayerHomeMap.Tile,
                            source     = settlement.mapLocation,
                            planetName = settlement.planetName,
                            goods      = new List <Thing> {
                                prisoner.prisoner
                            },
                            customDescription = "aPrisonerIsBeingDeliveredToYou".Translate(),
                            timeTillTrigger   = Find.TickManager.TicksGame + FactionColonies.ReturnTicksToArrive(settlement.mapLocation, Find.AnyPlayerHomeMap.Tile)
                        });

                        //reset window
                        prisoners.Remove(prisoner);
                        WindowUpdate();
                        return;
                    }));


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



                //increment i
                i++;
            }

            Text.Font   = fontBefore;
            Text.Anchor = anchorBefore;

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