diff --git a/Content.Client/Parallax/ParallaxControl.cs b/Content.Client/Parallax/ParallaxControl.cs index 0d2abe121a..943fee2cf3 100644 --- a/Content.Client/Parallax/ParallaxControl.cs +++ b/Content.Client/Parallax/ParallaxControl.cs @@ -2,6 +2,8 @@ using Robust.Client.Graphics; using Robust.Client.UserInterface; using Robust.Shared.Random; +using Robust.Shared.Timing; +using Robust.Shared.ViewVariables; namespace Content.Client.Parallax; @@ -10,10 +12,11 @@ namespace Content.Client.Parallax; /// public sealed class ParallaxControl : Control { + [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IParallaxManager _parallaxManager = default!; [Dependency] private readonly IRobustRandom _random = default!; - [ViewVariables(VVAccess.ReadWrite)] public Vector2i Offset { get; set; } + [ViewVariables(VVAccess.ReadWrite)] public Vector2 Offset { get; set; } public ParallaxControl() { @@ -21,20 +24,24 @@ public sealed class ParallaxControl : Control Offset = (_random.Next(0, 1000), _random.Next(0, 1000)); RectClipContent = true; + _parallaxManager.LoadParallaxByName("FastSpace"); } protected override void Draw(DrawingHandleScreen handle) { - foreach (var layer in _parallaxManager.GetParallaxLayers("Default")) + foreach (var layer in _parallaxManager.GetParallaxLayers("FastSpace")) { var tex = layer.Texture; - var texSize = tex.Size * layer.Config.Scale.Floored(); + var texSize = (tex.Size.X * (int) Size.X, tex.Size.Y * (int) Size.X) * layer.Config.Scale.Floored() / 540; var ourSize = PixelSize; + var currentTime = (float) _timing.RealTime.TotalSeconds; + var offset = Offset + new Vector2(currentTime * 100f, currentTime * 0f); + if (layer.Config.Tiled) { // Multiply offset by slowness to match normal parallax - var scaledOffset = (Offset * layer.Config.Slowness).Floored(); + var scaledOffset = (offset * layer.Config.Slowness).Floored(); // Then modulo the scaled offset by the size to prevent drawing a bunch of offscreen tiles for really small images. scaledOffset.X %= texSize.X; diff --git a/Resources/Prototypes/Parallaxes/default.yml b/Resources/Prototypes/Parallaxes/default.yml index 05f5c1668e..9ee45da9ad 100644 --- a/Resources/Prototypes/Parallaxes/default.yml +++ b/Resources/Prototypes/Parallaxes/default.yml @@ -4,34 +4,34 @@ - texture: !type:ImageParallaxTextureSource path: "/Textures/Parallaxes/layer1.png" - slowness: 0.998046875 + slowness: 0.5 scale: "1, 1" - texture: !type:GeneratedParallaxTextureSource id: "hq_wizard_stars" configPath: "/Prototypes/Parallaxes/parallax_config_stars.toml" - slowness: 0.996625 + slowness: 0.25 + - texture: + !type:GeneratedParallaxTextureSource + id: "hq_wizard_stars_slower" + configPath: "/Prototypes/Parallaxes/parallax_config_stars_dim.toml" + slowness: 0.15 - texture: !type:GeneratedParallaxTextureSource id: "hq_wizard_stars_dim" - configPath: "/Prototypes/Parallaxes/parallax_config_stars_dim.toml" - slowness: 0.989375 - - texture: - !type:GeneratedParallaxTextureSource - id: "hq_wizard_stars_faster" configPath: "/Prototypes/Parallaxes/parallax_config_stars-2.toml" - slowness: 0.987265625 + slowness: 0.375 - texture: !type:GeneratedParallaxTextureSource id: "hq_wizard_stars_dim_faster" configPath: "/Prototypes/Parallaxes/parallax_config_stars_dim-2.toml" - slowness: 0.984352 + slowness: 0.125 layersLQ: - texture: !type:GeneratedParallaxTextureSource id: "" configPath: "/Prototypes/Parallaxes/parallax_config.toml" - slowness: 0.875 + slowness: 0.5 layersLQUseHQ: false # Because hyperspace and the menu need their own.