Beispiel #1
0
        public static void ForceReform(MapParent mapParent)
        {
            if (GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map))
            {
                Messages.Message(Translator.Translate("EnemyOnTheMap"), MessageTypeDefOf.NeutralEvent, false);
                return;
            }

            if (Dialog_FormCaravan.AllSendablePawns(mapParent.Map, reform: true).Any((Pawn x) => x.IsColonist))
            {
                Messages.Message("MessageYouHaveToReformCaravanNow".Translate(), new GlobalTargetInfo(mapParent.Tile), MessageTypeDefOf.NeutralEvent);
                Current.Game.CurrentMap = mapParent.Map;
                Dialog_FormCaravan window = new Dialog_FormCaravan(mapParent.Map, reform: true, delegate
                {
                    if (mapParent.HasMap)
                    {
                        Find.WorldObjects.Remove(mapParent);
                    }
                }, mapAboutToBeRemoved: true);
                Find.WindowStack.Add(window);
                return;
            }
            List <Pawn> tmpPawns = new List <Pawn>();

            tmpPawns.Clear();
            tmpPawns.AddRange(from x in mapParent.Map.mapPawns.AllPawns
                              where x.Faction == Faction.OfPlayer || x.HostFaction == Faction.OfPlayer
                              select x);
            if (tmpPawns.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer)))
            {
                CaravanExitMapUtility.ExitMapAndCreateCaravan(tmpPawns, Faction.OfPlayer, mapParent.Tile, mapParent.Tile, -1);
            }
            tmpPawns.Clear();
            Find.WorldObjects.Remove(mapParent);
        }
Beispiel #2
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            var map = parms.target as Map;

            if (GenHostility.AnyHostileActiveThreatToPlayer(map))
            {
                //Grab all hostile targets.
                var hashSet =
                    new HashSet <IAttackTarget>(map.attackTargetsCache.TargetsHostileToFaction(Faction.OfPlayer));

                if (hashSet != null && hashSet.Count > 0)
                {
                    foreach (var target in hashSet)
                    {
                        if (target is Pawn enemyPawn && !enemyPawn.RaceProps.IsMechanoid &&
                            enemyPawn.GetStatValue(StatDefOf.PsychicSensitivity) >= 0.5f)
                        {
                            //Force panic fleeing
                            enemyPawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.PanicFlee,
                                                                                       "Cults_BastSanctuaryEnemy".Translate(), true);
                        }
                    }
                }
            }

            return(true);
        }
Beispiel #3
0
        private void CheckStartForceExitAndRemoveMapCountdown()
        {
            if (this.startedCountdown)
            {
                return;
            }
            if (GenHostility.AnyHostileActiveThreatToPlayer(base.Map))
            {
                return;
            }
            this.startedCountdown = true;
            int    num  = Mathf.RoundToInt(this.core.forceExitAndRemoveMapCountdownDurationDays * 60000f);
            string text = (!this.anyEnemiesInitially) ? "MessageSiteCountdownBecauseNoEnemiesInitially".Translate(new object[]
            {
                TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(num)
            }) : "MessageSiteCountdownBecauseNoMoreEnemies".Translate(new object[]
            {
                TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(num)
            });

            Messages.Message(text, this, MessageTypeDefOf.PositiveEvent);
            base.GetComponent <TimedForcedExit>().StartForceExitAndRemoveMapCountdown(num);
            TaleRecorder.RecordTale(TaleDefOf.CaravanAssaultSuccessful, new object[]
            {
                base.Map.mapPawns.FreeColonists.RandomElement <Pawn>()
            });
        }
