Ejemplo n.º 1
0
        public static void GenerateSmallRoomBarracks(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(smallRoomWallOffset, 0, smallRoomWallOffset).RotatedBy(rotation), Genstep_GenerateOutpost.zoneSideSize - 2 * smallRoomWallOffset, Genstep_GenerateOutpost.zoneSideSize - 2 * smallRoomWallOffset, rotation, TerrainDefOf.Concrete, TerrainDef.Named("WoodPlankFloor"), ref outpostData);

            // Spawn beds, lamp and temperature control.
            OG_Common.TrySpawnThingAt(ThingDef.Named("Bed"), ThingDefOf.WoodLog, rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 1).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("Bed"), ThingDefOf.WoodLog, rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 3).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("Bed"), ThingDefOf.WoodLog, rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 5).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("Bed"), ThingDefOf.WoodLog, rotatedOrigin + new IntVec3(smallRoomWallOffset + 5, 0, smallRoomWallOffset + 1).RotatedBy(rotation), true, new Rot4(Rot4.West.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("Bed"), ThingDefOf.WoodLog, rotatedOrigin + new IntVec3(smallRoomWallOffset + 5, 0, smallRoomWallOffset + 5).RotatedBy(rotation), true, new Rot4(Rot4.West.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 4, 0, smallRoomWallOffset + 3).RotatedBy(rotation), Color.white, ref outpostData);
            OG_Common.TrySpawnHeaterAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 5, 0, smallRoomWallOffset + 3).RotatedBy(rotation), ref outpostData);
            OG_Common.SpawnCoolerAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 6, 0, smallRoomWallOffset + 3).RotatedBy(rotation), new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData);
            // Spawn vertical alley and door.
            for (int zOffset = smallRoomWallOffset; zOffset <= Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset - 1).RotatedBy(rotation), ref outpostData);
        }
