Ejemplo n.º 1
0
        public override void Resolve(ResolveParams rp)
        {
            Map     map = BaseGen.globalSettings.map;
            Faction faction;

            if ((faction = rp.faction) == null)
            {
                faction = (Find.FactionManager.RandomEnemyFaction(false, false, true, TechLevel.Industrial) ?? Find.FactionManager.RandomEnemyFaction(false, false, true, TechLevel.Undefined));
            }
            Faction  faction2 = faction;
            Rot4?    thingRot = rp.thingRot;
            Rot4     rot      = (thingRot == null) ? Rot4.Random : thingRot.Value;
            ThingDef thingDef;

            if ((thingDef = rp.mortarDef) == null)
            {
                thingDef = (from x in DefDatabase <ThingDef> .AllDefsListForReading
                            where x.category == ThingCategory.Building && x.building.IsMortar
                            select x).RandomElement <ThingDef>();
            }
            ThingDef thingDef2 = thingDef;
            IntVec3  intVec;

            if (this.TryFindMortarSpawnCell(rp.rect, rot, thingDef2, out intVec))
            {
                if (thingDef2.HasComp(typeof(CompMannable)))
                {
                    IntVec3               c = ThingUtility.InteractionCellWhenAt(thingDef2, intVec, rot, map);
                    Lord                  singlePawnLord = LordMaker.MakeNewLord(faction2, new LordJob_ManTurrets(), map, null);
                    PawnKindDef           kind           = faction2.RandomPawnKind();
                    Faction               faction3       = faction2;
                    int                   tile           = map.Tile;
                    PawnGenerationRequest value          = new PawnGenerationRequest(kind, faction3, PawnGenerationContext.NonPlayer, tile, false, false, false, false, true, true, 1f, false, true, true, true, false, false, false, null, null, null, null, null, null, null, null);
                    ResolveParams         resolveParams  = rp;
                    resolveParams.faction = faction2;
                    resolveParams.singlePawnGenerationRequest = new PawnGenerationRequest?(value);
                    resolveParams.rect           = CellRect.SingleCell(c);
                    resolveParams.singlePawnLord = singlePawnLord;
                    BaseGen.symbolStack.Push("pawn", resolveParams);
                }
                ThingDef  turret    = thingDef2;
                bool      allowEMP  = false;
                TechLevel techLevel = faction2.def.techLevel;
                ThingDef  thingDef3 = TurretGunUtility.TryFindRandomShellDef(turret, allowEMP, true, techLevel, false, 250f);
                if (thingDef3 != null)
                {
                    ResolveParams resolveParams2 = rp;
                    resolveParams2.faction               = faction2;
                    resolveParams2.singleThingDef        = thingDef3;
                    resolveParams2.singleThingStackCount = new int?(Rand.RangeInclusive(5, Mathf.Min(8, thingDef3.stackLimit)));
                    BaseGen.symbolStack.Push("thing", resolveParams2);
                }
                ResolveParams resolveParams3 = rp;
                resolveParams3.faction        = faction2;
                resolveParams3.singleThingDef = thingDef2;
                resolveParams3.rect           = CellRect.SingleCell(intVec);
                resolveParams3.thingRot       = new Rot4?(rot);
                BaseGen.symbolStack.Push("thing", resolveParams3);
            }
        }
