public static void ChooseSpaceWeather(WeatherDecider __instance) { if (getMap(__instance).terrainGrid.TerrainAt(IntVec3.Zero)?.defName == "HardVacuum") { //No space weather getMap(__instance).weatherManager.lastWeather = WeatherDef.Named("NoneSpace"); getMap(__instance).weatherManager.curWeather = WeatherDef.Named("NoneSpace"); } }
public static bool Prefix(WeatherDecider __instance, ref WeatherDef __result) { try { // Get all of our ducks in order... var traverse = Traverse.Create(__instance); var map = traverse.Field("map").GetValue <Map>(); if (!Main.BiomeSettings.ContainsKey(map.Biome)) { return(true); } var biomeSetting = Main.BiomeSettings[map.Biome]; var weatherTemp = biomeSetting.BoundWeatherTemp(map.mapTemperature.OutdoorTemp); var rainAllowed = biomeSetting.CanIgnoreRainLimits() ? 0 : traverse.Field("ticksWhenRainAllowedAgain").GetValue <int>(); var preventRain = map.gameConditionManager.ActiveConditions.Any(x => x.def.preventRain); // If we're in the tutorial, just let it be if (TutorSystem.TutorialMode) { __result = WeatherDefOf.Clear; return(false); } //Log.Message($"temp {weatherTemp} rain prevent {preventRain} rainallowed {rainAllowed}"); // Otherwise, try and figure out the weather by weight if ( DefDatabase <WeatherDef> .AllDefs.TryRandomElementByWeight( w => biomeSetting.GetWeatherData(w).GetCommonality(map, rainAllowed, weatherTemp, preventRain), out var result)) { //Log.Message($"newweather {result.defName}"); __result = result; return(false); } // If we didn't, use the default weather Log.Warning( "Unable to choose suitable weather; this may mean your biome specific settings don't produce a viable range of weathers."); __result = WeatherDefOf.Clear; return(false); } catch (Exception exception) { Log.Error($"Unable to override choosing the next weather; falling back to vanilla. {exception}"); return(true); } }
private static void Postfix(WeatherDecider __instance, WeatherDef __result) { try { Map map = Traverse.Create(__instance).Field("map").GetValue <Map>(); var ZTracker = Current.Game.GetComponent <ZLevelsManager>(); if (ZTracker.ZLevelsTracker != null && ZTracker.ZLevelsTracker.ContainsKey(map.Tile)) { ZLogger.Message("Weather decider: " + __result + " - " + ZTracker.GetMapInfo(map)); if (ZTracker.GetZIndexFor(map) == 0) { foreach (var map2 in ZTracker.GetAllMaps(map.Tile)) { if (ZTracker.GetZIndexFor(map2) > 0) { ZLogger.Message("1 - " + ZTracker.GetMapInfo(map2) + " transitioting to " + __result); map2.weatherManager.TransitionTo(__result); map2.weatherManager.curWeatherAge = map.weatherManager.curWeatherAge; } } } else if (ZTracker.GetZIndexFor(map) > 0) { __result = map.weatherManager.curWeather; ZLogger.Message("2 - " + ZTracker.GetMapInfo(map) + " transitioting to " + __result); map.weatherManager.TransitionTo(__result); } else if (ZTracker.GetZIndexFor(map) < 0) { __result = WeatherDefOf.Clear; ZLogger.Message("3 - " + ZTracker.GetMapInfo(map) + " transitioting to " + __result); map.weatherManager.TransitionTo(__result); } ZLogger.Message("Changed weather for " + ZTracker.GetMapInfo(map) + " - " + __result); } } catch (Exception ex) { Log.Error("[Z-Levels] Patch_ChooseNextWeather patch produced an error. That should not happen and will break things. Send a Hugslib log to the Z-Levels developers. Error message: " + ex, true); } }
private static void Postfix(WeatherDecider __instance, ref WeatherDef __result, Map ___map) { try { var ZTracker = ZUtils.ZTracker; if (ZTracker.ZLevelsTracker != null && ZTracker.ZLevelsTracker.ContainsKey(___map.Tile)) { ZLogger.Message("Weather decider: " + __result + " - " + ZTracker.GetMapInfo(___map)); if (ZTracker.GetZIndexFor(___map) == 0) { foreach (var map2 in ZTracker.GetAllMaps(___map.Tile)) { if (ZTracker.GetZIndexFor(map2) > 0) { ZLogger.Message("1 - " + ZTracker.GetMapInfo(map2) + " transitioting to " + __result); map2.weatherManager.TransitionTo(__result); map2.weatherManager.curWeatherAge = ___map.weatherManager.curWeatherAge; } } } else if (ZTracker.GetZIndexFor(___map) > 0) { __result = ___map.weatherManager.curWeather; ZLogger.Message("2 - " + ZTracker.GetMapInfo(___map) + " transitioting to " + __result); ___map.weatherManager.TransitionTo(__result); } else if (ZTracker.GetZIndexFor(___map) < 0) { __result = WeatherDefOf.Clear; ZLogger.Message("3 - " + ZTracker.GetMapInfo(___map) + " transitioting to " + __result); ___map.weatherManager.TransitionTo(__result); } ZLogger.Message("Changed weather for " + ZTracker.GetMapInfo(___map) + " - " + __result); } } catch (Exception ex) { Log.Error("[Z-Levels] Patch_ChooseNextWeather patch produced an error. That should not happen and will break things. Send a Hugslib log to the Z-Levels developers. Error message: " + ex, true); } }
private static bool Prefix(WeatherDecider __instance, Map ___map, ref int ___curWeatherDuration) { try { var ZTracker = ZUtils.ZTracker; if (ZTracker.ZLevelsTracker != null && ZTracker.ZLevelsTracker.ContainsKey(___map.Tile) && ZTracker.GetZIndexFor(___map) < 0) { ___map.weatherManager.curWeather = null; WeatherDef weatherDef = WeatherDefOf.Clear; WeatherDef lastWeather = WeatherDefOf.Clear; ___map.weatherManager.curWeather = weatherDef; ___map.weatherManager.lastWeather = lastWeather; ___curWeatherDuration = weatherDef.durationRange.RandomInRange; ___map.weatherManager.curWeatherAge = Rand.Range(0, ___curWeatherDuration); return(false); } } catch (Exception ex) { Log.Error("[Z-Levels] Patch_WeatherManager patch produced an error. That should not happen and will break things. Send a Hugslib log to the Z-Levels developers. Error message: " + ex, true); } return(true); }
public void ConstructComponents() { this.spawnedThings = new ThingOwner <Thing>(this); this.cellIndices = new CellIndices(this); this.listerThings = new ListerThings(ListerThingsUse.Global); this.listerBuildings = new ListerBuildings(); this.mapPawns = new MapPawns(this); this.dynamicDrawManager = new DynamicDrawManager(this); this.mapDrawer = new MapDrawer(this); this.tooltipGiverList = new TooltipGiverList(); this.pawnDestinationReservationManager = new PawnDestinationReservationManager(); this.reservationManager = new ReservationManager(this); this.physicalInteractionReservationManager = new PhysicalInteractionReservationManager(); this.designationManager = new DesignationManager(this); this.lordManager = new LordManager(this); this.debugDrawer = new DebugCellDrawer(); this.passingShipManager = new PassingShipManager(this); this.haulDestinationManager = new HaulDestinationManager(this); this.gameConditionManager = new GameConditionManager(this); this.weatherManager = new WeatherManager(this); this.zoneManager = new ZoneManager(this); this.resourceCounter = new ResourceCounter(this); this.mapTemperature = new MapTemperature(this); this.temperatureCache = new TemperatureCache(this); this.areaManager = new AreaManager(this); this.attackTargetsCache = new AttackTargetsCache(this); this.attackTargetReservationManager = new AttackTargetReservationManager(this); this.lordsStarter = new VoluntarilyJoinableLordsStarter(this); this.thingGrid = new ThingGrid(this); this.coverGrid = new CoverGrid(this); this.edificeGrid = new EdificeGrid(this); this.blueprintGrid = new BlueprintGrid(this); this.fogGrid = new FogGrid(this); this.glowGrid = new GlowGrid(this); this.regionGrid = new RegionGrid(this); this.terrainGrid = new TerrainGrid(this); this.pathGrid = new PathGrid(this); this.roofGrid = new RoofGrid(this); this.fertilityGrid = new FertilityGrid(this); this.snowGrid = new SnowGrid(this); this.deepResourceGrid = new DeepResourceGrid(this); this.exitMapGrid = new ExitMapGrid(this); this.linkGrid = new LinkGrid(this); this.glowFlooder = new GlowFlooder(this); this.powerNetManager = new PowerNetManager(this); this.powerNetGrid = new PowerNetGrid(this); this.regionMaker = new RegionMaker(this); this.pathFinder = new PathFinder(this); this.pawnPathPool = new PawnPathPool(this); this.regionAndRoomUpdater = new RegionAndRoomUpdater(this); this.regionLinkDatabase = new RegionLinkDatabase(); this.moteCounter = new MoteCounter(); this.gatherSpotLister = new GatherSpotLister(); this.windManager = new WindManager(this); this.listerBuildingsRepairable = new ListerBuildingsRepairable(); this.listerHaulables = new ListerHaulables(this); this.listerMergeables = new ListerMergeables(this); this.listerFilthInHomeArea = new ListerFilthInHomeArea(this); this.reachability = new Reachability(this); this.itemAvailability = new ItemAvailability(this); this.autoBuildRoofAreaSetter = new AutoBuildRoofAreaSetter(this); this.roofCollapseBufferResolver = new RoofCollapseBufferResolver(this); this.roofCollapseBuffer = new RoofCollapseBuffer(); this.wildAnimalSpawner = new WildAnimalSpawner(this); this.wildPlantSpawner = new WildPlantSpawner(this); this.steadyEnvironmentEffects = new SteadyEnvironmentEffects(this); this.skyManager = new SkyManager(this); this.overlayDrawer = new OverlayDrawer(); this.floodFiller = new FloodFiller(this); this.weatherDecider = new WeatherDecider(this); this.fireWatcher = new FireWatcher(this); this.dangerWatcher = new DangerWatcher(this); this.damageWatcher = new DamageWatcher(); this.strengthWatcher = new StrengthWatcher(this); this.wealthWatcher = new WealthWatcher(this); this.regionDirtyer = new RegionDirtyer(this); this.cellsInRandomOrder = new MapCellsInRandomOrder(this); this.rememberedCameraPos = new RememberedCameraPos(this); this.mineStrikeManager = new MineStrikeManager(); this.storyState = new StoryState(this); this.retainedCaravanData = new RetainedCaravanData(this); this.components.Clear(); this.FillComponents(); }