Ejemplo n.º 2
0
        public override void CompTick()
        {
            Pawn pawn = this.parent as Pawn;

            if (pawn.Spawned)
            {
                if (pawn.Faction != null)
                {
                    if (pawn.Faction.IsPlayer && (pawn.Position.GetTerrain(pawn.Map) == TerrainDef.Named(Props.FirstStageTerrain)))
                    {
                        pawn.Map.terrainGrid.SetTerrain(pawn.Position, TerrainDef.Named(Props.SecondStageTerrain));
                        pawn.health.AddHediff(HediffDef.Named("AA_FertilizedTerrain"));
                    }

                    extraFertCounter--;
                    if (extraFertCounter <= 0)
                    {
                        if (pawn.Faction.IsPlayer && pawn.training.HasLearned(TrainableDefOf.Obedience) && ((pawn.Position.GetTerrain(pawn.Map) == TerrainDef.Named(Props.SecondStageTerrain))))
                        {
                            pawn.Map.terrainGrid.SetTerrain(pawn.Position, TerrainDef.Named(Props.ThirdStageTerrain));
                            pawn.health.AddHediff(HediffDef.Named("AA_FertilizedTerrain"));
                        }
                        extraFertCounter = 500;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public override void MapComponentTick()
        {
            base.MapComponentTick();
            if (Controller.Settings.waterFreezes.Equals(false))
            {
                return;
            }
            int   num  = Mathf.RoundToInt((float)this.map.Area * 0.00005f);
            int   area = this.map.Area;
            float cellTemp;

            for (int i = 0; i < num; i++)
            {
                this.cycleIndex++;
                if (this.cycleIndex >= area)
                {
                    this.cycleIndex = 0;
                }
                IntVec3 c          = this.map.cellsInRandomOrder.Get(this.cycleIndex);
                var     terrainDef = map.terrainGrid.TerrainAt(c);
                if (!GenTemperature.TryGetTemperatureForCell(c, map, out cellTemp))
                {
                    cellTemp = 0f;
                }
                float shallowChance    = (cellTemp * cellTemp) / 100f;
                float deepChance       = (cellTemp * cellTemp * 0.2f) / 100f;
                float permafrostChance = deepChance;
                if (permafrostChance > 0.2f)
                {
                    permafrostChance = 0.2f;
                }
                if (cellTemp < 0f)
                {
                    if (terrainDef.defName == "WaterShallow" || terrainDef.defName == "IceST")
                    {
                        int freezable = 0;
                        for (int k = -1; k < 2; k++)
                        {
                            for (int j = -1; j < 2; j++)
                            {
                                int x = c.x + k;
                                int z = c.z + j;
                                if ((k == 0 && j == 1) || (k == 0 && j == -1) || (k == 1 && j == 0) || (k == -1 && j == 0))
                                {
                                    if (x > 0 && x < this.map.Size.x && z > 0 && z < this.map.Size.z)
                                    {
                                        IntVec3 newSpot = new IntVec3(x, 0, z);
                                        if (!map.terrainGrid.TerrainAt(newSpot).defName.Contains("Water") && map.terrainGrid.TerrainAt(newSpot).defName != "Marsh" && map.terrainGrid.TerrainAt(newSpot).defName != "BridgeMarsh" && map.terrainGrid.TerrainAt(newSpot).defName != "Bridge")
                                        {
                                            freezable++;
                                        }
                                    }
                                }
                            }
                        }
                        if (Rand.Value < shallowChance * freezable)
                        {
                            List <Thing> thingList = c.GetThingList(map);
                            for (int j = 0; j < thingList.Count; j++)
                            {
                                Thing item = thingList[j];
                                if (item.def.defName == "Fishing Spot" || item.def.defName == "ZARS_FishingSpot")
                                {
                                    item.Destroy(DestroyMode.Vanish);
                                }
                            }
                            string iceType;
                            if (terrainDef.defName == "WaterShallow")
                            {
                                iceType = "IceST";
                            }
                            else
                            {
                                iceType = "IceS";
                            }
                            map.terrainGrid.SetTerrain(c, TerrainDef.Named(iceType));
                        }
                    }
                    if (terrainDef.defName == "WaterDeep" || terrainDef.defName == "IceDT")
                    {
                        int freezable = 0;
                        for (int k = -1; k < 2; k++)
                        {
                            for (int j = -1; j < 2; j++)
                            {
                                int x = c.x + k;
                                int z = c.z + j;
                                if ((k == 0 && j == 1) || (k == 0 && j == -1) || (k == 1 && j == 0) || (k == -1 && j == 0))
                                {
                                    if (x > 0 && x < this.map.Size.x && z > 0 && z < this.map.Size.z)
                                    {
                                        IntVec3 newSpot = new IntVec3(x, 0, z);
                                        if (!map.terrainGrid.TerrainAt(newSpot).defName.Contains("Water") && map.terrainGrid.TerrainAt(newSpot).defName != "Marsh" && map.terrainGrid.TerrainAt(newSpot).defName != "BridgeMarsh" && map.terrainGrid.TerrainAt(newSpot).defName != "Bridge")
                                        {
                                            freezable++;
                                        }
                                    }
                                }
                            }
                        }
                        if (Rand.Value < deepChance * freezable)
                        {
                            List <Thing> thingList = c.GetThingList(map);
                            for (int j = 0; j < thingList.Count; j++)
                            {
                                Thing item = thingList[j];
                                if (item.def.defName == "Fishing Spot" || item.def.defName == "ZARS_FishingSpot")
                                {
                                    item.Destroy(DestroyMode.Vanish);
                                }
                            }
                            string iceType;
                            if (terrainDef.defName == "WaterDeep")
                            {
                                iceType = "IceDT";
                            }
                            else
                            {
                                iceType = "IceD";
                            }
                            map.terrainGrid.SetTerrain(c, TerrainDef.Named(iceType));
                        }
                    }
                    if (terrainDef.defName == "Marsh" || terrainDef.defName == "IceMarshT")
                    {
                        int freezable = 0;
                        for (int k = -1; k < 2; k++)
                        {
                            for (int j = -1; j < 2; j++)
                            {
                                int x = c.x + k;
                                int z = c.z + j;
                                if ((k == 0 && j == 1) || (k == 0 && j == -1) || (k == 1 && j == 0) || (k == -1 && j == 0))
                                {
                                    if (x > 0 && x < this.map.Size.x && z > 0 && z < this.map.Size.z)
                                    {
                                        IntVec3 newSpot = new IntVec3(x, 0, z);
                                        if (!map.terrainGrid.TerrainAt(newSpot).defName.Contains("Water") && map.terrainGrid.TerrainAt(newSpot).defName != "Marsh" && map.terrainGrid.TerrainAt(newSpot).defName != "BridgeMarsh" && map.terrainGrid.TerrainAt(newSpot).defName != "Bridge")
                                        {
                                            freezable++;
                                        }
                                    }
                                }
                            }
                        }
                        if (Rand.Value < shallowChance * freezable)
                        {
                            List <Thing> thingList = c.GetThingList(map);
                            for (int j = 0; j < thingList.Count; j++)
                            {
                                Thing item = thingList[j];
                                if (item.def.defName == "Fishing Spot" || item.def.defName == "ZARS_FishingSpot")
                                {
                                    item.Destroy(DestroyMode.Vanish);
                                }
                            }
                            string iceType;
                            if (terrainDef.defName == "Marsh")
                            {
                                iceType = "IceMarshT";
                            }
                            else
                            {
                                iceType = "IceMarsh";
                            }
                            map.terrainGrid.SetTerrain(c, TerrainDef.Named(iceType));
                        }
                    }
                    if ((terrainDef.defName == "Soil" || terrainDef.defName == "Gravel" || terrainDef.defName == "MossyTerrain") && map.Biome.defName.Contains("Permafrost"))
                    {
                        int freezable = 0;
                        for (int k = -1; k < 2; k++)
                        {
                            for (int j = -1; j < 2; j++)
                            {
                                int x = c.x + k;
                                int z = c.z + j;
                                if ((k == 0 && j == 1) || (k == 0 && j == -1) || (k == 1 && j == 0) || (k == -1 && j == 0))
                                {
                                    if (x > 0 && x < this.map.Size.x && z > 0 && z < this.map.Size.z)
                                    {
                                        IntVec3 newSpot = new IntVec3(x, 0, z);
                                        if (map.terrainGrid.TerrainAt(newSpot).defName == "Ice")
                                        {
                                            freezable++;
                                        }
                                    }
                                }
                            }
                        }
                        if (Rand.Value < (permafrostChance / 8) * freezable)
                        {
                            List <Thing> thingList = c.GetThingList(map);
                            for (int j = 0; j < thingList.Count; j++)
                            {
                                Thing item = thingList[j];
                                if (item.def.thingClass == typeof(Plant))
                                {
                                    item.Destroy(DestroyMode.Vanish);
                                }
                            }
                            map.terrainGrid.SetTerrain(c, TerrainDef.Named("Ice"));
                        }
                    }
                }
                if (cellTemp > -4f)
                {
                    if (terrainDef.defName == "IceS" || terrainDef.defName == "IceD" || terrainDef.defName == "IceST" || terrainDef.defName == "IceDT")
                    {
                        int quickThaw = 1;
                        for (int k = -1; k < 2; k++)
                        {
                            for (int j = -1; j < 2; j++)
                            {
                                int x = c.x + k;
                                int z = c.z + j;
                                if ((k == 0 && j == 1) || (k == 0 && j == -1) || (k == 1 && j == 0) || (k == -1 && j == 0))
                                {
                                    if (x > 0 && x < this.map.Size.x && z > 0 && z < this.map.Size.z)
                                    {
                                        IntVec3 newSpot = new IntVec3(x, 0, z);
                                        if (!terrainDef.label.Contains("Thin"))
                                        {
                                            if (map.terrainGrid.TerrainAt(newSpot).defName.Contains("Water") || map.terrainGrid.TerrainAt(newSpot).defName == "Marsh" || map.terrainGrid.TerrainAt(newSpot).label.Contains("Thin"))
                                            {
                                                quickThaw++;
                                            }
                                        }
                                        else
                                        {
                                            if (map.terrainGrid.TerrainAt(newSpot).defName.Contains("Water") || map.terrainGrid.TerrainAt(newSpot).defName == "Marsh")
                                            {
                                                quickThaw++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (quickThaw == 1)
                        {
                            if (Rand.Value < 0.67f)
                            {
                                quickThaw = 0;
                            }
                        }
                        if (Rand.Value < (shallowChance * quickThaw))
                        {
                            string waterType;
                            if (terrainDef.defName == "IceST")
                            {
                                waterType = "WaterShallow";
                            }
                            else if (terrainDef.defName == "IceS")
                            {
                                waterType = "IceST";
                            }
                            else if (terrainDef.defName == "IceDT")
                            {
                                waterType = "WaterDeep";
                            }
                            else
                            {
                                waterType = "IceDT";
                            }
                            if (waterType.Contains("Water"))
                            {
                                map.snowGrid.SetDepth(c, 0f);
                            }
                            map.terrainGrid.SetTerrain(c, TerrainDef.Named(waterType));
                        }
                    }
                    if (terrainDef.defName.Contains("IceMarsh"))
                    {
                        int quickThaw = 1;
                        for (int k = -1; k < 2; k++)
                        {
                            for (int j = -1; j < 2; j++)
                            {
                                int x = c.x + k;
                                int z = c.z + j;
                                if ((k == 0 && j == 1) || (k == 0 && j == -1) || (k == 1 && j == 0) || (k == -1 && j == 0))
                                {
                                    if (x > 0 && x < this.map.Size.x && z > 0 && z < this.map.Size.z)
                                    {
                                        IntVec3 newSpot = new IntVec3(x, 0, z);
                                        if (!terrainDef.label.Contains("Thin"))
                                        {
                                            if (map.terrainGrid.TerrainAt(newSpot).defName.Contains("Water") || map.terrainGrid.TerrainAt(newSpot).defName == "Marsh" || map.terrainGrid.TerrainAt(newSpot).label.Contains("Thin"))
                                            {
                                                quickThaw++;
                                            }
                                        }
                                        else
                                        {
                                            if (map.terrainGrid.TerrainAt(newSpot).defName.Contains("Water") || map.terrainGrid.TerrainAt(newSpot).defName == "Marsh")
                                            {
                                                quickThaw++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (quickThaw == 1)
                        {
                            if (Rand.Value < 0.67f)
                            {
                                quickThaw = 0;
                            }
                        }
                        if (Rand.Value < (shallowChance * quickThaw))
                        {
                            string waterType;
                            if (terrainDef.defName == "IceMarsh")
                            {
                                waterType = "IceMarshT";
                            }
                            else
                            {
                                waterType = "Marsh";
                                map.snowGrid.SetDepth(c, 0f);
                            }
                            map.terrainGrid.SetTerrain(c, TerrainDef.Named(waterType));
                        }
                    }
                    if (terrainDef.defName == "Ice" && map.Biome.defName.Contains("Permafrost"))
                    {
                        int quickThaw = 0;
                        for (int k = -1; k < 2; k++)
                        {
                            for (int j = -1; j < 2; j++)
                            {
                                int x = c.x + k;
                                int z = c.z + j;
                                if ((k == 0 && j == 1) || (k == 0 && j == -1) || (k == 1 && j == 0) || (k == -1 && j == 0))
                                {
                                    if (x > 0 && x < this.map.Size.x && z > 0 && z < this.map.Size.z)
                                    {
                                        IntVec3 newSpot = new IntVec3(x, 0, z);
                                        if (!map.terrainGrid.TerrainAt(newSpot).defName.Contains("Ice"))
                                        {
                                            quickThaw++;
                                        }
                                    }
                                }
                            }
                        }
                        if (Rand.Value < ((permafrostChance / 4) * quickThaw))
                        {
                            map.terrainGrid.SetTerrain(c, TerrainDef.Named("Gravel"));
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private static void SpawnLaserFenceWithEntrance(IntVec3 laserFenceLeftOrigin, Rot4 rotation, int entranceWidth, ref OG_OutpostData outpostData)
        {
            // Note1: the fence is orthogonal to the parameter rotation.
            // Note2: the entrance width must be an odd number.
            int entranceWidthOffset = 1 + (entranceWidth / 2);

            for (int xOffset = 0; xOffset < Genstep_GenerateOutpost.zoneSideSize; xOffset++)
            {
                IntVec3 position = laserFenceLeftOrigin + new IntVec3(xOffset, 0, 0).RotatedBy(new Rot4(rotation.AsInt));
                if ((xOffset == 0) ||
                    (xOffset == Genstep_GenerateOutpost.zoneSideCenterOffset - entranceWidthOffset) ||
                    (xOffset == Genstep_GenerateOutpost.zoneSideCenterOffset + entranceWidthOffset) ||
                    (xOffset == Genstep_GenerateOutpost.zoneSideSize - 1))
                {
                    LaserFence.Building_LaserFencePylon pylon = OG_Common.TrySpawnLaserFencePylonAt(position, ref outpostData);
                    if (pylon != null)
                    {
                        if (xOffset == Genstep_GenerateOutpost.zoneSideCenterOffset - entranceWidthOffset)
                        {
                            if (rotation == Rot4.North)
                            {
                                pylon.ToggleEastFenceStatus();
                            }
                            else if (rotation == Rot4.East)
                            {
                                pylon.ToggleSouthFenceStatus();
                            }
                            else if (rotation == Rot4.South)
                            {
                                pylon.ToggleWestFenceStatus();
                            }
                            else if (rotation == Rot4.West)
                            {
                                pylon.ToggleNorthFenceStatus();
                            }
                            pylon.SwitchLaserFence();
                        }
                        if (xOffset == Genstep_GenerateOutpost.zoneSideCenterOffset + entranceWidthOffset)
                        {
                            if (rotation == Rot4.North)
                            {
                                pylon.ToggleWestFenceStatus();
                            }
                            else if (rotation == Rot4.East)
                            {
                                pylon.ToggleNorthFenceStatus();
                            }
                            else if (rotation == Rot4.South)
                            {
                                pylon.ToggleEastFenceStatus();
                            }
                            else if (rotation == Rot4.West)
                            {
                                pylon.ToggleSouthFenceStatus();
                            }
                            pylon.SwitchLaserFence();
                        }
                    }
                }
                OG_Common.SpawnFireproofPowerConduitAt(position, ref outpostData);
                Find.TerrainGrid.SetTerrain(position, TerrainDefOf.Concrete);
                if (xOffset == Genstep_GenerateOutpost.zoneSideCenterOffset)
                {
                    Find.TerrainGrid.SetTerrain(position, TerrainDef.Named("PavedTile"));
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Destroys the fishing pier and the fishing spot. Restores the original terrain cells.
 /// </summary>
 public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
 {
     base.Destroy(mode);
     Find.TerrainGrid.SetTerrain(riverCell, TerrainDef.Named(riverTerrainCellDefAsString));
     Find.TerrainGrid.SetTerrain(middleCell, TerrainDef.Named(middleTerrainCellDefAsString));
 }
 // Token: 0x0600000A RID: 10 RVA: 0x00002599 File Offset: 0x00001599
 public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
 {
     base.Map.terrainGrid.SetTerrain(base.Position, TerrainDef.Named(TerrainTypeAtBaseCellDefAsString));
     base.Destroy(mode);
 }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            const float baseFishingDuration = 2000f;

            int   fishingDuration            = (int)baseFishingDuration;
            float catchSomethingThreshold    = 0f;
            Building_FishingPier fishingPier = this.TargetThingA as Building_FishingPier;
            Passion     passion          = Passion.None;
            const float skillGainPerTick = 0.15f;
            float       skillGainFactor  = 0f;

            this.AddEndCondition(() =>
            {
                var targ = this.pawn.jobs.curJob.GetTarget(fishingPierIndex).Thing;
                if (targ is Building && !targ.Spawned)
                {
                    return(JobCondition.Incompletable);
                }
                return(JobCondition.Ongoing);
            });

            this.FailOnBurningImmobile(fishingPierIndex); // Bill giver or product burning in carry phase.

            this.rotateToFace = TargetIndex.B;

            yield return(Toils_Reserve.Reserve(fishingPierIndex));

            float fishingSkillLevel = 0f;

            fishingSkillLevel = this.pawn.skills.AverageOfRelevantSkillsFor(WorkTypeDefOf.Hunting);
            float fishingSkillDurationFactor = fishingSkillLevel / 20f;

            fishingDuration = (int)(baseFishingDuration * (1.5f - fishingSkillDurationFactor));

            yield return(Toils_Goto.GotoThing(fishingPierIndex, fishingPier.riverCell).FailOnDespawnedOrNull(fishingPierIndex));

            Toil fishToil = new Toil()
            {
                initAction = () =>
                {
                    ThingDef moteDef = null;
                    if (fishingPier.Rotation == Rot4.North)
                    {
                        moteDef = Util_FishIndustry.MoteFishingRodNorthDef;
                    }
                    else if (fishingPier.Rotation == Rot4.East)
                    {
                        moteDef = Util_FishIndustry.MoteFishingRodEastDef;
                    }
                    else if (fishingPier.Rotation == Rot4.South)
                    {
                        moteDef = Util_FishIndustry.MoteFishingRodSouthDef;
                    }
                    else
                    {
                        moteDef = Util_FishIndustry.MoteFishingRodWestDef;
                    }
                    this.fishingRodMote = (Mote)ThingMaker.MakeThing(moteDef, null);
                    this.fishingRodMote.exactPosition = fishingPier.fishingSpotCell.ToVector3Shifted();
                    this.fishingRodMote.Scale         = 1f;
                    GenSpawn.Spawn(this.fishingRodMote, fishingPier.fishingSpotCell, this.Map);
                    WorkTypeDef fishingWorkDef = WorkTypeDefOf.Hunting;
                    passion = this.pawn.skills.MaxPassionOfRelevantSkillsFor(fishingWorkDef);
                    if (passion == Passion.None)
                    {
                        skillGainFactor = 0.3f;
                    }
                    else if (passion == Passion.Minor)
                    {
                        skillGainFactor = 1f;
                    }
                    else
                    {
                        skillGainFactor = 1.5f;
                    }
                },
                tickAction = () =>
                {
                    if (passion == Passion.Minor)
                    {
                        this.pawn.needs.joy.GainJoy(NeedTunings.JoyPerXpForPassionMinor, JoyKindDefOf.Work);
                    }
                    else if (passion == Passion.Major)
                    {
                        this.pawn.needs.joy.GainJoy(NeedTunings.JoyPerXpForPassionMajor, JoyKindDefOf.Work);
                    }
                    this.pawn.skills.Learn(SkillDefOf.Shooting, skillGainPerTick * skillGainFactor);

                    if (this.ticksLeftThisToil == 1)
                    {
                        if (this.fishingRodMote != null)
                        {
                            this.fishingRodMote.Destroy();
                        }
                    }
                },
                defaultDuration     = fishingDuration,
                defaultCompleteMode = ToilCompleteMode.Delay
            };

            yield return(fishToil.WithProgressBarToilDelay(fishingPierIndex));

            Toil computeChanceToCatchToil = new Toil()
            {
                initAction = () =>
                {
                    catchSomethingThreshold = fishingSkillLevel / 20f;
                    // Reframe min and max chance (min 5%, max 75 % chance of success).
                    Mathf.Clamp(catchSomethingThreshold, 0.05f, 0.75f);
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            };

            yield return(computeChanceToCatchToil);

            Toil catchFishToil = new Toil()
            {
                initAction = () =>
                {
                    Job   curJob       = this.pawn.jobs.curJob;
                    Thing fishingCatch = null;

                    // 90% chance to successfully catch something.
                    bool catchIsSuccessful = (Rand.Value >= 0.1f);
                    if (catchIsSuccessful == false)
                    {
                        MoteMaker.ThrowMetaIcon(this.pawn.Position, this.Map, ThingDefOf.Mote_IncapIcon);
                        this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
                        return;
                    }

                    float catchSelectorValue = Rand.Value;
                    if (catchSelectorValue > 0.04f)
                    {
                        // Catch a fish.
                        bool fishSpotIsMarshy = (this.Map.terrainGrid.TerrainAt(fishingPier.fishingSpotCell) == TerrainDef.Named("Marsh"));
                        bool isDaytime        = (this.Map.skyManager.CurSkyGlow >= 0.4f);

                        PawnKindDef caugthFishDef = null;
                        if (fishSpotIsMarshy && isDaytime)
                        {
                            caugthFishDef = (from fishSpecies in Util_FishIndustry.GetFishSpeciesList()
                                             where fishSpecies.livesInMarsh
                                             where fishSpecies.catchableDuringDay
                                             select fishSpecies).RandomElementByWeight((PawnKindDef_FishSpecies def) => def.commonality);
                        }
                        else if (fishSpotIsMarshy && !isDaytime)
                        {
                            caugthFishDef = (from fishSpecies in Util_FishIndustry.GetFishSpeciesList()
                                             where fishSpecies.livesInMarsh
                                             where fishSpecies.catchableDuringNight
                                             select fishSpecies).RandomElementByWeight((PawnKindDef_FishSpecies def) => def.commonality);
                        }
                        else if (!fishSpotIsMarshy && isDaytime)
                        {
                            caugthFishDef = (from fishSpecies in Util_FishIndustry.GetFishSpeciesList()
                                             where fishSpecies.livesInSea
                                             where fishSpecies.catchableDuringDay
                                             select fishSpecies).RandomElementByWeight((PawnKindDef_FishSpecies def) => def.commonality);
                        }
                        else
                        {
                            caugthFishDef = (from fishSpecies in Util_FishIndustry.GetFishSpeciesList()
                                             where fishSpecies.livesInSea
                                             where fishSpecies.catchableDuringNight
                                             select fishSpecies).RandomElementByWeight((PawnKindDef_FishSpecies def) => def.commonality);
                        }
                        Pawn caughtFish = PawnGenerator.GeneratePawn(caugthFishDef);
                        GenSpawn.Spawn(caughtFish, this.pawn.Position, this.Map);
                        HealthUtility.GiveInjuriesToKill(caughtFish);
                        foreach (Thing thing in this.pawn.Position.GetThingList(this.Map))
                        {
                            Corpse fishCorpse = thing as Corpse;
                            if (fishCorpse != null)
                            {
                                fishingCatch = fishCorpse;
                            }
                        }
                        if (caughtFish.BodySize >= 0.1f)
                        {
                            fishingPier.fishStock--;
                            fishingPier.UpdateMaxFishStock();
                        }
                    }
                    else if (catchSelectorValue > 0.02)
                    {
                        fishingCatch            = GenSpawn.Spawn(Util_FishIndustry.OysterDef, this.pawn.Position, this.Map);
                        fishingCatch.stackCount = Rand.RangeInclusive(5, 27);
                    }
                    else
                    {
                        float bonusCatchValue = Rand.Value;
                        if (bonusCatchValue < 0.01f)
                        {
                            // Really small chance to find a sunken treasure!!!
                            fishingCatch            = GenSpawn.Spawn(ThingDefOf.Gold, this.pawn.Position, this.Map);
                            fishingCatch.stackCount = Rand.RangeInclusive(58, 289);
                            Thing treasureSilver = GenSpawn.Spawn(ThingDefOf.Silver, fishingPier.middleCell, this.Map);
                            treasureSilver.stackCount = Rand.RangeInclusive(237, 2154);
                            string eventText = this.pawn.Name.ToStringShort.CapitalizeFirst() + " has found a sunken treasure while fishing! What a good catch!\n";
                            Find.LetterStack.ReceiveLetter("Sunken treasure!", eventText, LetterType.Good, this.pawn);
                        }
                        else if (bonusCatchValue < 0.02f)
                        {
                            // Really small chance to find a complete power armor set + sniper or charge rifle.
                            Thing powerArmor = GenSpawn.Spawn(ThingDef.Named("Apparel_PowerArmor"), this.pawn.Position, this.Map);
                            fishingCatch = powerArmor; // Used to carry the power armor.
                            Thing powerArmorHelmet = GenSpawn.Spawn(ThingDef.Named("Apparel_PowerArmorHelmet"), this.pawn.Position, this.Map);
                            Thing rifle            = null;
                            if (Rand.Value < 0.5f)
                            {
                                rifle = GenSpawn.Spawn(ThingDef.Named("Gun_ChargeRifle"), this.pawn.Position, this.Map);
                            }
                            else
                            {
                                rifle = GenSpawn.Spawn(ThingDef.Named("Gun_SniperRifle"), this.pawn.Position, this.Map);
                            }
                            CompQuality qualityComp = powerArmor.TryGetComp <CompQuality>();
                            if (qualityComp != null)
                            {
                                qualityComp.SetQuality(QualityCategory.Masterwork, ArtGenerationContext.Outsider);
                            }
                            qualityComp = powerArmorHelmet.TryGetComp <CompQuality>();
                            if (qualityComp != null)
                            {
                                qualityComp.SetQuality(QualityCategory.Masterwork, ArtGenerationContext.Outsider);
                            }
                            qualityComp = rifle.TryGetComp <CompQuality>();
                            if (qualityComp != null)
                            {
                                qualityComp.SetQuality(QualityCategory.Masterwork, ArtGenerationContext.Outsider);
                            }

                            Faction faction    = Find.FactionManager.FirstFactionOfDef(FactionDefOf.SpacerHostile);
                            Pawn    deadMarine = PawnGenerator.GeneratePawn(PawnKindDefOf.SpaceSoldier, faction);
                            GenSpawn.Spawn(deadMarine, fishingPier.bankCell, this.Map);
                            HealthUtility.GiveInjuriesToKill(deadMarine);
                            List <Thing> thingsList = deadMarine.Position.GetThingList(this.Map);
                            foreach (Thing thing in thingsList)
                            {
                                if (thing.def.defName.Contains("Corpse"))
                                {
                                    CompRottable rotComp = thing.TryGetComp <CompRottable>();
                                    if (rotComp != null)
                                    {
                                        rotComp.RotProgress = 20f * GenDate.TicksPerDay; // 20 days so the corpse is dessicated.
                                    }
                                }
                            }
                            string eventText = this.pawn.Name.ToStringShort.CapitalizeFirst() + " has cought a dead body while fishing!\n\n'This is really disgusting but look at his gear! This guy was probably a MiningCo. security member. I wonder what happend to him...'\n";
                            Find.LetterStack.ReceiveLetter("Dead marine", eventText, LetterType.Good, this.pawn);
                        }
                        else
                        {
                            // Find a small amount of gold.
                            fishingCatch            = GenSpawn.Spawn(ThingDefOf.Gold, this.pawn.Position, this.Map);
                            fishingCatch.stackCount = Rand.RangeInclusive(1, 7);
                        }
                        // TODO: add chance to get hurt by a tailteeth (missing finger or even hand!).
                    }
                    IntVec3 storageCell;
                    if (StoreUtility.TryFindBestBetterStoreCellFor(fishingCatch, this.pawn, this.Map, StoragePriority.Unstored, this.pawn.Faction, out storageCell, true))
                    {
                        this.pawn.carryTracker.TryStartCarry(fishingCatch);
                        curJob.targetB = storageCell;
                        curJob.targetC = fishingCatch;
                        curJob.count   = 99999;
                    }
                    else
                    {
                        this.pawn.jobs.EndCurrentJob(JobCondition.Succeeded);
                    }
                }
            };

            yield return(catchFishToil);

            // Reserve the product and storage cell.
            yield return(Toils_Reserve.Reserve(TargetIndex.B));

            yield return(Toils_Reserve.Reserve(TargetIndex.C));

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true));

            yield return(Toils_Reserve.Release(fishingPierIndex));
        }
Ejemplo n.º 8
0
        public override void SpawnSetup(Map map, bool flag)
        {
            base.SpawnSetup(map, flag);
            TerrainDef terrainDef = map.terrainGrid.TerrainAt(base.Position);

            if (terrainDef.defName.Contains("Water"))
            {
                if (terrainDef == TerrainDef.Named("WaterDeep") || terrainDef == TerrainDef.Named("WaterOceanDeep") || terrainDef == TerrainDef.Named("WaterMovingDeep"))
                {
                    List <Thing> thingList = base.Position.GetThingList(map);

                    foreach (Thing t in thingList)
                    {
                        IEnumerable <IntVec3> cells = GenAdj.CellsOccupiedBy(t);
                        foreach (IntVec3 cell in cells)
                        {
                            map.terrainGrid.SetTerrain(cell, TerrainDef.Named("UnderPanelWater"));
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null)
        {
            TerrainDef terraindef = map.terrainGrid.TerrainAt(loc);

            if (terraindef == TerrainDef.Named("WaterDeep") || terraindef == TerrainDef.Named("WaterOceanDeep") || terraindef == TerrainDef.Named("WaterMovingDeep"))
            {
                return(true);
            }
            return(new AcceptanceReport("SS.OnlyDeepWater".Translate()));
        }
Ejemplo n.º 10
0
        public static void GenerateBatteryRoomZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, Rot4 linkedZoneRelativeRotation, 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(smallRoomWallOffset, 0, smallRoomWallOffset).RotatedBy(rotation), Genstep_GenerateOutpost.zoneSideSize - 2 * smallRoomWallOffset, Genstep_GenerateOutpost.zoneSideSize - 2 * smallRoomWallOffset, rotation, TerrainDefOf.Concrete, null, ref outpostData);

            // Generate batteries.
            OG_Common.TrySpawnThingAt(OG_Util.CompactAutonomousGeneratorDef, null, rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(smallRoomWallOffset + 4, 0, smallRoomWallOffset + 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(smallRoomWallOffset + 5, 0, smallRoomWallOffset + 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 5).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(smallRoomWallOffset + 2, 0, smallRoomWallOffset + 5).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(smallRoomWallOffset + 4, 0, smallRoomWallOffset + 5).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(smallRoomWallOffset + 5, 0, smallRoomWallOffset + 5).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);
            // Generate vertical alley and door.
            for (int zOffset = smallRoomWallOffset; zOffset <= Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset - 1).RotatedBy(rotation), ref outpostData);
            // Generate horizontal alley, door, lamp and power conduits.
            if (linkedZoneRelativeRotation == Rot4.West)
            {
                for (int xOffset = smallRoomWallOffset - 1; xOffset <= Genstep_GenerateOutpost.zoneSideCenterOffset; xOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
                }
                OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(smallRoomWallOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset).RotatedBy(rotation), ref outpostData);
                OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 5, 0, smallRoomWallOffset + 3).RotatedBy(rotation), Color.red, ref outpostData);
                for (int xOffset = 0; xOffset <= 1; xOffset++)
                {
                    OG_Common.SpawnFireproofPowerConduitAt(rotatedOrigin + new IntVec3(xOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset).RotatedBy(rotation), ref outpostData);
                }
            }
            else if (linkedZoneRelativeRotation == Rot4.East)
            {
                for (int xOffset = Genstep_GenerateOutpost.zoneSideCenterOffset; xOffset <= Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset; xOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
                }
                OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset - 1, 0, Genstep_GenerateOutpost.zoneSideCenterOffset).RotatedBy(rotation), ref outpostData);
                OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 3).RotatedBy(rotation), Color.red, ref outpostData);
                for (int xOffset = Genstep_GenerateOutpost.zoneSideSize - 2; xOffset <= Genstep_GenerateOutpost.zoneSideSize - 1; xOffset++)
                {
                    OG_Common.SpawnFireproofPowerConduitAt(rotatedOrigin + new IntVec3(xOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset).RotatedBy(rotation), ref outpostData);
                }
            }
        }
Ejemplo n.º 11
0
        public static Building_OutpostCommandConsole GenerateCommandRoomZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 cardinal, Rot4 linkedZoneRelativeRotation, ref OG_OutpostData outpostData)
        {
            Building_OutpostCommandConsole commandConsole = null;

            IntVec3 origin        = Zone.GetZoneOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd);
            IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, cardinal);

            OG_Common.GenerateEmptyRoomAt(rotatedOrigin + new IntVec3(smallRoomWallOffset, 0, smallRoomWallOffset).RotatedBy(cardinal), Genstep_GenerateOutpost.zoneSideSize - 2 * smallRoomWallOffset, Genstep_GenerateOutpost.zoneSideSize - 2 * smallRoomWallOffset, cardinal, TerrainDefOf.Concrete, null, ref outpostData);
            // Spawn command console.
            commandConsole = OG_Common.TrySpawnThingAt(OG_Util.OutpostCommandConsoleDef, null, rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset + 2).RotatedBy(cardinal), true, new Rot4(Rot4.South.AsInt + cardinal.AsInt), ref outpostData) as Building_OutpostCommandConsole;
            // Generate vertical alley.
            for (int zOffset = smallRoomWallOffset; zOffset < Genstep_GenerateOutpost.zoneSideCenterOffset; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, zOffset).RotatedBy(cardinal), TerrainDef.Named("PavedTile"));
            }
            // Generate horizontal alley, door and lamp.
            if (linkedZoneRelativeRotation == Rot4.West)
            {
                for (int xOffset = smallRoomWallOffset - 2; xOffset <= Genstep_GenerateOutpost.zoneSideCenterOffset; xOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset).RotatedBy(cardinal), TerrainDef.Named("PavedTile"));
                }
                OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(smallRoomWallOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset).RotatedBy(cardinal), ref outpostData);
            }
            else if (linkedZoneRelativeRotation == Rot4.East)
            {
                for (int xOffset = Genstep_GenerateOutpost.zoneSideCenterOffset; xOffset <= Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset + 1; xOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset).RotatedBy(cardinal), TerrainDef.Named("PavedTile"));
                }
                OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset - 1, 0, Genstep_GenerateOutpost.zoneSideCenterOffset).RotatedBy(cardinal), ref outpostData);
            }
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 1).RotatedBy(cardinal), Color.red, ref outpostData);
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 5, 0, smallRoomWallOffset + 1).RotatedBy(cardinal), Color.red, ref outpostData);

            return(commandConsole);
        }
        public override void Generate(Map map, GenStepParams parms)
        {
            CellRect rectToDefend;

            if (!MapGenerator.TryGetVar <CellRect>("RectOfInterest", out rectToDefend))
            {
                rectToDefend = CellRect.SingleCell(map.Center);
            }
            TerrainDef floorDef = TerrainDef.Named("FlagstoneGranite");             // rp.floorDef ?? BaseGenUtility.CorrespondingTerrainDef(thingDef, true);

            Faction       faction = Find.FactionManager.FirstFactionOfDef(DwarfDefOf.LotRD_MonsterFaction);
            ResolveParams rp      = default(ResolveParams);

            rp.rect = this.GetOutpostRect(rectToDefend, map);
            rp.rect = rp.rect.ExpandedBy(30);
            Log.Message(rp.rect.minX.ToString() + " " + rp.rect.minZ.ToString());
            rp.faction                   = faction;
            rp.floorDef                  = floorDef;
            rp.wallStuff                 = ThingDefOf.BlocksGranite;
            rp.pathwayFloorDef           = TerrainDef.Named("SilverTile");
            rp.edgeDefenseWidth          = new int?(2);
            rp.edgeDefenseTurretsCount   = 0;          // new int?(Rand.RangeInclusive(0, 1));
            rp.edgeDefenseMortarsCount   = new int?(0);
            rp.settlementPawnGroupPoints = new float?(0.4f);
            rp.chanceToSkipWallBlock     = 0.1f;
            BaseGen.globalSettings.map   = map;
//			BaseGen.globalSettings.minBuildings = 1;
//			BaseGen.globalSettings.minBarracks = 1;
//			BaseGen.symbolStack.Push("factionBase", resolveParams);
            Lord singlePawnLord = rp.singlePawnLord ?? LordMaker.MakeNewLord(faction, new LordJob_DefendPoint(rp.rect.CenterCell), map, null);



            BaseGen.symbolStack.Push("outdoorLighting", rp);
            ResolveParams resolveParams3 = rp;
            Pawn          pawn           = PawnGenerator.GeneratePawn(DwarfDefOf.LotRD_DragonFireDrake, faction);

            resolveParams3.singlePawnToSpawn = pawn;
            resolveParams3.rect           = new CellRect(rp.rect.CenterCell.x, rp.rect.CenterCell.z, 5, 5);
            resolveParams3.singlePawnLord = singlePawnLord;
            BaseGen.symbolStack.Push("pawn", resolveParams3);

            ThingDef thingDef = ThingDefOf.BlocksGranite;             //rp.wallStuff ?? BaseGenUtility.RandomCheapWallStuff(rp.faction, false);

            ///Dragon Room
            var dragonRoomParams = default(ResolveParams);
            var dragonRoomRect   = rp.rect.ContractedBy(Rand.Range(20, 25));

            //Rubble strewn about
            ResolveParams rubbleEverywhere = rp;

            rubbleEverywhere.rect              = rp.rect.ContractedBy(1);
            rubbleEverywhere.filthDef          = ThingDefOf.Filth_RubbleBuilding;
            rubbleEverywhere.chanceToSkipFloor = 0.25f;
            BaseGen.symbolStack.Push("filthMaker", rubbleEverywhere);

            //Corpses strewn about
            ResolveParams corpsesEverywhere = rp;

            corpsesEverywhere.rect       = dragonRoomRect.ContractedBy(1);
            corpsesEverywhere.hivesCount = Rand.Range(12, 18);
            corpsesEverywhere.faction    = Find.FactionManager.RandomEnemyFaction();
            BaseGen.symbolStack.Push("corpseMaker", corpsesEverywhere);

            //Corpses strewn about (2)
            ResolveParams corpsesEverywhereTwo = rp;

            corpsesEverywhereTwo.rect       = rp.rect.ContractedBy(1);
            corpsesEverywhereTwo.hivesCount = Rand.Range(12, 18);
            corpsesEverywhereTwo.faction    = Find.FactionManager.RandomEnemyFaction();
            BaseGen.symbolStack.Push("corpseMaker", corpsesEverywhereTwo);

            //Just place a dwaven throne.
            ResolveParams throneArea = rp;

            throneArea.rect             = CellRect.SingleCell(BottomHalf(dragonRoomRect).CenterCell);
            throneArea.singleThingDef   = ThingDef.Named("LotRD_DwarvenThrone");
            throneArea.singleThingStuff = ThingDefOf.BlocksGranite;
            BaseGen.symbolStack.Push("thing", throneArea);

            //Gold coins strewn about
            ResolveParams coinsEverywhere = rp;

            coinsEverywhere.rect              = BottomHalf(dragonRoomRect).ContractedBy(4);
            coinsEverywhere.filthDef          = ThingDef.Named("LotRD_Filth_GoldCoins");
            coinsEverywhere.chanceToSkipFloor = 0f;
            coinsEverywhere.filthDensity      = new FloatRange(1, 5);
            coinsEverywhere.streetHorizontal  = true;
            BaseGen.symbolStack.Push("filthMaker", coinsEverywhere);


            //Dragon horde
            ResolveParams dragonHorde = rp;

            dragonHorde.rect             = BottomHalf(dragonRoomRect).ContractedBy(5); //new CellRect(dragonRoomRect.minX, (int)(dragonRoomRect.minZ + dragonRoomRect.Height / 2f), dragonRoomRect.Width, (int)(dragonRoomRect.Height / 2f));
            dragonHorde.thingSetMakerDef = DwarfDefOf.LotRD_Treasure;
            var newParamsForItemGen = new ThingSetMakerParams();

            newParamsForItemGen.countRange          = new IntRange(15, 20);
            newParamsForItemGen.maxThingMarketValue = Rand.Range(10000, 15000);
            dragonHorde.thingSetMakerParams         = newParamsForItemGen;
            dragonHorde.singleThingStackCount       = 250;
            BaseGen.symbolStack.Push("stockpile", dragonHorde);
            //


            dragonRoomParams.rect = dragonRoomRect;
            BaseGen.symbolStack.Push("roof", dragonRoomParams);
            ResolveParams dragonDoorParams = dragonRoomParams;

            dragonDoorParams.rect = dragonRoomRect;
            BaseGen.symbolStack.Push("doors", dragonDoorParams);
            dragonDoorParams.rect = dragonRoomRect;
            ResolveParams dragonRoomWalls = dragonRoomParams;

            dragonRoomWalls.rect                  = dragonRoomRect;
            dragonRoomWalls.wallStuff             = thingDef;
            dragonRoomWalls.floorDef              = floorDef;
            dragonRoomWalls.chanceToSkipWallBlock = 0.25f;
            BaseGen.symbolStack.Push("edgeWalls", dragonRoomWalls);
            BaseGen.symbolStack.Push("clear", dragonRoomParams);

            ///
            /// Abandoned Dwarven Mountain Fortress
            int   num = 0;
            int?  edgeDefenseWidth = rp.edgeDefenseWidth;
            float num2             = (float)rp.rect.Area / 144f * 0.17f;

            BaseGen.globalSettings.minEmptyNodes = ((num2 >= 1f) ? GenMath.RoundRandom(num2) : 0);
            TraverseParms traverseParms = TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false);
            ResolveParams abandonedBase = rp;

            abandonedBase.rect    = rp.rect;
            abandonedBase.faction = faction;
            ResolveParams resolveParams4 = abandonedBase;

            resolveParams4.rect    = rp.rect.ContractedBy(num + 10);
            resolveParams4.faction = faction;
            BaseGen.symbolStack.Push("ensureCanReachMapEdge", resolveParams4);
            ResolveParams resolveParams5 = abandonedBase;

            resolveParams5.rect      = rp.rect.ContractedBy(num + 10);
            resolveParams5.faction   = faction;
            resolveParams5.wallStuff = thingDef;
            resolveParams5.floorDef  = floorDef;
            BaseGen.symbolStack.Push("basePart_outdoors", resolveParams5);
            ///

            ///Four Corners -- Four Guardtowers
            for (int i = 0; i < 3; i++)
            {
                IntVec3  towerCorner = rp.rect.Corners.ElementAt(i);
                CellRect towerRect   = new CellRect(towerCorner.x, towerCorner.z, 10, 10);
                var      towerParams = default(ResolveParams);
                towerParams.rect = towerRect;
                BaseGen.symbolStack.Push("roof", towerRect);
                ResolveParams towerDoorParams = towerParams;
                towerDoorParams.rect = towerRect;
                BaseGen.symbolStack.Push("doors", towerDoorParams);
                towerDoorParams.rect = towerRect;
                ResolveParams towerWallParams = towerParams;
                towerWallParams.rect                  = towerRect;
                towerWallParams.wallStuff             = thingDef;
                towerWallParams.floorDef              = floorDef;
                towerWallParams.chanceToSkipWallBlock = 0.1f;
                BaseGen.symbolStack.Push("edgeWalls", towerWallParams);
                BaseGen.symbolStack.Push("clear", towerParams);
            }


            BaseGen.symbolStack.Push("roof", rp);
            ResolveParams doorParams = rp;

            BaseGen.symbolStack.Push("doors", doorParams);
            ResolveParams resolveParams = rp;

            resolveParams.wallStuff             = thingDef;
            resolveParams.chanceToSkipWallBlock = 0.1f;
            BaseGen.symbolStack.Push("edgeWalls", resolveParams);
            ResolveParams thickwallParams = rp;

            thickwallParams.rect                  = thickwallParams.rect.ContractedBy(1);
            thickwallParams.wallStuff             = thingDef;
            thickwallParams.chanceToSkipWallBlock = 0.3f;
            BaseGen.symbolStack.Push("edgeWalls", thickwallParams);
            ResolveParams dthickwallParams = thickwallParams;

            dthickwallParams.rect = dthickwallParams.rect.ContractedBy(1);
            dthickwallParams.chanceToSkipWallBlock = 0.6f;
            BaseGen.symbolStack.Push("edgeWalls", dthickwallParams);
            ResolveParams resolveParams2 = rp;

            resolveParams2.floorDef = floorDef;
            BaseGen.symbolStack.Push("floor", resolveParams2);
            BaseGen.symbolStack.Push("clear", rp);
            if (rp.addRoomCenterToRootsToUnfog != null && rp.addRoomCenterToRootsToUnfog.Value && Current.ProgramState == ProgramState.MapInitializing)
            {
                MapGenerator.rootsToUnfog.Add(rp.rect.CenterCell);
            }

            Log.Message("generated dragon lair");
            BaseGen.Generate();
        }
