Exemple #1
0
 static void Postfix(PawnsArrivalModeWorker_EdgeWalkIn __instance, IncidentParms parms, ref bool __result)
 {
     if (parms.faction.HostileTo(Faction.OfPlayer) && !SpotterUtility.IncidentIsQueued(parms, IncidentDefOf.RaidEnemy))
     {
         __result = !SpotterUtility.TryScanForMotion(parms, IncidentDefOf.RaidEnemy);
     }
 }
        private static void SendCaravan(FCEvent evt)
        {
            Map playerHomeMap = Find.World.GetComponent <FactionFC>().TaxMap;

            if (DoDelayCaravanDueToDanger(evt))
            {
                return;
            }

            MakeDeliveryLetterAndMessage(evt);
            List <Pawn> pawns = new List <Pawn>();

            while (evt.goods.Count() > 0)
            {
                Pawn  pawn = PawnGenerator.GeneratePawn(FCPawnGenerator.WorkerOrMilitaryRequest());
                Thing next = evt.goods.First();

                if (pawn.carryTracker.innerContainer.TryAdd(next))
                {
                    evt.goods.Remove(next);
                }

                pawns.Add(pawn);
            }

            PawnsArrivalModeWorker_EdgeWalkIn pawnsArrivalModeWorker = new PawnsArrivalModeWorker_EdgeWalkIn();
            IncidentParms parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.FactionArrival, playerHomeMap);

            parms.spawnRotation = Rot4.FromAngleFlat((((Map)parms.target).Center - parms.spawnCenter).AngleFlat);

            RCellFinder.TryFindRandomPawnEntryCell(out parms.spawnCenter, playerHomeMap, CellFinder.EdgeRoadChance_Friendly);

            pawnsArrivalModeWorker.Arrive(pawns, parms);
            LordMaker.MakeNewLord(FCPawnGenerator.WorkerOrMilitaryRequest().Faction, new LordJob_DeliverSupplies(parms.spawnCenter), playerHomeMap, pawns);
        }
        static void Postfix(PawnsArrivalModeWorker_EdgeWalkIn __instance, IncidentParms parms, ref bool __result)
        {
            //return;
            if (PreemptiveStrike.Mod.PES_Settings.DebugModeOn)
            {
                Log.Message("-=PS=- Patch_EdgeWalkIn_TryResolveRaidSpawnCenter Postfix");                 //Lt. Bob - Logging
                IncidentInterceptorUtility.DebugParms(parms, __instance.ToString());
            }
            if (parms != null && parms.questTag != null)             //Lt. Bob - "Temporary" bypass fix? for Quest handling
            {
                Log.Message("-=PS=- It's a quest! Bailout! MAYDAY!", false);
                return;
            }

            //This is a temporary fix for refugee chased
            if (IncidentInterceptorUtility.IncidentInQueue(parms, IncidentDefOf.RaidEnemy))
            {
                return;
            }

            if (IncidentInterceptorUtility.IsIntercepting_IncidentExcecution)
            {
                if (IncidentInterceptorUtility.Intercept_Raid(parms))
                {
                    __result = false;
                }
            }
        }
Exemple #4
0
 static void Postfix(PawnsArrivalModeWorker_EdgeWalkIn __instance, IncidentParms parms, ref bool __result)
 {
     if (IncidentInterceptorUtility.IsIntercepting_IncidentExcecution)
     {
         if (IncidentInterceptorUtility.Intercept_Raid(parms, true))
         {
             __result = false;
         }
     }
 }
