private void Outcome_Disaster(Caravan caravan)
 {
     LongEventHandler.QueueLongEvent(delegate()
     {
         FactionRelationKind playerRelationKind = this.Faction.PlayerRelationKind;
         int randomInRange = DiplomacyTuning.Goodwill_PeaceTalksDisasterRange.RandomInRange;
         this.Faction.TryAffectGoodwillWith(Faction.OfPlayer, randomInRange, false, false, null, null);
         this.Faction.TrySetRelationKind(Faction.OfPlayer, FactionRelationKind.Hostile, false, null, null);
         IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, caravan);
         incidentParms.faction       = this.Faction;
         PawnGroupMakerParms defaultPawnGroupMakerParms  = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, incidentParms, true);
         defaultPawnGroupMakerParms.generateFightersOnly = true;
         List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms, true).ToList <Pawn>();
         Map map          = CaravanIncidentUtility.SetupCaravanAttackMap(caravan, list, false);
         if (list.Any <Pawn>())
         {
             LordMaker.MakeNewLord(incidentParms.faction, new LordJob_AssaultColony(this.Faction, true, true, false, false, true), map, list);
         }
         Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
         GlobalTargetInfo target = (!list.Any <Pawn>()) ? GlobalTargetInfo.Invalid : new GlobalTargetInfo(list[0].Position, map, false);
         string label            = "LetterLabelPeaceTalks_Disaster".Translate();
         string letterText       = this.GetLetterText("LetterPeaceTalks_Disaster".Translate(new object[]
         {
             this.Faction.def.pawnsPlural.CapitalizeFirst(),
             this.Faction.Name,
             Mathf.RoundToInt((float)randomInRange)
         }), caravan, playerRelationKind);
         PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref label, ref letterText, "LetterRelatedPawnsGroupGeneric".Translate(new object[]
         {
             Faction.OfPlayer.def.pawnsPlural
         }), true, true);
         Find.LetterStack.ReceiveLetter(label, letterText, LetterDefOf.ThreatBig, target, this.Faction, null);
     }, "GeneratingMapForNewEncounter", false, null);
 }
 private void Outcome_Disaster(Caravan caravan)
 {
     LongEventHandler.QueueLongEvent(delegate
     {
         FactionRelationKind playerRelationKind = base.Faction.PlayerRelationKind;
         int randomInRange = DiplomacyTuning.Goodwill_PeaceTalksDisasterRange.RandomInRange;
         base.Faction.TryAffectGoodwillWith(Faction.OfPlayer, randomInRange, canSendMessage: false, canSendHostilityLetter: false);
         base.Faction.TrySetRelationKind(Faction.OfPlayer, FactionRelationKind.Hostile, canSendLetter: false);
         IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, caravan);
         incidentParms.faction       = base.Faction;
         PawnGroupMakerParms defaultPawnGroupMakerParms  = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, incidentParms, ensureCanGenerateAtLeastOnePawn: true);
         defaultPawnGroupMakerParms.generateFightersOnly = true;
         List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms).ToList();
         Map map          = CaravanIncidentUtility.SetupCaravanAttackMap(caravan, list, sendLetterIfRelatedPawns: false);
         if (list.Any())
         {
             LordMaker.MakeNewLord(incidentParms.faction, new LordJob_AssaultColony(base.Faction), map, list);
         }
         Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
         GlobalTargetInfo target  = (list.Any() ? new GlobalTargetInfo(list[0].Position, map) : GlobalTargetInfo.Invalid);
         TaggedString letterLabel = "LetterLabelPeaceTalks_Disaster".Translate();
         TaggedString letterText  = GetLetterText("LetterPeaceTalks_Disaster".Translate(base.Faction.def.pawnsPlural.CapitalizeFirst(), base.Faction.NameColored, Mathf.RoundToInt(randomInRange)), caravan, playerRelationKind);
         PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref letterLabel, ref letterText, "LetterRelatedPawnsGroupGeneric".Translate(Faction.OfPlayer.def.pawnsPlural), informEvenIfSeenBefore: true);
         Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.ThreatBig, target, base.Faction);
     }, "GeneratingMapForNewEncounter", doAsynchronously: false, null);
 }
