示例#1
0
        protected bool Execute(Caravan caravan)
        {
            Map map = GetOrGenerateMapUtility.GetOrGenerateMap(caravan.Tile, DefDatabase <WorldObjectDef> .GetNamed("WanderingCaravanEncounter"));

            if (!WanderingCaravansUtility.AllWanderingCaravansSpawnableInMap(map).TryRandomElement(out PawnKindDef wanderingCaravanDef))
            {
                return(false);
            }
            MultipleCaravansCellFinder.FindStartingCellsFor2Groups(map, out IntVec3 caravanSpot, out IntVec3 wanderingCaravansSpot);
            IEnumerable <Pawn> wanderingCaravans = this.GenerateWanderingCaravans(wanderingCaravanDef);
            Pawn    infoPawn = wanderingCaravans.First();
            DiaNode diaNode  = new DiaNode($"A wandering {infoPawn.LabelCap} has been spotted in the distance by {caravan.LabelCap}, with more wandering caravans possible following it.\n\nYou can "
                                           + $"ignore them, or you can tame or kill them to obtain their potentially valuable inventory.")
            {
                options =
                {
                    new DiaOption("Go and claim their inventory")
                    {
                        action = delegate
                        {
                            string plural = wanderingCaravans.Count() > 1 ? "ies" : "y";
                            CaravanEnterMapUtility.Enter(caravan, map, pawn => CellFinder.RandomSpawnCellForPawnNear(caravanSpot, map));
                            Messages.Message($"You have {TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(60000)} to claim the wandering {infoPawn.LabelCap}s inventor{plural} before the "
                                             + $"caravan is reformed.", infoPawn, MessageTypeDefOf.PositiveEvent);
                            ((WorldObject)map.ParentHolder).GetComponent <TimedForcedExit>().StartForceExitAndRemoveMapCountdown();
                        },
                        resolveTree = true
                    }, new DiaOption("Ignore them and continue")
                    {
                        resolveTree = true
                    }
                }
            };

            Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, false, $"Wandering {infoPawn.LabelCap} spotted"));
            this.SpawnPawns(wanderingCaravans, map, wanderingCaravansSpot);
            return(true);
        }
示例#2
0
        public static void AlliedBooom(int destinationTile, IntVec3 targetCell)
        {
            if (!Find.WorldObjects.AnyMapParentAt(destinationTile))
            {
                Messages.Message("SWeaponDestoryBase".Translate(), MessageTypeDefOf.NeutralEvent, true);

                SoundDef.Named("ra2_StormAppear").PlayOneShotOnCamera(null);


                WorldObject worldObject = Find.WorldObjects.WorldObjectAt <WorldObject>(destinationTile);
                if (worldObject != null && worldObject.Faction != null && !worldObject.Faction.IsPlayer)
                {
                    worldObject.Faction.TryAffectGoodwillWith(Faction.OfPlayer, -999, true, true, null, null);
                }
                PeaceTalks peaceTalks = Find.WorldObjects.WorldObjectAt <PeaceTalks>(destinationTile);
                if (peaceTalks != null)
                {
                    try
                    {
                        peaceTalks.GetType().GetMethod("Outcome_Disaster", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(peaceTalks, null);
                    }
                    catch (Exception)
                    {
                    }
                    Find.WorldObjects.Remove(peaceTalks);
                }
                return;
            }



            MapParent mapParent = Find.WorldObjects.MapParentAt(destinationTile);

            if (mapParent.Faction != null && !mapParent.Faction.IsPlayer)
            {
                mapParent.Faction.TryAffectGoodwillWith(Faction.OfPlayer, -999, true, true, null, null);
            }

            if (mapParent.HasMap)
            {
                AlliedStormCondition asc = (AlliedStormCondition)ThingMaker.MakeThing(ThingDef.Named("AlliedStorm"), null);
                asc.centerLocation = targetCell.ToIntVec2;

                asc.SingleMap = mapParent.Map;
                SoundInfo info = SoundInfo.InMap(new TargetInfo(asc.centerLocation.ToIntVec3, asc.SingleMap, false), MaintenanceType.None);
                SoundDef.Named("ra2_StormAppear").PlayOneShotOnCamera(mapParent.Map);//.PlayOneShot(info);


                // SovietNuclearFallen bomb = (SovietNuclearFallen)ThingMaker.MakeThing(ThingDef.Named("SovietNuclearFallen"));
                // bomb.targetCell = targetCell;
                // bomb.ExactPosition = new Vector3(targetCell.x, 10, mapParent.Map.Size.z - 10);
                GenSpawn.Spawn(asc, asc.centerLocation.ToIntVec3, mapParent.Map);
                return;
            }

            Messages.Message("SWeaponDestoryBase".Translate(), mapParent, MessageTypeDefOf.NegativeEvent, true);
            SoundDef.Named("ra2_StormAppear").PlayOneShotOnCamera(null);
            SettlementBase settlementBase;

            if ((settlementBase = (mapParent as SettlementBase)) != null)
            {
                if (settlementBase.Faction == Faction.OfPlayer)
                {
                    return;
                }
                foreach (Faction faction in Find.FactionManager.AllFactionsListForReading)
                {
                    if (faction != Faction.OfPlayer)
                    {
                        faction.TryAffectGoodwillWith(Faction.OfPlayer, -10, true, true, null, null);
                    }
                }
                try
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.Append("LetterFactionBaseDefeated".Translate(new object[]
                    {
                        settlementBase.Label,
                        TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(60000)
                    }));

                    Find.LetterStack.ReceiveLetter("LetterLabelFactionBaseDefeated".Translate(), stringBuilder.ToString(), LetterDefOf.PositiveEvent, new GlobalTargetInfo(settlementBase.Tile), null, null);
                    DestroyedSettlement destroyedSettlement = (DestroyedSettlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.DestroyedSettlement);
                    destroyedSettlement.Tile = settlementBase.Tile;
                    Find.WorldObjects.Add(destroyedSettlement);
                }
                catch (Exception)
                {
                    Log.Warning("Failed to end settlement", false);
                }
            }
            Find.WorldObjects.Remove(mapParent);
        }
