public ChunkManager(IServiceProvider serviceProvider, GraphicsDevice graphics, World world) { Graphics = graphics; World = world; Options = serviceProvider.GetRequiredService <IOptionsProvider>().AlexOptions; Resources = serviceProvider.GetRequiredService <ResourceManager>(); var stillAtlas = Resources.Atlas.GetStillAtlas(); var fogStart = 0; Shaders = new RenderingShaders(Graphics); Shaders.SetTextures(stillAtlas); Shaders.SetAnimatedTextures(Resources.Atlas.GetAtlas(0)); RenderDistance = Options.VideoOptions.RenderDistance; Options.VideoOptions.RenderDistance.Bind( (value, newValue) => { RenderDistance = newValue; }); Chunks = new ConcurrentDictionary <ChunkCoordinates, ChunkColumn>(); CancellationToken = new CancellationTokenSource(); BlockLightCalculations = new BlockLightCalculations((World)world); SkyLightCalculator = new SkyLightCalculations(); Func <ChunkCoordinates, ChunkCoordinates, int> orderingTool = (a, b) => { var pos = new ChunkCoordinates(World.Camera.Position); var aDistance = a.DistanceTo(pos); var bDistance = b.DistanceTo(pos); if (aDistance < bDistance) { return(-1); } if (bDistance > aDistance) { return(1); } return(0); }; UpdateQueue = new FancyQueue <ChunkCoordinates>(); UpdateBorderQueue = new FancyQueue <ChunkCoordinates>(); FastUpdateQueue = new FancyQueue <ChunkCoordinates>(); }
public ChunkManager(IServiceProvider serviceProvider, GraphicsDevice graphics, World world) { Graphics = graphics; World = world; Options = serviceProvider.GetRequiredService <IOptionsProvider>().AlexOptions; Resources = serviceProvider.GetRequiredService <ResourceManager>(); var stillAtlas = Resources.Atlas.GetStillAtlas(); var fogStart = 0; Shaders = new RenderingShaders(Graphics); Shaders.SetTextures(stillAtlas); Shaders.SetAnimatedTextures(Resources.Atlas.GetAtlas(0)); _renderSampler.MaxMipLevel = stillAtlas.LevelCount; RenderDistance = Options.VideoOptions.RenderDistance; Options.VideoOptions.RenderDistance.Bind( (value, newValue) => { RenderDistance = newValue; }); Chunks = new ConcurrentDictionary <ChunkCoordinates, ChunkColumn>(); CancellationToken = new CancellationTokenSource(); BlockLightCalculations = new BlockLightCalculations(world, CancellationToken.Token); SkyLightCalculator = new SkyLightCalculations(CancellationToken.Token); UpdateQueue = new FancyQueue <ChunkCoordinates>(); UpdateBorderQueue = new FancyQueue <ChunkCoordinates>(); FastUpdateQueue = new FancyQueue <ChunkCoordinates>(); }