public DiaOption GetMedicalSupplyDiaOption(Building_OrbitalRelay orbitalRelay)
        {
            DiaOption           medicalSupplyDiaOption = new DiaOption("Request medical supply (" + Util_Spaceship.medicalSupplyCostInSilver + " silver)");
            Building_LandingPad landingPad             = Util_LandingPad.GetBestAvailableLandingPad(this.Map);

            if (Find.TickManager.TicksGame <= Util_Misc.Partnership.nextMedicalSupplyMinTick[this.Map])
            {
                medicalSupplyDiaOption.Disable("no available ship for now");
            }
            else if (TradeUtility.ColonyHasEnoughSilver(this.Map, Util_Spaceship.medicalSupplyCostInSilver) == false)
            {
                medicalSupplyDiaOption.Disable("not enough silver");
            }
            else if (landingPad == null)
            {
                medicalSupplyDiaOption.Disable("no available landing pad");
            }
            medicalSupplyDiaOption.action = delegate
            {
                TradeUtility.LaunchSilver(this.Map, Util_Spaceship.medicalSupplyCostInSilver);
                Util_Spaceship.SpawnSpaceship(landingPad, SpaceshipKind.Medical);
            };
            DiaNode supplyShipAcceptedDiaNode = new DiaNode("\"We are sending you a medical ship immediately.\n\n"
                                                            + "Hold on down there, we're coming!\n\n"
                                                            + "-- End of transmission --");
            DiaOption supplyShipAcceptedDiaOption = new DiaOption("OK");

            supplyShipAcceptedDiaOption.resolveTree = true;
            supplyShipAcceptedDiaNode.options.Add(supplyShipAcceptedDiaOption);
            medicalSupplyDiaOption.link = supplyShipAcceptedDiaNode;
            return(medicalSupplyDiaOption);
        }
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (forced == false)
            {
                return(false);
            }
            Pawn otherPawn = t as Pawn;

            if ((otherPawn == null) ||
                (pawn.Faction != otherPawn.Faction) ||
                otherPawn.def.race.Animal)
            {
                return(false);
            }
            if (Util_Misc.OrbitalHealing.HasAnyTreatableHediff(otherPawn) == false)
            {
                return(false);
            }
            foreach (Thing spaceship in pawn.Map.listerThings.ThingsOfDef(Util_Spaceship.SpaceshipMedical))
            {
                Building_SpaceshipMedical medicalSpaceship = spaceship as Building_SpaceshipMedical;
                if ((medicalSpaceship != null) &&
                    otherPawn.Downed &&
                    pawn.CanReserveAndReach(otherPawn, this.PathEndMode, Danger.Deadly, ignoreOtherReservations: true) &&
                    pawn.CanReach(spaceship, this.PathEndMode, Danger.Deadly) &&
                    (medicalSpaceship.orbitalHealingPawnsAboardCount < Building_SpaceshipMedical.orbitalHealingPawnsAboardMaxCount) &&
                    TradeUtility.ColonyHasEnoughSilver(pawn.Map, Util_Spaceship.orbitalHealingCost))
                {
                    return(true);
                }
            }
            return(false);
        }
        public DiaNode GetAirStrikeDetailsDiaNode(DiaNode parentNode, AirStrikeDef strikeDef)
        {
            DiaNode airStrikeDetailsDiaNode = new DiaNode(strikeDef.LabelCap + "\n\n"
                                                          + strikeDef.description + "\n\n"
                                                          + "Runs number: " + strikeDef.runsNumber + "\n\n"
                                                          + "Cost: " + strikeDef.costInSilver + " silvers");
            DiaOption airStrikeConfirmDiaOption = new DiaOption("Confirm");

            airStrikeConfirmDiaOption.action = delegate
            {
                this.previousTimeSpeed        = Find.TickManager.CurTimeSpeed;
                Find.TickManager.CurTimeSpeed = TimeSpeed.Paused;
                this.selectedStrikeDef        = strikeDef;
                Util_Misc.SelectAirStrikeTarget(this.Map, SpawnAirStrikeBeacon);
            };
            airStrikeConfirmDiaOption.resolveTree = true;
            if (TradeUtility.ColonyHasEnoughSilver(this.Map, strikeDef.costInSilver) == false)
            {
                airStrikeConfirmDiaOption.Disable("not enough silver");
            }
            airStrikeDetailsDiaNode.options.Add(airStrikeConfirmDiaOption);
            DiaOption airStrikeBackDiaOption = new DiaOption("Back");

            airStrikeBackDiaOption.link = parentNode;
            airStrikeDetailsDiaNode.options.Add(airStrikeBackDiaOption);
            return(airStrikeDetailsDiaNode);
        }
        public DiaOption GetCargoSupplyDiaOption(Building_OrbitalRelay orbitalRelay)
        {
            DiaOption           cargoSupplyDiaOption = new DiaOption("Request cargo supply (" + Util_Spaceship.cargoSupplyCostInSilver + " silver)");
            Building_LandingPad landingPad           = Util_LandingPad.GetBestAvailableLandingPad(this.Map);

            if (Find.TickManager.TicksGame <= Util_Misc.Partnership.nextRequestedSupplyMinTick[this.Map])
            {
                cargoSupplyDiaOption.Disable("no available ship for now");
            }
            else if (TradeUtility.ColonyHasEnoughSilver(this.Map, Util_Spaceship.cargoSupplyCostInSilver) == false)
            {
                cargoSupplyDiaOption.Disable("not enough silver");
            }
            else if (landingPad == null)
            {
                cargoSupplyDiaOption.Disable("no available landing pad");
            }
            cargoSupplyDiaOption.action = delegate
            {
                TradeUtility.LaunchSilver(this.Map, Util_Spaceship.cargoSupplyCostInSilver);
                Util_Spaceship.SpawnSpaceship(landingPad, SpaceshipKind.CargoRequested);
            };
            DiaNode supplyShipAcceptedDiaNode = new DiaNode("\"Alright, a supply ship should arrive soon with our best stuff.\n"
                                                            + "Greetings partner!\"\n\n"
                                                            + "-- End of transmission --");
            DiaOption supplyShipAcceptedDiaOption = new DiaOption("OK");

            supplyShipAcceptedDiaOption.resolveTree = true;
            supplyShipAcceptedDiaNode.options.Add(supplyShipAcceptedDiaOption);
            cargoSupplyDiaOption.link = supplyShipAcceptedDiaNode;
            return(cargoSupplyDiaOption);
        }
