Esempio n. 1
0
        public static void GenerateMortarZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            IntVec3 origin        = Zone.GetZoneOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd);
            IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation);

            // Spawn floor.
            for (int xOffset = 0; xOffset <= 10; xOffset++)
            {
                for (int zOffset = 0; zOffset <= 10; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            OG_Common.GenerateHorizontalAndVerticalPavedAlleys(origin);
            for (int xOffset = 7; xOffset <= 9; xOffset++)
            {
                for (int zOffset = 1; zOffset <= 3; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("MetalTile"));
                }
            }
            for (int xOffset = 6; xOffset <= 9; xOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, 2).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }

            // Spawn sandbags.
            for (int xOffset = 0; xOffset <= 4; xOffset++)
            {
                OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, rotatedOrigin + new IntVec3(xOffset, 0, 0).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
                OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, rotatedOrigin + new IntVec3(xOffset, 0, 10).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            }
            for (int xOffset = 6; xOffset <= 10; xOffset++)
            {
                OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, rotatedOrigin + new IntVec3(xOffset, 0, 10).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            }
            for (int zOffset = 0; zOffset <= 4; zOffset++)
            {
                OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, rotatedOrigin + new IntVec3(0, 0, zOffset).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            }
            for (int zOffset = 6; zOffset <= 10; zOffset++)
            {
                OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, rotatedOrigin + new IntVec3(0, 0, zOffset).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
                OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, rotatedOrigin + new IntVec3(10, 0, zOffset).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            }

            // Spawn mortars.
            OG_Common.TrySpawnThingAt(ThingDef.Named("Turret_MortarBomb"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(3, 0, 3).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("Turret_MortarBomb"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(2, 0, 7).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("Turret_MortarBomb"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(7, 0, 7).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);

            // Generate ammunition stockpile.
            for (int xOffset = 6; xOffset <= 10; xOffset++)
            {
                OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(xOffset, 0, 0).RotatedBy(rotation), ref outpostData);
                OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(xOffset, 0, 4).RotatedBy(rotation), ref outpostData);
            }
            for (int zOffset = 0; zOffset <= 4; zOffset++)
            {
                OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(6, 0, zOffset).RotatedBy(rotation), ref outpostData);
                OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(10, 0, zOffset).RotatedBy(rotation), ref outpostData);
            }
            for (int xOffset = 6; xOffset <= 10; xOffset++)
            {
                for (int zOffset = 0; zOffset <= 4; zOffset++)
                {
                    Find.RoofGrid.SetRoof(rotatedOrigin + new IntVec3(10, 0, zOffset).RotatedBy(rotation), OG_Util.IronedRoofDef);
                }
            }
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(6, 0, 2).RotatedBy(rotation), ref outpostData);
            Building_Storage rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(9, 0, 3).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData) as Building_Storage;

            foreach (IntVec3 cell in rack.OccupiedRect().Cells)
            {
                OG_Common.SpawnResourceAt(ThingDefOf.ArtilleryShell, ThingDefOf.ArtilleryShell.stackLimit, cell, true);
            }
            rack.GetStoreSettings().filter.SetDisallowAll();
            rack.GetStoreSettings().filter.SetAllow(ThingDefOf.ArtilleryShell, true);
            rack.GetStoreSettings().Priority = StoragePriority.Critical;
            rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(8, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData) as Building_Storage;
            foreach (IntVec3 cell in rack.OccupiedRect().Cells)
            {
                OG_Common.SpawnResourceAt(ThingDefOf.ArtilleryShell, ThingDefOf.ArtilleryShell.stackLimit, cell, true);
            }
            rack.GetStoreSettings().filter.SetDisallowAll();
            rack.GetStoreSettings().filter.SetAllow(ThingDefOf.ArtilleryShell, true);
            rack.GetStoreSettings().Priority = StoragePriority.Critical;

            OG_Common.GenerateHorizontalAndVerticalPavedAlleys(origin);
        }
