示例#1
0
文件: Map.cs 项目: potsh/RimWorld
 public void ConstructComponents()
 {
     spawnedThings      = new ThingOwner <Thing>(this);
     cellIndices        = new CellIndices(this);
     listerThings       = new ListerThings(ListerThingsUse.Global);
     listerBuildings    = new ListerBuildings();
     mapPawns           = new MapPawns(this);
     dynamicDrawManager = new DynamicDrawManager(this);
     mapDrawer          = new MapDrawer(this);
     tooltipGiverList   = new TooltipGiverList();
     pawnDestinationReservationManager = new PawnDestinationReservationManager();
     reservationManager = new ReservationManager(this);
     physicalInteractionReservationManager = new PhysicalInteractionReservationManager();
     designationManager             = new DesignationManager(this);
     lordManager                    = new LordManager(this);
     debugDrawer                    = new DebugCellDrawer();
     passingShipManager             = new PassingShipManager(this);
     haulDestinationManager         = new HaulDestinationManager(this);
     gameConditionManager           = new GameConditionManager(this);
     weatherManager                 = new WeatherManager(this);
     zoneManager                    = new ZoneManager(this);
     resourceCounter                = new ResourceCounter(this);
     mapTemperature                 = new MapTemperature(this);
     temperatureCache               = new TemperatureCache(this);
     areaManager                    = new AreaManager(this);
     attackTargetsCache             = new AttackTargetsCache(this);
     attackTargetReservationManager = new AttackTargetReservationManager(this);
     lordsStarter                   = new VoluntarilyJoinableLordsStarter(this);
     thingGrid                  = new ThingGrid(this);
     coverGrid                  = new CoverGrid(this);
     edificeGrid                = new EdificeGrid(this);
     blueprintGrid              = new BlueprintGrid(this);
     fogGrid                    = new FogGrid(this);
     glowGrid                   = new GlowGrid(this);
     regionGrid                 = new RegionGrid(this);
     terrainGrid                = new TerrainGrid(this);
     pathGrid                   = new PathGrid(this);
     roofGrid                   = new RoofGrid(this);
     fertilityGrid              = new FertilityGrid(this);
     snowGrid                   = new SnowGrid(this);
     deepResourceGrid           = new DeepResourceGrid(this);
     exitMapGrid                = new ExitMapGrid(this);
     avoidGrid                  = new AvoidGrid(this);
     linkGrid                   = new LinkGrid(this);
     glowFlooder                = new GlowFlooder(this);
     powerNetManager            = new PowerNetManager(this);
     powerNetGrid               = new PowerNetGrid(this);
     regionMaker                = new RegionMaker(this);
     pathFinder                 = new PathFinder(this);
     pawnPathPool               = new PawnPathPool(this);
     regionAndRoomUpdater       = new RegionAndRoomUpdater(this);
     regionLinkDatabase         = new RegionLinkDatabase();
     moteCounter                = new MoteCounter();
     gatherSpotLister           = new GatherSpotLister();
     windManager                = new WindManager(this);
     listerBuildingsRepairable  = new ListerBuildingsRepairable();
     listerHaulables            = new ListerHaulables(this);
     listerMergeables           = new ListerMergeables(this);
     listerFilthInHomeArea      = new ListerFilthInHomeArea(this);
     reachability               = new Reachability(this);
     itemAvailability           = new ItemAvailability(this);
     autoBuildRoofAreaSetter    = new AutoBuildRoofAreaSetter(this);
     roofCollapseBufferResolver = new RoofCollapseBufferResolver(this);
     roofCollapseBuffer         = new RoofCollapseBuffer();
     wildAnimalSpawner          = new WildAnimalSpawner(this);
     wildPlantSpawner           = new WildPlantSpawner(this);
     steadyEnvironmentEffects   = new SteadyEnvironmentEffects(this);
     skyManager                 = new SkyManager(this);
     overlayDrawer              = new OverlayDrawer();
     floodFiller                = new FloodFiller(this);
     weatherDecider             = new WeatherDecider(this);
     fireWatcher                = new FireWatcher(this);
     dangerWatcher              = new DangerWatcher(this);
     damageWatcher              = new DamageWatcher();
     strengthWatcher            = new StrengthWatcher(this);
     wealthWatcher              = new WealthWatcher(this);
     regionDirtyer              = new RegionDirtyer(this);
     cellsInRandomOrder         = new MapCellsInRandomOrder(this);
     rememberedCameraPos        = new RememberedCameraPos(this);
     mineStrikeManager          = new MineStrikeManager();
     storyState                 = new StoryState(this);
     retainedCaravanData        = new RetainedCaravanData(this);
     components.Clear();
     FillComponents();
 }
        public static void DoCellSteadyEffects(SteadyEnvironmentEffects __instance, IntVec3 c)
        {
            Map       map2      = map(__instance);
            Room      room      = c.GetRoom(map2, RegionType.Set_All);
            bool      roofed    = map2.roofGrid.Roofed(c);
            RoomGroup roomGroup = null;

            if (room != null)
            {
                roomGroup = room.Group;
            }
            bool roomUsesOutdoorTemperature = room != null && roomGroup != null && room.UsesOutdoorTemperature;

            if ((room == null) | roomUsesOutdoorTemperature)
            {
                if (outdoorMeltAmount(__instance) > 0.0)
                {
                    map2.snowGrid.AddDepth(c, -outdoorMeltAmount(__instance));
                }
                if (!roofed && snowRate(__instance) > 1.0 / 1000.0)
                {
                    AddFallenSnowAt(__instance, c, 23f / 500f * map2.weatherManager.SnowRate);
                }
            }
            if (room != null)
            {
                bool         protectedByEdifice = ProtectedByEdifice(c, map2);
                TerrainDef   terrain            = c.GetTerrain(map2);
                List <Thing> thingList          = c.GetThingList(map2);
                for (int index = 0; index < thingList.Count; ++index)
                {
                    Thing t = thingList[index];
                    if (t is Filth filth)
                    {
                        if (!roofed && t.def.filth.rainWashes && Rand.Chance(rainRate(__instance)))
                        {
                            filth.ThinFilth();
                        }
                        if (filth.DisappearAfterTicks != 0 && filth.TicksSinceThickened > filth.DisappearAfterTicks)
                        {
                            filth.Destroy(DestroyMode.Vanish);
                        }
                    }
                    else
                    {
                        TryDoDeteriorate(__instance, t, roofed, roomUsesOutdoorTemperature, protectedByEdifice, terrain);
                    }
                }
                if (!roomUsesOutdoorTemperature && roomGroup != null)
                {
                    float temperature = roomGroup.Temperature;
                    if (temperature > 0.0)
                    {
                        float num1 = MeltAmountAt(temperature);
                        if (num1 > 0.0)
                        {
                            map2.snowGrid.AddDepth(c, -num1);
                        }
                        if (room.RegionType.Passable() && temperature > (double)AutoIgnitionTemperatureRange.min)
                        {
                            double num2 = Rand.Value;
                            if (num2 < AutoIgnitionTemperatureRange.InverseLerpThroughRange(temperature) * 0.699999988079071 && Rand.Chance(FireUtility.ChanceToStartFireIn(c, map2)))
                            {
                                FireUtility.TryStartFireIn(c, map2, 0.1f);
                            }
                            if (num2 < 0.330000013113022)
                            {
                                MoteMaker.ThrowHeatGlow(c, map2, 2.3f);
                            }
                        }
                    }
                }
            }
            map2.gameConditionManager.DoSteadyEffects(c, map2);
        }
        // Token: 0x06000002 RID: 2 RVA: 0x0000224C File Offset: 0x0000044C
        private static void Postfix(IntVec3 c, SteadyEnvironmentEffects __instance)
        {
            Map map = HarmonyPatches.MapFieldInfo.GetValue(__instance) as Map;

            if (map == null)
            {
                return;
            }
            Room room = c.GetRoom(map, RegionType.Set_Passable);

            if (Settings.ColdFog || Settings.IceLayer)
            {
                Thing thing = (from t in c.GetThingList(map)
                               where t.def.defName == "IceOverlay"
                               select t).FirstOrDefault <Thing>();
                if (room == null && thing != null && Settings.IceLayer)
                {
                    thing.Destroy(DestroyMode.Vanish);
                    if (Rand.Range(1, 100) <= 20)
                    {
                        FilthMaker.TryMakeFilth(c, map, ThingDef.Named("FilthWater"), 1);
                    }
                }
                if (room != null && !room.UsesOutdoorTemperature && !room.Fogged && !room.IsDoorway)
                {
                    float num = 0.8f;
                    if (room.Temperature < (float)Settings.FogTemp)
                    {
                        if (thing == null && Settings.IceLayer)
                        {
                            GenSpawn.Spawn(ThingMaker.MakeThing(ThingDef.Named("IceOverlay"), null), c, map);
                        }
                        if (Settings.ColdFog)
                        {
                            Vector3 vector = c.ToVector3Shifted();
                            bool    flag   = true;
                            if (!GenView.ShouldSpawnMotesAt(vector, map) || map.moteCounter.SaturatedLowPriority)
                            {
                                flag = false;
                            }
                            vector += num * new Vector3(Rand.Value - 0.5f, 0f, Rand.Value - 0.5f);
                            if (!GenGrid.InBounds(vector, map))
                            {
                                flag = false;
                            }
                            if (flag)
                            {
                                MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named("Mote_FrostGlow"), null);
                                moteThrown.Scale         = Rand.Range(4f, 6f) * num;
                                moteThrown.rotationRate  = Rand.Range(-3f, 3f);
                                moteThrown.exactPosition = vector;
                                moteThrown.SetVelocity((float)(Rand.Bool ? -90 : 90), (float)((double)Settings.FogVelocity * 0.01));
                                GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(vector), map);
                            }
                        }
                    }
                    else if (thing != null)
                    {
                        thing.Destroy(DestroyMode.Vanish);
                        if (Rand.Range(1, 100) <= 20)
                        {
                            FilthMaker.TryMakeFilth(c, map, ThingDef.Named("FilthWater"), 1);
                        }
                    }
                }
            }
            if (!Settings.IceLayer)
            {
                Thing thing2 = (from t in c.GetThingList(map)
                                where t.def.defName == "IceOverlay"
                                select t).FirstOrDefault <Thing>();
                if (thing2 != null)
                {
                    thing2.Destroy(DestroyMode.Vanish);
                }
            }
            if (map.roofGrid != null && !map.roofGrid.Roofed(c) && (float)map.weatherManager.curWeatherAge >= 7500f && (map.weatherManager.curWeather.rainRate <= 0f || map.weatherManager.curWeather.snowRate > 0f))
            {
                Thing thing3 = (from t in c.GetThingList(map)
                                where t.def.defName == "FilthWater" || t.def.defName == "FilthWaterSpatter"
                                select t).FirstOrDefault <Thing>();
                if (thing3 != null && Rand.Value <= 0.2f)
                {
                    ((Filth)thing3).ThinFilth();
                }
            }
        }