static NewThingReplacement()
        {
            replacements = new List <Replacement>();

            //---------------------------------------------
            //---------------------------------------------
            //Here are valid replacements:
            replacements.Add(new Replacement(d => d.IsWall() || typeof(Building_Door).IsAssignableFrom(d.thingClass)));
            replacements.Add(new Replacement(d => typeof(Building_Cooler).IsAssignableFrom(d.thingClass),
                                             postAction: (n, o) =>
            {
                Building_Cooler newCooler = n as Building_Cooler;
                Building_Cooler oldCooler = o as Building_Cooler;
                //newCooler.compPowerTrader.PowerOn = oldCooler.compPowerTrader.PowerOn;	//should be flickable
                newCooler.compTempControl.targetTemperature = oldCooler.compTempControl.targetTemperature;
            }
                                             ));
            replacements.Add(new Replacement(d => typeof(Building_Bed).IsAssignableFrom(d.thingClass),
                                             preAction: (n, o) =>
            {
                Building_Bed newBed = n as Building_Bed;
                Building_Bed oldBed = o as Building_Bed;
                newBed.ForPrisoners = oldBed.ForPrisoners;
                newBed.Medical      = oldBed.Medical;
                oldBed.OwnersForReading.ListFullCopy().ForEach(p => p.ownership.ClaimBedIfNonMedical(newBed));
            }
                                             ));
            DesignationCategoryDef fencesDef = DefDatabase <DesignationCategoryDef> .GetNamed("Fences", false);

            if (fencesDef != null)
            {
                replacements.Add(new Replacement(d => d.designationCategory == fencesDef));
            }

            Action <Thing, Thing> transferBills = (n, o) =>
            {
                Building_WorkTable newTable = n as Building_WorkTable;
                Building_WorkTable oldTable = o as Building_WorkTable;

                foreach (Bill bill in oldTable.BillStack)
                {
                    newTable.BillStack.AddBill(bill);
                }
            };

            replacements.Add(new Replacement(d => d == NewThingDefOf.ElectricStove, n => n == NewThingDefOf.FueledStove, transferBills));
            replacements.Add(new Replacement(d => d == NewThingDefOf.ElectricTailoringBench, n => n == NewThingDefOf.HandTailoringBench, transferBills));

            replacements.Add(new Replacement(d => d.IsTable));

            replacements.Add(new Replacement(d => d.thingClass == FridgeCompat.fridgeType,
                                             postAction: (n, o) =>
            {
                FridgeCompat.DesiredTempInfo.SetValue(n, FridgeCompat.DesiredTempInfo.GetValue(o));
            }));

            replacements.Add(new Replacement(d => d.building?.isSittable ?? false));
            //---------------------------------------------
            //---------------------------------------------
        }
Ejemplo n.º 2
0
        public static Building_Cooler SpawnCoolerAt(IntVec3 position, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            ThingDef        coolerDef = ThingDef.Named("Cooler");
            Building_Cooler cooler    = OG_Common.TrySpawnThingAt(coolerDef, null, position, true, rotation, ref outpostData, false, true) as Building_Cooler;

            return(cooler);
        }
        static NewThingReplacement()
        {
            replacements = new List <Replacement>();

            //---------------------------------------------
            //---------------------------------------------
            //Here are valid replacements:
            replacements.Add(new Replacement(d => d.thingClass == typeof(Building_Door), n => n.IsWall() || n.thingClass == typeof(Building_Door)));
            replacements.Add(new Replacement(d => d.thingClass == typeof(Building_Cooler), n => n.thingClass == typeof(Building_Cooler),
                                             null,
                                             (n, o) =>
            {
                Building_Cooler newCooler = n as Building_Cooler;
                Building_Cooler oldCooler = o as Building_Cooler;
                //newCooler.compPowerTrader.PowerOn = oldCooler.compPowerTrader.PowerOn;	//should be flickable
                newCooler.compTempControl.targetTemperature = oldCooler.compTempControl.targetTemperature;
            }
                                             ));
            replacements.Add(new Replacement(d => d.thingClass == typeof(Building_Bed), n => n.thingClass == typeof(Building_Bed),
                                             (n, o) =>
            {
                Building_Bed newBed = n as Building_Bed;
                Building_Bed oldBed = o as Building_Bed;
                newBed.ForPrisoners = oldBed.ForPrisoners;
                newBed.Medical      = oldBed.Medical;
                oldBed.owners.ForEach(p => p.ownership.ClaimBedIfNonMedical(newBed));
            }
                                             ));
            replacements.Add(new Replacement(d => d.IsWall(), n => n.IsWall()));

            Action <Thing, Thing> transferBills = (n, o) =>
            {
                Building_WorkTable newTable = n as Building_WorkTable;
                Building_WorkTable oldTable = o as Building_WorkTable;

                foreach (Bill bill in oldTable.BillStack)
                {
                    newTable.BillStack.AddBill(bill);
                }
            };

            replacements.Add(new Replacement(d => d == NewThingDefOf.ElectricStove, n => n == NewThingDefOf.FueledStove, transferBills));
            replacements.Add(new Replacement(d => d == NewThingDefOf.ElectricTailoringBench, n => n == NewThingDefOf.HandTailoringBench, transferBills));
            //---------------------------------------------
            //---------------------------------------------
        }