Beispiel #4
0
 private void CheckStartForceExitAndRemoveMapCountdown()
 {
     if (startedCountdown)
     {
         if (GenHostility.AnyHostileActiveThreatToPlayer(base.Map))
         {
             anyEnemiesInitially = true;
             startedCountdown    = false;
             GetComponent <TimedForcedExit>().ResetForceExitAndRemoveMapCountdown();
         }
     }
     else if (!GenHostility.AnyHostileActiveThreatToPlayer(base.Map))
     {
         startedCountdown = true;
         float num = 0f;
         for (int i = 0; i < parts.Count; i++)
         {
             num = Mathf.Max(num, parts[i].def.forceExitAndRemoveMapCountdownDurationDays);
         }
         int num2 = Mathf.RoundToInt(num * 60000f);
         Messages.Message(anyEnemiesInitially ? "MessageSiteCountdownBecauseNoMoreEnemies".Translate(TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(num2)) : "MessageSiteCountdownBecauseNoEnemiesInitially".Translate(TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(num2)), this, MessageTypeDefOf.PositiveEvent);
         GetComponent <TimedForcedExit>().StartForceExitAndRemoveMapCountdown(num2);
         TaleRecorder.RecordTale(TaleDefOf.CaravanAssaultSuccessful, base.Map.mapPawns.FreeColonists.RandomElement());
     }
 }
        public override IEnumerable <Gizmo> GetGizmos()
        {
            MapParent mapParent = (MapParent)parent;

            if (!mapParent.HasMap)
            {
                yield break;
            }
            if (mapParent.Map.mapPawns.FreeColonistsSpawnedCount != 0)
            {
                Command_Action reformCaravan = new Command_Action {
                    defaultLabel = "CommandReformCaravan".Translate(),
                    defaultDesc  = "CommandReformCaravanDesc".Translate(),
                    icon         = FormCaravanCommand,
                    hotKey       = KeyBindingDefOf.Misc2,
                    tutorTag     = "ReformCaravan",
                    action       = delegate
                    {
                        Find.WindowStack.Add(new Dialog_FormCaravan(mapParent.Map, reform: true)); //always show reform caravan
                    }
                };
                //Disable caravan reforming due to hostiles only in instant mode
                if (GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map) && RealRuins_ModSettings.caravanReformType == 1)
                {
                    reformCaravan.Disable("CommandReformCaravanFailHostilePawns".Translate());
                }
                yield return(reformCaravan);
            }
        }
Beispiel #6
0
 private void CheckAllEnemiesDefeated()
 {
     if (!allEnemiesDefeatedSignalSent && base.HasMap && !GenHostility.AnyHostileActiveThreatToPlayer(base.Map, countDormantPawnsAsHostile: true))
     {
         QuestUtility.SendQuestTargetSignals(questTags, "AllEnemiesDefeated", this.Named("SUBJECT"));
         allEnemiesDefeatedSignalSent = true;
     }
 }
 private void CheckAllEnemiesDefeated(MapParent mapParent)
 {
     if (mapParent.HasMap && !GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map))
     {
         GiveRewardsAndSendLetter();
         StopQuest();
     }
 }
Beispiel #8
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            MapParent mapParent = (MapParent)parent;

            if (!mapParent.HasMap)
            {
                yield break;
            }
            if (!Reform)
            {
                Command_Action command_Action = new Command_Action();
                command_Action.defaultLabel = "CommandFormCaravan".Translate();
                command_Action.defaultDesc  = "CommandFormCaravanDesc".Translate();
                command_Action.icon         = FormCaravanCommand;
                command_Action.hotKey       = KeyBindingDefOf.Misc2;
                command_Action.tutorTag     = "FormCaravan";
                command_Action.action       = delegate
                {
                    Find.WindowStack.Add(new Dialog_FormCaravan(mapParent.Map));
                };
                yield return(command_Action);
            }
            else if (mapParent.Map.mapPawns.FreeColonistsSpawnedCount != 0)
            {
                Command_Action command_Action2 = new Command_Action();
                command_Action2.defaultLabel = "CommandReformCaravan".Translate();
                command_Action2.defaultDesc  = "CommandReformCaravanDesc".Translate();
                command_Action2.icon         = FormCaravanCommand;
                command_Action2.hotKey       = KeyBindingDefOf.Misc2;
                command_Action2.tutorTag     = "ReformCaravan";
                command_Action2.action       = delegate
                {
                    Find.WindowStack.Add(new Dialog_FormCaravan(mapParent.Map, reform: true));
                };
                if (GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map, countDormantPawnsAsHostile: true))
                {
                    command_Action2.Disable("CommandReformCaravanFailHostilePawns".Translate());
                }
                yield return(command_Action2);
            }
            if (!Prefs.DevMode)
            {
                yield break;
            }
            Command_Action command_Action3 = new Command_Action();

            command_Action3.defaultLabel = "Dev: Show available exits";
            command_Action3.action       = delegate
            {
                foreach (int item in CaravanExitMapUtility.AvailableExitTilesAt(mapParent.Map))
                {
                    Find.WorldDebugDrawer.FlashTile(item, 0f, null, 10);
                }
            };
            yield return(command_Action3);
        }