Exemple #3
0
 private void Outcome_Disaster(Caravan caravan)
 {
     LongEventHandler.QueueLongEvent(delegate
     {
         float randomInRange = PeaceTalks.DisasterFactionRelationOffset.RandomInRange;
         base.Faction.AffectGoodwillWith(Faction.OfPlayer, randomInRange);
         if (!base.Faction.HostileTo(Faction.OfPlayer))
         {
             base.Faction.SetHostileTo(Faction.OfPlayer, true);
         }
         IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.ThreatBig, caravan);
         incidentParms.faction       = base.Faction;
         PawnGroupMakerParms defaultPawnGroupMakerParms  = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(incidentParms, true);
         defaultPawnGroupMakerParms.generateFightersOnly = true;
         List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(PawnGroupKindDefOf.Normal, defaultPawnGroupMakerParms, true).ToList();
         Map map          = CaravanIncidentUtility.SetupCaravanAttackMap(caravan, list);
         if (list.Any())
         {
             LordMaker.MakeNewLord(incidentParms.faction, new LordJob_AssaultColony(base.Faction, true, true, false, false, true), map, list);
         }
         Find.TickManager.CurTimeSpeed = TimeSpeed.Paused;
         GlobalTargetInfo lookTarget   = (!list.Any()) ? GlobalTargetInfo.Invalid : new GlobalTargetInfo(list[0].Position, map, false);
         Find.LetterStack.ReceiveLetter("LetterLabelPeaceTalks_Disaster".Translate(), this.GetLetterText("LetterPeaceTalks_Disaster".Translate(base.Faction.def.pawnsPlural.CapitalizeFirst(), base.Faction.Name, Mathf.RoundToInt(randomInRange)), caravan), LetterDefOf.ThreatBig, lookTarget, null);
     }, "GeneratingMapForNewEncounter", false, null);
 }
		public static Map SetupCaravanAttackMap(Caravan caravan, List<Pawn> enemies)
		{
			int num = CaravanIncidentUtility.CalculateIncidentMapSize(caravan.PawnsListForReading, enemies);
			Map map = CaravanIncidentUtility.GetOrGenerateMapForIncident(caravan, new IntVec3(num, 1, num), WorldObjectDefOf.Ambush);
			IntVec3 playerStartingSpot;
			IntVec3 root;
			MultipleCaravansCellFinder.FindStartingCellsFor2Groups(map, out playerStartingSpot, out root);
			CaravanEnterMapUtility.Enter(caravan, map, (Pawn x) => CellFinder.RandomSpawnCellForPawnNear(playerStartingSpot, map, 4), CaravanDropInventoryMode.DoNotDrop, true);
			for (int i = 0; i < enemies.Count; i++)
			{
				IntVec3 loc = CellFinder.RandomSpawnCellForPawnNear(root, map, 4);
				GenSpawn.Spawn(enemies[i], loc, map, Rot4.Random, false);
			}
			return map;
		}
        public static Map SetupCaravanAttackMap(Caravan caravan, List <Pawn> enemies, bool sendLetterIfRelatedPawns)
        {
            int     num = CaravanIncidentUtility.CalculateIncidentMapSize(caravan.PawnsListForReading, enemies);
            Map     map = CaravanIncidentUtility.GetOrGenerateMapForIncident(caravan, new IntVec3(num, 1, num), WorldObjectDefOf.Ambush);
            IntVec3 playerStartingSpot;
            IntVec3 root;

            MultipleCaravansCellFinder.FindStartingCellsFor2Groups(map, out playerStartingSpot, out root);
            CaravanEnterMapUtility.Enter(caravan, map, (Pawn x) => CellFinder.RandomSpawnCellForPawnNear(playerStartingSpot, map, 4), CaravanDropInventoryMode.DoNotDrop, true);
            for (int i = 0; i < enemies.Count; i++)
            {
                IntVec3 loc = CellFinder.RandomSpawnCellForPawnNear(root, map, 4);
                GenSpawn.Spawn(enemies[i], loc, map, Rot4.Random, WipeMode.Vanish, false);
            }
            if (sendLetterIfRelatedPawns)
            {
                PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(enemies, "LetterRelatedPawnsGroupGeneric".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent, true, true);
            }
            return(map);
        }
