예제 #1
0
        private static void DoIncidentDebugAction(Dialog_DebugActionsMenu menu, IIncidentTarget target)
        {
            menu.DebugAction($"Incident on {target}", () =>
            {
                var list = new List <DebugMenuOption>();
                foreach (var localDef2 in DefDatabase <IncidentDef> .AllDefs.Where(d => d.TargetAllowed(target)).OrderBy(d => d.defName))
                {
                    IncidentDef localDef = localDef2;
                    string text          = localDef.defName;
                    IncidentParms parms  = StorytellerUtility.DefaultParmsNow(localDef.category, target);
                    if (!localDef.Worker.CanFireNow(parms, false))
                    {
                        text += " [NO]";
                    }

                    list.Add(new DebugMenuOption(text, DebugMenuOptionMode.Action, () =>
                    {
                        if (localDef.pointsScaleable)
                        {
                            StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain);
                            parms = storytellerComp.GenerateParms(localDef.category, parms.target);
                        }

                        ExecuteIncident(localDef, parms, target as Map);
                    }));
                }

                Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
            });
        }
예제 #2
0
        static void Postfix(Dialog_DebugActionsMenu __instance)
        {
            if (Current.ProgramState != ProgramState.Playing)
            {
                return;
            }

            var menu = __instance;

            menu.DoLabel("Local");

            menu.DebugAction("Save game", SaveGameLocal);
            menu.DebugAction("Print static fields", PrintStaticFields);
            menu.DebugAction("Queue incident", QueueIncident);
            menu.DebugAction("Blocking long event", BlockingLongEvent);

            if (Multiplayer.Client == null)
            {
                return;
            }
            if (!MpVersion.IsDebug)
            {
                return;
            }

            menu.DoLabel("Multiplayer");

            menu.DebugAction("Save game for everyone", SaveGameCmd);
            menu.DebugAction("Advance time", AdvanceTime);
        }
        // Verse.Dialog_DebugActionsMenu
        public static void DoListingItems_MapTools_Vamp(Dialog_DebugActionsMenu __instance)
        {
            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DoLabel").Invoke(__instance, new object[] { "Tools - Vampirism" });
            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugToolMap").Invoke(__instance, new object[] {
                "Spawn Vampire (Random)", new Action(() =>
                {
                    Pawn randomVampire =
                        VampireGen.GenerateVampire(VampireUtility.RandHigherGeneration, VampireUtility.RandBloodline, null, null, false);
                    GenSpawn.Spawn(randomVampire, UI.MouseCell(), Find.VisibleMap);
                })
            });


            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugToolMap").Invoke(__instance, new object[] {
                "Give Vampirism (Default)", new Action(() =>
                {
                    Pawn pawn = Find.VisibleMap.thingGrid.ThingsAt(UI.MouseCell()).Where((Thing t) => t is Pawn).Cast <Pawn>().FirstOrDefault <Pawn>();
                    if (pawn != null)
                    {
                        if (!pawn.IsVampire())
                        {
                            pawn.health.AddHediff(VampDefOf.ROM_Vampirism, null, null);
                            pawn.Drawer.Notify_DebugAffected();
                            MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, pawn.LabelShort + " is now a vampire", -1f);
                        }
                        else
                        {
                            Messages.Message(pawn.LabelCap + " is already a vampire.", MessageSound.RejectInput);
                        }
                    }
                })
            });

            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugToolMap").Invoke(__instance, new object[] {
                "Give Vampirism (w/Settings)", new Action(() =>
                {
                    Pawn pawn = Find.VisibleMap.thingGrid.ThingsAt(UI.MouseCell()).Where((Thing t) => t is Pawn).Cast <Pawn>().FirstOrDefault <Pawn>();
                    if (pawn != null)
                    {
                        //pawn.health.AddHediff(VampDefOf.ROM_Vampirism, null, null);
                        Find.WindowStack.Add(new Dialog_DebugOptionListLister(HarmonyPatches.Options_Bloodlines(pawn)));
                        //DebugTools.curTool = null;
                    }
                })
            });

            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugToolMap").Invoke(__instance, new object[] {
                "Add Blood (1)", new Action(() =>
                {
                    Pawn pawn = Find.VisibleMap.thingGrid.ThingsAt(UI.MouseCell()).Where((Thing t) => t is Pawn).Cast <Pawn>().FirstOrDefault <Pawn>();
                    if (pawn != null && pawn?.BloodNeed() is Need_Blood b)
                    {
                        b.AdjustBlood(1);
                        pawn.Drawer.Notify_DebugAffected();
                        MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "+1 Blood", -1f);
                    }
                })
            });