Exemple #5
0
        static void Postfix(PawnsArrivalModeWorker_EdgeWalkIn __instance, IncidentParms parms, ref bool __result)
        {
            //This is a temporary fix for refugee chased
            if (IncidentInterceptorUtility.IncidentInQueue(parms, IncidentDefOf.RaidEnemy))
            {
                return;
            }

            if (IncidentInterceptorUtility.IsIntercepting_IncidentExcecution)
            {
                if (IncidentInterceptorUtility.Intercept_Raid(parms))
                {
                    __result = false;
                }
            }
        }
 static bool Prefix(ref bool __result, ref PawnsArrivalModeWorker_EdgeWalkIn __instance, IncidentParms parms)
 {
     if (Entered)
     {
         return(true);
     }
     try
     {
         Entered = true;
         // We need to make DeepWater look impassible for a moment
         ToggledDeepWaterWalkable.DeepWaterValid = false;
         __result = __instance.TryResolveRaidSpawnCenter(parms);
     }
     finally
     {
         ToggledDeepWaterWalkable.DeepWaterValid = true;
         Entered = false;
     }
     return(!__result);
 }
        static void Postfix(PawnsArrivalModeWorker_EdgeWalkIn __instance, IncidentParms parms, ref bool __result)
        {
            if (PES_Settings.DebugModeOn)
            {
                Log.Message("-=PS=- Patch_EdgeWalkInGroups_TryResolveRaidSpawnCenter Prefix", false);
                IncidentInterceptorUtility.DebugParms(parms, __instance.ToString());
            }
            if (parms.quest != null || parms.questScriptDef != null)
            {
                Log.Message("-=PS=- It's a quest! Bailout! MAYDAY!", false);
                return;
            }

            if (IncidentInterceptorUtility.IsIntercepting_IncidentExcecution)
            {
                if (IncidentInterceptorUtility.Intercept_Raid(parms, true))
                {
                    __result = false;
                }
            }
        }
        private void DrawFactionButtons(Rect inRect, int buttonSize)         //Used to draw a list of buttons from the 'buttons' list
        {
            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Small;
            for (int i = 0; i < buttons.Count; i++)
            {
                if (Widgets.ButtonText(new Rect(140, 110 + ((buttonSize + 5) * i), 170, buttonSize), buttons[i]))
                {
                    if (buttons[i] == "FCOverview".Translate())
                    {                     //if click trade policy button
                                          //Log.Message(buttons[i]);
                        Log.Message("Success");
                        Find.WindowStack.Add(new FCWindow_Overview());
                    }


                    if (buttons[i] == "Military".Translate())
                    {
                        if (FactionColonies.getPlayerColonyFaction() == null)
                        {
                            Messages.Message(new Message("NoFactionForMilitary".Translate(), MessageTypeDefOf.RejectInput));
                        }
                        else
                        {
                            Find.WindowStack.Add(new MilitaryCustomizationWindowFc());
                        }
                    }

                    if (buttons[i] == "Actions".Translate())
                    {
                        List <FloatMenuOption> list = new List <FloatMenuOption>();

                        list.Add(new FloatMenuOption("TaxDeliveryMap".Translate(), delegate
                        {
                            List <FloatMenuOption> list2 = new List <FloatMenuOption>();


                            list2.Add(new FloatMenuOption("SetMap".Translate(), delegate
                            {
                                List <FloatMenuOption> settlementList = new List <FloatMenuOption>();

                                foreach (Map map in Find.Maps)
                                {
                                    if (map.IsPlayerHome)
                                    {
                                        settlementList.Add(new FloatMenuOption(map.Parent.LabelCap, delegate
                                        {
                                            faction.taxMap = map;
                                            Find.LetterStack.ReceiveLetter("Map Set!", "The tax delivery map has been set to the player colony of " + map.Parent.LabelCap + ".\n All taxes and other goods will be delivered there", LetterDefOf.NeutralEvent);
                                        }
                                                                               ));
                                    }
                                }

                                if (settlementList.Count == 0)
                                {
                                    settlementList.Add(new FloatMenuOption("No valid settlements to use.", null));
                                }

                                FloatMenu floatMenu2            = new FloatMenu(settlementList);
                                floatMenu2.vanishIfMouseDistant = true;
                                Find.WindowStack.Add(floatMenu2);
                            }));

                            FloatMenu floatMenu            = new FloatMenu(list2);
                            floatMenu.vanishIfMouseDistant = true;
                            Find.WindowStack.Add(floatMenu);
                        }));

                        list.Add(new FloatMenuOption("SetCapital".Translate(), delegate
                        {
                            faction.setCapital();
                        }));

                        list.Add(new FloatMenuOption("ActivateResearch".Translate(), delegate
                        {
                            faction.updateDailyResearch();
                        }));

                        list.Add(new FloatMenuOption("ResearchLevel".Translate(), delegate
                        {
                            Messages.Message("CurrentResearchLevel".Translate(faction.techLevel.ToString(), faction.returnNextTechToLevel()), MessageTypeDefOf.NeutralEvent);
                        }));

                        if (faction.hasPolicy(FCPolicyDefOf.technocratic))
                        {
                            list.Add(new FloatMenuOption("FCSendResearchItems".Translate(), delegate
                            {
                                if (Find.ColonistBar.GetColonistsInOrder().Count > 0)
                                {
                                    Pawn playerNegotiator = Find.ColonistBar.GetColonistsInOrder()[0];
                                    //Log.Message(playerNegotiator.Name + " Negotiator");

                                    FCTrader_Research trader = new FCTrader_Research();

                                    Find.WindowStack.Add(new Dialog_Trade(playerNegotiator, trader));
                                }
                                else
                                {
                                    Log.Message("Where are all the colonists?");
                                }
                            }));
                        }

                        if (faction.hasPolicy(FCPolicyDefOf.feudal))
                        {
                            list.Add(new FloatMenuOption("FCRequestMercenary".Translate(), delegate
                            {
                                if (faction.traitFeudalBoolCanUseMercenary)
                                {
                                    faction.traitFeudalBoolCanUseMercenary   = false;
                                    faction.traitFeudalTickLastUsedMercenary = Find.TickManager.TicksGame;

                                    PawnGenerationRequest request        = FCPawnGenerator.WorkerOrMilitaryRequest;
                                    request.ColonistRelationChanceFactor = 20f;
                                    Pawn pawn = PawnGenerator.GeneratePawn(request);

                                    IncidentParms parms = new IncidentParms
                                    {
                                        target  = Find.CurrentMap,
                                        faction = FactionColonies.getPlayerColonyFaction(),
                                        points  = 999,
                                        raidArrivalModeForQuickMilitaryAid = true,
                                        raidNeverFleeIndividual            = true,
                                        raidForceOneIncap = true,
                                        raidArrivalMode   = PawnsArrivalModeDefOf.CenterDrop,
                                        raidStrategy      = RaidStrategyDefOf.ImmediateAttackFriendly
                                    };
                                    parms.raidArrivalModeForQuickMilitaryAid = true;
                                    PawnsArrivalModeWorker_EdgeWalkIn worker = new PawnsArrivalModeWorker_EdgeWalkIn();
                                    worker.TryResolveRaidSpawnCenter(parms);
                                    worker.Arrive(new List <Pawn> {
                                        pawn
                                    }, parms);

                                    Find.LetterStack.ReceiveLetter("FCMercenaryJoined".Translate(), "FCMercenaryJoinedText".Translate(pawn.NameFullColored), LetterDefOf.PositiveEvent, new LookTargets(pawn));
                                    pawn.SetFaction(Faction.OfPlayer);
                                }
                                else
                                {
                                    Messages.Message("FCActionMercenaryOnCooldown".Translate(((faction.traitFeudalTickLastUsedMercenary + GenDate.TicksPerSeason) - Find.TickManager.TicksGame).ToTimeString()), MessageTypeDefOf.RejectInput);
                                }
                            }));
                        }


                        FloatMenu menu = new FloatMenu(list);
                        Find.WindowStack.Add(menu);
                    }
                }
            }
        }