Beispiel #9
0
        public override bool CanSummonNow(Map map)
        {
            if (!GenHostility.AnyHostileActiveThreatToPlayer(map))
            {
                Messages.Message("Cults_BastNoEnemiesOnMap".Translate(), MessageTypeDefOf.RejectInput);
                return(false);
            }

            return(true);
        }
Beispiel #10
0
        public override bool CanLeave()
        {
            if (GenHostility.AnyHostileActiveThreatToPlayer(this.Map))
            {
                Messages.Message(Translator.Translate("EnemyOnTheMap"), MessageTypeDefOf.NeutralEvent, false);
                return(false);
            }

            return(true);
        }
Beispiel #11
0
 private void CheckWonBattle()
 {
     if (!this.wonBattle && !GenHostility.AnyHostileActiveThreatToPlayer(base.Map))
     {
         Messages.Message("MessageAmbushVictory".Translate(TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(60000)), this, MessageTypeDefOf.PositiveEvent);
         TaleRecorder.RecordTale(TaleDefOf.CaravanAmbushDefeated, base.Map.mapPawns.FreeColonists.RandomElement());
         this.wonBattle = true;
         base.GetComponent <TimedForcedExit>().StartForceExitAndRemoveMapCountdown();
     }
 }
Beispiel #12
0
 private void CheckRecordAssaultSuccessfulTale()
 {
     if (anyEnemiesInitially && !caravanAssaultSuccessfulTaleRecorded && !GenHostility.AnyHostileActiveThreatToPlayer(base.Map))
     {
         caravanAssaultSuccessfulTaleRecorded = true;
         if (base.Map.mapPawns.FreeColonists.Any())
         {
             TaleRecorder.RecordTale(TaleDefOf.CaravanAssaultSuccessful, base.Map.mapPawns.FreeColonists.RandomElement());
         }
     }
 }
 private void CheckWonBattle()
 {
     if (!wonBattle && !GenHostility.AnyHostileActiveThreatToPlayer(base.Map))
     {
         string forceExitAndRemoveMapCountdownTimeLeftString = TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(60000);
         Find.LetterStack.ReceiveLetter("LetterLabelCaravansBattlefieldVictory".Translate(), "LetterCaravansBattlefieldVictory".Translate(forceExitAndRemoveMapCountdownTimeLeftString), LetterDefOf.PositiveEvent, this);
         TaleRecorder.RecordTale(TaleDefOf.CaravanAmbushDefeated, base.Map.mapPawns.FreeColonists.RandomElement());
         wonBattle = true;
         GetComponent <TimedForcedExit>().StartForceExitAndRemoveMapCountdown();
     }
 }
Beispiel #14
0
        public override void PostMapGenerate()
        {
            base.PostMapGenerate();
            Map map = base.Map;

            this.core.Worker.PostMapGenerate(map);
            for (int i = 0; i < this.parts.Count; i++)
            {
                this.parts[i].Worker.PostMapGenerate(map);
            }
            this.anyEnemiesInitially = GenHostility.AnyHostileActiveThreatToPlayer(base.Map);
        }
Beispiel #15
0
        public override void PostMapGenerate()
        {
            base.PostMapGenerate();
            Map map = base.Map;

            for (int i = 0; i < parts.Count; i++)
            {
                parts[i].def.Worker.PostMapGenerate(map);
            }
            anyEnemiesInitially          = GenHostility.AnyHostileActiveThreatToPlayer(base.Map);
            allEnemiesDefeatedSignalSent = false;
        }