Ejemplo n.º 4
0
        public static void GenerateMediumRoomBarn(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);

            OG_Common.GenerateEmptyRoomAt(rotatedOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), 9, 9, rotation, TerrainDefOf.Concrete, TerrainDefOf.Soil, ref outpostData);

            // Generate animal feed room.
            for (int xOffset = 2; xOffset <= 4; xOffset++)
            {
                OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(xOffset, 0, 5).RotatedBy(rotation), ref outpostData);
            }
            for (int zOffset = 2; zOffset <= 5; zOffset++)
            {
                OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(4, 0, zOffset).RotatedBy(rotation), ref outpostData);
            }
            IntVec3 doorPosition = rotatedOrigin + new IntVec3(4, 0, 3).RotatedBy(rotation);

            OG_Common.SpawnDoorAt(doorPosition, ref outpostData);
            Find.TerrainGrid.SetTerrain(doorPosition, TerrainDef.Named("PavedTile"));
            for (int xOffset = 2; xOffset <= 3; xOffset++)
            {
                for (int zOffset = 2; zOffset <= 4; zOffset++)
                {
                    IntVec3 fridgeCell = rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation);
                    Find.TerrainGrid.SetTerrain(fridgeCell, TerrainDef.Named("SterileTile"));
                    if ((zOffset == 2) || (zOffset == 4))
                    {
                        Thing hayStack = ThingMaker.MakeThing(ThingDef.Named("Hay"));
                        hayStack.stackCount = ThingDef.Named("Hay").stackLimit;
                        GenSpawn.Spawn(hayStack, fridgeCell);
                    }
                }
            }
            // Spawn animal beds.
            OG_Common.TrySpawnThingAt(ThingDef.Named("AnimalBed"), ThingDef.Named("Cloth"), rotatedOrigin + new IntVec3(2, 0, 6).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("AnimalBed"), ThingDef.Named("Cloth"), rotatedOrigin + new IntVec3(2, 0, 8).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("AnimalBed"), ThingDef.Named("Cloth"), rotatedOrigin + new IntVec3(4, 0, 8).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);

            OG_Common.TrySpawnThingAt(ThingDef.Named("AnimalBed"), ThingDef.Named("Cloth"), rotatedOrigin + new IntVec3(6, 0, 8).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("AnimalBed"), ThingDef.Named("Cloth"), rotatedOrigin + new IntVec3(8, 0, 8).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("AnimalBed"), ThingDef.Named("Cloth"), rotatedOrigin + new IntVec3(8, 0, 6).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);

            OG_Common.TrySpawnThingAt(ThingDef.Named("AnimalBed"), ThingDef.Named("Cloth"), rotatedOrigin + new IntVec3(8, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("AnimalBed"), ThingDef.Named("Cloth"), rotatedOrigin + new IntVec3(8, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("AnimalBed"), ThingDef.Named("Cloth"), rotatedOrigin + new IntVec3(6, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);

            // Spawn lamp, heater and coolers.
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(6, 0, 5).RotatedBy(rotation), Color.white, ref outpostData);
            OG_Common.TrySpawnHeaterAt(rotatedOrigin + new IntVec3(8, 0, 5).RotatedBy(rotation), ref outpostData);
            Building_Cooler cooler = OG_Common.SpawnCoolerAt(rotatedOrigin + new IntVec3(1, 0, 3).RotatedBy(rotation), new Rot4(Rot4.West.AsInt + rotation.AsInt), ref outpostData);

            cooler.compTempControl.targetTemperature = 5f;

            // Spawn vertical alley and doors.
            for (int zOffset = 0; zOffset <= 10; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, 1).RotatedBy(rotation), ref outpostData);
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, 9).RotatedBy(rotation), ref outpostData);
        }