Ejemplo n.º 2
0
        public override void Resolve(ResolveParams rp)
        {
            Map      map      = BaseGen.globalSettings.map;
            Faction  faction  = rp.faction ?? Find.FactionManager.RandomEnemyFaction(allowHidden: false, allowDefeated: false, allowNonHumanlike: true, TechLevel.Industrial) ?? Find.FactionManager.RandomEnemyFaction();
            Rot4?    thingRot = rp.thingRot;
            Rot4     rot      = (!thingRot.HasValue) ? Rot4.Random : thingRot.Value;
            ThingDef thingDef = rp.mortarDef ?? (from x in DefDatabase <ThingDef> .AllDefsListForReading
                                                 where x.category == ThingCategory.Building && x.building.IsMortar
                                                 select x).RandomElement();

            if (TryFindMortarSpawnCell(rp.rect, rot, thingDef, out IntVec3 cell))
            {
                if (thingDef.HasComp(typeof(CompMannable)))
                {
                    IntVec3               c = ThingUtility.InteractionCellWhenAt(thingDef, cell, rot, map);
                    Lord                  singlePawnLord = LordMaker.MakeNewLord(faction, new LordJob_ManTurrets(), map);
                    PawnKindDef           kind           = faction.RandomPawnKind();
                    Faction               faction2       = faction;
                    int                   tile           = map.Tile;
                    PawnGenerationRequest value          = new PawnGenerationRequest(kind, faction2, PawnGenerationContext.NonPlayer, tile, forceGenerateNewPawn: false, newborn: false, allowDead: false, allowDowned: false, canGeneratePawnRelations: true, mustBeCapableOfViolence: true, 1f, forceAddFreeWarmLayerIfNeeded: false, allowGay: true, allowFood: true, inhabitant: true);
                    ResolveParams         resolveParams  = rp;
                    resolveParams.faction = faction;
                    resolveParams.singlePawnGenerationRequest = value;
                    resolveParams.rect           = CellRect.SingleCell(c);
                    resolveParams.singlePawnLord = singlePawnLord;
                    BaseGen.symbolStack.Push("pawn", resolveParams);
                }
                ThingDef  turret    = thingDef;
                bool      allowEMP  = false;
                TechLevel techLevel = faction.def.techLevel;
                ThingDef  thingDef2 = TurretGunUtility.TryFindRandomShellDef(turret, allowEMP, mustHarmHealth: true, techLevel, allowAntigrainWarhead: false, 250f);
                if (thingDef2 != null)
                {
                    ResolveParams resolveParams2 = rp;
                    resolveParams2.faction               = faction;
                    resolveParams2.singleThingDef        = thingDef2;
                    resolveParams2.singleThingStackCount = Rand.RangeInclusive(5, Mathf.Min(8, thingDef2.stackLimit));
                    BaseGen.symbolStack.Push("thing", resolveParams2);
                }
                ResolveParams resolveParams3 = rp;
                resolveParams3.faction        = faction;
                resolveParams3.singleThingDef = thingDef;
                resolveParams3.rect           = CellRect.SingleCell(cell);
                resolveParams3.thingRot       = rot;
                BaseGen.symbolStack.Push("thing", resolveParams3);
            }
        }
Ejemplo n.º 3
0
        public override void Init()
        {
            base.Init();

            var customParams = CustomParams;

            Data.baseRadius = Mathf.InverseLerp(BaseRadiusMin, BaseRadiusMax, (float)lord.ownedPawns.Count / 50);
            Data.baseRadius = Mathf.Clamp(Data.baseRadius, BaseRadiusMin, BaseRadiusMax);
            List <Thing> list             = new List <Thing>();
            var          placedBlueprints = CustomSiegeUtility.PlaceBlueprints(Data, base.Map, lord.faction).ToList();

            for (int i = 0; i < placedBlueprints.Count; i++)
            {
                var blueprint_Build = placedBlueprints[i];
                Data.blueprints.Add(blueprint_Build);
                using (List <ThingDefCountClass> .Enumerator enumerator2 = blueprint_Build.MaterialsNeeded().GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        ThingDefCountClass cost = enumerator2.Current;
                        Thing thing             = list.FirstOrDefault((Thing t) => t.def == cost.thingDef);
                        if (thing != null)
                        {
                            thing.stackCount += cost.count;
                        }
                        else
                        {
                            Thing thing2 = ThingMaker.MakeThing(cost.thingDef, null);
                            thing2.stackCount = cost.count;
                            list.Add(thing2);
                        }
                    }
                }
                ThingDef thingDef = blueprint_Build.def.entityDefToBuild as ThingDef;
                if (thingDef != null)
                {
                    ThingDef  turret    = thingDef;
                    bool      allowEMP  = false;
                    TechLevel techLevel = lord.faction.def.techLevel;
                    ThingDef  thingDef2 = TurretGunUtility.TryFindRandomShellDef(turret, allowEMP, true, techLevel, false, 250f);
                    if (thingDef2 != null)
                    {
                        Thing thing3 = ThingMaker.MakeThing(thingDef2, null);
                        thing3.stackCount = InitalShellsPerCannon;
                        list.Add(thing3);
                    }
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                list[i].stackCount = Mathf.CeilToInt((float)list[i].stackCount * Rand.Range(1f, 1.2f));
            }
            List <List <Thing> > list2 = new List <List <Thing> >();

            for (int j = 0; j < list.Count; j++)
            {
                while (list[j].stackCount > list[j].def.stackLimit)
                {
                    int   num    = Mathf.CeilToInt((float)list[j].def.stackLimit * Rand.Range(0.9f, 0.999f));
                    Thing thing4 = ThingMaker.MakeThing(list[j].def, null);
                    thing4.stackCount   = num;
                    list[j].stackCount -= num;
                    list.Add(thing4);
                }
            }
            List <Thing> list3 = new List <Thing>();

            for (int k = 0; k < list.Count; k++)
            {
                list3.Add(list[k]);
                if (k % 2 == 1 || k == list.Count - 1)
                {
                    list2.Add(list3);
                    list3 = new List <Thing>();
                }
            }
            List <Thing> list4 = new List <Thing>();
            int          num2  = Mathf.RoundToInt(NutritionRangePerRaider.RandomInRange / customParams.mealDef.GetStatValueAbstract(StatDefOf.Nutrition) * lord.ownedPawns.Count);

            for (int l = 0; l < num2; l++)
            {
                Thing item = ThingMaker.MakeThing(customParams.mealDef, null);
                list4.Add(item);
            }
            list2.Add(list4);
            if (lord.faction.def.techLevel >= TechLevel.Industrial)
            {
                DropPodUtility.DropThingGroupsNear(Data.siegeCenter, Map, list2, 110);
            }
            else
            {
                for (int i = 0; i < list2.Count; i++)
                {
                    var group = list2[i];
                    if (DropCellFinder.TryFindDropSpotNear(Data.siegeCenter, Map, out IntVec3 pos, false, false))
                    {
                        for (int j = 0; j < group.Count; j++)
                        {
                            var thing = group[j];
                            thing.SetForbidden(true, false);
                            GenPlace.TryPlaceThing(thing, pos, Map, ThingPlaceMode.Near);
                        }
                    }
                }
            }
            Data.desiredBuilderFraction = BuilderCountFraction.RandomInRange;
        }
