Ejemplo n.º 1
0
        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 item in DebugActionsUtility.PointsOptions(extended: false))
            {
                Dictionary <Faction, int> factionCount = new Dictionary <Faction, int>();
                foreach (Faction allFaction in Find.FactionManager.AllFactions)
                {
                    factionCount.Add(allFaction, 0);
                }
                for (int i = 0; i < 500; i++)
                {
                    IncidentParms incidentParms = new IncidentParms();
                    incidentParms.target = Find.CurrentMap;
                    incidentParms.points = item;
                    if (TryResolveRaidFaction(incidentParms))
                    {
                        factionCount[incidentParms.faction]++;
                    }
                }
                list.Add(new TableDataGetter <Faction>(item.ToString("F0"), (Faction str) => ((float)factionCount[str] / 500f).ToStringPercent()));
            }
            Find.TickManager.DebugSetTicksGame(ticksGame);
            DebugTables.MakeTablesDialog(Find.FactionManager.AllFactions, list.ToArray());
        }
Ejemplo n.º 2
0
        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 item in DebugActionsUtility.PointsOptions(extended: false))
            {
                Dictionary <RaidStrategyDef, int> strats = new Dictionary <RaidStrategyDef, int>();
                foreach (RaidStrategyDef allDef in DefDatabase <RaidStrategyDef> .AllDefs)
                {
                    strats.Add(allDef, 0);
                }
                for (int i = 0; i < 500; i++)
                {
                    IncidentParms incidentParms = new IncidentParms();
                    incidentParms.target  = Find.CurrentMap;
                    incidentParms.points  = item;
                    incidentParms.faction = fac;
                    if (TryResolveRaidFaction(incidentParms))
                    {
                        ResolveRaidStrategy(incidentParms, PawnGroupKindDefOf.Combat);
                        if (incidentParms.raidStrategy != null)
                        {
                            strats[incidentParms.raidStrategy]++;
                        }
                    }
                }
                list.Add(new TableDataGetter <RaidStrategyDef>(item.ToString("F0"), (RaidStrategyDef str) => ((float)strats[str] / 500f).ToStringPercent()));
            }
            Find.TickManager.DebugSetTicksGame(ticksGame);
            DebugTables.MakeTablesDialog(DefDatabase <RaidStrategyDef> .AllDefs, list.ToArray());
        }
Ejemplo n.º 3
0
        public static void MechClusterBuildingSelection()
        {
            List <DebugMenuOption> list = new List <DebugMenuOption>();

            foreach (float item in DebugActionsUtility.PointsOptions(extended: false))
            {
                float localPoints = item;
                list.Add(new DebugMenuOption(item.ToString("F0"), DebugMenuOptionMode.Action, delegate
                {
                    string text = "";
                    for (int i = 0; i < 50; i++)
                    {
                        int num = Rand.Range(10, 20);
                        List <ThingDef> buildingDefsForCluster_NewTemp = GetBuildingDefsForCluster_NewTemp(localPoints, new IntVec2(num, num), canBeDormant: true, localPoints);
                        text = text + "points: " + localPoints + " , size: " + num;
                        foreach (ThingDef item2 in buildingDefsForCluster_NewTemp)
                        {
                            text = text + "\n- " + item2.defName;
                        }
                        text += "\n\n";
                    }
                    Log.Message(text);
                }));
            }
            Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
        }