Beispiel #5
0
        public static bool CanUpgradeDruglabs(Faction faction, List <Thing> requirements, int level)
        {
            requirements.Clear();
            Thing silver    = ThingMaker.MakeThing(ThingDefOf.Silver);
            Thing hops      = ThingMaker.MakeThing(ThingCategoryDefOf.PlantMatter.childThingDefs.Find(x => x.defName == "RawHops"));
            Thing smokeleaf = ThingMaker.MakeThing(ThingCategoryDefOf.PlantMatter.childThingDefs.Find(x => x.defName == "SmokeleafLeaves"));
            Thing psyLeaves = ThingMaker.MakeThing(ThingCategoryDefOf.PlantMatter.childThingDefs.Find(x => x.defName == "PsychoidLeaves"));

            switch (level)
            {
            case 0:
                silver.stackCount = 1000;
                requirements.Add(silver);
                hops.stackCount = 200;
                requirements.Add(hops);
                smokeleaf.stackCount = 200;
                requirements.Add(smokeleaf);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == hops.def).Sum(t => t.stackCount) >= hops.stackCount && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == smokeleaf.def).Sum(t => t.stackCount) >= smokeleaf.stackCount)
                {
                    return(true);
                }
                return(false);

            case 1:
                silver.stackCount = 4500;
                requirements.Add(silver);
                psyLeaves.stackCount = 150;
                requirements.Add(psyLeaves);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == psyLeaves.def).Sum(t => t.stackCount) >= psyLeaves.stackCount)
                {
                    return(true);
                }
                return(false);

            case 2:
                silver.stackCount = 7000;
                requirements.Add(silver);
                psyLeaves.stackCount = 500;
                requirements.Add(psyLeaves);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == psyLeaves.def).Sum(t => t.stackCount) >= psyLeaves.stackCount)
                {
                    return(true);
                }
                return(false);

            case 3:
                silver.stackCount = 13000;
                requirements.Add(silver);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount))
                {
                    return(true);
                }
                return(false);

            default:
                return(false);
            }
        }
Beispiel #6
0
        // ===================== Float menu options =====================
        public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn selPawn)
        {
            List <FloatMenuOption> options = new List <FloatMenuOption>();

            if (selPawn.CanReach(this, PathEndMode.ClosestTouch, Danger.Some, false, TraverseMode.ByPawn) == false)
            {
                return(GetFloatMenuOptionsCannotReach(selPawn));
            }

            // Base options.
            foreach (FloatMenuOption option in base.GetFloatMenuOptions(selPawn))
            {
                options.Add(option);
            }

            // Board to get orbital healing option.
            if (this.IsBurning())
            {
                FloatMenuOption burningOption = new FloatMenuOption("CannotUseReason".Translate(new object[]
                {
                    "BurningLower".Translate()
                }), null);
                options.Add(burningOption);
            }
            else
            {
                FloatMenuOption boardOption = null;
                if (Util_Misc.OrbitalHealing.HasAnyTreatableHediff(selPawn))
                {
                    if (this.orbitalHealingPawnsAboardCount >= orbitalHealingPawnsAboardMaxCount)
                    {
                        string optionLabel = "Board medical spaceship (no free slot)";
                        boardOption = new FloatMenuOption(optionLabel, null);
                    }
                    else if (TradeUtility.ColonyHasEnoughSilver(this.Map, Util_Spaceship.orbitalHealingCost))
                    {
                        Action action = delegate
                        {
                            Job job = new Job(Util_JobDefOf.BoardMedicalSpaceship, this);
                            selPawn.jobs.TryTakeOrderedJob(job);
                        };
                        string optionLabel = "Board medical spaceship (" + Util_Spaceship.orbitalHealingCost + " silver)";
                        boardOption = new FloatMenuOption(optionLabel, action);
                    }
                    else
                    {
                        string optionLabel = "Board medical spaceship (" + Util_Spaceship.orbitalHealingCost + " silver) (not enough silver)";
                        boardOption = new FloatMenuOption(optionLabel, null);
                    }
                    options.Add(boardOption);
                }
            }
            return(options);
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Pawn downedPawn = this.TargetThingA as Pawn;

            Toil gotoDownedPawnToil = Toils_Goto.GotoCell(downedPawnIndex, PathEndMode.OnCell).FailOn(delegate()
            {
                return(downedPawn.DestroyedOrNull() ||
                       (downedPawn.Downed == false));
            });

            yield return(gotoDownedPawnToil);

            yield return(Toils_Haul.StartCarryThing(downedPawnIndex));

            Toil gotoTravelDestToil = Toils_Haul.CarryHauledThingToCell(medicalSPaceshipCellIndex).FailOn(delegate()
            {
                return(this.pawn.carryTracker.CarriedThing.DestroyedOrNull() ||
                       (this.pawn.CanReach(this.pawn.jobs.curJob.targetB.Cell, PathEndMode.OnCell, Danger.Some) == false));
            });

            yield return(gotoTravelDestToil);

            Toil arrivedToil = new Toil()
            {
                initAction = () =>
                {
                    Thing carriedPawn = null;
                    this.pawn.carryTracker.TryDropCarriedThing(this.pawn.Position, ThingPlaceMode.Near, out carriedPawn);
                    Building_SpaceshipMedical medicalSpaceship = this.pawn.Position.GetFirstThing(this.pawn.Map, Util_Spaceship.SpaceshipMedical) as Building_SpaceshipMedical;
                    if (medicalSpaceship != null)
                    {
                        if (medicalSpaceship.orbitalHealingPawnsAboardCount >= Building_SpaceshipMedical.orbitalHealingPawnsAboardMaxCount)
                        {
                            Messages.Message((carriedPawn as Pawn).Name.ToStringShort + " cannot board MiningCo. medical spaceship.. There is no more any free slot.", carriedPawn, MessageTypeDefOf.RejectInput);
                        }
                        else if (TradeUtility.ColonyHasEnoughSilver(this.pawn.Map, Util_Spaceship.orbitalHealingCost))
                        {
                            TradeUtility.LaunchSilver(this.pawn.Map, Util_Spaceship.orbitalHealingCost);
                            medicalSpaceship.Notify_PawnBoarding(carriedPawn as Pawn, false);
                        }
                        else
                        {
                            Messages.Message((carriedPawn as Pawn).Name.ToStringShort + " cannot board MiningCo. medical spaceship.. You have not enough silver to pay for " + this.pawn.gender.GetPossessive() + " orbital healing.", carriedPawn, MessageTypeDefOf.RejectInput);
                        }
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            };

            yield return(arrivedToil);
        }
Beispiel #8
0
        public static bool CanUpgradeRawMaterials(Faction faction, List <Thing> requirements, int level)
        {
            requirements.Clear();
            Thing silver = ThingMaker.MakeThing(ThingDefOf.Silver);

            switch (level)
            {
            case 0:
                silver.stackCount = 2000;
                requirements.Add(silver);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount))
                {
                    return(true);
                }
                return(false);

            case 1:
                silver.stackCount = 3000;
                requirements.Add(silver);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount))
                {
                    return(true);
                }
                return(false);

            case 2:
                silver.stackCount = 4000;
                requirements.Add(silver);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount))
                {
                    return(true);
                }
                return(false);

            case 3:
                silver.stackCount = 5000;
                requirements.Add(silver);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount))
                {
                    return(true);
                }
                return(false);

            default:
                return(false);
            }
        }