예제 #4
0
        public static bool DoExecuteIncidentDebugAction_PreFix(Dialog_DebugActionsMenu __instance, IIncidentTarget target, IIncidentTarget altTarget)
        {
            //Log.Message("1");
            if (Find.Storyteller?.storytellerComps?.FirstOrDefault(x => x is StorytellerComp_OmenThreatCycle) != null)
            {
                //Log.Message("2");
                AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugAction").Invoke(__instance, new object[]
                {
                    "Execute incident...", new Action(delegate
                    {
                        //Log.Message("3");
                        List <DebugMenuOption> list = new List <DebugMenuOption>();
                        foreach (IncidentDef current in from d in DefDatabase <IncidentDef> .AllDefs
                                 where d.TargetAllowed(target) || (altTarget != null && d.TargetAllowed(altTarget))
                                 orderby !d.TargetAllowed(target), d.defName
                                 select d)
                        {
                            IIncidentTarget arg_98_1;
                            if (current.TargetAllowed(target))
                            {
                                IIncidentTarget target2 = target;
                                arg_98_1 = target2;
                            }
                            else
                            {
                                arg_98_1 = altTarget;
                            }
                            var thisIncidentTarget = arg_98_1;

                            string text = current.defName;
                            if (!current.Worker.CanFireNow(thisIncidentTarget))
                            {
                                text += " [NO]";
                            }
                            if (thisIncidentTarget == altTarget)
                            {
                                text = text + " (" + altTarget.GetType().Name.Truncate(52f, null) + ")";
                            }
                            list.Add(new DebugMenuOption(text, DebugMenuOptionMode.Action, delegate
                            {
                                IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, current.category, thisIncidentTarget);
                                if (current.pointsScaleable)
                                {
                                    StorytellerComp storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_ThreatCycle || x is StorytellerComp_RandomMain || x is StorytellerComp_OmenThreatCycle);
                                    incidentParms = storytellerComp.GenerateParms(current.category, incidentParms.target);
                                }
                                current.Worker.TryExecute(incidentParms);
                            }));
                        }
                        ;
                        Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
                    })
                });
                return(false);
            }
            return(true);
        }
예제 #5
0
        static void Postfix(Dialog_DebugActionsMenu __instance)
        {
            var menu = __instance;

            menu.DoLabel("Prison Labor Tools:");

            // Increase motivation
            menu.DebugToolMapForPawns("Tool: Motivation +10%", delegate(Pawn p)
            {
                if (p.needs.TryGetNeed <Need_Motivation>() != null)
                {
                    OffsetNeed(p, Need_Motivation.Def, 0.1f);
                }
            });
            // Decrease motivation
            menu.DebugToolMapForPawns("Tool: Motivation -10%", delegate(Pawn p)
            {
                if (p.needs.TryGetNeed <Need_Motivation>() != null)
                {
                    OffsetNeed(p, Need_Motivation.Def, -0.1f);
                }
            });
            // Increase treatment
            menu.DebugToolMapForPawns("Tool: Treatment +10%", delegate(Pawn p)
            {
                if (p.needs.TryGetNeed <Need_Treatment>() != null)
                {
                    OffsetNeed(p, Need_Treatment.Def, 0.1f);
                }
            });
            // Decrease treatment
            menu.DebugToolMapForPawns("Tool: Treatment -10%", delegate(Pawn p)
            {
                if (p.needs.TryGetNeed <Need_Treatment>() != null)
                {
                    OffsetNeed(p, Need_Treatment.Def, -0.1f);
                }
            });
            // Turn into prisoner
            menu.DebugToolMapForPawns("Tool: Turn into prisoner", delegate(Pawn p)
            {
                p.guest.SetGuestStatus(Faction.OfPlayer, true);
            });
            // Set free
            menu.DebugToolMapForPawns("Tool: Set free", delegate(Pawn p)
            {
                p.guest.SetGuestStatus(null, false);
            });
            // Set free
            menu.DebugAction("Toggle logging escape utility", () =>
            {
                LogEscapeUtilityEnabled = !LogEscapeUtilityEnabled;
            });
        }
예제 #6
0
 public static void Postfix(Dialog_DebugActionsMenu __instance)
 {
     try
     {
         DoListingItems_Mod(__instance);
     }
     catch (Exception e)
     {
         Log.Message($"PawnEducation : DoListingItems_Postfix error - {e.Message}");
     }
 }