Ejemplo n.º 13
0
        public static void GenerateSmallRoomWeaponRoom(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(smallRoomWallOffset, 0, smallRoomWallOffset).RotatedBy(rotation), Genstep_GenerateOutpost.zoneSideSize - 2 * smallRoomWallOffset, Genstep_GenerateOutpost.zoneSideSize - 2 * smallRoomWallOffset, rotation, TerrainDefOf.Concrete, TerrainDef.Named("MetalTile"), ref outpostData);

            // Spawn weapon racks, weapons and lamps.
            Building_Storage rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData) as Building_Storage;

            TrySpawnWeaponOnRack(rack);
            rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false);
            rack.GetStoreSettings().Priority = StoragePriority.Critical;
            rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(smallRoomWallOffset + 4, 0, smallRoomWallOffset + 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData) as Building_Storage;
            TrySpawnWeaponOnRack(rack);
            rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false);
            rack.GetStoreSettings().Priority = StoragePriority.Critical;
            rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(smallRoomWallOffset + 2, 0, smallRoomWallOffset + 5).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData) as Building_Storage;
            TrySpawnWeaponOnRack(rack);
            rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false);
            rack.GetStoreSettings().Priority = StoragePriority.Critical;
            rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(smallRoomWallOffset + 5, 0, smallRoomWallOffset + 5).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData) as Building_Storage;
            TrySpawnWeaponOnRack(rack);
            rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false);
            rack.GetStoreSettings().Priority = StoragePriority.Critical;
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 3).RotatedBy(rotation), Color.white, ref outpostData);
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 5, 0, smallRoomWallOffset + 3).RotatedBy(rotation), Color.white, ref outpostData);
            // Spawn vertical alley and door.
            for (int zOffset = smallRoomWallOffset; zOffset <= Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset - 1).RotatedBy(rotation), ref outpostData);
        }