Beispiel #9
0
        public static bool CanUpgradeComponents(Faction faction, List <Thing> requirements, int level)
        {
            requirements.Clear();
            Thing silver = ThingMaker.MakeThing(ThingDefOf.Silver);
            Thing steel  = ThingMaker.MakeThing(ThingDefOf.Steel);

            switch (level)
            {
            case 0:
                silver.stackCount = 2000;
                requirements.Add(silver);
                steel.stackCount = 1600;
                requirements.Add(steel);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == steel.def).Sum(t => t.stackCount) >= steel.stackCount)
                {
                    return(true);
                }
                return(false);

            case 1:
                silver.stackCount = 4500;
                requirements.Add(silver);
                steel.stackCount = 2500;
                requirements.Add(steel);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == steel.def).Sum(t => t.stackCount) >= steel.stackCount)
                {
                    return(true);
                }
                return(false);

            case 2:
                silver.stackCount = 7000;
                requirements.Add(silver);
                steel.stackCount = 4000;
                requirements.Add(steel);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == steel.def).Sum(t => t.stackCount) >= steel.stackCount)
                {
                    return(true);
                }
                return(false);

            default:
                return(false);
            }
        }
Beispiel #10
0
        public static bool CanUpgradeMedicine(Faction faction, List <Thing> requirements, int level)
        {
            requirements.Clear();
            Thing silver = ThingMaker.MakeThing(ThingDefOf.Silver);
            Thing cloth  = ThingMaker.MakeThing(ThingDefOf.Cloth, ThingDefOf.Cloth.IsStuff ? GenStuff.RandomStuffByCommonalityFor(ThingDefOf.Cloth, faction.def.techLevel) : null);

            switch (level)
            {
            case 0:
                silver.stackCount = 2500;
                requirements.Add(silver);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount))
                {
                    return(true);
                }
                return(false);

            case 1:
                silver.stackCount = 5000;
                cloth.stackCount  = 300;
                requirements.Add(silver);
                requirements.Add(cloth);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == cloth.def).Sum(t => t.stackCount) >= cloth.stackCount)
                {
                    return(true);
                }
                return(false);

            case 2:
                silver.stackCount = 7000;
                cloth.stackCount  = 600;
                requirements.Add(silver);
                requirements.Add(cloth);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == cloth.def).Sum(t => t.stackCount) >= cloth.stackCount)
                {
                    return(true);
                }
                return(false);

            default:
                return(false);
            }
        }
Beispiel #11
0
        public static bool CanUpgradeFood(Faction faction, List <Thing> requirements, int level)
        {
            requirements.Clear();
            Thing silver = ThingMaker.MakeThing(ThingDefOf.Silver);
            Thing hay    = ThingMaker.MakeThing(ThingDefOf.Hay);

            switch (level)
            {
            case 0:
                silver.stackCount = 250;
                requirements.Add(silver);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount))
                {
                    return(true);
                }
                return(false);

            case 1:
                silver.stackCount = 500;
                requirements.Add(silver);
                hay.stackCount = 300;
                requirements.Add(hay);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == hay.def).Sum(t => t.stackCount) >= hay.stackCount)
                {
                    return(true);
                }
                return(false);

            case 2:
                silver.stackCount = 1350;
                requirements.Add(silver);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount))
                {
                    return(true);
                }
                return(false);

            default:
                return(false);
            }
        }