Beispiel #16
0
 private void CheckWonBattle()
 {
     if (!wonBattle && !GenHostility.AnyHostileActiveThreatToPlayer(base.Map))
     {
         TimedDetectionRaids component = GetComponent <TimedDetectionRaids>();
         component.SetNotifiedSilently();
         string detectionCountdownTimeLeftString = component.DetectionCountdownTimeLeftString;
         Find.LetterStack.ReceiveLetter("LetterLabelCaravansBattlefieldVictory".Translate(), "LetterCaravansBattlefieldVictory".Translate(detectionCountdownTimeLeftString), LetterDefOf.PositiveEvent, this);
         TaleRecorder.RecordTale(TaleDefOf.CaravanAmbushDefeated, base.Map.mapPawns.FreeColonists.RandomElement());
         wonBattle = true;
     }
 }
 private void CheckAllEnemiesDefeated(MapParent mapParent)
 {
     if (!mapParent.HasMap)
     {
         return;
     }
     if (GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map))
     {
         return;
     }
     this.GiveRewardsAndSendLetter();
     this.StopQuest();
 }
        public override IEnumerable <Gizmo> GetGizmos()
        {
            _003CGetGizmos_003Ec__Iterator0 _003CGetGizmos_003Ec__Iterator = (_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0036: stateMachine*/;
            MapParent mapParent = base.parent as MapParent;

            if (!mapParent.HasMap)
            {
                yield break;
            }
            if (!this.Props.reformCaravan)
            {
                yield return((Gizmo) new Command_Action
                {
                    defaultLabel = "CommandFormCaravan".Translate(),
                    defaultDesc = "CommandFormCaravanDesc".Translate(),
                    icon = FormCaravanComp.FormCaravanCommand,
                    hotKey = KeyBindingDefOf.Misc2,
                    tutorTag = "FormCaravan",
                    action = delegate
                    {
                        Find.WindowStack.Add(new Dialog_FormCaravan(mapParent.Map, false, null, true, false));
                    }
                });

                /*Error: Unable to find new state assignment for yield return*/;
            }
            if (mapParent.Map.mapPawns.FreeColonistsSpawnedCount == 0)
            {
                yield break;
            }
            Command_Action reformCaravan = new Command_Action
            {
                defaultLabel = "CommandReformCaravan".Translate(),
                defaultDesc  = "CommandReformCaravanDesc".Translate(),
                icon         = FormCaravanComp.FormCaravanCommand,
                hotKey       = KeyBindingDefOf.Misc2,
                tutorTag     = "ReformCaravan",
                action       = delegate
                {
                    Find.WindowStack.Add(new Dialog_FormCaravan(mapParent.Map, true, null, true, false));
                }
            };

            if (GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map))
            {
                reformCaravan.Disable("CommandReformCaravanFailHostilePawns".Translate());
            }
            yield return((Gizmo)reformCaravan);

            /*Error: Unable to find new state assignment for yield return*/;
        }
Beispiel #19
0
 private static void AddCaravanExitTaleIfShould(Pawn pawn)
 {
     if (pawn.Spawned && pawn.IsFreeColonist)
     {
         if (pawn.Map.IsPlayerHome)
         {
             TaleRecorder.RecordTale(TaleDefOf.CaravanFormed, pawn);
         }
         else if (GenHostility.AnyHostileActiveThreatToPlayer(pawn.Map))
         {
             TaleRecorder.RecordTale(TaleDefOf.CaravanFled, pawn);
         }
     }
 }
Beispiel #20
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);
         }
     }
 }
        protected override void OpenBox(Pawn usedBy)
        {
            var map = usedBy.Map;

            Rand.PushState(parent.HashOffset());
            var hostileActivity = GenHostility.AnyHostileActiveThreatToPlayer(map);
            var selectedGroup   = IncidentGroups.RandomElementByWeight(kvp => kvp.Value.Chance);

            while (hostileActivity && selectedGroup.Key.Contains(IncidentCategoryDefOf.FactionArrival))
            {
                selectedGroup = IncidentGroups.RandomElementByWeight(kvp => kvp.Value.Chance);
            }
            var count = Rand.RangeInclusive(selectedGroup.Value.CountMin,
                                            Rand.RangeInclusive(selectedGroup.Value.CountStep, selectedGroup.Value.CountMax));

            for (var i = 0; i < count; i++)
            {
                var validIncidents =
                    (from incident in from def in DefDatabase <IncidentDef> .AllDefs
                     where selectedGroup.Key.Contains(def.category) && def.TargetAllowed(map)
                     select def
                     let parameters = StorytellerUtility.DefaultParmsNow(incident.category, map)
                                      where incident.Worker.CanFireNow(parameters)
                                      select incident).ToList();

                var selectedIncident =
                    validIncidents.RandomElementByWeight(IncidentChanceFinal);
                if (selectedIncident == null)
                {
                    continue;
                }

                var storyTellerParams = StorytellerUtility.DefaultParmsNow(selectedIncident.category, map);
                if (selectedIncident.pointsScaleable)
                {
                    var storytellerComp = Find.Storyteller.storytellerComps.First(x =>
                                                                                  x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain);
                    if (storytellerComp != null)
                    {
                        storyTellerParams =
                            storytellerComp.GenerateParms(selectedIncident.category, storyTellerParams.target);
                    }
                }

                selectedIncident.Worker.TryExecute(storyTellerParams);
            }

            Rand.PopState();
        }