Ejemplo n.º 4
0
        public override void LordToilTick()
        {
            base.LordToilTick();
            var customParams = CustomParams;
            var data         = Data;

            if (lord.ticksInToil == StartBuildingDelay)
            {
                lord.CurLordToil.UpdateAllDuties();
            }
            if (lord.ticksInToil > StartBuildingDelay && lord.ticksInToil % 500 == 0)
            {
                UpdateAllDuties();
            }
            if (Find.TickManager.TicksGame % 500 == 0)
            {
                if (!(from frame in Frames
                      where !frame.Destroyed
                      select frame).Any <Frame>())
                {
                    if (!(from blue in data.blueprints
                          where !blue.Destroyed
                          select blue).Any <Blueprint>() && !base.Map.listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial).Any((Thing b) => b.Faction == lord.faction && b.def.building.buildingTags.Contains("Artillery")))
                    {
                        lord.ReceiveMemo("NoArtillery");
                        return;
                    }
                }
                var arties     = Artillery;
                int shellCount = 0;
                int foodCount  = 0;
                for (int i = 0; i < GenRadial.NumCellsInRadius(20); i++)
                {
                    IntVec3 c = data.siegeCenter + GenRadial.RadialPattern[i];
                    if (c.InBounds(Map))
                    {
                        List <Thing> thingList = c.GetThingList(Map);
                        for (int j = 0; j < thingList.Count; j++)
                        {
                            var curThing = thingList[j];
                            if (curThing.def.IsShell && arties.Any(a => CustomSiegeUtility.AcceptsShell(a, curThing.def)))
                            {
                                shellCount += curThing.stackCount;
                            }
                            if (curThing.def == customParams.mealDef)
                            {
                                foodCount += curThing.stackCount;
                            }
                        }
                    }
                }
                // Prevent the shellpocalypse today!
                if (arties.Any() && shellCount < ReplenishAtShells)
                {
                    bool allowEMP          = false;
                    var  techLevel         = lord.faction.def.techLevel;
                    var  distinctArtillery = data.artilleryCounts.Keys.ToList();
                    var  shellCountsToGive = new Dictionary <ThingDef, int>();
                    for (int i = 0; i < ShellReplenishCount; i++)
                    {
                        var      artillery = distinctArtillery.RandomElementByWeight(a => data.artilleryCounts[a]);
                        ThingDef shellDef  = TurretGunUtility.TryFindRandomShellDef(artillery, allowEMP, true, techLevel, false, 250f);
                        if (shellDef != null)
                        {
                            if (shellCountsToGive.ContainsKey(shellDef))
                            {
                                shellCountsToGive[shellDef]++;
                            }
                            else
                            {
                                shellCountsToGive.Add(shellDef, 1);
                            }
                        }
                    }
                    foreach (var shell in shellCountsToGive)
                    {
                        DropSupplies(shell.Key, shell.Value);
                    }
                }
                if (foodCount < FoodUtility.StackCountForNutrition(ReplenishAtMeals, customParams.mealDef.GetStatValueAbstract(StatDefOf.Nutrition)))
                {
                    DropSupplies(customParams.mealDef, FoodUtility.StackCountForNutrition(MealReplenishCount, customParams.mealDef.GetStatValueAbstract(StatDefOf.Nutrition)));
                }
            }
        }
        public static void GenerateRoomFromLayout(List <string> layoutList, CellRect roomRect, Map map, StructureLayoutDef rld, bool generateConduit = true)
        {
            bool parentFaction = map.ParentFaction != null;

            if (rld.roofGrid != null)
            {
                GenerateRoofGrid(rld.roofGrid, roomRect, map);
            }

            List <string> allSymbList = new List <string>();

            foreach (string str in layoutList)
            {
                allSymbList.AddRange(str.Split(','));
            }

            int l = 0;

            foreach (IntVec3 cell in roomRect)
            {
                if (l < allSymbList.Count && allSymbList[l] != ".")
                {
                    SymbolDef temp = DefDatabase <SymbolDef> .GetNamedSilentFail(allSymbList[l]);

                    Thing thing;
                    if (temp != null)
                    {
                        if (temp.isTerrain && temp.terrainDef != null)
                        {
                            GenerateTerrainAt(map, cell, temp.terrainDef);
                        }
                        else if (temp.pawnKindDefNS != null && CGO.factionSettlement?.shouldRuin == false)
                        {
                            if (temp.lordJob != null)
                            {
                                Lord lord = CreateNewLord(temp.lordJob, map, cell);
                                for (int i = 0; i < temp.numberToSpawn; i++)
                                {
                                    Pawn pawn = temp.spawnPartOfFaction ? PawnGenerator.GeneratePawn(temp.pawnKindDefNS, map.ParentFaction) : PawnGenerator.GeneratePawn(temp.pawnKindDefNS);
                                    if (pawn != null)
                                    {
                                        if (temp.isSlave && parentFaction)
                                        {
                                            pawn.guest.SetGuestStatus(map.ParentFaction, GuestStatus.Prisoner);
                                        }

                                        GenSpawn.Spawn(pawn, cell, map, WipeMode.FullRefund);
                                        lord.AddPawn(pawn);
                                    }
                                }
                            }
                            else
                            {
                                for (int i = 0; i < temp.numberToSpawn; i++)
                                {
                                    Pawn pawn = temp.spawnPartOfFaction ? PawnGenerator.GeneratePawn(temp.pawnKindDefNS, map.ParentFaction) : PawnGenerator.GeneratePawn(temp.pawnKindDefNS);
                                    if (pawn != null)
                                    {
                                        if (temp.isSlave && parentFaction)
                                        {
                                            pawn.guest.SetGuestStatus(map.ParentFaction, GuestStatus.Prisoner);
                                        }
                                        GenSpawn.Spawn(pawn, cell, map, WipeMode.FullRefund);
                                    }
                                }
                            }
                        }
                        else if (temp.thingDef?.category == ThingCategory.Item && cell.Walkable(map))
                        {
                            thing            = ThingMaker.MakeThing(temp.thingDef, temp.stuffDef ?? (temp.thingDef.stuffCategories?.Count > 0 ? GenStuff.RandomStuffFor(temp.thingDef) : null));
                            thing.stackCount = Mathf.Clamp(Rand.RangeInclusive(1, temp.thingDef.stackLimit), 1, 75);

                            CompQuality quality = thing.TryGetComp <CompQuality>();
                            quality?.SetQuality(QualityUtility.GenerateQualityBaseGen(), ArtGenerationContext.Outsider);

                            GenSpawn.Spawn(thing, cell, map, WipeMode.FullRefund);
                            thing.SetForbidden(true, false);
                        }
                        else if (temp.thingDef != null)
                        {
                            thing = ThingMaker.MakeThing(temp.thingDef, temp.thingDef.CostStuffCount > 0 ? (temp.stuffDef ?? temp.thingDef.defaultStuff ?? ThingDefOf.WoodLog) : null);

                            CompRefuelable refuelable = thing.TryGetComp <CompRefuelable>();
                            refuelable?.Refuel(refuelable.Props.fuelCapacity);

                            CompPowerBattery battery = thing.TryGetComp <CompPowerBattery>();
                            battery?.AddEnergy(battery.Props.storedEnergyMax);

                            if (thing is Building_CryptosleepCasket cryptosleepCasket && Rand.Value < temp.chanceToContainPawn)
                            {
                                Pawn pawn = GeneratePawnForContainer(temp, map);
                                if (!cryptosleepCasket.TryAcceptThing(pawn))
                                {
                                    pawn.Destroy();
                                }
                            }
                            else if (thing is Building_CorpseCasket corpseCasket && Rand.Value < temp.chanceToContainPawn)
                            {
                                Pawn pawn = GeneratePawnForContainer(temp, map);
                                if (!corpseCasket.TryAcceptThing(pawn))
                                {
                                    pawn.Destroy();
                                }
                            }
                            else if (thing is Building_Crate crate)
                            {
                                List <Thing> thingList = new List <Thing>();
                                if (map.ParentFaction == Faction.OfPlayer && temp.thingSetMakerDefForPlayer != null)
                                {
                                    thingList = temp.thingSetMakerDefForPlayer.root.Generate(new ThingSetMakerParams());
                                }
                                else if (temp.thingSetMakerDef != null)
                                {
                                    thingList = temp.thingSetMakerDef.root.Generate(new ThingSetMakerParams());
                                }

                                foreach (Thing t in thingList)
                                {
                                    t.stackCount = Math.Min((int)(t.stackCount * temp.crateStackMultiplier), t.def.stackLimit);
                                }

                                thingList.ForEach(t =>
                                {
                                    if (!crate.TryAcceptThing(t, false))
                                    {
                                        t.Destroy();
                                    }
                                });
                            }

                            if (thing.def.category == ThingCategory.Pawn && CGO.factionSettlement?.shouldRuin == true)
                            {
                                l++;
                                continue;
                            }
                            else if (cell.GetFirstMineable(map) is Mineable m && thing.def.designationCategory == DesignationCategoryDefOf.Security)
                            {
                                l++;
                                continue;
                            }
                            else if (thing.def.category == ThingCategory.Plant && cell.GetTerrain(map).fertility > 0.5 && cell.Walkable(map)) // If it's a plant
                            {
                                Plant plant = thing as Plant;
                                plant.Growth = temp.plantGrowth; // apply the growth
                                GenSpawn.Spawn(plant, cell, map, WipeMode.VanishOrMoveAside);
                            }
                            else if (thing.def.category == ThingCategory.Building)
                            {
                                if (!cell.GetTerrain(map).affordances.Contains(TerrainAffordanceDefOf.Heavy))
                                {
                                    if (thing.def.building.isNaturalRock)
                                    {
                                        TerrainDef t = DefDatabase <TerrainDef> .GetNamedSilentFail($"{thing.def.defName}_Rough");

                                        map.terrainGrid.SetTerrain(cell, t ?? TerrainDefOf.Soil);
                                        foreach (IntVec3 intVec3 in CellRect.CenteredOn(cell, 1))
                                        {
                                            if (!intVec3.GetTerrain(map).BuildableByPlayer)
                                            {
                                                map.terrainGrid.SetTerrain(intVec3, t ?? TerrainDefOf.Soil);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        map.terrainGrid.SetTerrain(cell, TerrainDefOf.Bridge);
                                    }
                                }

                                if (thing.def.rotatable)
                                {
                                    GenSpawn.Spawn(thing, cell, map, new Rot4(temp.rotation.AsInt), WipeMode.VanishOrMoveAside);
                                }
                                else
                                {
                                    GenSpawn.Spawn(thing, cell, map, WipeMode.VanishOrMoveAside);
                                }

                                if (parentFaction)
                                {
                                    thing.SetFactionDirect(map.ParentFaction);
                                }
                            }

                            if (generateConduit && rld.spawnConduits && !thing.def.mineable && (thing.def.passability == Traversability.Impassable || thing.def.IsDoor) && map.ParentFaction?.def.techLevel >= TechLevel.Industrial) // Add power cable under all impassable
                            {
                                Thing c = ThingMaker.MakeThing(ThingDefOf.PowerConduit);
                                if (parentFaction)
                                {
                                    c.SetFactionDirect(map.ParentFaction);
                                }
                                GenSpawn.Spawn(c, cell, map, WipeMode.FullRefund);
                            }
                            // Handle mortar and mortar pawns
                            if (thing?.def?.building?.buildingTags?.Count > 0)
                            {
                                if (thing.def.building.IsMortar && thing.def.category == ThingCategory.Building && thing.def.building.buildingTags.Contains("Artillery_MannedMortar") && thing.def.HasComp(typeof(CompMannable)) && parentFaction)
                                {
                                    // Spawn pawn
                                    Lord singlePawnLord          = LordMaker.MakeNewLord(map.ParentFaction, new LordJob_ManTurrets(), map, null);
                                    PawnGenerationRequest value  = new PawnGenerationRequest(map.ParentFaction.RandomPawnKind(), map.ParentFaction, PawnGenerationContext.NonPlayer, map.Tile, mustBeCapableOfViolence: true, inhabitant: true);
                                    ResolveParams         rpPawn = new ResolveParams
                                    {
                                        faction = map.ParentFaction,
                                        singlePawnGenerationRequest = new PawnGenerationRequest?(value),
                                        rect           = CellRect.SingleCell(thing.InteractionCell),
                                        singlePawnLord = singlePawnLord
                                    };
                                    BaseGen.symbolStack.Push("pawn", rpPawn);
                                    // Spawn shells
                                    ThingDef shellDef = TurretGunUtility.TryFindRandomShellDef(thing.def, false, true, map.ParentFaction.def.techLevel, false, 250f);
                                    if (shellDef != null)
                                    {
                                        ResolveParams rpShell = new ResolveParams
                                        {
                                            faction               = map.ParentFaction,
                                            singleThingDef        = shellDef,
                                            singleThingStackCount = Rand.RangeInclusive(8, Math.Min(12, shellDef.stackLimit))
                                        };
                                        BaseGen.symbolStack.Push("thing", rpShell);
                                    }
                                }
                            }
                        }
Ejemplo n.º 6
0
        static bool Prefix(LordToil_Siege __instance)
        {
            LordToilTick(__instance);
            LordToilData_Siege data = __instance.Data;

            if (__instance.lord.ticksInToil == 450)
            {
                __instance.lord.CurLordToil.UpdateAllDuties();
            }
            if (__instance.lord.ticksInToil > 450 && __instance.lord.ticksInToil % 500 == 0)
            {
                __instance.UpdateAllDuties();
            }
            if (Find.TickManager.TicksGame % 500 > RefcellRespeedConfig.currentTimeMultiplier - 1)
            {
                return(false);
            }
            if (!__instance.Frames.Where <Frame>((Func <Frame, bool>)(frame => !frame.Destroyed)).Any <Frame>() && (!data.blueprints.Where <Blueprint>((Func <Blueprint, bool>)(blue => !blue.Destroyed)).Any <Blueprint>() && !__instance.Map.listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial).Any <Thing>((Predicate <Thing>)(b => b.Faction == __instance.lord.faction && b.def.building.buildingTags.Contains("Artillery")))))
            {
                __instance.lord.ReceiveMemo("NoArtillery");
            }
            else
            {
                int num1 = GenRadial.NumCellsInRadius(20f);
                int num2 = 0;
                int num3 = 0;
                for (int index1 = 0; index1 < num1; ++index1)
                {
                    IntVec3 c = data.siegeCenter + GenRadial.RadialPattern[index1];
                    if (c.InBounds(__instance.Map))
                    {
                        List <Thing> thingList = c.GetThingList(__instance.Map);
                        for (int index2 = 0; index2 < thingList.Count; ++index2)
                        {
                            if (thingList[index2].def.IsShell)
                            {
                                num2 += thingList[index2].stackCount;
                            }
                            if (thingList[index2].def == ThingDefOf.MealSurvivalPack)
                            {
                                num3 += thingList[index2].stackCount;
                            }
                        }
                    }
                }
                if (num2 < 4)
                {
                    ThingDef randomShellDef = TurretGunUtility.TryFindRandomShellDef(ThingDefOf.Turret_Mortar, false, techLevel: __instance.lord.faction.def.techLevel, maxMarketValue: 250f);
                    if (randomShellDef != null)
                    {
                        __instance.DropSupplies(randomShellDef, 6);
                    }
                }
                if (num3 >= 5)
                {
                    return(false);
                }
                __instance.DropSupplies(ThingDefOf.MealSurvivalPack, 12);
            }
            return(false);
        }