예제 #7
0
        private static void DoListingItems_Mod(Dialog_DebugActionsMenu __instance)
        {
            var clear = new Action(DebugAction_ClearCraftThoughts);
            var write = new Action(DebugAction_WriteModSettings);

            var t = Traverse.Create(__instance);

            t.Method("DoGap").GetValue();
            t.Method("DoLabel", "Mods - Misc").GetValue();
            t.Method("DebugAction", "Clear Play Log", clear).GetValue();
            t.Method("DebugAction", "Write Mod Settings", write).GetValue();
        }
        static void Postfix(Dialog_DebugActionsMenu __instance)
        {
            MethodInfo mi = typeof(Dialog_DebugOptionLister).GetMethod("DebugAction", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

            mi.Invoke(__instance, new Object[] { "Restore faction leaders", (Action) delegate {
                                                     foreach (Faction f in Find.FactionManager.AllFactions)
                                                     {
                                                         if (f.leader == null)
                                                         {
                                                             f.GenerateNewLeader();
                                                             if (f.leader == null)
                                                             {
                                                                 Log.Warning("No leader could be generated for faction " + f.GetCallLabel() + " - if that is unexpected fix xml definition for faction def " + f.def.defName + " and try again.");
                                                             }
                                                         }
                                                     }
                                                 } });
        }
예제 #9
0
        static void Postfix(Dialog_DebugActionsMenu __instance)
        {
            if (Multiplayer.Client == null)
            {
                return;
            }
            if (Current.ProgramState != ProgramState.Playing)
            {
                return;
            }

            var menu = __instance;

            menu.DoLabel("Local");

            menu.DebugAction("Save game", SaveGameLocal);
            menu.DebugAction("Print static fields", PrintStaticFields);

            if (!MpVersion.IsDebug)
            {
                return;
            }

            menu.DoLabel("Multiplayer");

            menu.DebugToolMap("T: Destroy thing", DestroyThing);
            menu.DebugToolMap("T: Mental state", DoMentalState);

            menu.DebugAction("Save game for everyone", SaveGameCmd);
            menu.DebugAction("Advance time", AdvanceTime);

            if (Find.CurrentMap != null)
            {
                DoIncidentDebugAction(menu, Find.CurrentMap);
            }

            if (Find.WorldSelector.SingleSelectedObject is IIncidentTarget target)
            {
                DoIncidentDebugAction(menu, target);
            }

            DoIncidentDebugAction(menu, Find.World);
        }
예제 #10
0
        static void Postfix(Dialog_DebugActionsMenu __instance)
        {
            var menu = __instance;

            if (MpVersion.IsDebug)
            {
                menu.DoLabel("Entry tools");
                menu.DebugAction("Entry action", EntryAction);
            }

            if (Current.ProgramState != ProgramState.Playing)
            {
                return;
            }

            menu.DoLabel("Local");

            menu.DebugAction("Save game", SaveGameLocal);
            menu.DebugAction("Print static fields", PrintStaticFields);

            if (MpVersion.IsDebug)
            {
                menu.DebugAction("Queue incident", QueueIncident);
                menu.DebugAction("Blocking long event", BlockingLongEvent);
            }

            if (Multiplayer.Client == null)
            {
                return;
            }

            if (MpVersion.IsDebug)
            {
                menu.DoLabel("Multiplayer");

                menu.DebugAction("Save game for everyone", SaveGameCmd);
                menu.DebugAction("Advance time", AdvanceTime);
                if (Multiplayer.game?.sync?.currentOpinion != null)
                {
                    menu.DebugAction("Force Desync", ForceDesync);
                }
            }
        }
        public void DoTable_RaidStrategySampled(Faction fac)
        {
            int ticksGame = Find.TickManager.TicksGame;

            Find.TickManager.DebugSetTicksGame(36000000);
            List <TableDataGetter <RaidStrategyDef> > list = new List <TableDataGetter <RaidStrategyDef> >();

            list.Add(new TableDataGetter <RaidStrategyDef>("defName", (RaidStrategyDef d) => d.defName));
            foreach (float num in Dialog_DebugActionsMenu.PointsOptions(false))
            {
                float points = num;
                Dictionary <RaidStrategyDef, int> strats = new Dictionary <RaidStrategyDef, int>();
                foreach (RaidStrategyDef key in DefDatabase <RaidStrategyDef> .AllDefs)
                {
                    strats.Add(key, 0);
                }
                for (int i = 0; i < 500; i++)
                {
                    IncidentParms incidentParms = new IncidentParms();
                    incidentParms.target  = Find.CurrentMap;
                    incidentParms.points  = points;
                    incidentParms.faction = fac;
                    if (this.TryResolveRaidFaction(incidentParms))
                    {
                        this.ResolveRaidStrategy(incidentParms, PawnGroupKindDefOf.Combat);
                        if (incidentParms.raidStrategy != null)
                        {
                            Dictionary <RaidStrategyDef, int> strats2;
                            RaidStrategyDef raidStrategy;
                            (strats2 = strats)[raidStrategy = incidentParms.raidStrategy] = strats2[raidStrategy] + 1;
                        }
                    }
                }
                list.Add(new TableDataGetter <RaidStrategyDef>(points.ToString("F0"), delegate(RaidStrategyDef str)
                {
                    int num2 = strats[str];
                    return(((float)num2 / 500f).ToStringPercent());
                }));
            }
            Find.TickManager.DebugSetTicksGame(ticksGame);
            DebugTables.MakeTablesDialog <RaidStrategyDef>(DefDatabase <RaidStrategyDef> .AllDefs, list.ToArray());
        }
예제 #12
0
 public static void PawnGroupsMade()
 {
     Dialog_DebugOptionListLister.ShowSimpleDebugMenu(from fac in Find.FactionManager.AllFactions
                                                      where !fac.def.pawnGroupMakers.NullOrEmpty()
                                                      select fac, (Faction fac) => fac.Name + " (" + fac.def.defName + ")", delegate(Faction fac)
     {
         StringBuilder sb = new StringBuilder();
         sb.AppendLine("FACTION: " + fac.Name + " (" + fac.def.defName + ") min=" + fac.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat));
         Action <float> action = delegate(float points)
         {
             if (!(points < fac.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat)))
             {
                 PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms
                 {
                     groupKind = PawnGroupKindDefOf.Combat,
                     tile      = Find.CurrentMap.Tile,
                     points    = points,
                     faction   = fac
                 };
                 sb.AppendLine("Group with " + pawnGroupMakerParms.points + " points (max option cost: " + MaxPawnCost(fac, points, RaidStrategyDefOf.ImmediateAttack, PawnGroupKindDefOf.Combat) + ")");
                 float num = 0f;
                 foreach (Pawn item in GeneratePawns(pawnGroupMakerParms, warnOnZeroResults: false).OrderBy((Pawn pa) => pa.kindDef.combatPower))
                 {
                     string text     = (item.equipment.Primary == null) ? "no-equipment" : item.equipment.Primary.Label;
                     Apparel apparel = item.apparel.FirstApparelOnBodyPartGroup(BodyPartGroupDefOf.Torso);
                     string text2    = (apparel == null) ? "shirtless" : apparel.LabelCap;
                     sb.AppendLine("  " + item.kindDef.combatPower.ToString("F0").PadRight(6) + item.kindDef.defName + ", " + text + ", " + text2);
                     num += item.kindDef.combatPower;
                 }
                 sb.AppendLine("         totalCost " + num);
                 sb.AppendLine();
             }
         };
         foreach (float item2 in Dialog_DebugActionsMenu.PointsOptions(extended: false))
         {
             float obj = item2;
             action(obj);
         }
         Log.Message(sb.ToString());
     });
 }
