Random lobby screens (#142)

* - add: Random lobby screens

* - add: animatedLobbyScreen prototypes
This commit is contained in:
Martell
2024-02-29 18:52:07 +03:00
committed by GitHub
parent 6180bc3b15
commit bbe2935f84
17 changed files with 191 additions and 2 deletions

View File

@@ -1,7 +1,10 @@
using System.Linq;
using Content.Shared._White;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Graphics.RSI;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
namespace Content.Client._Ohio.UI;
@@ -10,8 +13,9 @@ public sealed class AnimatedBackgroundControl : TextureRect
{
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IClyde _clyde = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private const string RsiPath = "/Textures/Ohio/Lobby/anim.rsi";
private string RsiPath = "/Textures/Ohio/Lobby/backgrounds/native.rsi";
private const int States = 1;
private IRenderTexture? _buffer;
@@ -88,4 +92,13 @@ public sealed class AnimatedBackgroundControl : TextureRect
base.Dispose(disposing);
_buffer?.Dispose();
}
public void RandomizeBackground()
{
var backgroundsProto = _prototypeManager.EnumeratePrototypes<AnimatedLobbyScreenPrototype>().ToList();
var random = new Random();
int index = random.Next(backgroundsProto.Count);
RsiPath = $"/Textures/{backgroundsProto[index].Path}";
InitializeStates();
}
}