Esempio n. 1
0
        private static void TestForceKillx100()
        {
            int  num = 0;
            Pawn pawn;

            while (true)
            {
                if (num < 100)
                {
                    PawnKindDef random = DefDatabase <PawnKindDef> .GetRandom();

                    pawn = PawnGenerator.GeneratePawn(random, FactionUtility.DefaultFactionFrom(random.defaultFactionType));
                    GenSpawn.Spawn(pawn, CellFinderLoose.RandomCellWith((IntVec3 c) => c.Standable(Find.CurrentMap), Find.CurrentMap), Find.CurrentMap);
                    HealthUtility.DamageUntilDead(pawn);
                    if (!pawn.Dead)
                    {
                        break;
                    }
                    num++;
                    continue;
                }
                return;
            }
            Log.Error("Pawn died not die: " + pawn + " at " + pawn.Position);
        }
Esempio n. 2
0
        public static IntVec3 TryFindCentralCell(Map map, int tightness, int minCellCount, Predicate <IntVec3> extraValidator = null)
        {
            int debug_numStand            = 0;
            int debug_numRoom             = 0;
            int debug_numTouch            = 0;
            int debug_numRoomCellCount    = 0;
            int debug_numExtraValidator   = 0;
            Predicate <IntVec3> validator = delegate(IntVec3 c)
            {
                if (!c.Standable(map))
                {
                    debug_numStand++;
                    return(false);
                }
                Room room = c.GetRoom(map, RegionType.Set_Passable);
                if (room == null)
                {
                    debug_numRoom++;
                    return(false);
                }
                if (!room.TouchesMapEdge)
                {
                    debug_numTouch++;
                    return(false);
                }
                if (room.CellCount < minCellCount)
                {
                    debug_numRoomCellCount++;
                    return(false);
                }
                if (extraValidator != null && !extraValidator(c))
                {
                    debug_numExtraValidator++;
                    return(false);
                }
                return(true);
            };

            for (int num = tightness; num >= 1; num--)
            {
                IntVec3 size            = map.Size;
                int     num2            = size.x / num;
                IntVec3 size2           = map.Size;
                int     minEdgeDistance = (size2.x - num2) / 2;
                IntVec3 result          = default(IntVec3);
                if (CellFinderLoose.TryFindRandomNotEdgeCellWith(minEdgeDistance, validator, map, out result))
                {
                    return(result);
                }
            }
            Log.Error("Found no good central spot. Choosing randomly. numStand=" + debug_numStand + ", numRoom=" + debug_numRoom + ", numTouch=" + debug_numTouch + ", numRoomCellCount=" + debug_numRoomCellCount + ", numExtraValidator=" + debug_numExtraValidator);
            return(CellFinderLoose.RandomCellWith((IntVec3 x) => x.Standable(map), map, 1000));
        }
        private static void TestForceKillx100()
        {
            for (int i = 0; i < 100; i++)
            {
                PawnKindDef random = DefDatabase <PawnKindDef> .GetRandom();

                Pawn pawn = PawnGenerator.GeneratePawn(random, FactionUtility.DefaultFactionFrom(random.defaultFactionType));
                GenSpawn.Spawn(pawn, CellFinderLoose.RandomCellWith((IntVec3 c) => c.Standable(Find.CurrentMap), Find.CurrentMap), Find.CurrentMap);
                HealthUtility.DamageUntilDead(pawn);
                if (!pawn.Dead)
                {
                    Log.Error(string.Concat("Pawn died not die: ", pawn, " at ", pawn.Position));
                    break;
                }
            }
        }
Esempio n. 4
0
        private static void TestSurgeryFailRidiculousx100()
        {
            for (int i = 0; i < 100; i++)
            {
                PawnKindDef random = DefDatabase <PawnKindDef> .GetRandom();

                Pawn pawn = PawnGenerator.GeneratePawn(random, FactionUtility.DefaultFactionFrom(random.defaultFactionType));
                GenSpawn.Spawn(pawn, CellFinderLoose.RandomCellWith((IntVec3 c) => c.Standable(Find.CurrentMap), Find.CurrentMap), Find.CurrentMap);
                pawn.health.forceIncap = true;
                HealthUtility.GiveInjuriesOperationFailureRidiculous(pawn);
                pawn.health.forceIncap = false;
                if (pawn.Dead)
                {
                    Log.Error("Pawn died: " + pawn + " at " + pawn.Position);
                }
            }
        }
Esempio n. 5
0
        private static void TestSurgeryFailCatastrophicx100()
        {
            for (int i = 0; i < 100; i++)
            {
                PawnKindDef random = DefDatabase <PawnKindDef> .GetRandom();

                Pawn pawn = PawnGenerator.GeneratePawn(random, FactionUtility.DefaultFactionFrom(random.defaultFactionType));
                GenSpawn.Spawn(pawn, CellFinderLoose.RandomCellWith((IntVec3 c) => c.Standable(Find.CurrentMap), Find.CurrentMap), Find.CurrentMap);
                pawn.health.forceIncap = true;
                BodyPartRecord part = pawn.health.hediffSet.GetNotMissingParts().RandomElement();
                HealthUtility.GiveInjuriesOperationFailureCatastrophic(pawn, part);
                pawn.health.forceIncap = false;
                if (pawn.Dead)
                {
                    Log.Error("Pawn died: " + pawn + " at " + pawn.Position);
                }
            }
        }
Esempio n. 6
0
        public static IntVec3 TryFindCentralCell(Map map, int tightness, int minCellCount, Predicate <IntVec3> extraValidator = null)
        {
            int debug_numStand            = 0;
            int debug_numRoom             = 0;
            int debug_numTouch            = 0;
            int debug_numRoomCellCount    = 0;
            int debug_numExtraValidator   = 0;
            Predicate <IntVec3> validator = delegate(IntVec3 c)
            {
                if (!c.Standable(map))
                {
                    debug_numStand++;
                    return(false);
                }
                Room room = c.GetRoom(map, RegionType.Set_Passable);
                if (room == null)
                {
                    debug_numRoom++;
                    return(false);
                }
                if (!room.TouchesMapEdge)
                {
                    debug_numTouch++;
                    return(false);
                }
                if (room.CellCount < minCellCount)
                {
                    debug_numRoomCellCount++;
                    return(false);
                }
                if (extraValidator != null && !extraValidator(c))
                {
                    debug_numExtraValidator++;
                    return(false);
                }
                return(true);
            };

            for (int i = tightness; i >= 1; i--)
            {
                int     num             = map.Size.x / i;
                int     minEdgeDistance = (map.Size.x - num) / 2;
                IntVec3 result;
                if (CellFinderLoose.TryFindRandomNotEdgeCellWith(minEdgeDistance, validator, map, out result))
                {
                    return(result);
                }
            }
            Log.Error(string.Concat(new object[]
            {
                "Found no good central spot. Choosing randomly. numStand=",
                debug_numStand,
                ", numRoom=",
                debug_numRoom,
                ", numTouch=",
                debug_numTouch,
                ", numRoomCellCount=",
                debug_numRoomCellCount,
                ", numExtraValidator=",
                debug_numExtraValidator
            }), false);
            return(CellFinderLoose.RandomCellWith((IntVec3 x) => x.Standable(map), map, 1000));
        }