Ejemplo n.º 14
0
        public static void GenerateSmallRoomMedibay(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(smallRoomWallOffset, 0, smallRoomWallOffset).RotatedBy(rotation), Genstep_GenerateOutpost.zoneSideSize - 2 * smallRoomWallOffset, Genstep_GenerateOutpost.zoneSideSize - 2 * smallRoomWallOffset, rotation, TerrainDefOf.Concrete, TerrainDef.Named("CarpetBlue"), ref outpostData);

            // Spawn medbeds and lamp.
            OG_Common.TrySpawnThingAt(ThingDef.Named("HospitalBed"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("HospitalBed"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 5).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("HospitalBed"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(smallRoomWallOffset + 5, 0, smallRoomWallOffset + 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("HospitalBed"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(smallRoomWallOffset + 5, 0, smallRoomWallOffset + 5).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.SpawnResourceAt(ThingDefOf.Medicine, Rand.RangeInclusive(7, 32), rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 3).RotatedBy(rotation));
            Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 3).RotatedBy(rotation), TerrainDef.Named("MetalTile"));
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 4, 0, smallRoomWallOffset + 3).RotatedBy(rotation), Color.blue, ref outpostData);
            OG_Common.TrySpawnHeaterAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 5, 0, smallRoomWallOffset + 3).RotatedBy(rotation), ref outpostData);
            OG_Common.SpawnCoolerAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 6, 0, smallRoomWallOffset + 3).RotatedBy(rotation), new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData);
            // Spawn vertical alley and door.
            for (int zOffset = smallRoomWallOffset; zOffset <= Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset - 1).RotatedBy(rotation), ref outpostData);
        }
Ejemplo n.º 15
0
        public static void GeneratePlazaZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation);

            // Generate paved floor.
            for (int xOffset = 3; xOffset <= 7; xOffset++)
            {
                for (int zOffset = 0; zOffset <= 10; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset), TerrainDef.Named("TileGranite"));
                }
            }
            for (int xOffset = 2; xOffset <= 8; xOffset++)
            {
                for (int zOffset = 1; zOffset <= 9; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset), TerrainDef.Named("TileGranite"));
                }
            }
            for (int xOffset = 1; xOffset <= 9; xOffset++)
            {
                for (int zOffset = 2; zOffset <= 8; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset), TerrainDef.Named("TileGranite"));
                }
            }
            for (int xOffset = 0; xOffset <= 10; xOffset++)
            {
                for (int zOffset = 3; zOffset <= 7; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset), TerrainDef.Named("TileGranite"));
                }
            }

            // Generate central paved alley.
            IntVec3 centralPylonPosition = rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset);

            for (int zOffset = 0; zOffset < Genstep_GenerateOutpost.zoneSideSize; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, zOffset), TerrainDef.Named("PavedTile"));
            }
            for (int xOffset = 0; xOffset < Genstep_GenerateOutpost.zoneSideSize; xOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset), TerrainDef.Named("PavedTile"));
            }
            foreach (IntVec3 cell in GenAdj.CellsAdjacent8Way(centralPylonPosition))
            {
                Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("PavedTile"));
            }

            // Generate pylon.
            OG_Common.TrySpawnWallAt(centralPylonPosition, ref outpostData);

            // Generate sandbags and power conduit.
            for (int rotationAsInt = 0; rotationAsInt < 4; rotationAsInt++)
            {
                Rot4    quarterRotation        = new Rot4(rotationAsInt);
                IntVec3 quarterSouthWestOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, quarterRotation);

                IntVec3 cell = quarterSouthWestOrigin + new IntVec3(0, 0, 4).RotatedBy(quarterRotation);
                OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, cell, false, Rot4.Invalid, ref outpostData);
                OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
                cell = quarterSouthWestOrigin + new IntVec3(0, 0, 3).RotatedBy(quarterRotation);
                OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, cell, false, Rot4.Invalid, ref outpostData);
                OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
                cell = quarterSouthWestOrigin + new IntVec3(1, 0, 3).RotatedBy(quarterRotation);
                OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, cell, false, Rot4.Invalid, ref outpostData);
                OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
                cell = quarterSouthWestOrigin + new IntVec3(1, 0, 2).RotatedBy(quarterRotation);
                OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, cell, false, Rot4.Invalid, ref outpostData);
                OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
                cell = quarterSouthWestOrigin + new IntVec3(2, 0, 2).RotatedBy(quarterRotation);
                OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, cell, false, Rot4.Invalid, ref outpostData);
                OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
                cell = quarterSouthWestOrigin + new IntVec3(2, 0, 1).RotatedBy(quarterRotation);
                OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, cell, false, Rot4.Invalid, ref outpostData);
                OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
                cell = quarterSouthWestOrigin + new IntVec3(3, 0, 1).RotatedBy(quarterRotation);
                OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, cell, false, Rot4.Invalid, ref outpostData);
                OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
                cell = quarterSouthWestOrigin + new IntVec3(3, 0, 0).RotatedBy(quarterRotation);
                OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, cell, false, Rot4.Invalid, ref outpostData);
                OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
                cell = quarterSouthWestOrigin + new IntVec3(4, 0, 0).RotatedBy(quarterRotation);
                OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, cell, false, Rot4.Invalid, ref outpostData);
                OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
                cell = quarterSouthWestOrigin + new IntVec3(5, 0, 0).RotatedBy(quarterRotation);
                OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
            }
        }
Ejemplo n.º 16
0
        protected override bool CanScatterAt(IntVec3 loc)
        {
            int mountainousBorderCells          = 0;
            int mountainousBorderCellsThreshold = 0;
            int aquaticCells          = 0;
            int aquaticCellsThreshold = 0;

            if (base.CanScatterAt(loc) == false)
            {
                return(false);
            }

            int minFreeAreaSideSize = 1;

            switch (this.outpostData.size)
            {
            case OG_OutpostSize.SmallOutpost:
                minFreeAreaSideSize = OG_SmallOutpost.areaSideLength;
                break;

            case OG_OutpostSize.BigOutpost:
                minFreeAreaSideSize = OG_BigOutpost.areaSideLength;
                break;
            }
            CellRect outpostArea = new CellRect(loc.x, loc.z, minFreeAreaSideSize, minFreeAreaSideSize);

            mountainousBorderCellsThreshold = (2 * outpostArea.Width + 2 * outpostArea.Height) / 4;
            aquaticCellsThreshold           = outpostArea.Area / 100;
            foreach (IntVec3 cell in outpostArea)
            {
                // Only for border cells: too close from edge or crossing an existing structure (potentially a shrine).
                if ((cell.x == outpostArea.minX) ||
                    (cell.x == outpostArea.maxX) ||
                    (cell.z == outpostArea.minZ) ||
                    (cell.z == outpostArea.maxZ))
                {
                    if (cell.CloseToEdge(20))
                    {
                        return(false);
                    }

                    Building building = cell.GetEdifice();
                    if (building != null)
                    {
                        mountainousBorderCells++;
                        if (mountainousBorderCells > mountainousBorderCellsThreshold)
                        {
                            return(false);
                        }
                    }
                }
                TerrainDef terrain = Find.TerrainGrid.TerrainAt(cell);
                if (terrain == TerrainDef.Named("WaterDeep"))
                {
                    return(false);
                }
                if ((terrain == TerrainDef.Named("Marsh")) ||
                    (terrain == TerrainDef.Named("Mud")) ||
                    (terrain == TerrainDef.Named("WaterShallow")))
                {
                    aquaticCells++;
                    if (aquaticCells > aquaticCellsThreshold)
                    {
                        return(false);
                    }
                }
                List <Thing> thingList = cell.GetThingList();
                foreach (Thing thing in thingList)
                {
                    if (thing.def.destroyable == false)
                    {
                        return(false);
                    }
                }
            }
            //Log.Message("Valid spawn point found! Mountainous cells/threshold, aquatic cells/threshold = " + mountainousBorderCells + "/" + mountainousBorderCellsThreshold + ", " + aquaticCells + "/" + aquaticCellsThreshold); // TODO. debug
            return(true);
        }