Ejemplo n.º 4
0
        private static void ExecuteRaidWithFaction()
        {
            StorytellerComp        storytellerComp = Find.Storyteller.storytellerComps.First((StorytellerComp x) => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain);
            IncidentParms          parms           = storytellerComp.GenerateParms(IncidentCategoryDefOf.ThreatBig, Find.CurrentMap);
            List <DebugMenuOption> list            = new List <DebugMenuOption>();

            foreach (Faction localFac2 in Find.FactionManager.AllFactions)
            {
                Faction localFac = localFac2;
                list.Add(new DebugMenuOption(localFac.Name + " (" + localFac.def.defName + ")", DebugMenuOptionMode.Action, delegate()
                {
                    parms.faction = localFac;
                    List <DebugMenuOption> list2 = new List <DebugMenuOption>();
                    foreach (float num in DebugActionsUtility.PointsOptions(true))
                    {
                        float localPoints = num;
                        list2.Add(new DebugMenuOption(num + " points", DebugMenuOptionMode.Action, delegate()
                        {
                            parms.points = localPoints;
                            IEnumerable <RaidStrategyDef> allDefs  = DefDatabase <RaidStrategyDef> .AllDefs;
                            Func <RaidStrategyDef, bool> predicate = ((RaidStrategyDef s) => s.Worker.CanUseWith(parms, PawnGroupKindDefOf.Combat));
                            List <RaidStrategyDef> source          = allDefs.Where(predicate).ToList();
                            Log.Message("Available strategies: " + string.Join(", ", (from s in source
                                                                                      select s.defName).ToArray <string>()));
                            parms.raidStrategy = VehicleRaidStrategyDefOf.ArmoredAttack;
                            if (parms.raidStrategy != null)
                            {
                                Log.Message("Strategy: " + parms.raidStrategy.defName);
                                IEnumerable <PawnsArrivalModeDef> allDefs2 = DefDatabase <PawnsArrivalModeDef> .AllDefs;

                                parms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn;                                //source2.RandomElement<PawnsArrivalModeDef>();
                                Log.Message("Arrival mode: " + parms.raidArrivalMode.defName);
                            }
                            IncidentDef incidentDef;
                            if (parms.faction.HostileTo(Faction.OfPlayer))
                            {
                                incidentDef = IncidentDefOf.RaidEnemy;
                            }
                            else
                            {
                                incidentDef = IncidentDefOf.RaidFriendly;
                            }
                            incidentDef.Worker.TryExecute(parms);
                        }));
                    }
                    Find.WindowStack.Add(new Dialog_DebugOptionListLister(list2));
                }));
            }
            Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
        }
        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 points in DebugActionsUtility.PointsOptions(false))
            {
                Dictionary <RaidStrategyDef, int> strats = new Dictionary <RaidStrategyDef, int>();
                foreach (RaidStrategyDef current in DefDatabase <RaidStrategyDef> .AllDefs)
                {
                    strats.Add(current, 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 num = strats[str];
                    return(((float)num / 500f).ToStringPercent());
                }));
            }
            Find.TickManager.DebugSetTicksGame(ticksGame);
            DebugTables.MakeTablesDialog <RaidStrategyDef>(DefDatabase <RaidStrategyDef> .AllDefs, list.ToArray());
        }
 public static void PawnGroupsMade()
 {
     Dialog_DebugOptionListLister.ShowSimpleDebugMenu(Find.FactionManager.AllFactions.Where((Faction fac) => !fac.def.pawnGroupMakers.NullOrEmpty()), (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 from pa in GeneratePawns(pawnGroupMakerParms, warnOnZeroResults: false)
                          orderby pa.kindDef.combatPower
                          select pa)
                 {
                     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 DebugActionsUtility.PointsOptions(extended: false))
         {
             action(item2);
         }
         Log.Message(sb.ToString());
     });
 }
        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 points in DebugActionsUtility.PointsOptions(false))
            {
                Dictionary <PawnsArrivalModeDef, int> modeCount = new Dictionary <PawnsArrivalModeDef, int>();
                foreach (PawnsArrivalModeDef current in DefDatabase <PawnsArrivalModeDef> .AllDefs)
                {
                    modeCount.Add(current, 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 num = modeCount[str];
                    return(((float)num / 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 points in DebugActionsUtility.PointsOptions(false))
            {
                Dictionary <Faction, int> factionCount = new Dictionary <Faction, int>();
                foreach (Faction current in Find.FactionManager.AllFactions)
                {
                    factionCount.Add(current, 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 num = factionCount[str];
                    return(((float)num / 500f).ToStringPercent());
                }));
            }
            Find.TickManager.DebugSetTicksGame(ticksGame);
            DebugTables.MakeTablesDialog <Faction>(Find.FactionManager.AllFactions, list.ToArray());
        }
        public static void FlareRaidPawnGroupsMade()
        {
            Dialog_DebugOptionListLister.ShowSimpleDebugMenu(
                elements : from fac in Find.FactionManager.AllFactions
                where !fac.def.pawnGroupMakers.NullOrEmpty() && fac.def.humanlikeFaction && fac.def.techLevel >= TechLevel.Industrial
                select fac,
                label : fac => fac.Name + " (" + fac.def.defName + ")",
                chosen : delegate(Faction fac)
            {
                var sb = new StringBuilder();
                sb.AppendLine($"Point multiplier = ;{SolarRaidGroupMaker.PointMultiplier};;Max pawn cost multiplier = ;{SolarRaidGroupMaker.MaxPawnCostMultiplier};;");
                float minPointsToGen = fac.def.MinPointsToGeneratePawnGroup(groupKind: PawnGroupKindDefOf.Combat);
                sb.AppendLine($"Faction =;{fac.def.defName};;Min pts to gen CombatGroup = ;{minPointsToGen};;");

                Action <float> action = delegate(float points)
                {
                    if (points < fac.def.MinPointsToGeneratePawnGroup(groupKind: PawnGroupKindDefOf.Combat))
                    {
                        return;
                    }

                    float originalPoints = points;
                    points = IncidentWorker_Raid.AdjustedRaidPoints(
                        points,
                        PawnsArrivalModeDefOf.CenterDrop,
                        RaidStrategyDefOf.ImmediateAttack,
                        fac,
                        PawnGroupKindDefOf.Combat
                        );
                    var pawnGroupMakerParms = new PawnGroupMakerParms
                    {
                        groupKind    = PawnGroupKindDefOf.Combat,
                        tile         = Find.CurrentMap.Tile,
                        points       = points,
                        faction      = fac,
                        raidStrategy = RaidStrategyDefOf.ImmediateAttack
                    };
                    pawnGroupMakerParms.groupKind = PawnGroupKindDefOf.Combat;



                    float maxPawnCost = PawnGroupMakerUtility.MaxPawnCost(
                        faction: fac,
                        totalPoints: points,
                        raidStrategy: RaidStrategyDefOf.ImmediateAttack,
                        groupKind: PawnGroupKindDefOf.Combat
                        );
                    sb.AppendLine(
                        value:
                        $"Adjusted Points =;{pawnGroupMakerParms.points};Original points;{originalPoints};Max pawn cost;{maxPawnCost};");

                    //Points: X; MaxPawnCost:
                    //$"{};{};{};{};{};{}"
                    //150;   Mercenary_Slasher; Gladius;  Y; Apparel_FlakJacket; NV_tinted_goggles
                    var num2 = 0f;
                    SolarRaidGroupMaker.TryGetRandomPawnGroupMaker(parms: pawnGroupMakerParms, out var groupMaker);
                    Log.Message(new string('-', 20));
                    Log.Message($"Random group maker result:");
                    Log.Message($"points = {points}");

                    Log.Message($"groupMaker. = {groupMaker.options.ConvertAll(opt => opt.kind.LabelCap).ToStringSafeEnumerable()}");
                    Log.Message(new string('-', 20));


                    foreach (Pawn pawn in SolarRaid_PawnGenerator.GeneratePawns(parms: pawnGroupMakerParms, groupMaker, false)
                             .OrderBy(keySelector: pa => pa.kindDef.combatPower))
                    {
                        sb.Append($"  {pawn.kindDef.combatPower.ToString(format: "F0").PadRight(totalWidth: 6)};{pawn.kindDef.LabelCap};");

                        if (pawn.equipment.Primary != null)
                        {
                            pawn.equipment.AllEquipmentListForReading.Aggregate(sb, (builder, comps) => builder.Append(comps.def.LabelCap + ","));
                        }
                        else
                        {
                            sb.Append("no equipment");
                        }

                        sb.Append(";");

                        var wornApparel  = pawn.apparel.WornApparel;
                        string torsoGear = "";
                        string eyeWear   = "";
                        string shield    = "";
                        for (int i = 0; i < wornApparel.Count; i++)
                        {
                            Apparel apparel = wornApparel[i];
                            for (int j = 0; j < apparel.def.apparel.bodyPartGroups.Count; j++)
                            {
                                if (apparel.def.apparel.bodyPartGroups[j] == BodyPartGroupDefOf.Torso)
                                {
                                    torsoGear += $"{apparel.def.LabelCap}, ";
                                }
                                else if (apparel.def.apparel.bodyPartGroups[j] == BodyPartGroupDefOf.Eyes)
                                {
                                    eyeWear += $"{apparel.def.LabelCap}, ";
                                }

                                if (apparel is ShieldBelt && shield.NullOrEmpty())
                                {
                                    shield = $"Y;";
                                }
                            }
                        }

                        torsoGear = torsoGear.NullOrEmpty() ? "shirtless" : torsoGear.TrimEnd(' ', ',');

                        eyeWear = eyeWear.NullOrEmpty() ? "not bespectacled" : eyeWear.TrimEnd(' ', ',');

                        shield = shield.NullOrEmpty() ? "N" : shield;


                        sb.Append($"{shield};{torsoGear};{eyeWear};");

                        if (pawn.health.hediffSet.hediffs.Count > 0)
                        {
                            pawn.health.hediffSet.hediffs.Aggregate(sb, (builder, comps) => builder.Append(comps.def.LabelCap + ","));
                        }
                        else
                        {
                            sb.Append("no hediffs");
                        }

                        sb.AppendLine();
                        num2 += pawn.kindDef.combatPower;
                    }

                    sb.AppendLine($";;;;Final point cost;{num2};");
                    sb.AppendLine();
                };

                foreach (float num in /*Dialog_DebugActionsMenu*/ DebugActionsUtility.PointsOptions(extended: false))
                {
                    float obj = num;
                    action(obj: obj);
                }

                Log.Message(text: sb.ToString());
#if DEBUG
                GUIUtility.systemCopyBuffer = sb.ToString();
#endif
            }
                );
        }
        public static void FlareRaidPawnGroupsMadeToXml()
        {
            Dialog_DebugOptionListLister.ShowSimpleDebugMenu(
                elements: new List <int>
            {
                11,
                12,
                13,
                14,
                21,
                22,
                23,
                24,
                31,
                32,
                33,
                34,
                41,
                42,
                43,
                44
            },
                label : i => $"Points x{i / 10} | MaxPawn x{i % 10}",
                chosen : delegate(int multi)
            {
                var trialData = new pawnGenTrial();
                SolarRaidGroupMaker.PointMultiplier       = multi / 10;
                SolarRaidGroupMaker.MaxPawnCostMultiplier = multi % 10;

                trialData.pointMultiplier       = SolarRaidGroupMaker.PointMultiplier;
                trialData.maxPawnCostMultiplier = SolarRaidGroupMaker.MaxPawnCostMultiplier;
                trialData.trialID = $"{multi}PawnGenTrial{Rand.Int}";

                var factions = Find.FactionManager.AllFactions.Where(
                    fac => !fac.def.pawnGroupMakers.NullOrEmpty() && fac.def.humanlikeFaction && fac.def.techLevel >= TechLevel.Industrial
                    ).ToList();

                int numTrials   = factions.Count;
                trialData.trial = new pawnGenTrialTrial[numTrials];

                for (var ind = 0; ind < factions.Count; ind++)
                {
                    Faction fac             = factions[ind];
                    pawnGenTrialTrial trial = new pawnGenTrialTrial
                    {
                        factionName = fac.def.LabelCap,
                        minPointsToGenCombatGroup =
                            fac.def.MinPointsToGeneratePawnGroup(groupKind: PawnGroupKindDefOf.Combat)
                    };


                    List <float> floats  = DebugActionsUtility.PointsOptions(extended: false).ToList();
                    trial.groupGenerated = new pawnGenTrialTrialGroupGenerated[floats.Count];

                    for (var index = 0; index < floats.Count; index++)
                    {
                        float num = floats[index];
                        float obj = num;
                        trial.groupGenerated[index] = groupGenerated(fac: fac, obj);
                    }

                    trialData.trial[ind] = trial;
                }

                XmlSerializer mySerializer = new
                                             XmlSerializer(typeof(pawnGenTrial));

                using (var writer = new StreamWriter("pawnGenData" + Rand.Int + ".xml"))
                {
                    mySerializer.Serialize(writer, trialData);
                }
            }
                );
        }