Beispiel #12
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Building_SpaceshipMedical medicalSpaceship = this.TargetThingA as Building_SpaceshipMedical;

            yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch).FailOn(delegate()
            {
                return medicalSpaceship.DestroyedOrNull();
            }));

            yield return(Toils_General.Wait(5 * GenTicks.TicksPerRealSecond).WithProgressBarToilDelay(medicalSpaceshipIndex).FailOn(delegate()
            {
                return medicalSpaceship.DestroyedOrNull();
            }));

            Toil boardToil = new Toil()
            {
                initAction = () =>
                {
                    if (medicalSpaceship.orbitalHealingPawnsAboardCount >= Building_SpaceshipMedical.orbitalHealingPawnsAboardMaxCount)
                    {
                        Messages.Message(this.pawn.Name.ToStringShort + " cannot board MiningCo. medical spaceship.. There is no more any free slot.", this.pawn, MessageTypeDefOf.RejectInput);
                    }
                    else if (TradeUtility.ColonyHasEnoughSilver(this.pawn.Map, Util_Spaceship.orbitalHealingCost))
                    {
                        TradeUtility.LaunchSilver(this.Map, Util_Spaceship.orbitalHealingCost);
                        medicalSpaceship.Notify_PawnBoarding(pawn, false);
                    }
                    else
                    {
                        Messages.Message(this.pawn.Name.ToStringShort + " cannot board MiningCo. medical spaceship.. You have not enough silver to pay for " + this.pawn.gender.GetPossessive() + " orbital healing.", this.pawn, MessageTypeDefOf.RejectInput);
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            };

            yield return(boardToil);
        }
        public DiaOption GetFeePaymentDiaOption(Building_OrbitalRelay orbitalRelay)
        {
            int       feeCost             = Util_Misc.Partnership.globalGoodwillFeeInSilver + Util_Misc.Partnership.feeInSilver[this.Map];
            DiaOption feePaymentDiaOption = new DiaOption("Pay partnership fee (" + feeCost + ")");

            feePaymentDiaOption.resolveTree = true;
            feePaymentDiaOption.action      = delegate
            {
                TradeUtility.LaunchSilver(orbitalRelay.Map, feeCost);
                Util_Misc.Partnership.globalGoodwillFeeInSilver = 0;
                Util_Misc.Partnership.feeInSilver[this.Map]     = 0;
                Messages.Message("Partnership fee paid to MiningCo..", MessageTypeDefOf.PositiveEvent);
                if (Util_Faction.MiningCoFaction.GoodwillWith(Faction.OfPlayer) < 0)
                {
                    // Reset goodwill to 0.
                    Util_Faction.AffectFactionGoodwillWithOther(Util_Faction.MiningCoFaction, Faction.OfPlayer, -Util_Faction.MiningCoFaction.GoodwillWith(Faction.OfPlayer));
                }
            };
            if (TradeUtility.ColonyHasEnoughSilver(this.Map, feeCost) == false)
            {
                feePaymentDiaOption.Disable("not enough silver");
            }
            return(feePaymentDiaOption);
        }
Beispiel #14
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!TryGetRandomAvailableTargetMap(out map))
            {
                return(false);
            }

            SettlementBase settlementBase = RandomNearbyTradeableSettlement(map.Tile);

            if (settlementBase == null)
            {
                return(false);
            }

            int destination = Rand.Chance(directConnectionChance) ? map.Tile : AllyOfNearbySettlement(settlementBase)?.Tile ?? map.Tile;

            int maxPriority = settlementBase.Faction.def.techLevel >= TechLevel.Medieval ? 30 : 20;

            RoadDef roadToBuild = DefDatabase <RoadDef> .AllDefsListForReading.Where(x => x.priority <= maxPriority).RandomElement();

            WorldPath path = WorldPath.NotFound;
            //StringBuilder stringBuilder = new StringBuilder();

            int    cost2       = 12000;
            int    timeToBuild = 0;
            string letterTitle = "MFI_RoadWorks".Translate();
            List <WorldObject_RoadConstruction> list = new List <WorldObject_RoadConstruction>();

            using (path = Find.WorldPathFinder.FindPath(destination, settlementBase.Tile, null))
            {
                if (path != null && path != WorldPath.NotFound)
                {
                    float roadCount = path.NodesReversed.Count(x => !Find.WorldGrid[x].Roads.NullOrEmpty() &&
                                                               Find.WorldGrid[x].Roads.Any(roadLink => roadLink.road.priority >= roadToBuild.priority) ||
                                                               Find.WorldObjects.AnyWorldObjectOfDefAt(MFI_DefOf.MFI_RoadUnderConstruction, x));

                    if (roadCount / path.NodesReversed.Count >= maxRoadCoverage)
                    {
                        Log.Message($"MFI :: too many roads leading from {(Find.WorldObjects.AnyWorldObjectAt(destination) ? Find.WorldObjects.ObjectsAt(destination).FirstOrDefault()?.Label : destination.ToString())} to {settlementBase} for road project");
                        return(false);
                    }
                    //stringBuilder.Append($"Path found from {settlementBase.Label} to {map.info.parent.Label}. Length = {path.NodesReversed.Count} ");
                    //not 0 and - 1
                    for (int i = 1; i < path.NodesReversed.Count - 1; i++)
                    {
                        cost2 += Caravan_PathFollower.CostToMove(CaravanTicksPerMoveUtility.DefaultTicksPerMove, path.NodesReversed[i], path.NodesReversed[i + 1]);

                        timeToBuild += (int)(2 * GenDate.TicksPerHour
                                             * WorldPathGrid.CalculatedMovementDifficultyAt(path.NodesReversed[i], true)
                                             * Find.WorldGrid.GetRoadMovementDifficultyMultiplier(i, i + 1));

                        if (!Find.WorldGrid[path.NodesReversed[i]].Roads.NullOrEmpty() &&
                            Find.WorldGrid[path.NodesReversed[i]].Roads.Any(roadLink => roadLink.road.priority >= roadToBuild.priority))
                        {
                            timeToBuild = timeToBuild / 2;
                        }

                        WorldObject_RoadConstruction roadConstruction = (WorldObject_RoadConstruction)WorldObjectMaker.MakeWorldObject(MFI_DefOf.MFI_RoadUnderConstruction);
                        roadConstruction.Tile     = path.NodesReversed[i];
                        roadConstruction.nextTile = path.NodesReversed[i + 1];
                        roadConstruction.road     = roadToBuild;
                        roadConstruction.SetFaction(settlementBase.Faction);
                        roadConstruction.projectedTimeOfCompletion = Find.TickManager.TicksGame + timeToBuild;
                        list.Add(roadConstruction);
                    }
                    cost2 = cost2 / 10;
                    DiaNode   node   = new DiaNode("MFI_RoadWorksDialogue".Translate(settlementBase, path.NodesReversed.Count, cost2)); // {settlementBase} wants {cost2 / 10} to build a road of {path.NodesReversed.Count}");
                    DiaOption accept = new DiaOption("OK".Translate())
                    {
                        resolveTree = true,
                        action      = () =>
                        {
                            TradeUtility.LaunchSilver(TradeUtility.PlayerHomeMapWithMostLaunchableSilver(), cost2);
                            foreach (WorldObject_RoadConstruction worldObjectRoadConstruction in list)
                            {
                                Find.WorldObjects.Add(worldObjectRoadConstruction);
                            }
                            list.Clear();
                        }
                    };

                    if (!TradeUtility.ColonyHasEnoughSilver(TradeUtility.PlayerHomeMapWithMostLaunchableSilver(), cost2))
                    {
                        accept.Disable("NeedSilverLaunchable".Translate(cost2));
                    }
                    DiaOption reject = new DiaOption("RejectLetter".Translate())
                    {
                        resolveTree = true,
                        action      = () =>
                        {
                            for (int i = list.Count - 1; i >= 0; i--)
                            {
                                list[i] = null;
                            }
                            list.Clear();
                        }
                    };

                    node.options.Add(accept);
                    node.options.Add(reject);

                    //Log.Message(stringBuilder.ToString());
                    Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(node, settlementBase.Faction));
                    Find.Archive.Add(new ArchivedDialog(node.text, letterTitle, settlementBase.Faction));
                }
            }
            return(true);
        }