예제 #13
0
        // Verse.Dialog_DebugActionsMenu
        public static void DoListingItems_World_PostFix(Dialog_DebugActionsMenu __instance)
        {
            //Traverse.Create(__instance).Method("DoLabel", new object[] { "Tools - Spawning" });

            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DoLabel").Invoke(__instance, new object[] { "Tools - Spawning" });
            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugToolWorld").Invoke(__instance, new object[] {
                "Place Road", new Action(() =>
                                         //Traverse.Create(__instance).Method("DebugToolWorld", new object[] {"Place Road", new Action(delegate
                {
                    int num = GenWorld.MouseTile(false);
                    //Tile tile = Find.WorldGrid[num];

                    //GlobalTargetInfo startInfo = default(GlobalTargetInfo);
                    GlobalTargetInfo endInfo = default(GlobalTargetInfo);
                    //Find.WorldTargeter.StopTargeting();
                    //Find.WorldTargeter.BeginTargeting(delegate(GlobalTargetInfo t)
                    //{
                    //    startInfo = t;
                    //    return true;
                    //},
                    //    true, null, false, null, delegate(GlobalTargetInfo target)
                    //    {
                    //        return "Start Road Here.";
                    //    });

                    //Find.WorldTargeter.StopTargeting();
                    DebugTools.curTool = null;
                    Find.WorldTargeter.BeginTargeting(delegate(GlobalTargetInfo s)
                    {
                        endInfo = s;
                        Find.World.grid.OverlayRoad(num, endInfo.Tile, RoadDefOf.DirtRoad);
                        Find.World.renderer.RegenerateAllLayersNow();
                        return(true);
                    },
                                                      true, null, false, null, delegate(GlobalTargetInfo target)
                    {
                        return("End Road Here.");
                    });
                })
            });
        }
        public void DoTable_RaidArrivalModeSampled(Faction fac)
        {
            int ticksGame = Find.TickManager.TicksGame;

            Find.TickManager.DebugSetTicksGame(36000000);
            List <TableDataGetter <PawnsArrivalModeDef> > list = new List <TableDataGetter <PawnsArrivalModeDef> >();

            list.Add(new TableDataGetter <PawnsArrivalModeDef>("mode", (PawnsArrivalModeDef f) => f.defName));
            foreach (float num in Dialog_DebugActionsMenu.PointsOptions(false))
            {
                float points = num;
                Dictionary <PawnsArrivalModeDef, int> modeCount = new Dictionary <PawnsArrivalModeDef, int>();
                foreach (PawnsArrivalModeDef key in DefDatabase <PawnsArrivalModeDef> .AllDefs)
                {
                    modeCount.Add(key, 0);
                }
                for (int i = 0; i < 500; i++)
                {
                    IncidentParms incidentParms = new IncidentParms();
                    incidentParms.target  = Find.CurrentMap;
                    incidentParms.points  = points;
                    incidentParms.faction = fac;
                    if (this.TryResolveRaidFaction(incidentParms))
                    {
                        this.ResolveRaidStrategy(incidentParms, PawnGroupKindDefOf.Combat);
                        this.ResolveRaidArriveMode(incidentParms);
                        Dictionary <PawnsArrivalModeDef, int> modeCount2;
                        PawnsArrivalModeDef raidArrivalMode;
                        (modeCount2 = modeCount)[raidArrivalMode = incidentParms.raidArrivalMode] = modeCount2[raidArrivalMode] + 1;
                    }
                }
                list.Add(new TableDataGetter <PawnsArrivalModeDef>(points.ToString("F0"), delegate(PawnsArrivalModeDef str)
                {
                    int num2 = modeCount[str];
                    return(((float)num2 / 500f).ToStringPercent());
                }));
            }
            Find.TickManager.DebugSetTicksGame(ticksGame);
            DebugTables.MakeTablesDialog <PawnsArrivalModeDef>(DefDatabase <PawnsArrivalModeDef> .AllDefs, list.ToArray());
        }
        public void DoTable_RaidFactionSampled()
        {
            int ticksGame = Find.TickManager.TicksGame;

            Find.TickManager.DebugSetTicksGame(36000000);
            List <TableDataGetter <Faction> > list = new List <TableDataGetter <Faction> >();

            list.Add(new TableDataGetter <Faction>("name", (Faction f) => f.Name));
            foreach (float num in Dialog_DebugActionsMenu.PointsOptions(false))
            {
                float points = num;
                Dictionary <Faction, int> factionCount = new Dictionary <Faction, int>();
                foreach (Faction key in Find.FactionManager.AllFactions)
                {
                    factionCount.Add(key, 0);
                }
                for (int i = 0; i < 500; i++)
                {
                    IncidentParms incidentParms = new IncidentParms();
                    incidentParms.target = Find.CurrentMap;
                    incidentParms.points = points;
                    if (this.TryResolveRaidFaction(incidentParms))
                    {
                        Dictionary <Faction, int> factionCount2;
                        Faction faction;
                        (factionCount2 = factionCount)[faction = incidentParms.faction] = factionCount2[faction] + 1;
                    }
                }
                list.Add(new TableDataGetter <Faction>(points.ToString("F0"), delegate(Faction str)
                {
                    int num2 = factionCount[str];
                    return(((float)num2 / 500f).ToStringPercent());
                }));
            }
            Find.TickManager.DebugSetTicksGame(ticksGame);
            DebugTables.MakeTablesDialog <Faction>(Find.FactionManager.AllFactions, list.ToArray());
        }
        private static void <PawnGroupsMade> m__3(Faction fac)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Concat(new object[]
            {
                "FACTION: ",
                fac.Name,
                " (",
                fac.def.defName,
                ") min=",
                fac.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat)
            }));
            Action <float> action = delegate(float points)
            {
                if (points < fac.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat))
                {
                    return;
                }
                PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms();
                pawnGroupMakerParms.groupKind = PawnGroupKindDefOf.Combat;
                pawnGroupMakerParms.tile      = Find.CurrentMap.Tile;
                pawnGroupMakerParms.points    = points;
                pawnGroupMakerParms.faction   = fac;
                sb.AppendLine(string.Concat(new object[]
                {
                    "Group with ",
                    pawnGroupMakerParms.points,
                    " points (max option cost: ",
                    PawnGroupMakerUtility.MaxPawnCost(fac, points, RaidStrategyDefOf.ImmediateAttack, PawnGroupKindDefOf.Combat),
                    ")"
                }));
                float num2 = 0f;
                foreach (Pawn pawn in from pa in PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms, false)
                         orderby pa.kindDef.combatPower
                         select pa)
                {
                    string text;
                    if (pawn.equipment.Primary != null)
                    {
                        text = pawn.equipment.Primary.Label;
                    }
                    else
                    {
                        text = "no-equipment";
                    }
                    Apparel apparel = pawn.apparel.FirstApparelOnBodyPartGroup(BodyPartGroupDefOf.Torso);
                    string  text2;
                    if (apparel != null)
                    {
                        text2 = apparel.LabelCap;
                    }
                    else
                    {
                        text2 = "shirtless";
                    }
                    sb.AppendLine(string.Concat(new string[]
                    {
                        "  ",
                        pawn.kindDef.combatPower.ToString("F0").PadRight(6),
                        pawn.kindDef.defName,
                        ", ",
                        text,
                        ", ",
                        text2
                    }));
                    num2 += pawn.kindDef.combatPower;
                }
                sb.AppendLine("         totalCost " + num2);
                sb.AppendLine();
            };

            foreach (float num in Dialog_DebugActionsMenu.PointsOptions(false))
            {
                float obj = num;
                action(obj);
            }
            Log.Message(sb.ToString(), false);
        }
