Fix parallax generation.
It broke when IoC got made thread local, since it is done in the thread pool.
This commit is contained in:
@@ -6,6 +6,7 @@ using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SixLabors.Primitives;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.Interfaces.Log;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Noise;
|
||||
@@ -17,9 +18,9 @@ namespace Content.Client.Parallax
|
||||
{
|
||||
private readonly List<Layer> Layers = new List<Layer>();
|
||||
|
||||
public static Image<Rgba32> GenerateParallax(TomlTable config, Size size)
|
||||
public static Image<Rgba32> GenerateParallax(TomlTable config, Size size, ISawmill sawmill)
|
||||
{
|
||||
Logger.DebugS("parallax", "Generating parallax!");
|
||||
sawmill.Debug("Generating parallax!");
|
||||
var generator = new ParallaxGenerator();
|
||||
generator._loadConfig(config);
|
||||
|
||||
@@ -28,7 +29,7 @@ namespace Content.Client.Parallax
|
||||
foreach (var layer in generator.Layers)
|
||||
{
|
||||
layer.Apply(image);
|
||||
Logger.DebugS("parallax", "Layer {0} done!", count++);
|
||||
sawmill.Debug("Layer {0} done!", count++);
|
||||
}
|
||||
|
||||
return image;
|
||||
|
||||
@@ -9,6 +9,7 @@ using SixLabors.ImageSharp;
|
||||
using SixLabors.Primitives;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Shared.Interfaces.Log;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -19,6 +20,7 @@ namespace Content.Client.Parallax
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IResourceCache _resourceCache;
|
||||
[Dependency] private readonly ILogManager _logManager;
|
||||
#pragma warning restore 649
|
||||
|
||||
private static readonly ResourcePath ParallaxConfigPath = new ResourcePath("/parallax_config.toml");
|
||||
@@ -77,8 +79,9 @@ namespace Content.Client.Parallax
|
||||
configStream?.Dispose();
|
||||
}
|
||||
|
||||
var sawmill = _logManager.GetSawmill("parallax");
|
||||
// Generate the parallax in the thread pool.
|
||||
var image = await Task.Run(() => ParallaxGenerator.GenerateParallax(table, new Size(1920, 1080)));
|
||||
var image = await Task.Run(() => ParallaxGenerator.GenerateParallax(table, new Size(1920, 1080), sawmill));
|
||||
// And load it in the main thread for safety reasons.
|
||||
ParallaxTexture = Texture.LoadFromImage(image, "Parallax");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user