Beispiel #15
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!TryGetRandomAvailableTargetMap(out var map))
            {
                return(false);
            }

            var settlement = RandomNearbyTradeableSettlement(map.Tile);

            if (settlement?.Faction?.leader == null)
            {
                return(false);
            }

            //TODO: look into making the below dynamic based on requester's biome, faction, pirate outpost vicinity and other stuff.
            var thingCategoryDef = DetermineThingCategoryDef();

            var letterToSend  = DetermineLetterToSend(thingCategoryDef);
            var feeRequest    = Math.Max(Rand.Range(150, 300), (int)parms.points);
            var categorylabel = thingCategoryDef == ThingCategoryDefOf.PlantFoodRaw
                ? thingCategoryDef.label + " items"
                : thingCategoryDef.label;
            var diaNode = new DiaNode(letterToSend.Translate(
                                          settlement.Faction.leader.LabelShort,
                                          settlement.Faction.def.leaderTitle,
                                          settlement.Faction.Name,
                                          settlement.Label,
                                          categorylabel,
                                          feeRequest
                                          ).AdjustedFor(settlement.Faction.leader));

            var traveltime = CalcuteTravelTimeForTrader(settlement.Tile, map);
            var accept     = new DiaOption("RansomDemand_Accept".Translate())
            {
                action = () =>
                {
                    //spawn a trader with a stock gen that accepts our goods, has decent-ish money and nothing else.
                    //first attempt had a newly created trader for each, but the game can't save that. Had to define in XML.
                    parms.faction = settlement.Faction;
                    var traderKind = DefDatabase <TraderKindDef> .GetNamed("MFI_EmptyTrader_" + thingCategoryDef);

                    traderKind.stockGenerators.First(x => x.HandlesThingDef(ThingDefOf.Silver)).countRange.max +=
                        feeRequest;
                    traderKind.stockGenerators.First(x => x.HandlesThingDef(ThingDefOf.Silver)).countRange.min +=
                        feeRequest;

                    traderKind.label = thingCategoryDef.label + " " + "MFI_Trader".Translate();
                    parms.traderKind = traderKind;
                    parms.forced     = true;
                    parms.target     = map;

                    Find.Storyteller.incidentQueue.Add(IncidentDefOf.TraderCaravanArrival,
                                                       Find.TickManager.TicksGame + traveltime, parms);
                    TradeUtility.LaunchSilver(map, feeRequest);
                }
            };
            var acceptLink = new DiaNode("MFI_TraderSent".Translate(
                                             settlement.Faction.leader?.LabelShort,
                                             traveltime.ToStringTicksToPeriodVague(false)
                                             ).CapitalizeFirst());

            acceptLink.options.Add(DiaOption.DefaultOK);
            accept.link = acceptLink;

            if (!TradeUtility.ColonyHasEnoughSilver(map, feeRequest))
            {
                accept.Disable("NeedSilverLaunchable".Translate(feeRequest.ToString()));
            }

            var reject = new DiaOption("RansomDemand_Reject".Translate())
            {
                action      = () => { },
                resolveTree = true
            };

            diaNode.options = new List <DiaOption> {
                accept, reject
            };

            Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(diaNode, settlement.Faction,
                                                                    title: "MFI_ReverseTradeRequestTitle".Translate(map.info.parent.Label).CapitalizeFirst()));
            Find.Archive.Add(new ArchivedDialog(diaNode.text,
                                                "MFI_ReverseTradeRequestTitle".Translate(map.info.parent.Label).CapitalizeFirst(), settlement.Faction));

            return(true);
        }
Beispiel #16
0
 protected override bool CanFireNowSub(IncidentParms parms)
 {
     return(base.CanFireNowSub(parms) && TryFindFactions(out Faction faction) && TryFindSettlement(out Settlement settlement, faction) && Find.ResearchManager.AnyProjectIsAvailable && TryFindSutiableResearch(out ResearchProjectDef def, faction) && TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, (int)silverCurve.Evaluate((int)def.techLevel)));
 }