示例#3
0
        private bool HostileDefeated()
        {
            if (parent.GetComponent <TimedForcedExit>().ForceExitAndRemoveMapCountdownActive)
            {
                return(false);
            }
            MapParent map = (MapParent)parent;

            if (map.HasMap && map.Faction == ally && survivors && !GenHostility.AnyHostileActiveThreatTo(map.Map, map.Faction))
            {
                parent.Faction.TryAffectGoodwillWith(Faction.OfPlayer, 12);
                DropPodUtility.DropThingsNear(DropCellFinder.TradeDropSpot(Find.AnyPlayerHomeMap), Find.AnyPlayerHomeMap, rewards, 110, false, true, true);
                string text = TranslatorFormattedStringExtensions.Translate("SettlementDefenderWon", parent, TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(Global.DayInTicks), parent.Faction.leader) + GenLabel.ThingsLabel(rewards, string.Empty);
                GenThing.TryAppendSingleRewardInfo(ref text, rewards);
                Find.LetterStack.ReceiveLetter("LetterLabelSettlementDefenderWon".Translate(), text, LetterDefOf.PositiveEvent, parent, null, null);
                map.Map.Parent.GetComponent <TimedForcedExit>().StartForceExitAndRemoveMapCountdown(Global.DayInTicks);
                return(true);
            }
            return(false);
        }