예제 #17
0
            static void Postfix(Dialog_DebugActionsMenu __instance, ref List <Dialog_DebugActionsMenu.DebugActionOption> ___debugActions)
            {
                // *** Force Start Reunion Event ***
                var debugAddAlly = new Dialog_DebugActionsMenu.DebugActionOption();

                debugAddAlly.actionType = DebugActionType.Action;
                debugAddAlly.label      = "Force Start Reunion Event";
                debugAddAlly.category   = CATEGORY;
                debugAddAlly.action     = delegate
                {
                    GameComponent.DecideAndDoEvent();
                };
                ___debugActions.Add(debugAddAlly);                 // add to main list

                // *** Make world pawn "Ally" ***
                debugAddAlly            = new Dialog_DebugActionsMenu.DebugActionOption();
                debugAddAlly.actionType = DebugActionType.Action;
                debugAddAlly.label      = "Make world pawn \"Ally\"...";
                debugAddAlly.category   = CATEGORY;
                debugAddAlly.action     = delegate
                {
                    List <DebugMenuOption> list       = new List <DebugMenuOption>();
                    Action <Pawn>          actionPawn = delegate(Pawn p)
                    {
                        if (p != null && p.story != null)
                        {
                            GameComponent.TryRemoveTrait(p);
                            GameComponent.ListAllyAvailable.Add(p);
                            Find.WorldPawns.RemovePawn(p);
                            Util.Msg(p.Name + " has been removed from the World and added to the Ally list.");
                            if (GameComponent.ListAllyAvailable.Count == 1)
                            {
                                GameComponent.TryScheduleNextEvent(ScheduleMode.Forced);
                            }
                        }
                    };

                    foreach (Pawn current in Find.WorldPawns.AllPawnsAlive)
                    {
                        Pawn pLocal = current;
                        if (current != null && current.story != null)                         // don't list those already with the trait
                        {
                            list.Add(new DebugMenuOption(current.LabelShort, DebugMenuOptionMode.Action, delegate
                            {
                                actionPawn(pLocal);
                            }));
                        }
                    }

                    Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
                };
                ___debugActions.Add(debugAddAlly);                 // add to main list

                // *** Print Ally List ***
                var debugPrintAllyList = new Dialog_DebugActionsMenu.DebugActionOption();

                debugPrintAllyList.actionType = DebugActionType.Action;
                debugPrintAllyList.label      = "Print \"Ally\" list";
                debugPrintAllyList.category   = CATEGORY;
                debugPrintAllyList.action     = delegate
                {
                    if (GameComponent.ListAllyAvailable.Count > 0)
                    {
                        Util.PrintAllyList();
                    }
                    else
                    {
                        Util.Msg("There are no allies in the Ally list!");
                    }
                };
                ___debugActions.Add(debugPrintAllyList);                 // add to main list
            }