Beispiel #17
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!TryFindFactions(out Faction faction) || !TryFindSutiableResearch(out ResearchProjectDef def, faction) || !TryFindSettlement(out Settlement settlement, faction) || !TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, (int)silverCurve.Evaluate((int)def.techLevel)))
            {
                return(false);
            }

            Thing silver = ThingMaker.MakeThing(ThingDefOf.Silver);

            silver.stackCount = (int)silverCurve.Evaluate((int)def.techLevel);

            DiaNode nodeRoot = new DiaNode(TranslatorFormattedStringExtensions.Translate("ResearchGained", faction.leader, silver.stackCount, def.label));

            nodeRoot.options.Add(new DiaOption("ResearchGained_Purchase".Translate(silver.stackCount))
            {
                action = () =>
                {
                    Find.ResearchManager.FinishProject(def, false, PawnGenerator.GeneratePawn(new PawnGenerationRequest(PawnKindDefOf.Villager, faction, PawnGenerationContext.NonPlayer, -1, false, false, false, false, false)));
                    TradeUtility.LaunchSilver(Find.AnyPlayerHomeMap, silver.stackCount);
                },
                link = new DiaNode(TranslatorFormattedStringExtensions.Translate("ResearchGainedPurchase", def.label))
                {
                    options =
                    {
                        new DiaOption("OK".Translate())
                        {
                            resolveTree = true
                        }
                    }
                }
            });
            nodeRoot.options.Add(new DiaOption("ResearchGained_Decline".Translate())
            {
                resolveTree = true
            });
            string title = "ResearchGainedTitle".Translate();

            Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(nodeRoot, faction, true, true, title));
            Find.Archive.Add(new ArchivedDialog(nodeRoot.text, title, faction));

            Find.ResearchManager.FinishProject(def, false, PawnGenerator.GeneratePawn(new PawnGenerationRequest(PawnKindDefOf.Villager, faction, PawnGenerationContext.NonPlayer, -1, false, false, false, false, false)));
            return(false);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!TryGetRandomAvailableTargetMap(map: out Map map))
            {
                return(false);
            }
            SettlementBase settlement = RandomNearbyTradeableSettlement(originTile: map.Tile);

            if (settlement != null)
            {
                //TODO: look into making the below dynamic based on requester's biome, faction, pirate outpost vicinity and other stuff.
                ThingCategoryDef thingCategoryDef = DetermineThingCategoryDef();

                string letterToSend  = DetermineLetterToSend(thingCategoryDef: thingCategoryDef);
                int    feeRequest    = Math.Max(val1: Rand.Range(min: 150, max: 300), val2: (int)parms.points);
                string categorylabel = (thingCategoryDef == ThingCategoryDefOf.PlantFoodRaw) ? thingCategoryDef.label + " items" : thingCategoryDef.label;
                //ChoiceLetter_ReverseTradeRequest choiceLetterReverseTradeRequest = (ChoiceLetter_ReverseTradeRequest)LetterMaker.MakeLetter(label: this.def.letterLabel, text: letterToSend.Translate(
                //    settlement.Faction.leader.LabelShort,
                //    settlement.Faction.def.leaderTitle,
                //    settlement.Faction.Name,
                //    settlement.Label,
                //    categorylabel,
                //    feeRequest
                //).AdjustedFor(p: settlement.Faction.leader), def: this.def.letterDef);

                //choiceLetterReverseTradeRequest.title = "MFI_ReverseTradeRequestTitle".Translate(map.info.parent.Label).CapitalizeFirst();
                //choiceLetterReverseTradeRequest.thingCategoryDef = thingCategoryDef;
                //choiceLetterReverseTradeRequest.map = map;
                //parms.target = map;
                //choiceLetterReverseTradeRequest.incidentParms = parms;
                //choiceLetterReverseTradeRequest.faction = settlement.Faction;
                //choiceLetterReverseTradeRequest.fee = feeRequest;
                //choiceLetterReverseTradeRequest.StartTimeout(duration: TimeoutTicks);
                //choiceLetterReverseTradeRequest.tile = settlement.Tile;
                //Find.LetterStack.ReceiveLetter(let: choiceLetterReverseTradeRequest);
                //Find.World.GetComponent<WorldComponent_OutpostGrower>().Registerletter(choiceLetterReverseTradeRequest);

                DiaNode diaNode = new DiaNode(letterToSend.Translate(
                                                  settlement.Faction.leader.LabelShort,
                                                  settlement.Faction.def.leaderTitle,
                                                  settlement.Faction.Name,
                                                  settlement.Label,
                                                  categorylabel,
                                                  feeRequest
                                                  ).AdjustedFor(p: settlement.Faction.leader));

                int       traveltime = this.CalcuteTravelTimeForTrader(originTile: settlement.Tile, map);
                DiaOption accept     = new DiaOption(text: "RansomDemand_Accept".Translate())
                {
                    action = () =>
                    {
                        //spawn a trader with a stock gen that accepts our goods, has decent-ish money and nothing else.
                        //first attempt had a newly created trader for each, but the game can't save that. Had to define in XML.
                        parms.faction = settlement.Faction;;
                        TraderKindDef traderKind = DefDatabase <TraderKindDef> .GetNamed(defName : "MFI_EmptyTrader_" + thingCategoryDef);

                        traderKind.stockGenerators.First(predicate: x => x.HandlesThingDef(thingDef: ThingDefOf.Silver)).countRange.max += feeRequest;
                        traderKind.stockGenerators.First(predicate: x => x.HandlesThingDef(thingDef: ThingDefOf.Silver)).countRange.min += feeRequest;

                        traderKind.label = thingCategoryDef.label + " " + "MFI_Trader".Translate();
                        parms.traderKind = traderKind;
                        parms.forced     = true;

                        Find.Storyteller.incidentQueue.Add(def: IncidentDefOf.TraderCaravanArrival, fireTick: Find.TickManager.TicksGame + traveltime, parms: parms);
                        TradeUtility.LaunchSilver(map: map, fee: feeRequest);
                    },
                };
                DiaNode acceptLink = new DiaNode(text: "MFI_TraderSent".Translate(
                                                     settlement.Faction.leader?.LabelShort,
                                                     traveltime.ToStringTicksToPeriodVague(vagueMin: false)
                                                     ).CapitalizeFirst());
                acceptLink.options.Add(DiaOption.DefaultOK);
                accept.link = acceptLink;

                if (!TradeUtility.ColonyHasEnoughSilver(map: map, fee: feeRequest))
                {
                    accept.Disable(newDisabledReason: "NeedSilverLaunchable".Translate(feeRequest.ToString()));
                }

                DiaOption reject = new DiaOption(text: "RansomDemand_Reject".Translate())
                {
                    action = () =>
                    {
                    },
                    resolveTree = true
                };

                diaNode.options = new List <DiaOption> {
                    accept, reject
                };

                Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(diaNode, settlement.Faction, title: "MFI_ReverseTradeRequestTitle".Translate(map.info.parent.Label).CapitalizeFirst()));
                Find.Archive.Add(new ArchivedDialog(diaNode.text, "MFI_ReverseTradeRequestTitle".Translate(map.info.parent.Label).CapitalizeFirst(), settlement.Faction));

                return(true);
            }
            return(false);
        }