Beispiel #22
0
 public override void Tick()
 {
     base.Tick();
     if (HasMap && Faction != Faction.OfPlayer)
     {
         if (!GenHostility.AnyHostileActiveThreatToPlayer(Map))
         {
             //show letter about enemies defeated
             originalFaction = Faction;
             SetFaction(Faction.OfPlayer);
             Debug.Log("Setting player faction, cached mat set to nil");
             cachedMat = null;
         }
     }
 }
Beispiel #23
0
        /// <summary>
        /// Adds FormVehicleCaravan gizmo to FormCaravanComp, allowing
        /// </summary>
        /// <param name="__result"></param>
        /// <param name="__instance"></param>
        /// <returns></returns>
        public static IEnumerable <Gizmo> AddVehicleGizmosPassthrough(IEnumerable <Gizmo> __result, FormCaravanComp __instance)
        {
            IEnumerator <Gizmo> enumerator = __result.GetEnumerator();

            if (__instance.parent is MapParent mapParent && __instance.ParentHasMap)
            {
                if (!__instance.Reform)
                {
                    yield return(new Command_Action()
                    {
                        defaultLabel = "CommandFormVehicleCaravan".Translate(),
                        defaultDesc = "CommandFormVehicleCaravanDesc".Translate(),
                        icon = Settlement.FormCaravanCommand,
                        action = delegate()
                        {
                            Find.Tutor.learningReadout.TryActivateConcept(ConceptDefOf.FormCaravan);
                            Find.WindowStack.Add(new Dialog_FormVehicleCaravan(mapParent.Map));
                        }
                    });
                }
                else if (mapParent.Map.mapPawns.AllPawnsSpawned.Where(p => p is VehiclePawn).Count() > 0)
                {
                    Command_Action command_Action = new Command_Action
                    {
                        defaultLabel = "CommandReformVehicleCaravan".Translate(),
                        defaultDesc  = "CommandReformVehicleCaravanDesc".Translate(),
                        icon         = FormCaravanComp.FormCaravanCommand,
                        hotKey       = KeyBindingDefOf.Misc2,
                        action       = delegate()
                        {
                            Find.WindowStack.Add(new Dialog_FormVehicleCaravan(mapParent.Map, true));
                        }
                    };
                    if (GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map, true))
                    {
                        command_Action.Disable("CommandReformCaravanFailHostilePawns".Translate());
                    }
                    yield return(command_Action);
                }
            }
            while (enumerator.MoveNext())
            {
                var element = enumerator.Current;
                yield return(element);
            }
        }
        protected override void OpenBox(Pawn usedBy)
        {
            Map map = usedBy.Map;

            Rand.PushState(parent.HashOffset());
            bool hostileActivity = GenHostility.AnyHostileActiveThreatToPlayer(map);
            KeyValuePair <List <IncidentCategoryDef>, IncidentGroupData> selectedGroup = incidentGroups.RandomElementByWeight(kvp => kvp.Value.chance);

            while (hostileActivity && selectedGroup.Key.Contains(IncidentCategoryDefOf.FactionArrival))
            {
                selectedGroup = incidentGroups.RandomElementByWeight(kvp => kvp.Value.chance);
            }
            int count = Rand.RangeInclusive(selectedGroup.Value.countMin, Rand.RangeInclusive(selectedGroup.Value.countStep, selectedGroup.Value.countMax));

            for (int i = 0; i < count; i++)
            {
                List <IncidentDef> validIncidents = new List <IncidentDef>();
                foreach (IncidentDef incident in from def in DefDatabase <IncidentDef> .AllDefs where selectedGroup.Key.Contains(def.category) && def.TargetAllowed(map) select def)
                {
                    IncidentParms parms = StorytellerUtility.DefaultParmsNow(incident.category, map);
                    if (incident.Worker.CanFireNow(parms, false))
                    {
                        validIncidents.Add(incident);
                    }
                }
                IncidentDef selectedIncident = validIncidents.RandomElementByWeight(new Func <IncidentDef, float>(IncidentChanceFinal));
                if (selectedIncident != null)
                {
                    IncidentParms parms = StorytellerUtility.DefaultParmsNow(selectedIncident.category, map);
                    if (selectedIncident.pointsScaleable)
                    {
                        StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain);
                        if (storytellerComp != null)
                        {
                            parms = storytellerComp.GenerateParms(selectedIncident.category, parms.target);
                        }
                    }
                    selectedIncident.Worker.TryExecute(parms);
                }
            }
            Rand.PopState();
        }