예제 #18
0
        // Verse.Dialog_DebugActionsMenu
        public static void DoListingItems_MapTools_Vamp(Dialog_DebugActionsMenu __instance)
        {
            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DoLabel").Invoke(__instance, new object[] { "Tools - Vampirism" });
            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugToolMap").Invoke(__instance, new object[] {
                "Spawn Vampire (Random)", new Action(() =>
                {
                    Pawn randomVampire =
                        VampireGen.GenerateVampire(VampireUtility.RandHigherGeneration, VampireUtility.RandBloodline, null);
                    GenSpawn.Spawn(randomVampire, UI.MouseCell(), Find.CurrentMap);
                })
            });


            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugToolMap").Invoke(__instance, new object[] {
                "Give Vampirism (Default)", new Action(() =>
                {
                    Pawn pawn = Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).Where((Thing t) => t is Pawn).Cast <Pawn>().FirstOrDefault();
                    if (pawn != null)
                    {
                        if (!pawn.IsVampire())
                        {
                            pawn.health.AddHediff(VampDefOf.ROM_Vampirism, null, null);
                            pawn.Drawer.Notify_DebugAffected();
                            MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, pawn.LabelShort + " is now a vampire");
                        }
                        else
                        {
                            Messages.Message(pawn.LabelCap + " is already a vampire.", MessageTypeDefOf.RejectInput);
                        }
                    }
                })
            });

            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugToolMap").Invoke(__instance, new object[] {
                "Give Vampirism (w/Settings)", new Action(() =>
                {
                    Pawn pawn = Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).Where((Thing t) => t is Pawn).Cast <Pawn>().FirstOrDefault();
                    if (pawn != null)
                    {
                        //pawn.health.AddHediff(VampDefOf.ROM_Vampirism, null, null);
                        Find.WindowStack.Add(new Dialog_DebugOptionListLister(Options_Bloodlines(pawn)));
                        //DebugTools.curTool = null;
                    }
                })
            });



            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugToolMap").Invoke(__instance, new object[] {
                "Remove Vampirism", new Action(() =>
                {
                    Pawn pawn = Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).Where((Thing t) => t is Pawn).Cast <Pawn>().FirstOrDefault();
                    if (pawn != null)
                    {
                        if (pawn.IsVampire())
                        {
                            if (pawn.health.hediffSet.GetFirstHediffOfDef(VampDefOf.ROM_Vampirism) is HediffVampirism vampirism)
                            {
                                pawn.health.RemoveHediff(vampirism);
                            }
                            if (pawn?.health?.hediffSet?.GetHediffs <Hediff_AddedPart>()?.First() is Hediff_AddedPart_Fangs fangs)
                            {
                                BodyPartRecord rec = fangs.Part;
                                pawn.health.RemoveHediff(fangs);
                                pawn.health.RestorePart(rec);
                            }
                            pawn.Drawer.Notify_DebugAffected();
                            MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, pawn.LabelShort + " is no longer a vampire");
                        }
                        else
                        {
                            Messages.Message(pawn.LabelCap + " is already a vampire.", MessageTypeDefOf.RejectInput);
                        }
                    }
                })
            });
예제 #19
0
        static void DebugAction(this Dialog_DebugActionsMenu instance, string label, Action action)
        {
            var method = typeof(Dialog_DebugActionsMenu).GetMethod("DebugAction", BindingFlags.Instance | BindingFlags.NonPublic);

            method.Invoke(instance, new object[] { label, action });
        }