Beispiel #19
0
        public static bool CanUpgradeArmoryNWeaponry(Faction faction, List <Thing> requirements, int level)
        {
            requirements.Clear();
            Thing silver   = ThingMaker.MakeThing(ThingDefOf.Silver);
            Thing steel    = ThingMaker.MakeThing(ThingDefOf.Steel);
            Thing plasteel = ThingMaker.MakeThing(ThingDefOf.Plasteel);

            switch (level)
            {
            case 0:
                // 1000 silver, 150 steel
                silver.stackCount = 1000;
                steel.stackCount  = 150;
                requirements.Add(silver);
                requirements.Add(steel);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == steel.def).Sum(t => t.stackCount) >= steel.stackCount)
                {
                    return(true);
                }
                return(false);

            case 1:
                // 1000 silver, 150 steel
                silver.stackCount = 1750;
                steel.stackCount  = 300;
                requirements.Add(silver);
                requirements.Add(steel);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == steel.def).Sum(t => t.stackCount) >= steel.stackCount)
                {
                    return(true);
                }
                return(false);

            case 2:
                // 1000 silver, 150 steel
                silver.stackCount = 3000;
                steel.stackCount  = 500;
                requirements.Add(silver);
                requirements.Add(steel);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == steel.def).Sum(t => t.stackCount) >= steel.stackCount)
                {
                    return(true);
                }
                return(false);

            case 3:
                // 1000 silver, 150 steel
                silver.stackCount   = 3000;
                steel.stackCount    = 875;
                plasteel.stackCount = 300;
                requirements.Add(silver);
                requirements.Add(steel);
                requirements.Add(plasteel);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == steel.def).Sum(t => t.stackCount) >= steel.stackCount && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == plasteel.def).Sum(t => t.stackCount) >= plasteel.stackCount)
                {
                    return(true);
                }
                return(false);

            default:
                return(false);
            }
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!Find.FactionManager.AllFactionsVisible.Where(f => f.def.techLevel <= TechLevel.Neolithic &&
                                                              !f.HostileTo(Faction.OfPlayer))
                .TryRandomElement(out var faction))
            {
                return(false);
            }

            if (faction == null)
            {
                return(false);
            }

            if (!TryGetRandomAvailableTargetMap(out var map))
            {
                return(false);
            }

            if (map == null)
            {
                return(false);
            }

            if (!TryFindTile(out var tile))
            {
                return(false);
            }

            var fee = Rand.RangeInclusive(400, 1000);

            var diaNode = new DiaNode("MFI_MysticalShamanLetter".Translate(faction.Name, fee.ToString()));
            var accept  = new DiaOption("RansomDemand_Accept".Translate())
            {
                action = () =>
                {
                    var mysticalShaman =
                        (MysticalShaman)WorldObjectMaker.MakeWorldObject(MFI_DefOf.MFI_MysticalShaman);
                    mysticalShaman.Tile = tile;
                    mysticalShaman.SetFaction(faction);
                    var randomInRange = TimeoutDaysRange.RandomInRange;
                    mysticalShaman.GetComponent <TimeoutComp>().StartTimeout(randomInRange * GenDate.TicksPerDay);
                    Find.WorldObjects.Add(mysticalShaman);
                    TradeUtility.LaunchSilver(map, fee);
                },
                resolveTree = true
            };

            if (!TradeUtility.ColonyHasEnoughSilver(map, fee))
            {
                accept.Disable("NeedSilverLaunchable".Translate(fee.ToString()));
            }

            var reject = new DiaOption("RansomDemand_Reject".Translate())
            {
                action      = () => { },
                resolveTree = true
            };

            diaNode.options = new List <DiaOption> {
                accept, reject
            };

            Find.WindowStack.Add(new Dialog_NodeTree(diaNode, title: def.letterLabel));
            Find.Archive.Add(new ArchivedDialog(diaNode.text, def.letterLabel));

            return(true);
        }
