protected override void DoEffect(IntVec3 c)
        {
            TerrainDef localTerrain = base.TargetLocA.GetTerrain(base.Map);
            TerrainDef newTerrain   = null;

            switch (localTerrain.ToString())
            {
            case null:
                Log.Error("No terrain found!");
                break;

            case "SoftSand":
                newTerrain = TerrainDef.Named("Soil");
                break;

            case "Sand":
                newTerrain = TerrainDef.Named("SoftSand");
                break;

            case "Gravel":
                newTerrain = TerrainDef.Named("Sand");
                break;

            case "MossyTerrain":
                newTerrain = TerrainDef.Named("Gravel");
                break;

            case "MarshyTerrain":
                newTerrain = TerrainDef.Named("MossyTerrain");
                break;
            }

            base.Map.terrainGrid.SetTerrain(base.TargetLocA, newTerrain);
            FilthMaker.RemoveAllFilth(base.TargetLocA, base.Map);
        }
Esempio n. 2
0
 public override void specialCellAffects(IntVec3 c)
 {
     //set terrain
     if (this.terrainType == "wet")
     {
         this.parent.Map.terrainGrid.SetTerrain(c, this.Props.wetTile);
     }
     else if (this.terrainType == "deep")
     {
         this.parent.Map.terrainGrid.SetTerrain(c, this.Props.deepTile);
     }
     FilthMaker.RemoveAllFilth(c, this.parent.Map);
 }
        public void LiquidateRoom()
        {
            Room room = Position.GetRoom(Map, RegionType.Set_All);

            if (room != null && !room.PsychologicallyOutdoors)
            {
                float wealth            = room.GetStat(RoomStatDefOf.Wealth);
                float roomSize          = room.CellCount;
                float humanPawnCount    = 0;
                float nonHumanPawnCount = 0;
                foreach (IntVec3 cell in room.Cells)
                {
                    if (Map.terrainGrid.CanRemoveTopLayerAt(cell))
                    {
                        Map.terrainGrid.RemoveTopLayer(cell, false);
                        FilthMaker.RemoveAllFilth(cell, Map);
                    }
                    foreach (Thing t in cell.GetThingList(Map).ToList())
                    {
                        if (t is Building_CryptosleepCasket)
                        {
                            foreach (Thing thing in ((IEnumerable <Thing>)InnerContainerField.GetValue(t)))
                            {
                                if (thing is Pawn p)
                                {
                                    if (p.RaceProps.Humanlike)
                                    {
                                        humanPawnCount++;
                                    }
                                    else
                                    {
                                        nonHumanPawnCount++;
                                    }
                                }
                            }
                        }
                        if (t.def.destroyable && t != this)
                        {
                            t.Destroy();
                        }
                    }
                }
                float points = 0.001f * wealth + roomSize + 10f * nonHumanPawnCount + 100f * humanPawnCount;
                if (Prefs.DevMode)
                {
                    Log.Message($"==SpdTec Room Liquidation Report==\nWealth: {wealth}\nRoom size: {roomSize}\nPawns: (non-human {nonHumanPawnCount}), (human {humanPawnCount})\nPoints: {points}");
                }
                this.Destroy();
            }
        }
Esempio n. 4
0
        public void CleanTick()
        {
            if (CleaningStationSettings.isDynamicPower())
            {
                float powerFactor = -1f * (500f / (500f + (float)cleanableCells.Count()));
                compPowerTrader.PowerOutput = (float)Math.Round(CleaningStationSettings.GetPowerConsumption() * cleanableCells.Count() * powerFactor);
            }

            if (compPowerTrader.PowerOn)
            {
                foreach (IntVec3 cleanMe in cleanableCells)
                {
                    FilthMaker.RemoveAllFilth(cleanMe, this.Map);
                }
            }
        }