예제 #20
0
        public static void DebugActionPostfix(Dialog_DebugActionsMenu __instance)
        {
            Traverse menuTraverse = Traverse.Create(root: __instance);

            menuTraverse.Method(name: "DoGap").GetValue();
            menuTraverse.Method("DoLabel", "NightVision Testing: ").GetValue();
            menuTraverse.Method("DoLabel", "   Pawn Spawners: ").GetValue();

            menuTraverse.Method(
                "DebugAction",
                "T: AB Shoot",
                (Action) delegate
            {
                var list3 = new List <DebugMenuOption>();

                for (var i = 0; i < 4; i++)
                {
                    int skill = Math.Min(val1: i * 7, val2: 20);

                    list3.Add(
                        item: new DebugMenuOption(
                            label: "ShootSkill: " + skill,
                            mode: DebugMenuOptionMode.Action,
                            method: delegate
                    {
                        var listAB = new List <DebugMenuOption>();

                        foreach (AorB ab in ABShoot)
                        {
                            listAB.Add(
                                item: new DebugMenuOption(
                                    label: ab.label,
                                    mode: DebugMenuOptionMode.Action,
                                    method: delegate
                            {
                                var list4 = new List <DebugMenuOption>();

                                list4.Add(
                                    item: new DebugMenuOption(
                                        label: "None",
                                        mode: DebugMenuOptionMode.Tool,
                                        method: delegate
                                {
                                    SpawnPawn(
                                        skill: skill,
                                        ab: ab,
                                        hediffs: null,
                                        AffectsEye: false,
                                        skilldef: Defs_Rimworld.ShootSkill
                                        );
                                }
                                        )
                                    );

                                foreach (KeyValuePair <HediffDef, Hediff_LightModifiers> hediffDef in Settings.Store.HediffLightMods)
                                {
                                    HediffDef nvhediff = hediffDef.Key;
                                    Hediff_LightModifiers hediffMods = hediffDef.Value;

                                    list4.Add(
                                        item: new DebugMenuOption(
                                            label: nvhediff.defName,
                                            mode: DebugMenuOptionMode.Tool,
                                            method: delegate
                                    {
                                        SpawnPawn(
                                            skill: skill,
                                            ab: ab,
                                            hediffs: nvhediff,
                                            AffectsEye: hediffMods.AffectsEye,
                                            skilldef: Defs_Rimworld.ShootSkill
                                            );
                                    }
                                            )
                                        );
                                }

                                Find.WindowStack.Add(window: new Dialog_DebugOptionListLister(options: list4));
                            }
                                    )
                                );
                        }

                        Find.WindowStack.Add(window: new Dialog_DebugOptionListLister(options: listAB));
                    }
                            )
                        );
                }

                Find.WindowStack.Add(window: new Dialog_DebugOptionListLister(options: list3));
            }
                ).GetValue();

            menuTraverse.Method(
                "DebugAction",
                "T: AB Melee",
                (Action) delegate
            {
                var list3 = new List <DebugMenuOption>();

                for (var i = 0; i < 4; i++)
                {
                    int skill = Math.Min(val1: i * 7, val2: 20);

                    list3.Add(
                        item: new DebugMenuOption(
                            label: "Melee: " + skill,
                            mode: DebugMenuOptionMode.Action,
                            method: delegate
                    {
                        var listAB = new List <DebugMenuOption>();

                        foreach (AorB ab in ABMelee)
                        {
                            listAB.Add(
                                item: new DebugMenuOption(
                                    label: ab.label,
                                    mode: DebugMenuOptionMode.Action,
                                    method: delegate
                            {
                                var list4 = new List <DebugMenuOption>();

                                list4.Add(
                                    item: new DebugMenuOption(
                                        label: "None",
                                        mode: DebugMenuOptionMode.Tool,
                                        method: delegate
                                {
                                    SpawnPawn(
                                        skill: skill,
                                        ab: ab,
                                        hediffs: null,
                                        AffectsEye: false,
                                        skilldef: Defs_Rimworld.MeleeSkill
                                        );
                                }
                                        )
                                    );

                                foreach (KeyValuePair <HediffDef, Hediff_LightModifiers> hediffDef in Settings.Store.HediffLightMods)
                                {
                                    HediffDef nvhediff = hediffDef.Key;
                                    Hediff_LightModifiers hediffMods = hediffDef.Value;

                                    list4.Add(
                                        item: new DebugMenuOption(
                                            label: nvhediff.defName,
                                            mode: DebugMenuOptionMode.Tool,
                                            method: delegate
                                    {
                                        SpawnPawn(
                                            skill: skill,
                                            ab: ab,
                                            hediffs: nvhediff,
                                            AffectsEye: hediffMods.AffectsEye,
                                            skilldef: Defs_Rimworld.MeleeSkill
                                            );
                                    }
                                            )
                                        );
                                }

                                Find.WindowStack.Add(window: new Dialog_DebugOptionListLister(options: list4));
                            }
                                    )
                                );
                        }

                        Find.WindowStack.Add(window: new Dialog_DebugOptionListLister(options: listAB));
                    }
                            )
                        );
                }

                Find.WindowStack.Add(window: new Dialog_DebugOptionListLister(options: list3));
            }
                ).GetValue();

            menuTraverse.Method("DoLabel", "    Battle Royales ").GetValue();

            menuTraverse.Method(
                "DebugAction",
                "NightVision: Battle Royale Melee",
                (Action) delegate
            {
                PerformBattleRoyale(skill: Defs_Rimworld.MeleeSkill);
            }
                ).GetValue();

            menuTraverse.Method(
                "DebugAction",
                "NightVision: Battle Royale ShootSkill",
                (Action) delegate
            {
                PerformBattleRoyale(skill: Defs_Rimworld.ShootSkill);
            }
                ).GetValue();
        }
예제 #21
0
 public static void PawnGroupsMade()
 {
     Dialog_DebugOptionListLister.ShowSimpleDebugMenu <Faction>(from fac in Find.FactionManager.AllFactions
                                                                where !fac.def.pawnGroupMakers.NullOrEmpty <PawnGroupMaker>()
                                                                select fac, (Faction fac) => fac.Name + " (" + fac.def.defName + ")", delegate(Faction fac)
     {
         StringBuilder sb = new StringBuilder();
         sb.AppendLine(string.Concat(new object[]
         {
             "FACTION: ",
             fac.Name,
             " (",
             fac.def.defName,
             ") min=",
             fac.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat)
         }));
         Action <float> action = delegate(float points)
         {
             if (points < fac.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat))
             {
                 return;
             }
             PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms();
             pawnGroupMakerParms.groupKind           = PawnGroupKindDefOf.Combat;
             pawnGroupMakerParms.tile    = Find.CurrentMap.Tile;
             pawnGroupMakerParms.points  = points;
             pawnGroupMakerParms.faction = fac;
             sb.AppendLine(string.Concat(new object[]
             {
                 "Group with ",
                 pawnGroupMakerParms.points,
                 " points (max option cost: ",
                 PawnGroupMakerUtility.MaxPawnCost(fac, points, RaidStrategyDefOf.ImmediateAttack, PawnGroupKindDefOf.Combat),
                 ")"
             }));
             float num = 0f;
             foreach (Pawn current in PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms, false).OrderBy((Pawn pa) => pa.kindDef.combatPower))
             {
                 string text;
                 if (current.equipment.Primary != null)
                 {
                     text = current.equipment.Primary.Label;
                 }
                 else
                 {
                     text = "no-equipment";
                 }
                 Apparel apparel = current.apparel.FirstApparelOnBodyPartGroup(BodyPartGroupDefOf.Torso);
                 string text2;
                 if (apparel != null)
                 {
                     text2 = apparel.LabelCap;
                 }
                 else
                 {
                     text2 = "shirtless";
                 }
                 sb.AppendLine(string.Concat(new string[]
                 {
                     "  ",
                     current.kindDef.combatPower.ToString("F0").PadRight(6),
                     current.kindDef.defName,
                     ", ",
                     text,
                     ", ",
                     text2
                 }));
                 num += current.kindDef.combatPower;
             }
             sb.AppendLine("         totalCost " + num);
             sb.AppendLine();
         };
         foreach (float obj in Dialog_DebugActionsMenu.PointsOptions(false))
         {
             action(obj);
         }
         Log.Message(sb.ToString(), false);
     });
 }