Beispiel #21
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!Find.FactionManager.AllFactionsVisible.Where(predicate: f => f.def.techLevel <= TechLevel.Neolithic &&
                                                              !f.HostileTo(other: Faction.OfPlayer)).TryRandomElement(result: out Faction faction))
            {
                return(false);
            }

            if (!TryGetRandomAvailableTargetMap(map: out Map map))
            {
                return(false);
            }

            if (faction == null)
            {
                return(false);
            }

            if (map == null)
            {
                return(false);
            }

            if (!TryFindTile(tile: out int tile))
            {
                return(false);
            }

            int fee = Rand.RangeInclusive(min: 400, max: 1000);

            //ChoiceLetter_MysticalShaman choiceLetterMysticalShaman = (ChoiceLetter_MysticalShaman)LetterMaker.MakeLetter(label: this.def.letterLabel, text: "MFI_MysticalShamanLetter".Translate(faction.Name, fee.ToString()), def: this.def.letterDef);
            //choiceLetterMysticalShaman.title = "MFI_MysticalShamanTitle".Translate().CapitalizeFirst();
            //choiceLetterMysticalShaman.faction = faction;
            //choiceLetterMysticalShaman.tile = tile;
            //choiceLetterMysticalShaman.map = map;
            //choiceLetterMysticalShaman.fee = fee;
            //choiceLetterMysticalShaman.StartTimeout(duration: TimeoutTicks);
            //Find.LetterStack.ReceiveLetter(let: choiceLetterMysticalShaman);
            //Find.World.GetComponent<WorldComponent_OutpostGrower>().Registerletter(choiceLetterMysticalShaman);

            DiaNode   diaNode = new DiaNode("MFI_MysticalShamanLetter".Translate(faction.Name, fee.ToString()));
            DiaOption accept  = new DiaOption(text: "RansomDemand_Accept".Translate())
            {
                action = () =>
                {
                    MysticalShaman mysticalShaman = (MysticalShaman)WorldObjectMaker.MakeWorldObject(def: MFI_DefOf.MFI_MysticalShaman);
                    mysticalShaman.Tile = tile;
                    mysticalShaman.SetFaction(newFaction: faction);
                    int randomInRange = TimeoutDaysRange.RandomInRange;
                    mysticalShaman.GetComponent <TimeoutComp>().StartTimeout(ticks: randomInRange * GenDate.TicksPerDay);
                    Find.WorldObjects.Add(o: mysticalShaman);
                    TradeUtility.LaunchSilver(map: map, fee: fee);
                },
                resolveTree = true
            };

            if (!TradeUtility.ColonyHasEnoughSilver(map: map, fee: fee))
            {
                accept.Disable(newDisabledReason: "NeedSilverLaunchable".Translate(fee.ToString()));
            }

            DiaOption reject = new DiaOption(text: "RansomDemand_Reject".Translate())
            {
                action = () =>
                {
                },
                resolveTree = true
            };

            diaNode.options = new List <DiaOption> {
                accept, reject
            };

            Find.WindowStack.Add(new Dialog_NodeTree(diaNode, title: this.def.letterLabel));
            Find.Archive.Add(new ArchivedDialog(diaNode.text, this.def.letterLabel));

            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!TryFindAdjcentSettlemet(out Settlement bomber))
            {
                return(false);
            }
            float        silver = silverCurve.Evaluate(1 - (1 / Find.AnyPlayerHomeMap.wealthWatcher.WealthTotal));
            List <Thing> demand = new List <Thing>();

            GenerateDemands(demand, silver);

            silver = GenThing.GetMarketValue(demand);

            int    countdown = countDown.RandomInRange * Global.DayInTicks;
            string text      = TranslatorFormattedStringExtensions.Translate("BombardmentThreat", bomber.Faction.leader, bomber.Faction.def.leaderTitle, bomber.Name, silver.ToStringMoney(null), GenLabel.ThingsLabel(demand, string.Empty), countdown.ToStringTicksToPeriod());

            GenThing.TryAppendSingleRewardInfo(ref text, demand);

            DiaNode nodeRoot = new DiaNode(text);

            nodeRoot.options.Add(new DiaOption("BombardmentThreat_AcceptThings".Translate())
            {
                action = () =>
                {
                    foreach (Thing t in demand)
                    {
                        TradeUtility.LaunchThingsOfType(t.def, t.stackCount, Find.AnyPlayerHomeMap, null);
                    }
                },
                link = new DiaNode(TranslatorFormattedStringExtensions.Translate("BombardmentThreatAcceptThings", bomber.Faction.leader))
                {
                    options =
                    {
                        new DiaOption("OK".Translate())
                        {
                            resolveTree = true
                        }
                    }
                }
            });
            if (TradeUtility.ColonyHasEnoughSilver(TradeUtility.PlayerHomeMapWithMostLaunchableSilver(), (int)silver * 2))
            {
                nodeRoot.options.Add(new DiaOption("BombardmentThreat_AcceptSilver".Translate((silver * 2).ToStringMoney()))
                {
                    action = () =>
                    {
                        TradeUtility.LaunchSilver(Find.AnyPlayerHomeMap, (int)silver * 2);
                    },
                    link = new DiaNode(TranslatorFormattedStringExtensions.Translate("BombardmentThreatAcceptThings", bomber.Faction.leader))
                    {
                        options =
                        {
                            new DiaOption("OK".Translate())
                            {
                                resolveTree = true
                            }
                        }
                    }
                });
            }
            else
            {
                nodeRoot.options.Add(new DiaOption("BombardmentThreat_AcceptSilver".Translate(((float)silver * 2).ToStringMoney()))
                {
                    disabled       = true,
                    disabledReason = "BombardmentThreat_AcceptSilverDisabled".Translate()
                });
            }
            nodeRoot.options.Add(new DiaOption("BombardmentThreat_Refusal".Translate())
            {
                action = () =>
                {
                    Find.AnyPlayerHomeMap.GetComponent <FE_MapComponent_Bombardment>().StartComp(def.durationDays.RandomInRange * Global.DayInTicks, bomber, countdown);
                },
                link = new DiaNode("BombardmentThreatRefusal".Translate(bomber.Faction.leader))
                {
                    options =
                    {
                        new DiaOption("OK".Translate())
                        {
                            resolveTree = true
                        }
                    }
                }
            });
            string title = "LetterLabelBombardmentTitle".Translate();

            Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(nodeRoot, bomber.Faction, true, true, title));
            Find.Archive.Add(new ArchivedDialog(nodeRoot.text, title, bomber.Faction));
            return(true);
        }
Beispiel #23
0
        public static bool CanUpgradeProstheticslabs(Faction faction, List <Thing> requirements, int level)
        {
            requirements.Clear();
            Thing silver      = ThingMaker.MakeThing(ThingDefOf.Silver);
            Thing steel       = ThingMaker.MakeThing(ThingDefOf.Steel);
            Thing comp        = ThingMaker.MakeThing(ThingDefOf.ComponentIndustrial);
            Thing compAdvence = ThingMaker.MakeThing(ThingDefOf.ComponentSpacer);

            switch (level)
            {
            case 0:
                silver.stackCount = 2000;
                requirements.Add(silver);
                steel.stackCount = 800;
                requirements.Add(steel);
                comp.stackCount = 30;
                requirements.Add(comp);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == steel.def).Sum(t => t.stackCount) >= steel.stackCount && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == comp.def).Sum(t => t.stackCount) >= comp.stackCount)
                {
                    return(true);
                }
                return(false);

            case 1:
                silver.stackCount = 4500;
                requirements.Add(silver);
                steel.stackCount = 2000;
                requirements.Add(steel);
                compAdvence.stackCount = 15;
                requirements.Add(comp);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == steel.def).Sum(t => t.stackCount) >= steel.stackCount && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == compAdvence.def).Sum(t => t.stackCount) >= compAdvence.stackCount)
                {
                    return(true);
                }
                return(false);

            case 2:
                silver.stackCount = 7000;
                requirements.Add(silver);
                steel.stackCount = 2000;
                requirements.Add(steel);
                compAdvence.stackCount = 30;
                requirements.Add(comp);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == steel.def).Sum(t => t.stackCount) >= steel.stackCount && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == compAdvence.def).Sum(t => t.stackCount) >= compAdvence.stackCount)
                {
                    return(true);
                }
                return(false);

            case 3:
                silver.stackCount = 10000;
                requirements.Add(silver);
                steel.stackCount = 2000;
                requirements.Add(steel);
                compAdvence.stackCount = 50;
                requirements.Add(comp);
                if (TradeUtility.ColonyHasEnoughSilver(Find.AnyPlayerHomeMap, silver.stackCount) && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == steel.def).Sum(t => t.stackCount) >= steel.stackCount && TradeUtility.AllLaunchableThingsForTrade(Find.AnyPlayerHomeMap).Where(t => t.def == compAdvence.def).Sum(t => t.stackCount) >= compAdvence.stackCount)
                {
                    return(true);
                }
                return(false);

            default:
                return(false);
            }
        }