/// <summary> /// Builds or rebuilds the the light sources for the world. /// TODO: Call this whenenver render distance changes! /// </summary> public void BuildLightsForWorld() { if (TheSun != null) { TheSun.Destroy(); MainWorldView.Lights.Remove(TheSun); TheSunClouds.Destroy(); MainWorldView.Lights.Remove(TheSunClouds); ThePlanet.Destroy(); MainWorldView.Lights.Remove(ThePlanet); } View3D.CheckError("Load - World - Deletes"); int wid = CVars.r_shadowquality.ValueI; TheSun = new SkyLight(Location.Zero, MaximumStraightBlockDistance() * 2, SunLightDef, new Location(0, 0, -1), MaximumStraightBlockDistance() * 2 + Chunk.CHUNK_SIZE * 2, false, wid); MainWorldView.Lights.Add(TheSun); View3D.CheckError("Load - World - Sun"); // TODO: Separate cloud quality CVar? TheSunClouds = new SkyLight(Location.Zero, MaximumStraightBlockDistance() * 2, CloudSunLightDef, new Location(0, 0, -1), MaximumStraightBlockDistance() * 2 + Chunk.CHUNK_SIZE * 2, true, wid); MainWorldView.Lights.Add(TheSunClouds); View3D.CheckError("Load - World - Clouds"); // TODO: Separate planet quality CVar? ThePlanet = new SkyLight(Location.Zero, MaximumStraightBlockDistance() * 2, PlanetLightDef, new Location(0, 0, -1), MaximumStraightBlockDistance() * 2 + Chunk.CHUNK_SIZE * 2, false, wid); MainWorldView.Lights.Add(ThePlanet); View3D.CheckError("Load - World - Planet"); OnCloudShadowChanged(null, null); View3D.CheckError("Load - World - Changed"); }
public void BuildWorld() { if (TheSun != null) { TheSun.Destroy(); MainWorldView.Lights.Remove(TheSun); ThePlanet.Destroy(); MainWorldView.Lights.Remove(ThePlanet); TheSunClouds.Destroy(); MainWorldView.Lights.Remove(TheSunClouds); } // TODO: DESTROY OLD REGION! // TODO: Radius -> max view rad * 2 // TODO: Size -> max view rad * 2 + 30 * 2 TheSun = new SkyLight(Location.Zero, Chunk.CHUNK_SIZE * 30, SunLightDef, new Location(0, 0, -1), Chunk.CHUNK_SIZE * 35, false); MainWorldView.Lights.Add(TheSun); // TODO: Separate cloud quality CVar? TheSunClouds = new SkyLight(Location.Zero, Chunk.CHUNK_SIZE * 30, CloudSunLightDef, new Location(0, 0, -1), Chunk.CHUNK_SIZE * 35, true); MainWorldView.Lights.Add(TheSunClouds); // TODO: Separate planet quality CVar? ThePlanet = new SkyLight(Location.Zero, Chunk.CHUNK_SIZE * 30, PlanetLightDef, new Location(0, 0, -1), Chunk.CHUNK_SIZE * 35, false); MainWorldView.Lights.Add(ThePlanet); TheRegion = new Region(); TheRegion.TheClient = this; TheRegion.BuildWorld(); Player = new PlayerEntity(TheRegion); TheRegion.SpawnEntity(Player); onCloudShadowChanged(null, null); }
/// <summary> /// Fired when the entity is despawned. /// </summary> public override void OnDespawn() { if (Entity.Engine is GameEngine3D eng) { eng.MainView.Lights.Remove(InternalLight); InternalLight.Destroy(); InternalLight = null; Entity.OnPositionChanged -= FixPosition; Entity.OnTick -= Tick; } else { SysConsole.Output(OutputType.WARNING, "3D light despawned from a non-3D-engine-based game!"); } }