예제 #22
0
        static void DebugToolMapForPawns(this Dialog_DebugActionsMenu instance, string label, Action <Pawn> pawnAction)
        {
            var method = typeof(Dialog_DebugActionsMenu).GetMethod("DebugToolMapForPawns", BindingFlags.Instance | BindingFlags.NonPublic);

            method.Invoke(instance, new object[] { label, pawnAction });
        }
        // Verse.Dialog_DebugActionsMenu
        public static void DebugMoonActions(Dialog_DebugActionsMenu __instance)
        {
            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DoLabel")
            .Invoke(__instance, new object[] { "Tools - Werewolves" });

            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugToolMap").Invoke(__instance, new object[]
            {
                "Give Lycanthropy (Normal)", new Action(() =>
                {
                    var pawn = Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).Where(t => t is Pawn)
                               .Cast <Pawn>().FirstOrDefault();
                    if (pawn == null)
                    {
                        return;
                    }

                    if (!pawn.IsWerewolf())
                    {
                        pawn.story.traits.GainTrait(new Trait(WWDefOf.ROM_Werewolf));
                        //pawn.health.AddHediff(VampDefOf.ROM_Vampirism, null, null);
                        pawn.Drawer.Notify_DebugAffected();
                        MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, pawn.LabelShort + " is now a werewolf");
                    }
                    else
                    {
                        Messages.Message(pawn.LabelCap + " is already a werewolf.", MessageTypeDefOf.RejectInput);
                    }
                }),
                false
            });

            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugToolMap").Invoke(__instance, new object[]
            {
                "Give Lycanthropy (Metis Chance)", new Action(() =>
                {
                    var pawn = Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).Where(t => t is Pawn)
                               .Cast <Pawn>().FirstOrDefault();
                    if (pawn == null)
                    {
                        return;
                    }

                    if (!pawn.IsWerewolf())
                    {
                        pawn.story.traits.GainTrait(new Trait(WWDefOf.ROM_Werewolf, -1));
                        //pawn.health.AddHediff(VampDefOf.ROM_Vampirism, null, null);
                        pawn.Drawer.Notify_DebugAffected();
                        MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, pawn.LabelShort + " is now a werewolf");
                    }
                    else
                    {
                        Messages.Message(pawn.LabelCap + " is already a werewolf.", MessageTypeDefOf.RejectInput);
                    }
                }),
                false
            });

            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugToolMap").Invoke(__instance, new object[]
            {
                "Remove Lycanthropy", new Action(() =>
                {
                    var pawn = Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).Where(t => t is Pawn)
                               .Cast <Pawn>().FirstOrDefault();
                    if (pawn == null)
                    {
                        return;
                    }

                    if (pawn.IsWerewolf())
                    {
                        if (pawn.CompWW().IsTransformed)
                        {
                            pawn.CompWW().TransformBack();
                        }

                        pawn.story.traits.allTraits.RemoveAll(x =>
                                                              x.def == WWDefOf.ROM_Werewolf); //GainTrait(new Trait(WWDefOf.ROM_Werewolf, -1));
                        //pawn.health.AddHediff(VampDefOf.ROM_Vampirism, null, null);
                        pawn.Drawer.Notify_DebugAffected();
                        MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, pawn.LabelShort + " is no longer a werewolf");
                    }
                    else
                    {
                        Messages.Message(pawn.LabelCap + " is not a werewolf.", MessageTypeDefOf.RejectInput);
                    }
                }),
                false
            });

            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugAction").Invoke(__instance, new object[]
            {
                "Regenerate Moons",
                new Action(() => Find.World.GetComponent <WorldComponent_MoonCycle>().DebugRegenerateMoons(Find.World)),
                false
            });

            AccessTools.Method(typeof(Dialog_DebugActionsMenu), "DebugAction").Invoke(__instance, new object[]
            {
                "Next Full Moon",
                new Action(() => Find.World.GetComponent <WorldComponent_MoonCycle>().DebugTriggerNextFullMoon()),
                false
            });
        }
예제 #24
0
 private static List <Dialog_DebugActionsMenu.DebugActionOption> GetList(Dialog_DebugActionsMenu __instance)
 {
     return(__instance.debugActions.Where(x => __instance.FilterAllows(x.label)).ToList());
 }