Esempio n. 5
0
        /*
         * private static int nextloadID = 0;
         * private int loadID;
         */

        //constructs a Vessel_Structure
        public Vessel_Structure(Zone_Shipyard shipyard)
        {
            /*
             * loadID = nextloadID;
             * nextloadID++;
             */
            map = shipyard.Map;
            ResetGrids();
            int     avgDenom     = 0;
            IntVec3 avgNumerator = IntVec3.Zero;

            foreach (IntVec3 cell in shipyard.cells)
            {
                if (map.terrainGrid.TerrainAt(cell).defName.StartsWith("Boat_"))
                {
                    if (map.terrainGrid.TerrainAt(cell) != null)
                    {
                        SetTerrain(cell, map.terrainGrid.TerrainAt(cell));
                        map.terrainGrid.RemoveTopLayer(cell, false);
                        FilthMaker.RemoveAllFilth(cell, map);
                        avgNumerator += cell;
                        avgDenom++;
                    }

                    /*
                     * if (map.terrainGrid.UnderTerrainAt(cell) != null)
                     * {
                     *  SetUnderTerrain(cell, map.terrainGrid.UnderTerrainAt(cell));
                     *  avgNumerator += cell;
                     *  avgDenom++;
                     * }
                     */
                    List <Thing> thingList = map.thingGrid.ThingsListAtFast(cell);
                    for (int i = thingList.Count - 1; i >= 0; i--)
                    {
                        RegisterInCell(thingList[i], cell);
                        thingList[i].DeSpawn();

                        avgNumerator += cell;
                        avgDenom++;
                    }
                    cells.Add(cell);
                }
            }
            Center = new IntVec3(avgNumerator.x / avgDenom, avgNumerator.y / avgDenom, avgNumerator.z / avgDenom);
        }
Esempio n. 6
0
        // Token: 0x060000EF RID: 239 RVA: 0x00008640 File Offset: 0x00006840
        public static bool CompleteConstruction_Prefix(Frame __instance, Pawn worker)
        {
            bool flag = !worker.RaceProps.Humanlike;
            bool result;

            if (flag)
            {
                Thing thing = __instance.holdingOwner.Take(__instance);
                __instance.resourceContainer.ClearAndDestroyContents(DestroyMode.Vanish);
                Map map = worker.Map;
                __instance.Destroy(DestroyMode.Vanish);
                bool flag2 = __instance.GetStatValue(StatDefOf.WorkToBuild, true) > 150f && __instance.def.entityDefToBuild is ThingDef && ((ThingDef)__instance.def.entityDefToBuild).category == ThingCategory.Building;
                if (flag2)
                {
                    SoundDefOf.Building_Complete.PlayOneShot(new TargetInfo(thing.Position, map, false));
                }
                ThingDef thingDef = __instance.def.entityDefToBuild as ThingDef;
                Thing    thing2   = null;
                bool     flag3    = thingDef != null;
                if (flag3)
                {
                    thing2 = ThingMaker.MakeThing(thingDef, thing.Stuff);
                    thing2.SetFactionDirect(thing.Faction);
                    CompQuality compQuality = thing2.TryGetComp <CompQuality>();
                    bool        flag4       = compQuality != null;
                    if (flag4)
                    {
                        int             relevantSkillLevel = 1;
                        QualityCategory q = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, false);
                        compQuality.SetQuality(q, ArtGenerationContext.Colony);
                        QualityUtility.SendCraftNotification(thing2, worker);
                    }
                    CompArt compArt = thing2.TryGetComp <CompArt>();
                    bool    flag5   = compArt != null;
                    if (flag5)
                    {
                        bool flag6 = compQuality == null;
                        if (flag6)
                        {
                            compArt.InitializeArt(ArtGenerationContext.Colony);
                        }
                        compArt.JustCreatedBy(worker);
                    }
                    thing2.HitPoints = Mathf.CeilToInt((float)__instance.HitPoints / (float)thing.MaxHitPoints * (float)thing2.MaxHitPoints);
                    GenSpawn.Spawn(thing2, thing.Position, worker.Map, thing.Rotation, WipeMode.Vanish, false);
                }
                else
                {
                    map.terrainGrid.SetTerrain(thing.Position, (TerrainDef)__instance.def.entityDefToBuild);
                    FilthMaker.RemoveAllFilth(thing.Position, map);
                }
                worker.records.Increment(RecordDefOf.ThingsConstructed);
                bool flag7 = thing2 != null && thing2.GetStatValue(StatDefOf.WorkToBuild, true) >= 9500f;
                if (flag7)
                {
                    TaleRecorder.RecordTale(TaleDefOf.CompletedLongConstructionProject, new object[]
                    {
                        worker,
                        thing2.def
                    });
                }
                result = false;
            }
            else
            {
                result = true;
            }
            return(result);
        }
Esempio n. 7
0
 protected override void DoEffect(IntVec3 c)
 {
     GenSpawn.Spawn(ThingDef.Named("Sand"), c, pawn.Map).stackCount = 20;
     FilthMaker.RemoveAllFilth(c, this.Map);
 }