示例#4
0
        private bool FriendliesDead()
        {
            MapParent map = (MapParent)parent;

            if (map.Map.mapPawns.FreeHumanlikesSpawnedOfFaction(map.Map.ParentFaction).Count(p => !p.Downed && !p.Dead && p.RaceProps.Humanlike) == 0)
            {
                DestroyedSettlement destroyedSettlement = (DestroyedSettlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.DestroyedSettlement);
                destroyedSettlement.Tile = parent.Tile;
                Find.WorldObjects.Add(destroyedSettlement);
                map.Map.info.parent = destroyedSettlement;
                Find.WorldObjects.Remove(parent);
                destroyedSettlement.GetComponent <TimedForcedExit>().StartForceExitAndRemoveMapCountdown();
                survivors = false;
                parent.GetComponent <TimedForcedExit>().StartForceExitAndRemoveMapCountdown(Global.DayInTicks);
                Find.LetterStack.ReceiveLetter("LetterLabelSettlementDefenderLost".Translate(), TranslatorFormattedStringExtensions.Translate("SettlementDefenderLost", parent, TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(Global.DayInTicks), parent.Faction.leader)
                                               , LetterDefOf.NegativeEvent, new LookTargets(parent.Tile), null, null);
                return(true);
            }
            return(false);
        }
        // Token: 0x04001627 RID: 5671

        public void Booom()
        {
            if (!Find.WorldObjects.AnyMapParentAt(destinationTile))
            {
                Messages.Message("SWeaponDestoryBase".Translate(), MessageTypeDefOf.NeutralEvent);
                // DubDef.hugeExplosionDistantDef.PlayOneShotOnCamera(null);
                var worldObject = Find.WorldObjects.WorldObjectAt <WorldObject>(destinationTile);
                if (worldObject?.Faction != null && !worldObject.Faction.IsPlayer)
                {
                    worldObject.Faction.TryAffectGoodwillWith(Faction.OfPlayer, -999);
                }

                var peaceTalks = Find.WorldObjects.WorldObjectAt <PeaceTalks>(destinationTile);
                if (peaceTalks == null)
                {
                    return;
                }

                try
                {
                    peaceTalks.GetType()
                    .GetMethod("Outcome_Disaster", BindingFlags.Instance | BindingFlags.NonPublic)
                    ?.Invoke(peaceTalks, null);
                }
                catch
                {
                    // ignored
                }

                Find.WorldObjects.Remove(peaceTalks);

                return;
            }


            mapParent = Find.WorldObjects.MapParentAt(destinationTile);
            if (mapParent.Faction != null && !mapParent.Faction.IsPlayer)
            {
                mapParent.Faction.TryAffectGoodwillWith(Faction.OfPlayer, -999);
            }

            /*
             * if (this.mapParent is DestroyedSettlement)
             * {
             *  Messages.Message("critBombDet".Translate(), MessageTypeDefOf.NeutralEvent, true);
             *  // DubDef.hugeExplosionDistantDef.PlayOneShotOnCamera(null);
             *  return;
             * }
             */
            if (mapParent.HasMap)
            {
                //IntVec3 destinationCell = CellFinderLoose.TryFindCentralCell(this.mapParent.Map, 25, 1000, null);

                // SkyfallerMaker.SpawnSkyfaller(ThingDef.Named("NuclearIncoming"), ThingDef.Named("SovietNuclearStrike"), destinationCell, this.mapParent.Map);
                var bomb = (SovietNuclearFallen)ThingMaker.MakeThing(ThingDef.Named("SovietNuclearFallen"));
                bomb.targetCell    = targetCell;
                bomb.ExactPosition = new Vector3(targetCell.x, 10, mapParent.Map.Size.z - 10);
                GenSpawn.Spawn(bomb, bomb.ExactPosition.ToIntVec3(), mapParent.Map);
                return;
            }

            Messages.Message("SWeaponDestoryBase".Translate(), mapParent, MessageTypeDefOf.NegativeEvent);
            SoundDef.Named("ra2_NuclearExplode").PlayOneShotOnCamera();
            Settlement settlementBase;

            if ((settlementBase = mapParent as Settlement) != null)
            {
                if (settlementBase.Faction == Faction.OfPlayer)
                {
                    return;
                }

                foreach (var faction in Find.FactionManager.AllFactionsListForReading)
                {
                    if (faction != Faction.OfPlayer)
                    {
                        faction.TryAffectGoodwillWith(Faction.OfPlayer, -10);
                    }
                }

                try
                {
                    var stringBuilder = new StringBuilder();
                    stringBuilder.Append("LetterFactionBaseDefeated".Translate(settlementBase.Label,
                                                                               TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(60000)));

                    Find.LetterStack.ReceiveLetter("LetterLabelFactionBaseDefeated".Translate(),
                                                   stringBuilder.ToString(), LetterDefOf.PositiveEvent, new GlobalTargetInfo(settlementBase.Tile));
                    var destroyedSettlement =
                        (DestroyedSettlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.DestroyedSettlement);
                    destroyedSettlement.Tile = settlementBase.Tile;
                    Find.WorldObjects.Add(destroyedSettlement);
                }
                catch
                {
                    Log.Warning("Failed to end settlement");
                }
            }

            Find.WorldObjects.Remove(mapParent);
        }
示例#6
0
 private void CheckStartForceExitAndRemoveMapCountdown()
 {
     if (!startedCountdown && SetUpCampSettings.mapTimerDays != SetUpCampSettings.mapTimerDaysmin && SetUpCampSettings.mapTimerDays != SetUpCampSettings.mapTimerDaysmax)
     {
         if (!GenHostility.AnyHostileActiveThreatToPlayer(Map))
         {
             startedCountdown = true;
             int    num  = Mathf.RoundToInt(forceExitAndRemoveMapCountdownDurationDays * 60000f);
             string text = "MessageSiteCountdownBecauseNoEnemiesInitially".Translate(TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(num));
             Messages.Message(text, this, MessageTypeDefOf.PositiveEvent, true);
             GetComponent <TimedForcedExit>().StartForceExitAndRemoveMapCountdown(num);
         }
     }
 }