Esempio n. 2
0
        public static void GenerateOutpost(OG_OutpostData outpostDataParameter)
        {
            outpostData = outpostDataParameter;
            outpostData.triggerIntrusion = null;
            outpostData.outpostThingList = new List <Thing>();

            // Reset zoneMap.
            for (int zoneOrd = 0; zoneOrd < verticalZonesNumber; zoneOrd++)
            {
                for (int zoneAbs = 0; zoneAbs < horizontalZonesNumber; zoneAbs++)
                {
                    zoneMap[zoneOrd, zoneAbs] = new ZoneProperties(ZoneType.NotYetGenerated, Rot4.North, Rot4.North);
                }
            }
            // Clear the whole area and remove any roof.
            CellRect rect = new CellRect(outpostData.areaSouthWestOrigin.x - 1, outpostData.areaSouthWestOrigin.z - 1, areaSideLength + 2, areaSideLength + 2);

            foreach (IntVec3 cell in rect.Cells)
            {
                Find.RoofGrid.SetRoof(cell, null);
                List <Thing> thingList = cell.GetThingList();
                for (int j = thingList.Count - 1; j >= 0; j--)
                {
                    Thing thing = thingList[j];
                    if (thing.def.destroyable)
                    {
                        thing.Destroy(DestroyMode.Vanish);
                    }
                }
            }
            // Create the intrusion trigger.
            outpostData.triggerIntrusion = (TriggerIntrusion)ThingMaker.MakeThing(ThingDef.Named("TriggerIntrusion"));
            GenSpawn.Spawn(outpostData.triggerIntrusion, rect.Center);

            GenerateOutpostLayout();

            // TODO: debug. Display the generated layout.

            /*for (int zoneOrd = 0; zoneOrd < verticalZonesNumber; zoneOrd++)
             * {
             *  for (int zoneAbs = 0; zoneAbs < horizontalZonesNumber; zoneAbs++)
             *  {
             *      ZoneProperties zone = zoneMap[zoneOrd, zoneAbs];
             *      Log.Message("Layout: zoneMap[" + zoneOrd + "," + zoneAbs + "] => " + zone.zoneType.ToString() + "," + zone.rotation.ToString() + "," + zone.linkedZoneRelativeRotation.ToString());
             *  }
             * }*/
            GenerateOutpostZones(outpostData.areaSouthWestOrigin);

            IntVec3 mainRoomZoneOrigin = Zone.GetZoneOrigin(outpostData.areaSouthWestOrigin, mainRoomZoneAbs, mainRoomZoneOrd);

            OG_Common.GenerateSas(mainRoomZoneOrigin + new IntVec3(5, 0, 10), Rot4.North, 3, smallRoomWallOffset * 2, ref outpostData);
            OG_Common.GenerateSas(mainRoomZoneOrigin + new IntVec3(10, 0, 5), Rot4.East, 3, smallRoomWallOffset * 2, ref outpostData);
            OG_Common.GenerateSas(mainRoomZoneOrigin + new IntVec3(5, 0, 0), Rot4.South, 3, smallRoomWallOffset * 2, ref outpostData);
            OG_Common.GenerateSas(mainRoomZoneOrigin + new IntVec3(0, 0, 5), Rot4.West, 3, smallRoomWallOffset * 2, ref outpostData);

            // Generate laser fences.
            OG_LaserFence.GenerateLaserFence(zoneMap, ref outpostData);
            // Generate battle remains.
            OG_WarfieldEffects.GenerateWarfieldEffects(zoneMap, horizontalZonesNumber, verticalZonesNumber, outpostData);
            // Damage outpost to reflect its history.
            OG_RuinEffects.GenerateRuinEffects(ref outpostData);
            // Don't generate permanent inhabitants for small outposts. Those are just used as a shack by exploration teams.

            // Initialize command console data.
            outpostData.outpostThingList    = OG_Util.RefreshThingList(outpostData.outpostThingList);
            commandConsole.outpostThingList = outpostData.outpostThingList.ListFullCopy <Thing>();
            commandConsole.dropZoneCenter   = outpostData.dropZoneCenter;
            // Initialize intrusion trigger data.
            outpostData.triggerIntrusion.commandConsole = commandConsole;

            SendWelcomeLetter(outpostData);
        }
Esempio n. 3
0
        public static void GenerateFarmZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation);

            // Spawn floor (excepted in zone corners).
            for (int xOffset = 1; xOffset <= 9; xOffset++)
            {
                for (int zOffset = 0; zOffset <= 10; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Soil);
                }
            }
            for (int xOffset = 0; xOffset <= 10; xOffset++)
            {
                for (int zOffset = 1; zOffset <= 9; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Soil);
                }
            }
            for (int xOffset = 0; xOffset < 11; xOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, 5).RotatedBy(rotation), OG_Util.DirtFloorDef);
            }
            for (int zOffset = 0; zOffset < 11; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), OG_Util.DirtFloorDef);
            }

            // Generate crops.
            ThingDef plantDef = ThingDef.Named("PlantHealroot");

            if (Rand.Value < 0.5f)
            {
                plantDef = ThingDef.Named("PlantDevilstrand");
            }
            for (int xOffset = 0; xOffset < 5; xOffset++)
            {
                for (int zOffset = 0; zOffset < 5; zOffset++)
                {
                    if ((xOffset == 0) && (zOffset == 0))
                    {
                        continue;
                    }
                    GenSpawn.Spawn(plantDef, rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation));
                }
            }
            plantDef = ThingDef.Named("PlantCorn");
            if (Rand.Value < 0.5f)
            {
                plantDef = ThingDef.Named("PlantRice");
            }
            for (int xOffset = 6; xOffset < 11; xOffset++)
            {
                for (int zOffset = 0; zOffset < 5; zOffset++)
                {
                    if ((xOffset == 10) && (zOffset == 0))
                    {
                        continue;
                    }
                    GenSpawn.Spawn(plantDef, rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation));
                }
            }
            plantDef = ThingDefOf.PlantPotato;
            if (Rand.Value < 0.5f)
            {
                plantDef = ThingDef.Named("PlantStrawberry");
            }
            for (int xOffset = 0; xOffset < 5; xOffset++)
            {
                for (int zOffset = 6; zOffset < 11; zOffset++)
                {
                    if ((xOffset == 0) && (zOffset == 10))
                    {
                        continue;
                    }
                    GenSpawn.Spawn(plantDef, rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation));
                }
            }
            plantDef = ThingDef.Named("PlantHops");
            if (Rand.Value < 0.5f)
            {
                plantDef = ThingDef.Named("PlantCotton");
            }
            for (int xOffset = 6; xOffset < 11; xOffset++)
            {
                for (int zOffset = 6; zOffset < 11; zOffset++)
                {
                    if ((xOffset == 10) && (zOffset == 10))
                    {
                        continue;
                    }
                    GenSpawn.Spawn(plantDef, rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation));
                }
            }
        }