private void LevelFinalizeInit() { base.Initialize(); simSounds.Initialize(); simParticles.Initialize(); cloudRenderer = new CloudRenderer(capi, this); smoothedLightLevel = capi.World.BlockAccessor.GetLightLevel(capi.World.Player.Entity.Pos.AsBlockPos, EnumLightLevelType.OnlySunLight); dummySim = new WeatherSimulationRegion(this, 0, 0); dummySim.Initialize(); adjacentSims[0] = dummySim; adjacentSims[1] = dummySim; adjacentSims[2] = dummySim; adjacentSims[3] = dummySim; capi.Ambient.CurrentModifiers.InsertBefore("serverambient", "weather", blendedWeatherData.Ambient); haveLevelFinalize = true; // Pre init the clouds. capi.Ambient.UpdateAmbient(0.1f); CloudRenderer renderer = this.cloudRenderer as CloudRenderer; renderer.blendedCloudDensity = capi.Ambient.BlendedCloudDensity; renderer.blendedGlobalCloudBrightness = capi.Ambient.BlendedCloudBrightness; renderer.CloudTick(0.1f); }
public WeatherSimulationRegion getOrCreateWeatherSimForRegion(long index2d, IMapRegion mapregion) { Vec3i regioncoord = MapRegionPosFromIndex2D(index2d); WeatherSimulationRegion weatherSim; lock (weatherSimByMapRegionLock) { if (weatherSimByMapRegion.TryGetValue(index2d, out weatherSim)) { return(weatherSim); } } weatherSim = new WeatherSimulationRegion(this, regioncoord.X, regioncoord.Z); weatherSim.Initialize(); byte[] data; if (mapregion.ModData.TryGetValue("weather", out data)) { try { weatherSim.FromBytes(data); //api.World.Logger.Notification("{2}: Loaded weather pattern @{0}/{1}", regioncoord.X, regioncoord.Z, api.Side); } catch (Exception) { //api.World.Logger.Warning("Unable to load weather pattern from region {0}/{1}, will load a random one. Likely due to game version change.", regioncoord.X, regioncoord.Z); weatherSim.LoadRandomPattern(); weatherSim.NewWePattern.OnBeginUse(); } } else { //api.World.Logger.Notification("{2}: Random weather pattern @{0}/{1}", regioncoord.X, regioncoord.Z, api.Side); weatherSim.LoadRandomPattern(); weatherSim.NewWePattern.OnBeginUse(); mapregion.ModData["weather"] = weatherSim.ToBytes(); } weatherSim.MapRegion = mapregion; lock (weatherSimByMapRegionLock) { weatherSimByMapRegion[index2d] = weatherSim; } return(weatherSim); }
public void InitDummySim() { dummySim = new WeatherSimulationRegion(this, 0, 0); dummySim.IsDummy = true; dummySim.Initialize(); var rand = new LCGRandom(api.World.Seed); rand.InitPositionSeed(3, 3); rainOverlayPattern = new WeatherPattern(this, GeneralConfig.RainOverlayPattern, rand, 0, 0); rainOverlayPattern.Initialize(0, api.World.Seed); rainOverlayPattern.OnBeginUse(); rainOverlaySnap = new WeatherDataSnapshot(); }