示例#7
0
 private void CheckStartForceExitAndRemoveMapCountdown()
 {
     if (SetUpCampSettings.mapTimerDays != SetUpCampSettings.mapTimerDaysmin)
     {
         if (startedCountdown)
         {
             if (GenHostility.AnyHostileActiveThreatToPlayer(Map, false))
             {
                 startedCountdown = false;
                 GetComponent <TimedForcedExit>().ResetForceExitAndRemoveMapCountdown();
             }
         }
         else
         {
             if (!GenHostility.AnyHostileActiveThreatToPlayer(Map))
             {
                 startedCountdown = true;
                 int ticksTillLeaving = Mathf.RoundToInt(SetUpCampSettings.mapTimerDays * 60000f);
                 Messages.Message("MessageSiteCountdownBecauseNoEnemiesInitially".Translate(TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(ticksTillLeaving)), this, MessageTypeDefOf.PositiveEvent, true);
                 GetComponent <TimedForcedExit>().StartForceExitAndRemoveMapCountdown(ticksTillLeaving);
             }
         }
     }
 }
        protected bool Execute(Caravan caravan)
        {
            Map map = GetOrGenerateMapUtility.GetOrGenerateMap(caravan.Tile, DefDatabase <WorldObjectDef> .GetNamed("WanderingCaravanEncounter"));

            if (!WanderingCaravansUtility.AllWanderingCaravansSpawnableInMap(map).TryRandomElement(out PawnKindDef wanderingCaravanDef))
            {
                return(false);
            }
            MultipleCaravansCellFinder.FindStartingCellsFor2Groups(map, out IntVec3 caravanSpot, out IntVec3 wanderingCaravansSpot);
            IEnumerable <Pawn> wanderingCaravans = this.GenerateWanderingCaravans(wanderingCaravanDef);
            Pawn    infoPawn = wanderingCaravans.First();
            DiaNode diaNode  = new DiaNode($"WanderingCaravan.WanderingCaravan_Spotted".Translate(infoPawn.LabelCap, caravan.LabelCap))
            {
                options =
                {
                    new DiaOption("WanderingCaravan.WanderingCaravan_Accept")
                    {
                        action = delegate
                        {
                            string plural = wanderingCaravans.Count() > 1 ? "ies" : "y";
                            CaravanEnterMapUtility.Enter(caravan, map, pawn => CellFinder.RandomSpawnCellForPawnNear(caravanSpot, map));
                            Messages.Message($"WanderingCaravan.WanderingCaravan_Accepted".Translate(TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(60000), infoPawn.LabelCap, plural), infoPawn, MessageTypeDefOf.PositiveEvent);
                            ((WorldObject)map.ParentHolder).GetComponent <TimedForcedExit>().StartForceExitAndRemoveMapCountdown();
                        },
                        resolveTree = true
                    }, new DiaOption("WanderingCaravan.WanderingCaravan_Reject".Translate())
                    {
                        resolveTree = true
                    }
                }
            };

            Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, false, $"WanderingCaravan.WanderingCaravan_Title".Translate(infoPawn.LabelCap)));
            this.SpawnPawns(wanderingCaravans, map, wanderingCaravansSpot);
            return(true);
        }
        private bool HostileDefeated()
        {
            MapParent map = (MapParent)parent;

            if (map.HasMap && !GenHostility.AnyHostileActiveThreatTo(map.Map, Faction.OfPlayer))
            {
                active = false;
                List <Pawn> prisoner  = map.Map.mapPawns.AllPawns.Where(x => !x.Dead && !x.Downed && (x.IsPrisoner || x.kindDef == PawnKindDefOf.Slave)).ToList();
                int         pawnSaved = prisoner.Count(x => !x.Dead);
                if (pawnSaved == 0)
                {
                    Find.LetterStack.ReceiveLetter("LetterLabelSettlementRescueFail".Translate(), TranslatorFormattedStringExtensions.Translate("SettlementRescueFail", parent.Faction, TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(Global.DayInTicks),
                                                                                                                                                ally.leader, ally.def.pawnsPlural), LetterDefOf.NegativeEvent, parent, null, null);
                    return(true);
                }
                else
                {
                    prisoner[0].Faction.TryAffectGoodwillWith(Faction.OfPlayer, 10 * pawnSaved);
                }

                foreach (Pawn p in prisoner)
                {
                    if (Rand.Chance(UnWillingChance))
                    {
                        pawnStaying++;
                        p.mindState.WillJoinColonyIfRescued = false;
                    }
                }
                if (pawnStaying >= 3)
                {
                    resurrectSet = true;
                }
                DropPodUtility.DropThingsNear(DropCellFinder.TradeDropSpot(Find.AnyPlayerHomeMap), Find.AnyPlayerHomeMap, new Gift_RewardGeneratorBasedTMagic().Generate(500, new List <Thing>()), 110, false, true, true);
                string text = TranslatorFormattedStringExtensions.Translate("SettlementRescueWin", parent.Faction, TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(Global.DayInTicks), ally.leader, ally.def.leaderTitle) + GenLabel.ThingsLabel(new Gift_RewardGeneratorBasedTMagic().Generate(500, new List <Thing>()), string.Empty);
                Find.LetterStack.ReceiveLetter("LetterLabelSettlementRescue".Translate(), text, LetterDefOf.PositiveEvent, parent, null, null);
                return(true);
            }
            return(false);
        }