private void PropagatesBorderLightSources(VisualChunk chunk) { //Get surrending cubes from this chunk Range3I cubeRangeWithBorder = chunk.CubeRange; cubeRangeWithBorder.Position.X--; cubeRangeWithBorder.Position.Z--; cubeRangeWithBorder.Size.X += 2; cubeRangeWithBorder.Size.Z += 2; var test = cubeRangeWithBorder.AllExclude(chunk.CubeRange); foreach (var BorderCube in cubeRangeWithBorder.AllExclude(chunk.CubeRange)) { PropagateLightSourcesForced(BorderCube, chunk); } //Propagate the light from Entities located in chunks around me, but that have a light source block inside my chunk ! foreach (var surrendingChunk in chunk.FourSurroundingChunks) { //Propagate the light from light entities linked to border ! foreach (ILightEmitterEntity LightingEntity in surrendingChunk.OutOfChunkLightSourceStaticEntities) { //Get the Cube where is located the entity Vector3I entityBlockPosition = LightingEntity.Position.ToCubePosition(); if (chunk.CubeRange.Contains(entityBlockPosition)) { PropagateLightSourcesForced(entityBlockPosition, chunk); } } } PropagateLightInsideStaticEntities(chunk); }
private void PlayerDisplacementChunkEvents() { double distance = MVector3.Distance2D(_lastPlayerTriggeredPosition, PlayerManager.Player.Position); //Triggered when player has move a distance of 8 blocks (half chunk distance) if (distance > (AbstractChunk.ChunkSize.X / 2d)) { var newEventNotificationArea = new Range3I { Position = BlockHelper.EntityToChunkPosition(PlayerManager.Player.Position) - _eventNotificationArea.Size / 2, Size = _eventNotificationArea.Size }; var chunks2Syncro = newEventNotificationArea.AllExclude(_eventNotificationArea); if (chunks2Syncro != null) { bool synchroFullyRequested = true; //Get all new chunk in the area that are in a state ready to be requested ! //Check that the concerned chunks are in a correct state to be requested. foreach (var chunkPosition in chunks2Syncro) { if (ResyncChunk(chunkPosition, false) == false) { synchroFullyRequested = false; break; } } if (synchroFullyRequested) { _eventNotificationArea = newEventNotificationArea; } } _lastPlayerTriggeredPosition = PlayerManager.Player.Position; ChunkNeed2BeSorted = true; } }