Re-organize all projects (#4166)
This commit is contained in:
12
Content.Client/Parallax/Managers/IParallaxManager.cs
Normal file
12
Content.Client/Parallax/Managers/IParallaxManager.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using Robust.Client.Graphics;
|
||||
|
||||
namespace Content.Client.Parallax.Managers
|
||||
{
|
||||
public interface IParallaxManager
|
||||
{
|
||||
event Action<Texture>? OnTextureLoaded;
|
||||
Texture? ParallaxTexture { get; }
|
||||
void LoadParallax();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Client.Interfaces.Parallax;
|
||||
using Content.Shared;
|
||||
using Nett;
|
||||
using Robust.Client.Graphics;
|
||||
@@ -15,7 +14,7 @@ using Robust.Shared.Utility;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
|
||||
namespace Content.Client.Parallax
|
||||
namespace Content.Client.Parallax.Managers
|
||||
{
|
||||
internal sealed class ParallaxManager : IParallaxManager
|
||||
{
|
||||
47
Content.Client/Parallax/ParallaxControl.cs
Normal file
47
Content.Client/Parallax/ParallaxControl.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using Content.Client.Parallax.Managers;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Client.Parallax
|
||||
{
|
||||
/// <summary>
|
||||
/// Renders the parallax background as a UI control.
|
||||
/// </summary>
|
||||
public sealed class ParallaxControl : Control
|
||||
{
|
||||
[Dependency] private readonly IParallaxManager _parallaxManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)] public Vector2i Offset { get; set; }
|
||||
|
||||
public ParallaxControl()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
Offset = (_random.Next(0, 1000), _random.Next(0, 1000));
|
||||
RectClipContent = true;
|
||||
}
|
||||
|
||||
protected override void Draw(DrawingHandleScreen handle)
|
||||
{
|
||||
var tex = _parallaxManager.ParallaxTexture;
|
||||
if (tex == null)
|
||||
return;
|
||||
|
||||
var size = tex.Size;
|
||||
var ourSize = PixelSize;
|
||||
|
||||
for (var x = -size.X + Offset.X; x < ourSize.X; x += size.X)
|
||||
{
|
||||
for (var y = -size.Y + Offset.Y; y < ourSize.Y; y += size.Y)
|
||||
{
|
||||
handle.DrawTexture(tex, (x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using Content.Client.Interfaces.Parallax;
|
||||
using Content.Client.Parallax.Managers;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
Reference in New Issue
Block a user