Exemple #6
0
        public override string GetInspectString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(base.GetInspectString());
            if (stringBuilder.Length != 0)
            {
                stringBuilder.AppendLine();
            }
            if (this.Resting)
            {
                stringBuilder.Append("CaravanResting".Translate());
            }
            else if (this.AnyPawnHasExtremeMentalBreak)
            {
                stringBuilder.Append("CaravanMemberMentalBreak".Translate(new object[]
                {
                    this.FirstPawnWithExtremeMentalBreak.LabelShort
                }));
            }
            else if (this.AllOwnersDowned)
            {
                stringBuilder.Append("AllCaravanMembersDowned".Translate());
            }
            else if (this.AllOwnersHaveMentalBreak)
            {
                stringBuilder.Append("AllCaravanMembersMentalBreak".Translate());
            }
            else if (this.pather.Moving)
            {
                if (this.pather.arrivalAction != null)
                {
                    stringBuilder.Append(this.pather.arrivalAction.ReportString);
                }
                else
                {
                    stringBuilder.Append("CaravanTraveling".Translate());
                }
            }
            else
            {
                Settlement settlement = CaravanVisitUtility.SettlementVisitedNow(this);
                if (settlement != null)
                {
                    stringBuilder.Append("CaravanVisiting".Translate(new object[]
                    {
                        settlement.Label
                    }));
                }
                else
                {
                    stringBuilder.Append("CaravanWaiting".Translate());
                }
            }
            if (this.pather.Moving)
            {
                float num = (float)CaravanArrivalTimeEstimator.EstimatedTicksToArrive(this, true) / 60000f;
                stringBuilder.AppendLine();
                stringBuilder.Append("CaravanEstimatedTimeToDestination".Translate(new object[]
                {
                    num.ToString("0.#")
                }));
            }
            if (this.ImmobilizedByMass)
            {
                stringBuilder.AppendLine();
                stringBuilder.Append("CaravanImmobilizedByMass".Translate());
            }
            string text;

            if (CaravanPawnsNeedsUtility.AnyPawnOutOfFood(this, out text))
            {
                stringBuilder.AppendLine();
                stringBuilder.Append("CaravanOutOfFood".Translate());
                if (!text.NullOrEmpty())
                {
                    stringBuilder.Append(" ");
                    stringBuilder.Append(text);
                    stringBuilder.Append(".");
                }
            }
            else if (this.DaysWorthOfFood.First < 1000f)
            {
                Pair <float, float> daysWorthOfFood = this.DaysWorthOfFood;
                stringBuilder.AppendLine();
                if (daysWorthOfFood.Second < 1000f)
                {
                    stringBuilder.Append("CaravanDaysOfFoodRot".Translate(new object[]
                    {
                        daysWorthOfFood.First.ToString("0.#"),
                        daysWorthOfFood.Second.ToString("0.#")
                    }));
                }
                else
                {
                    stringBuilder.Append("CaravanDaysOfFood".Translate(new object[]
                    {
                        daysWorthOfFood.First.ToString("0.#")
                    }));
                }
            }
            stringBuilder.AppendLine();
            stringBuilder.AppendLine(string.Concat(new string[]
            {
                "CaravanBaseMovementTime".Translate(),
                ": ",
                ((float)this.TicksPerMove / 2500f).ToString("0.##"),
                " ",
                "CaravanHoursPerTile".Translate()
            }));
            stringBuilder.AppendLine("CurrentTileMovementTime".Translate() + ": " + Caravan_PathFollower.CostToDisplay(this, base.Tile, this.pather.nextTile, -1f).ToStringTicksToPeriod(true, false, true));
            stringBuilder.Append("StealthFactor".Translate() + ": " + CaravanIncidentUtility.CalculateCaravanStealthFactor(this.PawnsListForReading.Count).ToString("F1"));
            return(stringBuilder.ToString());
        }