Ejemplo n.º 17
0
        public static void GenerateStraightAlleyZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation);

            // Spawn lamps.
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(4, 0, 2).RotatedBy(rotation), Color.white, ref outpostData);
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(4, 0, 8).RotatedBy(rotation), Color.white, ref outpostData);
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(6, 0, 2).RotatedBy(rotation), Color.white, ref outpostData);
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(6, 0, 8).RotatedBy(rotation), Color.white, ref outpostData);

            // Generate central paved alley.
            for (int zOffset = 0; zOffset < Genstep_GenerateOutpost.zoneSideSize; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }

            // Generate concrete border and power conduit.
            for (int zOffset = 0; zOffset <= 10; zOffset++)
            {
                IntVec3 cell = rotatedOrigin + new IntVec3(4, 0, zOffset).RotatedBy(rotation);
                OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
                Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Concrete);

                cell = rotatedOrigin + new IntVec3(6, 0, zOffset).RotatedBy(rotation);
                OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
                Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Concrete);
            }
        }
 private static bool Prefix(IntVec3 c, Map map, float elevation, float fertility, ref TerrainDef __result)
 {
     if (map.Biome.defName.Contains("Archipelago"))
     {
         float adjustment = 0.0f;
         if (Controller.Settings.waterLevel < 1)
         {
             adjustment = -0.1f;
         }
         else if (Controller.Settings.waterLevel < 2)
         {
             adjustment = -0.05f;
         }
         else if (Controller.Settings.waterLevel < 3)
         {
         }
         else if (Controller.Settings.waterLevel < 4)
         {
             adjustment = 0.05f;
         }
         else
         {
             adjustment = 0.1f;
         }
         bool lakeIsles = false;
         if (map.Biome.defName.Contains("_Fresh"))
         {
             lakeIsles = true;
         }
         if (elevation < 0.75f)
         {
             Building edifice = c.GetEdifice(map);
             if (edifice != null)
             {
                 edifice.Destroy(DestroyMode.Vanish);
             }
             map.roofGrid.SetRoof(c, null);
             for (int i = -1; i < 2; i++)
             {
                 for (int j = -1; j < 2; j++)
                 {
                     int x = c.x + i;
                     int z = c.z + j;
                     if (x >= 0 && z >= 0 && x < map.Size.x && z < map.Size.z)
                     {
                         IntVec3 newSpot = new IntVec3(x, 0, z);
                         if (map.roofGrid.RoofAt(newSpot) != null)
                         {
                             if (map.roofGrid.RoofAt(newSpot).isThickRoof)
                             {
                                 map.roofGrid.SetRoof(newSpot, RoofDefOf.RoofRockThin);
                             }
                             else
                             {
                                 if ((i == 0 && j != 0) || (i != 0 && j == 0))
                                 {
                                     if (Rand.Value < 0.33)
                                     {
                                         map.roofGrid.SetRoof(newSpot, null);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (elevation > 0.65f && elevation <= 0.69f)
         {
             __result = TerrainDefOf.Gravel;
             return(false);
         }
         if (elevation > 0.69f & elevation < 0.71f)
         {
             __result = TerrainDefOf.Gravel;
             return(false);
         }
         if (elevation >= 0.71f)
         {
             __result = GenStep_RocksFromGrid.RockDefAt(c).building.naturalTerrain;
             return(false);
         }
         TerrainDef deepWater    = TerrainDefOf.WaterOceanDeep;
         TerrainDef shallowWater = TerrainDefOf.WaterOceanShallow;
         if (lakeIsles.Equals(true))
         {
             deepWater    = TerrainDefOf.WaterDeep;
             shallowWater = TerrainDefOf.WaterShallow;
         }
         if (elevation < 0.35f + adjustment)
         {
             __result = deepWater;
             return(false);
         }
         if (elevation < 0.45f + adjustment)
         {
             __result = shallowWater;
             return(false);
         }
         TerrainDef borderTerrainL = TerrainDefOf.Sand;
         TerrainDef borderTerrainH = TerrainDefOf.Sand;
         if (lakeIsles.Equals(true))
         {
             if (map.Biome.defName.Contains("Boreal") || map.Biome.defName.Contains("Tundra"))
             {
                 borderTerrainL = TerrainDef.Named("Mud");
                 borderTerrainH = TerrainDef.Named("MossyTerrain");
             }
             else if (map.Biome.defName.Contains("ColdBog") || map.Biome.defName.Contains("Swamp"))
             {
                 borderTerrainL = TerrainDef.Named("Marsh");
                 borderTerrainH = TerrainDef.Named("MarshyTerrain");
             }
             else if (map.Biome.defName.Contains("Temperate") || map.Biome.defName.Contains("Tropical"))
             {
                 borderTerrainL = TerrainDef.Named("Mud");
                 borderTerrainH = TerrainDef.Named("SoilRich");
             }
         }
         if (elevation < 0.47f + adjustment)
         {
             __result = borderTerrainL;
             return(false);
         }
         if (elevation < 0.50f + adjustment)
         {
             __result = borderTerrainH;
             return(false);
         }
         TerrainDef terrainDef = TerrainThreshold.TerrainAtValue(map.Biome.terrainsByFertility, fertility);
         if (terrainDef != null)
         {
             __result = terrainDef;
             return(false);
         }
         __result = borderTerrainH;
         return(false);
     }
     return(true);
 }
        // Token: 0x06000009 RID: 9 RVA: 0x000022C4 File Offset: 0x000012C4
        public override void SpawnSetup(Map map, bool respawningAfterLoad)
        {
            base.SpawnSetup(map, respawningAfterLoad);
            TerrainDef terrainDef = map.terrainGrid.TerrainAt(base.Position);

            if (terrainDef == TerrainDef.Named("Mud"))
            {
                TerrainTypeAtBaseCellDefAsString = terrainDef.ToString();
                map.terrainGrid.SetTerrain(base.Position, Util_sd_bridges.Sd_bridges_fakeMudDef);
            }
            if (terrainDef == TerrainDef.Named("Marsh"))
            {
                TerrainTypeAtBaseCellDefAsString = terrainDef.ToString();
                map.terrainGrid.SetTerrain(base.Position, Util_sd_bridges.Sd_bridges_fakeMarshDef);
            }
            if (terrainDef == TerrainDef.Named("WaterShallow"))
            {
                TerrainTypeAtBaseCellDefAsString = terrainDef.ToString();
                map.terrainGrid.SetTerrain(base.Position, Util_sd_bridges.Sd_bridges_fakeWaterShallowDef);
            }
            if (terrainDef == TerrainDef.Named("WaterOceanShallow"))
            {
                TerrainTypeAtBaseCellDefAsString = terrainDef.ToString();
                map.terrainGrid.SetTerrain(base.Position, Util_sd_bridges.Sd_bridges_fakeWaterOceanShallowDef);
            }
            if (terrainDef == TerrainDef.Named("WaterMovingShallow"))
            {
                TerrainTypeAtBaseCellDefAsString = terrainDef.ToString();
                map.terrainGrid.SetTerrain(base.Position, Util_sd_bridges.Sd_bridges_fakeWaterMovingShallowDef);
            }
            if (terrainDef == TerrainDef.Named("WaterDeep"))
            {
                TerrainTypeAtBaseCellDefAsString = terrainDef.ToString();
                map.terrainGrid.SetTerrain(base.Position, Util_sd_bridges.Sd_bridges_fakeDeepWaterDef);
            }
            if (terrainDef == TerrainDef.Named("WaterOceanDeep"))
            {
                TerrainTypeAtBaseCellDefAsString = terrainDef.ToString();
                map.terrainGrid.SetTerrain(base.Position, Util_sd_bridges.Sd_bridges_fakeWaterOceanDeepDef);
            }
            if (terrainDef == TerrainDef.Named("WaterMovingChestDeep"))
            {
                TerrainTypeAtBaseCellDefAsString = terrainDef.ToString();
                map.terrainGrid.SetTerrain(base.Position, Util_sd_bridges.Sd_bridges_fakeWaterMovingChestDeepDef);
            }
            if (terrainDef == TerrainDef.Named("sd_bridges_DigUpWater"))
            {
                TerrainTypeAtBaseCellDefAsString = terrainDef.ToString();
                map.terrainGrid.SetTerrain(base.Position, Util_sd_bridges.Sd_bridges_fakeMudDef);
            }
            if (terrainDef == TerrainDef.Named("sd_bridges_MarshWater"))
            {
                TerrainTypeAtBaseCellDefAsString = terrainDef.ToString();
                map.terrainGrid.SetTerrain(base.Position, Util_sd_bridges.Sd_bridges_fakeMarshDef);
            }
            if (terrainDef == TerrainDef.Named("sd_bridges_ShallowWater"))
            {
                TerrainTypeAtBaseCellDefAsString = terrainDef.ToString();
                map.terrainGrid.SetTerrain(base.Position, Util_sd_bridges.Sd_bridges_fakeWaterShallowDef);
            }
            if (terrainDef == TerrainDef.Named("sd_bridges_DeepWater"))
            {
                TerrainTypeAtBaseCellDefAsString = terrainDef.ToString();
                map.terrainGrid.SetTerrain(base.Position, Util_sd_bridges.Sd_bridges_fakeWaterShallowDef);
            }
        }
Ejemplo n.º 20
0
        public static void DrawRiversCard(Rect rect)
        {
            // setting up the scrollbar
            Rect rect2 = rect.ContractedBy(4f);

            // initial height with everything collapsed
            float height = 400f;

            if (settings.flagRiverBeach)
            {
                height += 100f;
            }
            if (settings.flagRiverDir)
            {
                height += 70f;
            }
            if (settings.flagRiverLoc)
            {
                height += 150f;
            }

            Rect viewRect = new Rect(0f, 0f, rect2.width - 18f, Math.Max(height, viewHeight));

            Widgets.BeginScrollView(rect2, ref scrollPosition, viewRect, true);


            Listing_Standard listing = new Listing_Standard();

            listing.Begin(viewRect);
            listing.GapLine();

            // River size and style
            settings.sizeRiver = InterfaceUtility.LabeledSlider(listing, settings.sizeRiver, 0.1f, 3f, InterfaceUtility.FormatLabel("ZMD_sizeRiver", "ZMD_size" + ThingsCard.GetDensityLabel(settings.sizeRiver)), "ZMD_size1".Translate(), "ZMD_size6".Translate());
            Rect selStyleRect = listing.GetRect(40f);

            Rect selButtonRect = selStyleRect;
            Rect descRect      = selStyleRect;

            selButtonRect.xMax -= 0.66f * viewRect.width;
            descRect.xMin      += 0.34f * viewRect.width;
            Rect iconRect = new Rect(descRect);

            iconRect.xMin += 10f;
            iconRect.xMax  = iconRect.xMin + 40f;

            string    texPath = String.Format("GUI/{0}", GetRiverStyleLabel(settings.selRiverStyle));
            Texture2D icon    = ContentFinder <Texture2D> .Get(texPath, true);

            Widgets.DrawTextureRotated(iconRect, icon, 0);
            descRect.xMin += 60f;

            Widgets.Label(descRect, (GetRiverStyleLabel(settings.selRiverStyle) + "Desc").Translate());
            Listing_Standard Listing_selRiverStyle = new Listing_Standard();

            Listing_selRiverStyle.Begin(selButtonRect);

            // river style selection
            if (Listing_selRiverStyle.ButtonTextLabeled("ZMD_riverStyle".Translate(), GetRiverStyleLabel(settings.selRiverStyle).Translate()))
            {
                List <FloatMenuOption> riverStyleList = new List <FloatMenuOption>();

                riverStyleList.Add(new FloatMenuOption("ZMD_riverStyleVanilla".Translate(), delegate
                {
                    settings.selRiverStyle = MapDesignerSettings.RiverStyle.Vanilla;
                }));
                riverStyleList.Add(new FloatMenuOption("ZMD_riverStyleSpring".Translate(), delegate
                {
                    settings.selRiverStyle = MapDesignerSettings.RiverStyle.Spring;
                }));
                riverStyleList.Add(new FloatMenuOption("ZMD_riverStyleCanal".Translate(), delegate
                {
                    settings.selRiverStyle = MapDesignerSettings.RiverStyle.Canal;
                }));

                //riverStyleList.Add(new FloatMenuOption("ZMD_riverStyleConfluence".Translate(), delegate
                //{
                //    settings.selRiverStyle = MapDesignerSettings.RiverStyle.Confluence;
                //}));
                //riverStyleList.Add(new FloatMenuOption("ZMD_riverStyleFork".Translate(), delegate
                //{
                //    settings.selRiverStyle = MapDesignerSettings.RiverStyle.Fork;
                //}));
                //riverStyleList.Add(new FloatMenuOption("ZMD_riverStyleOxbow".Translate(), delegate
                //{
                //    settings.selRiverStyle = MapDesignerSettings.RiverStyle.Oxbow;
                //}));
                Find.WindowStack.Add(new FloatMenu(riverStyleList));
            }
            Listing_selRiverStyle.End();

            listing.Gap(listing.verticalSpacing);

            // river banks
            listing.CheckboxLabeled("ZMD_flagRiverBeach".Translate(), ref settings.flagRiverBeach, "ZMD_flagRiverBeach".Translate());

            if (MapDesignerMod.mod.settings.flagRiverBeach)
            {
                Rect riverBeachRect = listing.GetRect(90f);
                riverBeachRect.xMin += 20f;
                riverBeachRect.xMax -= 20f;
                Listing_Standard riverBeachListing = new Listing_Standard();
                riverBeachListing.Begin(riverBeachRect);

                settings.riverBeachSize = InterfaceUtility.LabeledSlider(riverBeachListing, settings.riverBeachSize, 0f, 35f, "ZMD_riverBeachSize".Translate(), "ZMD_size0".Translate(), "ZMD_size6".Translate());

                List <TerrainDef> shoreOptions = new List <TerrainDef>();

                shoreOptions.Add(TerrainDefOf.Soil);
                shoreOptions.Add(TerrainDef.Named("SoilRich"));
                shoreOptions.Add(TerrainDefOf.Sand);
                shoreOptions.Add(TerrainDef.Named("MarshyTerrain"));
                shoreOptions.Add(TerrainDef.Named("Mud"));
                shoreOptions.Add(TerrainDefOf.Ice);

                Rect             selectRect     = riverBeachListing.GetRect(30f).LeftHalf();
                Listing_Standard terrainListing = new Listing_Standard();
                terrainListing.Begin(selectRect);

                if (terrainListing.ButtonTextLabeled("ZMD_lakeShore".Translate(), TerrainDef.Named(settings.riverShore).label))
                {
                    List <FloatMenuOption> shoreTerrList = new List <FloatMenuOption>();
                    foreach (TerrainDef terr in shoreOptions)
                    {
                        shoreTerrList.Add(new FloatMenuOption(terr.label, delegate { settings.riverShore = terr.defName; }, MenuOptionPriority.Default));
                    }
                    Find.WindowStack.Add(new FloatMenu(shoreTerrList));
                }
                terrainListing.End();
                riverBeachListing.End();
            }

            // river direction
            listing.CheckboxLabeled("ZMD_flagRiverDir".Translate(), ref MapDesignerMod.mod.settings.flagRiverDir, "ZMD_flagRiverDir".Translate());
            if (MapDesignerMod.mod.settings.flagRiverDir)
            {
                settings.riverDir = InterfaceUtility.AnglePicker(listing, settings.riverDir, "ZMD_Angle".Translate(), 2, true);
                listing.Gap();
            }

            // river location
            listing.CheckboxLabeled("ZMD_riverPosition".Translate(), ref MapDesignerMod.mod.settings.flagRiverLoc, "ZMD_riverPosition".Translate());
            if (MapDesignerMod.mod.settings.flagRiverLoc)
            {
                if (settings.flagRiverLocAbs)
                {
                    listing.CheckboxLabeled(String.Format("{0}: {1}", "ZMD_riverLocAbs".Translate(), "ZMD_riverLocAbsDesc".Translate()), ref MapDesignerMod.mod.settings.flagRiverLocAbs, "ZMD_riverLocAbsDesc".Translate());
                }
                else
                {
                    listing.CheckboxLabeled(String.Format("{0}: {1}", "ZMD_riverLocRel".Translate(), "ZMD_riverLocRelDesc".Translate()), ref MapDesignerMod.mod.settings.flagRiverLocAbs, "ZMD_riverLocRelDesc".Translate());
                }

                InterfaceUtility.LocationPicker(listing, 0.3f, ref settings.riverCenterDisp, 40f);
            }



            // Beaches
            listing.GapLine();

            Rect selCoastDir = listing.GetRect(35f);

            selCoastDir.xMax -= 0.66f * viewRect.width;
            Listing_Standard Listing_selCoastDir = new Listing_Standard();

            Listing_selCoastDir.Begin(selCoastDir);

            // beach direction
            if (Listing_selCoastDir.ButtonTextLabeled("ZMD_coastDir".Translate(), GetCoastDirLabel(settings.coastDir).Translate()))
            {
                List <FloatMenuOption> coastDirList = new List <FloatMenuOption>();

                coastDirList.Add(new FloatMenuOption("ZMD_coastDirVanilla".Translate(), delegate
                {
                    settings.coastDir = MapDesignerSettings.CoastDirection.Vanilla;
                }));
                coastDirList.Add(new FloatMenuOption("ZMD_north".Translate(), delegate
                {
                    settings.coastDir = MapDesignerSettings.CoastDirection.North;
                }));
                coastDirList.Add(new FloatMenuOption("ZMD_east".Translate(), delegate
                {
                    settings.coastDir = MapDesignerSettings.CoastDirection.East;
                }));
                coastDirList.Add(new FloatMenuOption("ZMD_south".Translate(), delegate
                {
                    settings.coastDir = MapDesignerSettings.CoastDirection.South;
                }));
                coastDirList.Add(new FloatMenuOption("ZMD_west".Translate(), delegate
                {
                    settings.coastDir = MapDesignerSettings.CoastDirection.West;
                }));

                Find.WindowStack.Add(new FloatMenu(coastDirList));
            }
            Listing_selCoastDir.End();

            // beach terrain
            Rect beachTerrRect = listing.GetRect(35f);

            beachTerrRect.xMax -= 0.66f * viewRect.width;

            //beachTerrRect.xMin += 20f;
            //beachTerrRect.xMax -= 20f;
            //Listing_Standard riverBeachListing = new Listing_Standard();
            //riverBeachListing.Begin(beachTerrRect);

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

            beachTerrOptions.Add("Sand");
            beachTerrOptions.Add("Soil");
            beachTerrOptions.Add("SoilRich");
            beachTerrOptions.Add("MarshyTerrain");
            beachTerrOptions.Add("Mud");
            beachTerrOptions.Add("Ice");

            Listing_Standard beachTerrListing = new Listing_Standard();

            beachTerrListing.Begin(beachTerrRect);

            if (beachTerrListing.ButtonTextLabeled("ZMD_coastTerr".Translate(), settings.beachTerr == "Vanilla" ? "ZMD_coastTerrVanilla".Translate().ToString() : TerrainDef.Named(settings.beachTerr).label))
            {
                List <FloatMenuOption> beachTerrList = new List <FloatMenuOption>();
                beachTerrList.Add(new FloatMenuOption("ZMD_coastTerrVanilla".Translate(), delegate { settings.beachTerr = "Vanilla"; }, MenuOptionPriority.Default));

                foreach (string terr in beachTerrOptions)
                {
                    beachTerrList.Add(new FloatMenuOption(TerrainDef.Named(terr).label, delegate { settings.beachTerr = terr; }, MenuOptionPriority.Default));
                }
                Find.WindowStack.Add(new FloatMenu(beachTerrList));
            }
            beachTerrListing.End();



            // reset
            listing.GapLine();

            if (listing.ButtonText("ZMD_resetRivers".Translate()))
            {
                ResetRiversSettings();
            }

            listing.End();

            viewHeight = listing.CurHeight;
            Widgets.EndScrollView();
        }
Ejemplo n.º 21
0
        public override void MapComponentTick()
        {
            if (Controller.Settings.waterResponsive.Equals(false) || map.Biome == BiomeDefOf.SeaIce)
            {
                return;
            }
            base.MapComponentTick();
            int mapArea;

            if (MP.enabled)
            {
                mapArea = Mathf.RoundToInt(map.Area * 0.000175f);
            }
            else
            {
                mapArea = Mathf.RoundToInt(map.Area * Rand.Range(0.000065f, 0.000320f));
            }
            for (int i = 0; i < mapArea; i++)
            {
                loopCycle++;
                if (loopCycle >= map.Area)
                {
                    loopCycle = 0;
                }
                IntVec3 terrainCell = map.cellsInRandomOrder.Get(loopCycle);
                GenTemperature.TryGetTemperatureForCell(terrainCell, map, out float terrainTemp);
                float shallowSpeed = terrainTemp <0f && terrainTemp> -20f ? -terrainTemp * 7f : -terrainTemp * 18f;
                float deepSpeed    = terrainTemp <0f && terrainTemp> -20f ? -terrainTemp / 10f : -terrainTemp / 3f;
                float thawSpeed    = terrainTemp < 0f ? -terrainTemp * 10f : terrainTemp * 21f;
                var   terrainDef   = map.terrainGrid.TerrainAt(terrainCell);

                // freeze process
                if (terrainTemp < -35f)
                {
                    if (terrainDef.defName == "WaterOceanShallow")
                    {
                        int            toFreeze     = 0;
                        float          tempConstant = 0f;
                        List <IntVec3> tileList     = GenAdjFast.AdjacentCellsCardinal(terrainCell);
                        tileList.Add(terrainCell);
                        IntVec3 newTile = tileList.RandomElement();
                        if (newTile.InBounds(map))
                        {
                            if (!map.terrainGrid.TerrainAt(newTile).defName.Contains("Water") &&
                                map.terrainGrid.TerrainAt(newTile).defName != "Marsh" &&
                                map.terrainGrid.TerrainAt(newTile).defName != "BridgeMarsh" &&
                                map.terrainGrid.TerrainAt(newTile).defName != "Bridge")
                            {
                                toFreeze++;
                                tempConstant++;
                            }
                            if (terrainDef.defName == "WaterOceanShallow")
                            {
                                if (Rand.Value < shallowSpeed * toFreeze * (tempConstant * 30f))
                                {
                                    string iceName;
                                    if (terrainDef.defName == "WaterOceanShallow")
                                    {
                                        iceName = "IceOceanShallow";
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                    map.terrainGrid.SetTerrain(terrainCell, TerrainDef.Named(iceName));
                                }
                            }
                        }
                    }
                }
                if (terrainTemp < -20f)
                {
                    if (terrainDef.defName == "WaterMovingShallow" || terrainDef.defName == "WaterMovingChestDeep")
                    {
                        int            toFreeze     = 0;
                        float          tempConstant = 0f;
                        List <IntVec3> tileList     = GenAdjFast.AdjacentCellsCardinal(terrainCell);
                        tileList.Add(terrainCell);
                        IntVec3 newTile = tileList.RandomElement();
                        if (newTile.InBounds(map))
                        {
                            if (!map.terrainGrid.TerrainAt(newTile).defName.Contains("Water") &&
                                map.terrainGrid.TerrainAt(newTile).defName != "Marsh" &&
                                map.terrainGrid.TerrainAt(newTile).defName != "BridgeMarsh" &&
                                map.terrainGrid.TerrainAt(newTile).defName != "Bridge")
                            {
                                toFreeze++;
                                tempConstant++;
                            }
                            if (terrainDef.defName == "WaterMovingShallow")
                            {
                                if (Rand.Value < shallowSpeed * toFreeze * (tempConstant * 30f))
                                {
                                    string iceName;
                                    if (terrainDef.defName == "WaterMovingShallow")
                                    {
                                        iceName = "IceMovingShallow";
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                    map.terrainGrid.SetTerrain(terrainCell, TerrainDef.Named(iceName));
                                }
                            }
                            if (terrainDef.defName == "WaterMovingChestDeep")
                            {
                                if (Rand.Value < deepSpeed * toFreeze * (tempConstant * 3f))
                                {
                                    string iceName;
                                    if (terrainDef.defName == "WaterMovingChestDeep")
                                    {
                                        iceName = "IceMovingChestDeep";
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                    map.terrainGrid.SetTerrain(terrainCell, TerrainDef.Named(iceName));
                                }
                            }
                        }
                    }
                }
                if (terrainTemp < 0f)
                {
                    if (terrainDef.defName == "WaterShallow" || terrainDef.defName == "Marsh" || terrainDef.defName == "WaterDeep" || terrainDef.defName == "WaterOceanShallow")
                    {
                        int            toFreeze     = 0;
                        float          tempConstant = 0f;
                        List <IntVec3> tileList     = GenAdjFast.AdjacentCellsCardinal(terrainCell);
                        tileList.Add(terrainCell);
                        IntVec3 newTile = tileList.RandomElement();
                        if (newTile.InBounds(map))
                        {
                            if (!map.terrainGrid.TerrainAt(newTile).defName.Contains("Water") &&
                                map.terrainGrid.TerrainAt(newTile).defName != "Marsh" &&
                                map.terrainGrid.TerrainAt(newTile).defName != "BridgeMarsh" &&
                                map.terrainGrid.TerrainAt(newTile).defName != "Bridge")
                            {
                                toFreeze++;
                                tempConstant++;
                            }
                            if (terrainDef.defName == "WaterShallow" || terrainDef.defName == "Marsh")
                            {
                                if (Rand.Value < shallowSpeed * toFreeze * (tempConstant * 10f))
                                {
                                    string iceName;
                                    if (terrainDef.defName == "WaterShallow")
                                    {
                                        iceName = "IceShallow";
                                    }
                                    else
                                    {
                                        iceName = "IceMarsh";
                                    }
                                    map.terrainGrid.SetTerrain(terrainCell, TerrainDef.Named(iceName));
                                }
                            }
                            if (terrainDef.defName == "WaterDeep")
                            {
                                if (Rand.Value < deepSpeed * toFreeze * (tempConstant * 10f))
                                {
                                    string iceName;
                                    if (terrainDef.defName == "WaterDeep")
                                    {
                                        iceName = "IceDeep";
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                    map.terrainGrid.SetTerrain(terrainCell, TerrainDef.Named(iceName));
                                }
                            }
                        }
                    }
                }

                // Thaw process
                if (terrainTemp > -19f)
                {
                    if (terrainDef.defName == "IceOceanShallow")
                    {
                        int            toThaw       = 0;
                        float          tempConstant = 0f;
                        List <IntVec3> tileList     = GenAdjFast.AdjacentCellsCardinal(terrainCell);
                        tileList.Add(terrainCell);
                        IntVec3 newTile = tileList.RandomElement();
                        if (newTile.InBounds(map))
                        {
                            if (!map.terrainGrid.TerrainAt(newTile).defName.Contains("Ice") &&
                                map.terrainGrid.TerrainAt(newTile).defName != "BridgeMarsh" &&
                                map.terrainGrid.TerrainAt(newTile).defName != "Bridge")
                            {
                                toThaw++;
                                tempConstant++;
                            }
                            if (Rand.Value < thawSpeed * toThaw * (tempConstant * 5f))
                            {
                                string waterName;
                                if (terrainDef.defName == "IceOceanShallow")
                                {
                                    waterName = "WaterOceanShallow";
                                }
                                else
                                {
                                    continue;
                                }
                                if (waterName.Contains("Water"))
                                {
                                    map.snowGrid.SetDepth(terrainCell, 0f);
                                }
                                map.terrainGrid.SetTerrain(terrainCell, TerrainDef.Named(waterName));
                            }
                        }
                    }
                }
                if (terrainTemp > -13f)
                {
                    if (terrainDef.defName == "IceMovingShallow" || terrainDef.defName == "IceMovingChestDeep")
                    {
                        int            toThaw       = 0;
                        float          tempConstant = 0f;
                        List <IntVec3> tileList     = GenAdjFast.AdjacentCellsCardinal(terrainCell);
                        tileList.Add(terrainCell);
                        IntVec3 newTile = tileList.RandomElement();
                        if (newTile.InBounds(map))
                        {
                            if (!map.terrainGrid.TerrainAt(newTile).defName.Contains("Ice") &&
                                map.terrainGrid.TerrainAt(newTile).defName != "BridgeMarsh" &&
                                map.terrainGrid.TerrainAt(newTile).defName != "Bridge")
                            {
                                toThaw++;
                                tempConstant++;
                            }
                            if (Rand.Value < thawSpeed * toThaw * (tempConstant * 5f))
                            {
                                string waterName;
                                if (terrainDef.defName == "IceMovingShallow")
                                {
                                    waterName = "WaterMovingShallow";
                                }
                                else
                                {
                                    waterName = "WaterMovingChestDeep";
                                }

                                if (waterName.Contains("Water"))
                                {
                                    map.snowGrid.SetDepth(terrainCell, 0f);
                                }
                                map.terrainGrid.SetTerrain(terrainCell, TerrainDef.Named(waterName));
                            }
                        }
                    }
                }
                if (terrainTemp > 0f)
                {
                    if (terrainDef.defName == "IceShallow" || terrainDef.defName == "IceDeep" || terrainDef.defName == "IceMarsh")
                    {
                        int            toThaw   = 0;
                        List <IntVec3> tileList = GenAdjFast.AdjacentCellsCardinal(terrainCell);
                        tileList.Add(terrainCell);
                        IntVec3 newTile = tileList.RandomElement();
                        if (newTile.InBounds(map))
                        {
                            if (!map.terrainGrid.TerrainAt(newTile).defName.Contains("Ice") &&
                                map.terrainGrid.TerrainAt(newTile).defName != "BridgeMarsh" &&
                                map.terrainGrid.TerrainAt(newTile).defName != "Bridge")
                            {
                                toThaw++;
                            }
                            if (Rand.Value < thawSpeed * toThaw)
                            {
                                string waterName;
                                if (terrainDef.defName == "IceShallow")
                                {
                                    waterName = "WaterShallow";
                                }
                                else if (terrainDef.defName == "IceDeep")
                                {
                                    waterName = "WaterDeep";
                                }
                                else
                                {
                                    waterName = "Marsh";
                                }

                                if (waterName.Contains("Water") || waterName == "Marsh")
                                {
                                    map.snowGrid.SetDepth(terrainCell, 0f);
                                }
                                map.terrainGrid.SetTerrain(terrainCell, TerrainDef.Named(waterName));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 22
0
        public static void GenerateSecondaryEntranceZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation);

            // Generate central paved alley.
            for (int xOffset = 4; xOffset <= 6; xOffset++)
            {
                for (int zOffset = 0; zOffset < Genstep_GenerateOutpost.zoneSideSize; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            for (int zOffset = 0; zOffset < Genstep_GenerateOutpost.zoneSideSize; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }

            // Generate north west turret.
            IntVec3 northWestOrigin = rotatedOrigin + new IntVec3(1, 0, 6).RotatedBy(rotation);

            for (int xOffset = 0; xOffset < 4; xOffset++)
            {
                for (int zOffset = 0; zOffset < 4; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(northWestOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(0, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(3, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(0, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(1, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(2, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(3, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(OG_Util.VulcanTurretDef, ThingDefOf.Steel, northWestOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);

            // Generate north east turret.
            IntVec3 norththEastOrigin = rotatedOrigin + new IntVec3(6, 0, 6).RotatedBy(rotation);

            for (int xOffset = 0; xOffset < 4; xOffset++)
            {
                for (int zOffset = 0; zOffset < 4; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(norththEastOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, norththEastOrigin + new IntVec3(0, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, norththEastOrigin + new IntVec3(3, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, norththEastOrigin + new IntVec3(0, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, norththEastOrigin + new IntVec3(1, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, norththEastOrigin + new IntVec3(2, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, norththEastOrigin + new IntVec3(3, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(OG_Util.VulcanTurretDef, ThingDefOf.Steel, norththEastOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);

            // Spawn south west sandbags and floor.
            IntVec3 southWestOrigin = rotatedOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation);

            for (int xOffset = 0; xOffset < 3; xOffset++)
            {
                for (int zOffset = 0; zOffset < 3; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(southWestOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(0, 0, 0).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(0, 0, 1).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(0, 0, 2).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(1, 0, 2).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(2, 0, 2).RotatedBy(rotation), false, Rot4.North, ref outpostData);

            // Spawn south east sandbags and floor.
            IntVec3 southEastOrigin = rotatedOrigin + new IntVec3(6, 0, 1).RotatedBy(rotation);

            for (int xOffset = 0; xOffset < 3; xOffset++)
            {
                for (int zOffset = 0; zOffset < 3; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(southEastOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(2, 0, 0).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(0, 0, 2).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(1, 0, 2).RotatedBy(rotation), false, Rot4.North, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(2, 0, 2).RotatedBy(rotation), false, Rot4.North, ref outpostData);
        }
Ejemplo n.º 23
0
        public void ChangeTheGraphics()
        {
            if (this.Map != null)
            {
                Vector2       vector            = this.ageTracker.CurKindLifeStage.bodyGraphicData.drawSize;
                Graphic_Multi dessicatedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(this.ageTracker.CurKindLifeStage.dessicatedBodyGraphicData.texPath, ShaderDatabase.Cutout, vector, Color.white);

                if ((this.Position.GetTerrain(this.Map) == TerrainDef.Named("Ice")) || (this.Position.GetSnowDepth(this.Map) > 0) || (this.Map.mapTemperature.OutdoorTemp < -10f))
                {
                    LongEventHandler.ExecuteWhenFinished(delegate
                    {
                        Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(this.ageTracker.CurKindLifeStage.bodyGraphicData.texPath + "Winter", ShaderDatabase.Cutout, vector, Color.white);
                        this.pawn_renderer.graphics.nakedGraphic      = nakedGraphic;
                        this.pawn_renderer.graphics.dessicatedGraphic = dessicatedGraphic;
                        (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = this.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                        StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMin, -60f);
                        StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMax, 10f);
                    });
                    woolType = 1;
                }
                else if ((this.Position.GetTerrain(this.Map) == TerrainDef.Named("MossyTerrain")) || (this.Position.GetTerrain(this.Map) == TerrainDef.Named("MarshyTerrain")) || (this.Position.GetTerrain(this.Map) == TerrainDef.Named("SoilRich")) ||
                         (this.Position.GetTerrain(this.Map).IsWater))
                {
                    LongEventHandler.ExecuteWhenFinished(delegate
                    {
                        Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(this.ageTracker.CurKindLifeStage.bodyGraphicData.texPath + "Jungle", ShaderDatabase.Cutout, vector, Color.white);
                        this.pawn_renderer.graphics.nakedGraphic      = nakedGraphic;
                        this.pawn_renderer.graphics.dessicatedGraphic = dessicatedGraphic;

                        (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = this.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                        StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMin, -10f);
                        StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMax, 35f);
                    });
                    woolType = 2;
                }
                else if ((this.Position.GetTerrain(this.Map) == TerrainDef.Named("Sand")) || (this.Position.GetTerrain(this.Map) == TerrainDef.Named("SoftSand")))
                {
                    LongEventHandler.ExecuteWhenFinished(delegate
                    {
                        Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(this.ageTracker.CurKindLifeStage.bodyGraphicData.texPath + "Desert", ShaderDatabase.Cutout, vector, Color.white);
                        this.pawn_renderer.graphics.nakedGraphic      = nakedGraphic;
                        this.pawn_renderer.graphics.dessicatedGraphic = dessicatedGraphic;

                        (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = this.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                        StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMin, 0f);
                        StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMax, 65f);
                    });
                    woolType = 3;
                }
                else
                {
                    LongEventHandler.ExecuteWhenFinished(delegate
                    {
                        Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(this.ageTracker.CurKindLifeStage.bodyGraphicData.texPath, ShaderDatabase.Cutout, vector, Color.white);
                        this.pawn_renderer.graphics.nakedGraphic      = nakedGraphic;
                        this.pawn_renderer.graphics.dessicatedGraphic = dessicatedGraphic;

                        (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = this.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                        StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMin, -10f);
                        StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMax, 35f);
                    });
                    woolType = 0;
                }
            }
            else
            {
                StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMin, -60f);
                StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMax, 60f);
            }
        }
Ejemplo n.º 24
0
        public static void GenerateEntranchedZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation);
            IntVec3 cell          = rotatedOrigin;

            // Generate south west battery shelter.
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(0, 0, 0).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(3, 0, 0).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(0, 0, 3).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(3, 0, 3).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            for (int xOffset = 0; xOffset < 4; xOffset++)
            {
                for (int zOffset = 0; zOffset < 4; zOffset++)
                {
                    cell = rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation);
                    Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Concrete);
                    Find.RoofGrid.SetRoof(cell, OG_Util.IronedRoofDef);
                }
            }

            // Generate south east battery shelter.
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(7, 0, 0).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(10, 0, 0).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(7, 0, 3).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnWallAt(rotatedOrigin + new IntVec3(10, 0, 3).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(8, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(9, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            for (int xOffset = 7; xOffset < 11; xOffset++)
            {
                for (int zOffset = 0; zOffset < 4; zOffset++)
                {
                    cell = rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation);
                    Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Concrete);
                    Find.RoofGrid.SetRoof(cell, OG_Util.IronedRoofDef);
                }
            }

            // Generate central paved alley.
            for (int xOffset = 4; xOffset <= 6; xOffset++)
            {
                for (int zOffset = 0; zOffset < 7; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            for (int zOffset = 0; zOffset < 7; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }

            // Generate north west force field.
            IntVec3 northWestOrigin = rotatedOrigin + new IntVec3(0, 0, 6).RotatedBy(rotation);

            for (int xOffset = 0; xOffset < 5; xOffset++)
            {
                for (int zOffset = 0; zOffset < 2; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(northWestOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            for (int xOffset = 1; xOffset <= 3; xOffset++)
            {
                Find.TerrainGrid.SetTerrain(northWestOrigin + new IntVec3(xOffset, 0, 2).RotatedBy(rotation), TerrainDefOf.Concrete);
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(0, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(1, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(2, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(3, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(3, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northWestOrigin + new IntVec3(4, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            for (int zOffset = -3; zOffset <= 3; zOffset++)
            {
                if ((zOffset == 1) &&
                    ModsConfig.IsActive("M&Co. ForceField"))
                {
                    // Do not spawn power conduit under force field as it generates a warning message.
                    continue;
                }
                OG_Common.SpawnFireproofPowerConduitAt(northWestOrigin + new IntVec3(2, 0, zOffset).RotatedBy(rotation), ref outpostData);
            }
            if (ModsConfig.IsActive("M&Co. ForceField"))
            {
                OG_Common.TrySpawnThingAt(ThingDef.Named("ForceFieldGenerator"), null, northWestOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            }

            // Generate central sandbag.
            cell = rotatedOrigin + new IntVec3(5, 0, 7).RotatedBy(rotation);
            Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Concrete);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, cell, false, Rot4.Invalid, ref outpostData);

            // Generate north east force field.
            IntVec3 northEastOrigin = rotatedOrigin + new IntVec3(6, 0, 6).RotatedBy(rotation);

            for (int xOffset = 0; xOffset < 5; xOffset++)
            {
                for (int zOffset = 0; zOffset < 2; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(northEastOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            for (int xOffset = 1; xOffset <= 3; xOffset++)
            {
                Find.TerrainGrid.SetTerrain(northEastOrigin + new IntVec3(xOffset, 0, 2).RotatedBy(rotation), TerrainDefOf.Concrete);
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(0, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(1, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(2, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(3, 0, 2).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(3, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, northEastOrigin + new IntVec3(4, 0, 1).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            for (int zOffset = -3; zOffset <= 3; zOffset++)
            {
                if ((zOffset == 1) &&
                    ModsConfig.IsActive("M&Co. ForceField"))
                {
                    // Do not spawn power conduit under force field as it generates a warning message.
                    continue;
                }
                OG_Common.SpawnFireproofPowerConduitAt(northEastOrigin + new IntVec3(2, 0, zOffset).RotatedBy(rotation), ref outpostData);
            }
            if (ModsConfig.IsActive("M&Co. ForceField"))
            {
                OG_Common.TrySpawnThingAt(ThingDef.Named("ForceFieldGenerator"), null, northEastOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            }
        }
Ejemplo n.º 25
0
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot)
        {
            TerrainDef terrainDef = Find.TerrainGrid.TerrainAt(loc);

            if (terrainDef != TerrainDef.Named("WaterShallow") && terrainDef != TerrainDef.Named("WaterDeep") && terrainDef != TerrainDef.Named("Marsh"))
            {
                return(new AcceptanceReport("Water pump must be placed on a Water."));
            }
            List <Thing> list  = Find.ListerThings.ThingsOfDef(Util_Industrialisation.WaterPumpDef);
            List <Thing> list2 = Find.ListerThings.ThingsOfDef(Util_Industrialisation.WaterPumpDef.blueprintDef);
            List <Thing> list3 = Find.ListerThings.ThingsOfDef(Util_Industrialisation.WaterPumpDef.frameDef);

            if (list != null && (from building in list
                                 where loc.InHorDistOf(building.Position, 15f)
                                 select building).Count <Thing>() > 0)
            {
                return(new AcceptanceReport("An other water pump is too close."));
            }
            if (list2 != null && (from building in list2
                                  where loc.InHorDistOf(building.Position, 15f)
                                  select building).Count <Thing>() > 0)
            {
                return(new AcceptanceReport("An other water pump blueprint is too close."));
            }
            if (list3 != null && (from building in list3
                                  where loc.InHorDistOf(building.Position, 15f)
                                  select building).Count <Thing>() > 0)
            {
                return(new AcceptanceReport("An other water pump frame is too close."));
            }
            return(true);
        }
Ejemplo n.º 26
0
        public static void GenerateMainEntranceZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation);
            IntVec3 cell          = rotatedOrigin;

            // Spawn concrete floor.
            for (int xOffset = -1; xOffset <= 11; xOffset++)
            {
                for (int zOffset = -1; zOffset <= 5; zOffset++)
                {
                    cell = rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation);
                    Find.TerrainGrid.SetTerrain(cell, TerrainDefOf.Concrete);
                }
            }

            // Generate central paved alley.
            for (int xOffset = 4; xOffset <= 6; xOffset++)
            {
                for (int zOffset = 0; zOffset <= 10; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            for (int zOffset = -1; zOffset <= 10; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }

            // Generate south west turret.
            IntVec3 southWestOrigin = rotatedOrigin;

            for (int xOffset = 0; xOffset < 5; xOffset++)
            {
                for (int zOffset = 0; zOffset < 5; zOffset++)
                {
                    cell = southWestOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation);
                    if ((xOffset == 0) ||
                        (zOffset == 0))
                    {
                        OG_Common.TrySpawnWallAt(cell, ref outpostData);
                        OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
                    }
                }
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(1, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(2, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(3, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(4, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southWestOrigin + new IntVec3(4, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(OG_Util.VulcanTurretDef, ThingDefOf.Steel, southWestOrigin + new IntVec3(2, 0, 2).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);

            // Generate south east turret.
            IntVec3 southEastOrigin = rotatedOrigin;

            for (int xOffset = 6; xOffset < 11; xOffset++)
            {
                for (int zOffset = 0; zOffset < 5; zOffset++)
                {
                    cell = southEastOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation);
                    if ((xOffset == 10) ||
                        (zOffset == 0))
                    {
                        OG_Common.TrySpawnWallAt(cell, ref outpostData);
                        OG_Common.SpawnFireproofPowerConduitAt(cell, ref outpostData);
                    }
                }
            }
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(6, 0, 3).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(6, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(7, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(8, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Sandbags, null, southEastOrigin + new IntVec3(9, 0, 4).RotatedBy(rotation), false, Rot4.Invalid, ref outpostData);
            OG_Common.TrySpawnThingAt(OG_Util.VulcanTurretDef, ThingDefOf.Steel, southEastOrigin + new IntVec3(7, 0, 2).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);

            // Generate central door and power conduit.
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, 0).RotatedBy(rotation), ref outpostData);
            OG_Common.SpawnFireproofPowerConduitAt(rotatedOrigin + new IntVec3(5, 0, 0).RotatedBy(rotation), ref outpostData);

            // Generate ironed roof.
            for (int xOffset = 0; xOffset <= 10; xOffset++)
            {
                for (int zOffset = 0; zOffset <= 4; zOffset++)
                {
                    Find.RoofGrid.SetRoof(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), OG_Util.IronedRoofDef);
                }
            }
        }
Ejemplo n.º 27
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            QualityCategory      fishingEquipmentQuality = QualityCategory.Normal;
            float                catchSomethingThreshold = 0f;
            Building_FishingPier fishingPier             = this.TargetThingA as Building_FishingPier;
            Passion              passion = Passion.None;
            int         fishingDuration  = 1000;
            const float skillGainPerTick = 0.15f;
            float       skillGainFactor  = 0f;

            this.AddEndCondition(() =>
            {
                var targ = this.pawn.jobs.curJob.GetTarget(fishingPierIndex).Thing;
                if (targ is Building && !targ.Spawned)
                {
                    return(JobCondition.Incompletable);
                }
                return(JobCondition.Ongoing);
            });

            this.FailOnBurningImmobile(fishingPierIndex); // Bill giver or product burning in carry phase.

            yield return(Toils_Reserve.Reserve(fishingPierIndex));

            float statValue = this.pawn.GetStatValue(Util_FishIndustry.FishingSpeedDef, true);

            fishingDuration = (int)Math.Round((double)(800f / statValue));

            yield return(Toils_Goto.GotoThing(fishingPierIndex, fishingPier.riverCell).FailOnDespawnedOrNull(fishingPierIndex));

            Toil verifyFisherHasFishingEquipmentToil = new Toil()
            {
                initAction = () =>
                {
                    if ((this.pawn.equipment.Primary != null) &&
                        (this.pawn.equipment.Primary.def == Util_FishIndustry.HarpoonDef))
                    {
                        this.fishingEquipment = FishingEquipment.Harpoon;
                        this.pawn.equipment.Primary.TryGetQuality(out fishingEquipmentQuality);
                    }
                    foreach (Apparel apparel in this.pawn.apparel.WornApparel)
                    {
                        if (apparel.def == Util_FishIndustry.FishingRodDef)
                        {
                            this.fishingEquipment = FishingEquipment.FishingRod;
                            apparel.TryGetQuality(out fishingEquipmentQuality);
                            break;
                        }
                    }
                    if (this.fishingEquipment == FishingEquipment.NoEquipment)
                    {
                        this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
                    }
                }
            };

            yield return(verifyFisherHasFishingEquipmentToil);

            Toil fishToil = new Toil()
            {
                initAction = () =>
                {
                    ThingDef moteDef = null;

                    switch (fishingEquipment)
                    {
                    case FishingEquipment.FishingRod:
                        if (fishingPier.Rotation == Rot4.North)
                        {
                            moteDef = Util_FishIndustry.MoteFishingRodNorthDef;
                        }
                        else if (fishingPier.Rotation == Rot4.East)
                        {
                            moteDef = Util_FishIndustry.MoteFishingRodEastDef;
                        }
                        else if (fishingPier.Rotation == Rot4.South)
                        {
                            moteDef = Util_FishIndustry.MoteFishingRodSouthDef;
                        }
                        else
                        {
                            moteDef = Util_FishIndustry.MoteFishingRodWestDef;
                        }
                        break;
                    }
                    if (moteDef != null)
                    {
                        fishingEquipmentMote = (MoteThrown)ThingMaker.MakeThing(moteDef);
                        fishingEquipmentMote.exactPosition   = fishingPier.fishingSpotCell.ToVector3Shifted();
                        fishingEquipmentMote.exactPosition.y = Altitudes.AltitudeFor(AltitudeLayer.VisEffects);
                        GenSpawn.Spawn(fishingEquipmentMote, fishingPier.fishingSpotCell);
                    }
                    WorkTypeDef fishingWorkDef = DefDatabase <WorkTypeDef> .GetNamed("Fishing");

                    passion = this.pawn.skills.MaxPassionOfRelevantSkillsFor(fishingWorkDef);
                    if (passion == Passion.None)
                    {
                        skillGainFactor = 0.3f;
                    }
                    else if (passion == Passion.Minor)
                    {
                        skillGainFactor = 1f;
                    }
                    else
                    {
                        skillGainFactor = 1.5f;
                    }
                },
                tickAction = () =>
                {
                    switch (fishingEquipment)
                    {
                    case FishingEquipment.FishingRod:
                        fishingEquipmentMote.Maintain();
                        break;

                    case FishingEquipment.Harpoon:
                        if (Find.TickManager.TicksGame % GenTicks.TickRareInterval == 0)
                        {
                            Bullet     thrownHarpoon = GenSpawn.Spawn(Util_FishIndustry.HarpoonDef.Verbs.First().projectileDef, this.pawn.Position) as Bullet;
                            TargetInfo targetCell    = new TargetInfo(fishingPier.fishingSpotCell + new IntVec3(Rand.RangeInclusive(-1, 1), 0, Rand.RangeInclusive(0, 2)).RotatedBy(fishingPier.Rotation));
                            thrownHarpoon.Launch(this.pawn, targetCell);
                        }
                        break;
                    }
                    this.pawn.Drawer.rotator.FaceCell(fishingPier.fishingSpotCell);

                    if (passion == Passion.Minor)
                    {
                        this.pawn.needs.joy.GainJoy(NeedTunings.JoyPerXpForPassionMinor, JoyKindDefOf.Work);
                    }
                    else if (passion == Passion.Major)
                    {
                        this.pawn.needs.joy.GainJoy(NeedTunings.JoyPerXpForPassionMajor, JoyKindDefOf.Work);
                    }
                    SkillDef fishingSkillDef = DefDatabase <SkillDef> .GetNamed("Fishing");

                    this.pawn.skills.Learn(fishingSkillDef, skillGainPerTick * skillGainFactor);
                },
                defaultDuration     = fishingDuration,
                defaultCompleteMode = ToilCompleteMode.Delay
            };

            yield return(fishToil.WithProgressBarToilDelay(fishingPierIndex));

            yield return(verifyFisherHasFishingEquipmentToil); // Could be dropped during fishToil.

            Toil computeChanceToCatchToil = new Toil()
            {
                initAction = () =>
                {
                    float       fishingSkillLevel = 0f;
                    WorkTypeDef fishingWorkDef    = DefDatabase <WorkTypeDef> .GetNamed("Fishing");

                    fishingSkillLevel = this.pawn.skills.AverageOfRelevantSkillsFor(fishingWorkDef);
                    float fishingEquipmentQualityFactor = (float)fishingEquipmentQuality / (float)QualityCategory.Legendary;
                    float fishingSkillFactor            = fishingSkillLevel / 20f;
                    float snowFactor             = 1 - Find.SnowGrid.GetDepth(fishingPier.fishingSpotCell);
                    float fishingEquipmentOffset = 0f;
                    switch (this.fishingEquipment)
                    {
                    case FishingEquipment.Harpoon:
                        fishingEquipmentOffset = 0.2f;
                        break;

                    case FishingEquipment.FishingRod:
                        fishingEquipmentOffset = 0.5f;
                        break;
                    }
                    catchSomethingThreshold = ((fishingEquipmentOffset * fishingEquipmentQualityFactor) + 0.4f * fishingSkillFactor) * (0.25f + 0.75f * snowFactor);
                    // Reframe min and max chance (min 5%, max 75 % chance of success).
                    catchSomethingThreshold = catchSomethingThreshold * 0.75f;
                    catchSomethingThreshold = Math.Max(catchSomethingThreshold, 0.05f);
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            };

            yield return(computeChanceToCatchToil);

            Toil catchFishToil = new Toil()
            {
                initAction = () =>
                {
                    Job   curJob       = this.pawn.jobs.curJob;
                    Thing fishingCatch = null;

                    bool catchIsSuccessful = Rand.Value <= catchSomethingThreshold;
                    if (catchIsSuccessful == false)
                    {
                        MoteThrower.ThrowDrift(this.pawn.Position, ThingDefOf.Mote_IncapIcon);
                        this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
                        return;
                    }

                    float catchSelectorValue = Rand.Value;
                    if (catchSelectorValue > 0.04f)
                    {
                        // Catch a fish.
                        TerrainDef      fishSpotType    = Find.TerrainGrid.TerrainAt(fishingPier.fishingSpotCell);
                        List <ThingDef> fishSpeciesList = null;
                        ThingDef_FishSpeciesProperties.AquaticEnvironment aquaticEnvironment;
                        ThingDef_FishSpeciesProperties.LivingTime         livingTime;
                        float fishSpeciesTotalCommonality = 0f;
                        float fishSpeciesCommonalitySum   = 0f;

                        // Aquatic environment.
                        if (fishSpotType == TerrainDef.Named("Marsh"))
                        {
                            aquaticEnvironment = ThingDef_FishSpeciesProperties.AquaticEnvironment.Marsh;
                        }
                        else
                        {
                            aquaticEnvironment = ThingDef_FishSpeciesProperties.AquaticEnvironment.Sea;
                        }
                        // Day time.
                        if (SkyManager.CurSkyGlow >= 0.4f)
                        {
                            livingTime = ThingDef_FishSpeciesProperties.LivingTime.Day;
                        }
                        else
                        {
                            livingTime = ThingDef_FishSpeciesProperties.LivingTime.Night;
                        }

                        fishSpeciesList             = Util_FishIndustry.GetFishSpeciesList(aquaticEnvironment, livingTime);
                        fishSpeciesTotalCommonality = Util_FishIndustry.GetFishSpeciesTotalCommonality(aquaticEnvironment, livingTime);

                        float    randomSelector      = Rand.Range(0f, fishSpeciesTotalCommonality);
                        ThingDef selectedFishSpecies = null;
                        for (int fishSpeciesIndex = 0; fishSpeciesIndex < fishSpeciesList.Count; fishSpeciesIndex++)
                        {
                            ThingDef_FishSpeciesProperties currentFishSpecies = fishSpeciesList[fishSpeciesIndex] as ThingDef_FishSpeciesProperties;
                            fishSpeciesCommonalitySum += currentFishSpecies.commonality;

                            if (randomSelector <= fishSpeciesCommonalitySum)
                            {
                                selectedFishSpecies = currentFishSpecies;
                                break;
                            }
                        }

                        fishingCatch            = GenSpawn.Spawn(selectedFishSpecies, this.pawn.Position);
                        fishingCatch.stackCount = (selectedFishSpecies as ThingDef_FishSpeciesProperties).catchQuantity;
                        fishingPier.fishStock--;
                    }
                    else if (catchSelectorValue > 0.02)
                    {
                        fishingCatch            = GenSpawn.Spawn(Util_FishIndustry.OysterDef, this.pawn.Position);
                        fishingCatch.stackCount = Rand.RangeInclusive(5, 27);
                    }
                    else
                    {
                        float bonusCatchValue = Rand.Value;
                        if (bonusCatchValue < 0.01f)
                        {
                            // Really small chance to find a sunken treasure!!!
                            fishingCatch            = GenSpawn.Spawn(ThingDefOf.Gold, this.pawn.Position);
                            fishingCatch.stackCount = Rand.RangeInclusive(58, 289);
                            Thing treasureSilver = GenSpawn.Spawn(ThingDefOf.Silver, fishingPier.middleCell);
                            treasureSilver.stackCount = Rand.RangeInclusive(237, 2154);
                            string eventText = this.pawn.Name.ToStringShort.CapitalizeFirst() + " has found a sunken treasure while fishing! What a good catch!\n";
                            Find.LetterStack.ReceiveLetter("Sunken treasure!", eventText, LetterType.Good, this.pawn.Position);
                        }
                        else if (bonusCatchValue < 0.02f)
                        {
                            // Really small chance to find a complete power armor set + sniper or charge rifle.
                            Thing powerArmor = GenSpawn.Spawn(ThingDef.Named("Apparel_PowerArmor"), this.pawn.Position);
                            fishingCatch = powerArmor; // Used to carry the power armor.
                            Thing powerArmorHelmet = GenSpawn.Spawn(ThingDef.Named("Apparel_PowerArmorHelmet"), this.pawn.Position);
                            Thing rifle            = null;
                            if (Rand.Value < 0.5f)
                            {
                                rifle = GenSpawn.Spawn(ThingDef.Named("Gun_ChargeRifle"), this.pawn.Position);
                            }
                            else
                            {
                                rifle = GenSpawn.Spawn(ThingDef.Named("Gun_SniperRifle"), this.pawn.Position);
                            }
                            CompQuality qualityComp = powerArmor.TryGetComp <CompQuality>();
                            if (qualityComp != null)
                            {
                                qualityComp.SetQuality(QualityCategory.Masterwork, ArtGenerationContext.Outsider);
                            }
                            qualityComp = powerArmorHelmet.TryGetComp <CompQuality>();
                            if (qualityComp != null)
                            {
                                qualityComp.SetQuality(QualityCategory.Masterwork, ArtGenerationContext.Outsider);
                            }
                            qualityComp = rifle.TryGetComp <CompQuality>();
                            if (qualityComp != null)
                            {
                                qualityComp.SetQuality(QualityCategory.Masterwork, ArtGenerationContext.Outsider);
                            }

                            Faction faction    = Find.FactionManager.FirstFactionOfDef(FactionDefOf.SpacerHostile);
                            Pawn    deadMarine = PawnGenerator.GeneratePawn(PawnKindDefOf.SpaceSoldier, faction);
                            GenSpawn.Spawn(deadMarine, fishingPier.bankCell);
                            HealthUtility.GiveInjuriesToKill(deadMarine);
                            List <Thing> thingsList = deadMarine.Position.GetThingList();
                            foreach (Thing thing in thingsList)
                            {
                                if (thing.def.defName.Contains("Corpse"))
                                {
                                    CompRottable rotComp = thing.TryGetComp <CompRottable>();
                                    if (rotComp != null)
                                    {
                                        rotComp.rotProgress = 20f * 60000f; // 20 days so the corpse is dessicated.
                                    }
                                }
                            }
                            string eventText = this.pawn.Name.ToStringShort.CapitalizeFirst() + " has cought a dead body while fishing!\n\n'This is really disgusting but look at his gear! This guy was probably a Mining & Co. security member. I wonder what happend to him...'\n";
                            Find.LetterStack.ReceiveLetter("Dead marine", eventText, LetterType.Good, this.pawn.Position);
                        }
                        else
                        {
                            // Find a small amount of gold.
                            fishingCatch            = GenSpawn.Spawn(ThingDefOf.Gold, this.pawn.Position);
                            fishingCatch.stackCount = Rand.RangeInclusive(1, 7);
                        }
                        // TODO: add chance to get hurt by a tailteeth (missing finger or even hand!).
                    }
                    IntVec3 storageCell;
                    if (StoreUtility.TryFindBestBetterStoreCellFor(fishingCatch, this.pawn, StoragePriority.Unstored, this.pawn.Faction, out storageCell, true))
                    {
                        this.pawn.carrier.TryStartCarry(fishingCatch);
                        curJob.targetB       = storageCell;
                        curJob.targetC       = fishingCatch;
                        curJob.maxNumToCarry = 99999;
                    }
                    else
                    {
                        this.pawn.jobs.EndCurrentJob(JobCondition.Succeeded);
                    }
                }
            };

            yield return(catchFishToil);

            // Reserve the product and storage cell.
            yield return(Toils_Reserve.Reserve(TargetIndex.B));

            yield return(Toils_Reserve.Reserve(TargetIndex.C));

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true));

            yield return(Toils_Reserve.Release(fishingPierIndex));
        }
Ejemplo n.º 28
0
        public static void GenerateBigSasZone(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, bool generateSecondarySas, ref OG_OutpostData outpostData)
        {
            IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation);
            IntVec3 cell          = rotatedOrigin;

            OG_Common.GenerateEmptyRoomAt(rotatedOrigin + new IntVec3(3, 0, -1).RotatedBy(rotation), 5, 13, rotation, null, null, ref outpostData);

            // Spawn lamps.
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(4, 0, 2).RotatedBy(rotation), Color.white, ref outpostData);
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(4, 0, 8).RotatedBy(rotation), Color.white, ref outpostData);

            // Spawn floor and roof.
            for (int xOffset = 2; xOffset <= 8; xOffset++)
            {
                for (int zOffset = 0; zOffset < 11; zOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                }
            }
            for (int zOffset = 0; zOffset < 11; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }

            // Spawn doors.
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, -1).RotatedBy(rotation), ref outpostData);
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, 11).RotatedBy(rotation), ref outpostData);

            // Spawn secondary sas.
            if (generateSecondarySas)
            {
                OG_Common.GenerateEmptyRoomAt(rotatedOrigin + new IntVec3(3, 0, 4).RotatedBy(rotation), 3, 6, new Rot4(rotation.AsInt + Rot4.West.AsInt), null, null, ref outpostData);

                // Spawn concrete and paved alley (don't use standard default floor as it may overlap existing medium room floor).
                for (int xOffset = -2; xOffset <= 4; xOffset++)
                {
                    for (int zOffset = 3; zOffset <= 7; zOffset++)
                    {
                        Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, zOffset).RotatedBy(rotation), TerrainDefOf.Concrete);
                    }
                }
                for (int xOffset = -2; xOffset <= 4; xOffset++)
                {
                    Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, 5).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
                }
                // Spawn doors.
                OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(-2, 0, 5).RotatedBy(rotation), ref outpostData);
                OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(3, 0, 5).RotatedBy(rotation), ref outpostData);
            }
        }
Ejemplo n.º 29
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            const float baseFishingDuration    = 2400f;
            const float skillGainPerTick       = 0.15f;
            const float catchSuccessRateInZone = 0.70f;

            int     fishingDuration = (int)baseFishingDuration;
            Passion passion         = Passion.None;

            // Compute fishing duration.
            float fishingSkillLevel = 0f;

            fishingSkillLevel = this.pawn.skills.AverageOfRelevantSkillsFor(WorkTypeDefOf.Hunting);
            float fishingSkillDurationFactor = fishingSkillLevel / 20f;

            fishingDuration = (int)(baseFishingDuration * (1.5f - fishingSkillDurationFactor));

            // Compute pawn rotation.
            if (cardinalDir == IntVec3.Invalid)
            {
                cardinalDir = GenAdj.CardinalDirections.RandomElement();
                foreach (IntVec3 direction in GenAdj.CardinalDirections.InRandomOrder())
                {
                    if (Util_Zone_Fishing.IsAquaticTerrain(this.Map, this.TargetLocA + direction))
                    {
                        cardinalDir = direction;
                        break;
                    }
                }
                this.pawn.CurJob.SetTarget(TargetIndex.B, this.TargetLocA + cardinalDir);
                this.rotateToFace = TargetIndex.B;
            }

            yield return(Toils_Goto.GotoCell(this.TargetLocA, this.pathEndMode).FailOn(FishingForbiddenOrNoFishAtTargetLocA));

            Toil fishToil = new Toil()
            {
                initAction = () =>
                {
                },
                tickAction = () =>
                {
                    if (passion == Passion.Minor)
                    {
                        this.pawn.needs.joy.GainJoy(NeedTunings.JoyPerXpForPassionMinor, JoyKindDefOf.Work);
                    }
                    else if (passion == Passion.Major)
                    {
                        this.pawn.needs.joy.GainJoy(NeedTunings.JoyPerXpForPassionMajor, JoyKindDefOf.Work);
                    }
                    this.pawn.skills.Learn(SkillDefOf.Shooting, skillGainPerTick);

                    // Spawn mote or maintain it.
                    if (this.fishingRodMote.DestroyedOrNull())
                    {
                        IntVec3  motePosition = this.TargetLocA + cardinalDir;
                        ThingDef moteDef      = null;
                        if (cardinalDir == new IntVec3(0, 0, 1))
                        {
                            moteDef = Util_FishIndustry.MoteFishingRodNorthDef;
                        }
                        else if (cardinalDir == new IntVec3(1, 0, 0))
                        {
                            moteDef = Util_FishIndustry.MoteFishingRodEastDef;
                        }
                        else if (cardinalDir == new IntVec3(0, 0, -1))
                        {
                            moteDef = Util_FishIndustry.MoteFishingRodSouthDef;
                        }
                        else
                        {
                            moteDef = Util_FishIndustry.MoteFishingRodWestDef;
                        }
                        this.fishingRodMote = (Mote)ThingMaker.MakeThing(moteDef, null);
                        this.fishingRodMote.exactPosition = motePosition.ToVector3Shifted();
                        this.fishingRodMote.Scale         = 1f;
                        GenSpawn.Spawn(this.fishingRodMote, motePosition, this.Map);
                    }
                    else
                    {
                        this.fishingRodMote.Maintain();
                    }
                },
                defaultDuration     = fishingDuration,
                defaultCompleteMode = ToilCompleteMode.Delay
            };

            yield return(fishToil.WithProgressBarToilDelay(this.fishingSpotIndex).FailOn(FishingForbiddenOrNoFishAtTargetLocA));;

            Toil catchFishToil = new Toil()
            {
                initAction = () =>
                {
                    Thing fishingCatch = null;

                    bool catchIsSuccessful = (Rand.Value <= catchSuccessRateInZone);
                    if (catchIsSuccessful == false)
                    {
                        MoteMaker.ThrowMetaIcon(this.pawn.Position, this.Map, ThingDefOf.Mote_IncapIcon);
                        this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
                        return;
                    }

                    float catchSelectorValue = Rand.Value;

                    if ((catchSelectorValue < 0.02) &&
                        Util_FishIndustry.GetFishSpeciesList(this.Map.Biome).Contains(Util_FishIndustry.TailteethPawnKindDef as PawnKindDef_FishSpecies))
                    {
                        // Get hurt by a tailteeth.
                        this.pawn.TakeDamage(new DamageInfo(DamageDefOf.Bite, Rand.Range(5, 12)));
                        Messages.Message(this.pawn.NameStringShort + "FishIndustry.FisherBitten".Translate(), this.pawn, MessageTypeDefOf.NegativeHealthEvent);
                        this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable);
                        return;
                    }
                    else if (catchSelectorValue < 0.04)
                    {
                        // Find oysters.
                        fishingCatch            = GenSpawn.Spawn(Util_FishIndustry.OysterDef, this.pawn.Position, this.Map);
                        fishingCatch.stackCount = Rand.RangeInclusive(5, 27);
                    }
                    else
                    {
                        // Catch a fish.
                        bool fishSpotIsOcean = (this.Map.terrainGrid.TerrainAt(this.TargetLocA) == TerrainDefOf.WaterOceanShallow) ||
                                               (this.Map.terrainGrid.TerrainAt(this.TargetLocA) == TerrainDefOf.WaterOceanDeep);
                        bool fishSpotIsMarshy = (this.Map.terrainGrid.TerrainAt(this.TargetLocA) == TerrainDef.Named("Marsh"));

                        PawnKindDef caugthFishDef = null;
                        if (fishSpotIsOcean)
                        {
                            caugthFishDef = (from fishSpecies in Util_FishIndustry.GetFishSpeciesList(this.Map.Biome)
                                             where fishSpecies.livesInOcean
                                             select fishSpecies).RandomElementByWeight((PawnKindDef_FishSpecies def) => def.commonality);
                        }
                        else if (fishSpotIsMarshy)
                        {
                            caugthFishDef = (from fishSpecies in Util_FishIndustry.GetFishSpeciesList(this.Map.Biome)
                                             where fishSpecies.livesInMarsh
                                             select fishSpecies).RandomElementByWeight((PawnKindDef_FishSpecies def) => def.commonality);
                        }
                        else
                        {
                            caugthFishDef = (from fishSpecies in Util_FishIndustry.GetFishSpeciesList(this.Map.Biome)
                                             where fishSpecies.livesInRiver
                                             select fishSpecies).RandomElementByWeight((PawnKindDef_FishSpecies def) => def.commonality);
                        }
                        Pawn caughtFish = PawnGenerator.GeneratePawn(caugthFishDef);
                        ExecutionUtility.DoExecutionByCut(this.pawn, caughtFish);
                        Corpse corpse = caughtFish.ParentHolder as Corpse;
                        GenSpawn.Spawn(corpse, this.pawn.Position, this.Map);
                        fishingCatch = corpse;
                        fishingCatch.SetForbidden(false);
                        if (caughtFish.BodySize >= 0.1f)
                        {
                            Zone_Fishing fishingZone = this.Map.zoneManager.ZoneAt(this.TargetLocA) as Zone_Fishing;
                            if ((fishingZone != null) &&
                                fishingZone.fishesPosition.Contains(this.TargetLocA))
                            {
                                fishingZone.fishesPosition.Remove(this.TargetLocA);
                            }
                        }
                    }

                    IntVec3 storageCell;
                    if (StoreUtility.TryFindBestBetterStoreCellFor(fishingCatch, this.pawn, this.Map, StoragePriority.Unstored, this.pawn.Faction, out storageCell, true))
                    {
                        this.pawn.Reserve(fishingCatch, this.job);
                        this.pawn.Reserve(storageCell, this.job);
                        this.pawn.CurJob.SetTarget(TargetIndex.B, storageCell);
                        this.pawn.CurJob.SetTarget(TargetIndex.A, fishingCatch);
                        this.pawn.CurJob.count    = 9999;
                        this.pawn.CurJob.haulMode = HaulMode.ToCellStorage;
                    }
                    else
                    {
                        this.pawn.jobs.EndCurrentJob(JobCondition.Succeeded);
                    }
                }
            };

            yield return(catchFishToil);

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A));

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true));
        }
Ejemplo n.º 30
0
        public override void Generate(Map map)
        {
            if (map.Biome != Util_CaveBiome.CaveBiomeDef)
            {
                // Nothing to do.
                return;
            }

            // Get river origin side.
            int  riverEntrySideAsInt = Rand.RangeInclusive(2, 3);
            int  riverExitSideAsInt  = (riverEntrySideAsInt + 2) % 4;
            Rot4 riverEntrySide      = new Rot4(riverEntrySideAsInt);
            Rot4 riverExitSide       = new Rot4(riverExitSideAsInt);

            // Get river origin and end coordinates.
            Vector2 riverStart = Vector2.zero;
            Vector2 riverEnd   = Vector2.zero;

            switch (riverEntrySideAsInt)
            {
            default:
            case 2:     // South.
                if ((riverEntrySideAsInt == 0) ||
                    (riverEntrySideAsInt == 1))
                {
                    Log.Warning("CaveBiome: river entry side (" + riverEntrySideAsInt + ") should not occur.");
                }
                riverStart = new Vector2(Rand.RangeInclusive((int)((float)(map.Size.x) * 0.25f), (int)((float)(map.Size.x) * 0.75f)), -OutOfBoundsOffset);
                riverEnd   = new Vector2(Rand.RangeInclusive((int)((float)(map.Size.x) * 0.25f), (int)((float)(map.Size.x) * 0.75f)), map.Size.z + OutOfBoundsOffset);
                break;

            case 3:     // West.
                riverStart = new Vector2(-OutOfBoundsOffset, Rand.RangeInclusive((int)((float)(map.Size.z) * 0.25f), (int)((float)(map.Size.z) * 0.75f)));
                riverEnd   = new Vector2(map.Size.x + OutOfBoundsOffset, Rand.RangeInclusive((int)((float)(map.Size.z) * 0.25f), (int)((float)(map.Size.z) * 0.75f)));
                break;
            }

            // Get straight river points.
            Vector2        riverVector           = riverEnd - riverStart;
            int            numberOfParts         = (int)Math.Ceiling((double)(riverVector.magnitude / RiverPartsGranularity));
            Vector2        riverVectorNormalized = riverVector / (float)numberOfParts;
            List <Vector2> riverCoordinates      = new List <Vector2>();
            Vector2        vector = riverStart;

            for (int partIndex = 0; partIndex < numberOfParts; partIndex++)
            {
                riverCoordinates.Add(vector);
                vector += riverVectorNormalized;
            }

            // Generate Perlin map and apply perturbations.
            Perlin         perlinMap            = new Perlin(0.05, 2.0, 0.5, 4, Rand.Range(0, 2147483647), QualityMode.High);
            List <Vector2> riverCoordinatesCopy = riverCoordinates.ListFullCopy <Vector2>();

            riverCoordinates.Clear();
            List <float> riverWidth = new List <float>();

            for (int coordinatesIndex = 0; coordinatesIndex < riverCoordinatesCopy.Count; coordinatesIndex++)
            {
                float   perturbation     = RiverLateralFactor * (float)perlinMap.GetValue((double)coordinatesIndex, 0.0, 0.0);
                Vector2 pointCoordinates = Vector2.zero;
                if (riverEntrySide == Rot4.South)
                {
                    pointCoordinates = riverCoordinatesCopy[coordinatesIndex] + perturbation * Vector2.right;
                }
                else
                {
                    pointCoordinates = riverCoordinatesCopy[coordinatesIndex] + perturbation * Vector2.down;
                }
                riverCoordinates.Add(pointCoordinates);

                float width = Mathf.Min(Mathf.Abs(RiverWidthFactor * (float)perlinMap.GetValue(0.0, 0.0, (double)coordinatesIndex)), 8f);
                riverWidth.Add(width);
            }

            // Generate river from coordinates.
            for (int coordinatesIndex = 0; coordinatesIndex < riverCoordinates.Count - 1; coordinatesIndex++)
            {
                float   width               = Mathf.Max(2.5f, riverWidth[coordinatesIndex]);
                Vector2 riverPart           = riverCoordinates[coordinatesIndex + 1] - riverCoordinates[coordinatesIndex];
                Vector2 riverPartNormalized = riverPart / RiverPartsGranularity;
                for (int pointIndex = 0; pointIndex < RiverPartsGranularity; pointIndex++)
                {
                    IntVec3 point = new IntVec3(riverCoordinates[coordinatesIndex]) + new IntVec3(pointIndex * riverPartNormalized);
                    // Generate mud.
                    foreach (IntVec3 cell in GenRadial.RadialCellsAround(point, width + 1.9f, true))
                    {
                        if (cell.InBounds(map) == false)
                        {
                            continue;
                        }
                        Thing building = cell.GetEdifice(map);
                        if (building != null)
                        {
                            continue;
                        }
                        TerrainDef terrain = map.terrainGrid.TerrainAt(cell);
                        // Do not change stony terrains.
                        if ((terrain.defName.Contains("Rough") == false) &&
                            (terrain != TerrainDefOf.WaterShallow) &&
                            (terrain != TerrainDefOf.WaterDeep))
                        {
                            map.terrainGrid.SetTerrain(cell, TerrainDef.Named("Mud"));
                        }
                    }
                    // Generate shallow water and remove building/roof.
                    foreach (IntVec3 cell in GenRadial.RadialCellsAround(point, width, true))
                    {
                        if (cell.InBounds(map) == false)
                        {
                            continue;
                        }
                        Thing building = cell.GetEdifice(map);
                        if (building != null)
                        {
                            building.Destroy();
                        }
                        if (map.roofGrid.Roofed(cell))
                        {
                            map.roofGrid.SetRoof(cell, null);
                        }
                        TerrainDef terrain = map.terrainGrid.TerrainAt(cell);
                        if (terrain != TerrainDefOf.WaterDeep)
                        {
                            map.terrainGrid.SetTerrain(cell, TerrainDefOf.WaterShallow);
                        }
                    }
                    // Generate deep water.
                    if (width > 4)
                    {
                        foreach (IntVec3 cell in GenRadial.RadialCellsAround(point, width - 3.9f, true))
                        {
                            if (cell.InBounds(map) == false)
                            {
                                continue;
                            }
                            map.terrainGrid.SetTerrain(cell, TerrainDefOf.WaterDeep);
                        }
                    }
                }
            }
            IntVec3 offset = IntVec3.Zero;

            if (riverEntrySide == Rot4.South)
            {
                offset = new IntVec3(8, 0, 0);
            }
            else
            {
                offset = new IntVec3(0, 0, 8);
            }
            MapGenerator.PlayerStartSpot = new IntVec3(riverCoordinates[riverCoordinates.Count / 2]) + offset;
        }