Exemple #9
0
        private void DrawFactionButtons(Rect inRect, int buttonSize)         //Used to draw a list of buttons from the 'buttons' list
        {
            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Small;
            for (int i = 0; i < buttons.Count; i++)
            {
                if (Widgets.ButtonText(new Rect(140, 110 + ((buttonSize + 5) * i), 170, buttonSize), buttons[i]))
                {
                    if (buttons[i] == "FCOverview".Translate())
                    {                     //if click trade policy button
                                          //Log.Message(buttons[i]);
                        Log.Message("Success");
                        Find.WindowStack.Add(new FCWindow_Overview());
                    }


                    if (buttons[i] == "Military".Translate())
                    {
                        if (FactionColonies.getPlayerColonyFaction() == null)
                        {
                            Messages.Message(new Message("NoFactionForMilitary".Translate(), MessageTypeDefOf.RejectInput));
                        }
                        else
                        {
                            Find.WindowStack.Add(new militaryCustomizationWindowFC());
                        }
                    }

                    if (buttons[i] == "Actions".Translate())
                    {
                        List <FloatMenuOption> list = new List <FloatMenuOption>();

                        list.Add(new FloatMenuOption("TaxDeliveryMap".Translate(), delegate
                        {
                            List <FloatMenuOption> list2 = new List <FloatMenuOption>();


                            list2.Add(new FloatMenuOption("SetMap".Translate(), delegate
                            {
                                List <FloatMenuOption> settlementList = new List <FloatMenuOption>();

                                foreach (Map map in Find.Maps)
                                {
                                    if (map.IsPlayerHome)
                                    {
                                        settlementList.Add(new FloatMenuOption(map.Parent.LabelCap, delegate
                                        {
                                            faction.taxMap = map;
                                            Find.LetterStack.ReceiveLetter("Map Set!", "The tax delivery map has been set to the player colony of " + map.Parent.LabelCap + ".\n All taxes and other goods will be delivered there", LetterDefOf.NeutralEvent);
                                        }
                                                                               ));
                                    }
                                }

                                if (settlementList.Count == 0)
                                {
                                    settlementList.Add(new FloatMenuOption("No valid settlements to use.", null));
                                }

                                FloatMenu floatMenu2            = new FloatMenu(settlementList);
                                floatMenu2.vanishIfMouseDistant = true;
                                Find.WindowStack.Add(floatMenu2);
                            }));

                            FloatMenu floatMenu            = new FloatMenu(list2);
                            floatMenu.vanishIfMouseDistant = true;
                            Find.WindowStack.Add(floatMenu);
                        }));

                        list.Add(new FloatMenuOption("SetCapital".Translate(), delegate
                        {
                            faction.setCapital();
                        }));

                        list.Add(new FloatMenuOption("ActivateResearch".Translate(), delegate
                        {
                            faction.updateDailyResearch();
                        }));

                        list.Add(new FloatMenuOption("ResearchLevel".Translate(), delegate
                        {
                            Messages.Message("CurrentResearchLevel".Translate(faction.techLevel.ToString(), faction.returnNextTechToLevel()), MessageTypeDefOf.NeutralEvent);
                        }));

                        if (faction.hasPolicy(FCPolicyDefOf.technocratic))
                        {
                            list.Add(new FloatMenuOption("FCSendResearchItems".Translate(), delegate
                            {
                                if (Find.ColonistBar.GetColonistsInOrder().Count > 0)
                                {
                                    Pawn playerNegotiator = Find.ColonistBar.GetColonistsInOrder()[0];
                                    //Log.Message(playerNegotiator.Name + " Negotiator");

                                    FCTrader_Research trader = new FCTrader_Research();

                                    Find.WindowStack.Add(new Dialog_Trade(playerNegotiator, trader));
                                }
                                else
                                {
                                    Log.Message("Where are all the colonists?");
                                }
                            }));
                        }

                        if (faction.hasPolicy(FCPolicyDefOf.feudal))
                        {
                            list.Add(new FloatMenuOption("FCRequestMercenary".Translate(), delegate
                            {
                                if (faction.traitFeudalBoolCanUseMercenary)
                                {
                                    faction.traitFeudalBoolCanUseMercenary   = false;
                                    faction.traitFeudalTickLastUsedMercenary = Find.TickManager.TicksGame;
                                    List <PawnKindDef> listKindDef           = new List <PawnKindDef>();
                                    foreach (ThingDef def in Find.World.GetComponent <FactionFC>().raceFilter.AllowedThingDefs)
                                    {
                                        listKindDef.Add(def.race.AnyPawnKind);
                                    }
                                    PawnGroupMaker groupMaker             = FactionColonies.getPlayerColonyFaction().def.pawnGroupMakers.RandomElement();
                                    PawnGroupMakerParms group             = new PawnGroupMakerParms();
                                    group.groupKind                       = groupMaker.kindDef;
                                    group.faction                         = FactionColonies.getPlayerColonyFaction();
                                    group.dontUseSingleUseRocketLaunchers = true;
                                    group.generateFightersOnly            = true;
                                    group.points = 2000;

                                    group.raidStrategy = RaidStrategyDefOf.ImmediateAttackFriendly;


                                    PawnKindDef pawnkind = new PawnKindDef();
                                    PawnKindDef kind     = groupMaker.GeneratePawns(group).RandomElement().kindDef;
                                    pawnkind             = listKindDef.RandomElement();

                                    pawnkind.techHediffsTags            = kind.techHediffsTags;
                                    pawnkind.apparelTags                = kind.apparelTags;
                                    pawnkind.isFighter                  = kind.isFighter;
                                    pawnkind.combatPower                = kind.combatPower;
                                    pawnkind.gearHealthRange            = kind.gearHealthRange;
                                    pawnkind.weaponTags                 = kind.weaponTags;
                                    pawnkind.apparelMoney               = kind.apparelMoney;
                                    pawnkind.weaponMoney                = kind.weaponMoney;
                                    pawnkind.apparelAllowHeadgearChance = kind.apparelAllowHeadgearChance;
                                    pawnkind.techHediffsMoney           = kind.techHediffsMoney;
                                    pawnkind.label = kind.label;

                                    Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(pawnkind, Find.FactionManager.OfPlayer, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 20f));


                                    IncidentParms parms = new IncidentParms();
                                    parms.target        = Find.CurrentMap;
                                    parms.faction       = FactionColonies.getPlayerColonyFaction();
                                    parms.points        = 999;
                                    parms.raidArrivalModeForQuickMilitaryAid = true;
                                    parms.raidNeverFleeIndividual            = true;
                                    parms.raidForceOneIncap = true;
                                    parms.raidArrivalMode   = PawnsArrivalModeDefOf.CenterDrop;
                                    parms.raidStrategy      = RaidStrategyDefOf.ImmediateAttackFriendly;
                                    parms.raidArrivalModeForQuickMilitaryAid = true;
                                    PawnsArrivalModeWorker_EdgeWalkIn worker = new PawnsArrivalModeWorker_EdgeWalkIn();
                                    worker.TryResolveRaidSpawnCenter(parms);
                                    worker.Arrive(new List <Pawn> {
                                        pawn
                                    }, parms);

                                    Find.LetterStack.ReceiveLetter("FCMercenaryJoined".Translate(), "FCMercenaryJoinedText".Translate(pawn.NameFullColored), LetterDefOf.PositiveEvent, new LookTargets(pawn));
                                }
                                else
                                {
                                    Messages.Message("FCActionMercenaryOnCooldown".Translate(((faction.traitFeudalTickLastUsedMercenary + GenDate.TicksPerSeason) - Find.TickManager.TicksGame).ToStringTicksToDays()), MessageTypeDefOf.RejectInput);
                                }
                            }));
                        }


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