Beispiel #25
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            MapParent mapParent = (MapParent)this.parent;

            if (mapParent.HasMap)
            {
                if (!this.Reform)
                {
                    yield return(new Command_Action
                    {
                        defaultLabel = "CommandFormCaravan".Translate(),
                        defaultDesc = "CommandFormCaravanDesc".Translate(),
                        icon = FormCaravanComp.FormCaravanCommand,
                        hotKey = KeyBindingDefOf.Misc2,
                        tutorTag = "FormCaravan",
                        action = delegate()
                        {
                            Find.WindowStack.Add(new Dialog_FormCaravan(mapParent.Map, false, null, false));
                        }
                    });
                }
                else if (mapParent.Map.mapPawns.FreeColonistsSpawnedCount != 0)
                {
                    Command_Action reformCaravan = new Command_Action();
                    reformCaravan.defaultLabel = "CommandReformCaravan".Translate();
                    reformCaravan.defaultDesc  = "CommandReformCaravanDesc".Translate();
                    reformCaravan.icon         = FormCaravanComp.FormCaravanCommand;
                    reformCaravan.hotKey       = KeyBindingDefOf.Misc2;
                    reformCaravan.tutorTag     = "ReformCaravan";
                    reformCaravan.action       = delegate()
                    {
                        Find.WindowStack.Add(new Dialog_FormCaravan(mapParent.Map, true, null, false));
                    };
                    if (GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map))
                    {
                        reformCaravan.Disable("CommandReformCaravanFailHostilePawns".Translate());
                    }
                    yield return(reformCaravan);
                }
            }
            yield break;
        }
 public static void GenerateCaravanExitTale(Pawn pawn)
 {
     if (pawn.Spawned && pawn.IsFreeColonist)
     {
         if (pawn.Map.IsPlayerHome)
         {
             TaleRecorder.RecordTale(TaleDefOf.CaravanFormed, new object[]
             {
                 pawn
             });
         }
         else if (GenHostility.AnyHostileActiveThreatToPlayer(pawn.Map))
         {
             TaleRecorder.RecordTale(TaleDefOf.CaravanFled, new object[]
             {
                 pawn
             });
         }
     }
 }
 public override void Tick()
 {
     base.Tick();
     if (HasMap)
     {
         if (!GenHostility.AnyHostileActiveThreatToPlayer(Map))
         {
             if (Faction != Faction.OfPlayer)
             {
                 SetFaction(Faction.OfPlayer);
             }
         }
         else
         {
             if (Faction == Faction.OfPlayer)
             {
                 SetFaction(null); //reset faction to forbid fast caravan reform and add green border
             }
         }
     }
 }
Beispiel #28
0
 /// <summary>
 /// Create Tale for VehicleCaravan
 /// </summary>
 /// <param name="pawn"></param>
 public static void AddCaravanExitTaleIfShould(Pawn pawn)
 {
     if (pawn.Spawned && pawn.IsFreeColonist)
     {
         if (pawn.Map.IsPlayerHome)
         {
             TaleRecorder.RecordTale(TaleDefOf.CaravanFormed, new object[]
             {
                 pawn
             });
             return;
         }
         if (GenHostility.AnyHostileActiveThreatToPlayer(pawn.Map, false))
         {
             TaleRecorder.RecordTale(TaleDefOf.CaravanFled, new object[]
             {
                 pawn
             });
         }
     }
 }
        private void CheckWonBattle()
        {
            if (this.wonBattle)
            {
                return;
            }
            if (GenHostility.AnyHostileActiveThreatToPlayer(base.Map))
            {
                return;
            }
            string forceExitAndRemoveMapCountdownTimeLeftString = TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(60000);

            Find.LetterStack.ReceiveLetter("LetterLabelCaravansBattlefieldVictory".Translate(), "LetterCaravansBattlefieldVictory".Translate(new object[]
            {
                forceExitAndRemoveMapCountdownTimeLeftString
            }), LetterDefOf.PositiveEvent, this, null, null);
            TaleRecorder.RecordTale(TaleDefOf.CaravanAmbushDefeated, new object[]
            {
                base.Map.mapPawns.FreeColonists.RandomElement <Pawn>()
            });
            this.wonBattle = true;
            base.GetComponent <TimedForcedExit>().StartForceExitAndRemoveMapCountdown();
        }
Beispiel #30
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);
             }
         }
     }
 }