diff --git a/Content.Server/GameTicking/GameTicker.Lobby.cs b/Content.Server/GameTicking/GameTicker.Lobby.cs index 4f8e16382d..e1ab61020a 100644 --- a/Content.Server/GameTicking/GameTicker.Lobby.cs +++ b/Content.Server/GameTicking/GameTicker.Lobby.cs @@ -101,7 +101,7 @@ namespace Content.Server.GameTicking private TickerLobbyStatusEvent GetStatusMsg(ICommonSession session) { _playerGameStatuses.TryGetValue(session.UserId, out var status); - return new TickerLobbyStatusEvent(RunLevel != GameRunLevel.PreRoundLobby, LobbyType, LobbyBackground, LobbyParallax, LobbyAnimation, status == PlayerGameStatus.ReadyToPlay, _roundStartTime, RoundPreloadTime, RoundStartTimeSpan, Paused); // Sunrise-edit + return new TickerLobbyStatusEvent(RunLevel != GameRunLevel.PreRoundLobby, LobbyType, LobbyArt, LobbyParallax, LobbyAnimation, status == PlayerGameStatus.ReadyToPlay, _roundStartTime, RoundPreloadTime, RoundStartTimeSpan, Paused); // Sunrise-edit } private void SendStatusToAll() diff --git a/Content.Server/GameTicking/GameTicker.LobbyBackground.cs b/Content.Server/GameTicking/GameTicker.LobbyBackground.cs deleted file mode 100644 index a6baf94a25..0000000000 --- a/Content.Server/GameTicking/GameTicker.LobbyBackground.cs +++ /dev/null @@ -1,70 +0,0 @@ -using Robust.Shared.Random; -using System.Linq; -using Content.Shared._Sunrise.Lobby; -using Content.Shared.GameTicking; -using Content.Shared.GameTicking.Prototypes; - -namespace Content.Server.GameTicking; - -public sealed partial class GameTicker -{ - // Sunrise-Start - [ViewVariables] - public string? LobbyType { get; private set; } - [ViewVariables] - public string? LobbyAnimation { get; private set; } - [ViewVariables] - public string? LobbyParallax { get; private set; } - [ViewVariables] - public string? LobbyBackground { get; private set; } - - [ViewVariables] - private List? _lobbyParallaxes; - - [ViewVariables] - private List? _lobbyArts; - - [ViewVariables] - private List? _lobbyAnimations; - - private void InitializeLobbyBackground() - { - _lobbyArts = _prototypeManager.EnumeratePrototypes() - .Select(x => x.ID) - .ToList(); - - _lobbyParallaxes = _prototypeManager.EnumeratePrototypes() - .Select(x => x.ID) - .ToList(); - - _lobbyAnimations = _prototypeManager.EnumeratePrototypes() - .Select(x => x.ID) - .ToList(); - RandomizeLobbyBackgroundArt(); - RandomizeLobbyBackgroundParallax(); - RandomizeLobbyBackgroundAnimation(); - RandomizeLobbyBackgroundType(); - } - - private void RandomizeLobbyBackgroundParallax() - { - LobbyParallax = _lobbyParallaxes!.Any() ? _robustRandom.Pick(_lobbyParallaxes!) : null; - } - - private void RandomizeLobbyBackgroundAnimation() - { - LobbyAnimation = _lobbyAnimations!.Any() ? _robustRandom.Pick(_lobbyAnimations!) : null; - } - - private void RandomizeLobbyBackgroundType() - { - var values = (LobbyBackgroundType[])Enum.GetValues(typeof(LobbyBackgroundType)); - LobbyType = values[_robustRandom.Next(values.Length)].ToString(); - } - - private void RandomizeLobbyBackgroundArt() - { - LobbyBackground = _lobbyArts!.Any() ? _robustRandom.Pick(_lobbyArts!) : null; - } - // Sunrise-End -} diff --git a/Content.Server/_Sunrise/GameTicking/GameTicker.LobbyBackground.cs b/Content.Server/_Sunrise/GameTicking/GameTicker.LobbyBackground.cs new file mode 100644 index 0000000000..5eeec0af83 --- /dev/null +++ b/Content.Server/_Sunrise/GameTicking/GameTicker.LobbyBackground.cs @@ -0,0 +1,103 @@ +using Robust.Shared.Random; +using System.Linq; +using Content.Shared._Sunrise.Lobby; +using Content.Shared._Sunrise.SunriseCCVars; +using Content.Shared.GameTicking; +using Robust.Shared.Prototypes; + +namespace Content.Server.GameTicking; + +public sealed partial class GameTicker +{ + #region Public variables + + [ViewVariables] + public string? LobbyType { get; private set; } + + [ViewVariables] + public ProtoId? LobbyAnimation { get; private set; } + + [ViewVariables] + public ProtoId? LobbyParallax { get; private set; } + + [ViewVariables] + public ProtoId? LobbyArt { get; private set; } + + [ViewVariables] + public ProtoId LobbyBackgroundPreset { get; private set; } + + #endregion + + #region Private variables + + [ViewVariables] + private List? _lobbyArts; + + [ViewVariables] + private List? _lobbyAnimations; + + [ViewVariables] + private List? _lobbyParallaxes; + + #endregion + + private void InitializeLobbyBackground() + { + Subs.CVar(_cfg, SunriseCCVars.LobbyBackgroundPreset, x => LobbyBackgroundPreset = x, true); + var preset = _prototypeManager.Index(LobbyBackgroundPreset); + + _lobbyArts = _prototypeManager.EnumeratePrototypes() + .Select(x => x.ID) + .Where(x => preset.AllArtsAllowed || preset.WhitelistArts.Contains(x)) + .ToList(); + + _lobbyAnimations = _prototypeManager.EnumeratePrototypes() + .Select(x => x.ID) + .Where(x => preset.AllAnimationsAllowed || preset.WhitelistAnimations.Contains(x)) + .ToList(); + + _lobbyParallaxes = _prototypeManager.EnumeratePrototypes() + .Select(x => x.ID) + .Where(x => preset.AllParallaxesAllowed || preset.WhitelistParallaxes.Contains(x)) + .ToList(); + + RandomizeLobbyBackgroundArt(); + RandomizeLobbyBackgroundParallax(); + RandomizeLobbyBackgroundAnimation(); + RandomizeLobbyBackgroundType(); + } + + #region Randomize methods + + private void RandomizeLobbyBackgroundArt() + { + if (_lobbyArts is null || _lobbyArts.Count == 0) + return; + + LobbyArt = _robustRandom.Pick(_lobbyArts); + } + + private void RandomizeLobbyBackgroundAnimation() + { + if (_lobbyAnimations is null || _lobbyAnimations.Count == 0) + return; + + LobbyAnimation = _robustRandom.Pick(_lobbyAnimations); + } + + private void RandomizeLobbyBackgroundParallax() + { + if (_lobbyParallaxes is null || _lobbyParallaxes.Count == 0) + return; + + LobbyParallax = _robustRandom.Pick(_lobbyParallaxes); + } + + private void RandomizeLobbyBackgroundType() + { + var values = Enum.GetValues(); + LobbyType = values[_robustRandom.Next(values.Length)].ToString(); + } + + #endregion +} diff --git a/Content.Shared/_Sunrise/Lobby/LobbyAnimationPrototype.cs b/Content.Shared/_Sunrise/Lobby/LobbyAnimationPrototype.cs index 10301700b9..640e319405 100644 --- a/Content.Shared/_Sunrise/Lobby/LobbyAnimationPrototype.cs +++ b/Content.Shared/_Sunrise/Lobby/LobbyAnimationPrototype.cs @@ -1,22 +1,30 @@ using System.Numerics; using Robust.Shared.Prototypes; -using Robust.Shared.Utility; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array; namespace Content.Shared._Sunrise.Lobby; -[Prototype("lobbyAnimation")] -public sealed partial class LobbyAnimationPrototype : IPrototype +[Prototype] +public sealed partial class LobbyAnimationPrototype : IPrototype, IInheritingPrototype { - /// - [IdDataField] - public string ID { get; set; } = default!; + /// + [ParentDataField(typeof(AbstractPrototypeIdArraySerializer))] + public string[]? Parents { get; private set; } - [DataField("animation", required: true)] + /// + [NeverPushInheritance, AbstractDataField] + public bool Abstract { get; private set; } + + /// + [IdDataField] + public string ID { get; private set; } = default!; + + [DataField(required: true)] public string Animation = default!; - [DataField("scale")] + [DataField] public Vector2 Scale = new(1f, 1f); - [DataField("state")] + [DataField] public string State = "animation"; } diff --git a/Content.Shared/_Sunrise/Lobby/LobbyArtPrototype.cs b/Content.Shared/_Sunrise/Lobby/LobbyArtPrototype.cs index 6ce18e39e3..86be09b3c6 100644 --- a/Content.Shared/_Sunrise/Lobby/LobbyArtPrototype.cs +++ b/Content.Shared/_Sunrise/Lobby/LobbyArtPrototype.cs @@ -1,30 +1,27 @@ using Robust.Shared.Prototypes; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array; namespace Content.Shared._Sunrise.Lobby; [Prototype] -public sealed partial class LobbyArtPrototype : IPrototype +public sealed partial class LobbyArtPrototype : IPrototype, IInheritingPrototype { - /// + /// + [ParentDataField(typeof(AbstractPrototypeIdArraySerializer))] + public string[]? Parents { get; private set; } + + /// + [NeverPushInheritance, AbstractDataField] + public bool Abstract { get; private set; } + + /// [IdDataField] - public string ID { get; set; } = default!; + public string ID { get; private set; } = default!; /// /// The sprite path to use as the background. This should ideally be 1920x1080. /// - [DataField("background", required: true)] + [DataField(required: true)] public string Background = default!; - - /// - /// The title of the background to be displayed in the lobby. - /// - [DataField] - public LocId Title = "lobby-state-background-unknown-title"; - - /// - /// The artist who made the art for the background. - /// - [DataField] - public LocId Artist = "lobby-state-background-unknown-artist"; } diff --git a/Content.Shared/_Sunrise/Lobby/LobbyBackgroundPreset.cs b/Content.Shared/_Sunrise/Lobby/LobbyBackgroundPreset.cs new file mode 100644 index 0000000000..7f692b0a4a --- /dev/null +++ b/Content.Shared/_Sunrise/Lobby/LobbyBackgroundPreset.cs @@ -0,0 +1,38 @@ +using Robust.Shared.Prototypes; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array; + +namespace Content.Shared._Sunrise.Lobby; + +[Prototype] +public sealed partial class LobbyBackgroundPresetPrototype : IPrototype, IInheritingPrototype +{ + /// + [ParentDataField(typeof(AbstractPrototypeIdArraySerializer))] + public string[]? Parents { get; private set; } + + /// + [NeverPushInheritance, AbstractDataField] + public bool Abstract { get; private set; } + + /// + [IdDataField] + public string ID { get; private set; } = default!; + + [DataField] + public List> WhitelistArts = []; + + [DataField] + public List> WhitelistAnimations = []; + + [DataField] + public List> WhitelistParallaxes = []; + + [DataField] + public bool AllArtsAllowed; + + [DataField] + public bool AllAnimationsAllowed; + + [DataField] + public bool AllParallaxesAllowed; +} diff --git a/Content.Shared/_Sunrise/Lobby/LobbyParallaxPrototype.cs b/Content.Shared/_Sunrise/Lobby/LobbyParallaxPrototype.cs index 22047c1d3d..5622f72bfd 100644 --- a/Content.Shared/_Sunrise/Lobby/LobbyParallaxPrototype.cs +++ b/Content.Shared/_Sunrise/Lobby/LobbyParallaxPrototype.cs @@ -1,13 +1,23 @@ using Robust.Shared.Prototypes; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array; namespace Content.Shared._Sunrise.Lobby; -[Prototype("lobbyParallax")] -public sealed partial class LobbyParallaxPrototype : IPrototype +[Prototype] +public sealed partial class LobbyParallaxPrototype : IPrototype, IInheritingPrototype { - [IdDataField] - public string ID { get; set; } = default!; + /// + [ParentDataField(typeof(AbstractPrototypeIdArraySerializer))] + public string[]? Parents { get; private set; } - [DataField("parallax", required: true)] + /// + [NeverPushInheritance, AbstractDataField] + public bool Abstract { get; private set; } + + /// + [IdDataField] + public string ID { get; private set; } = default!; + + [DataField(required: true)] public string Parallax = default!; } diff --git a/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.Lobby.cs b/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.Lobby.cs new file mode 100644 index 0000000000..925a21eafc --- /dev/null +++ b/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.Lobby.cs @@ -0,0 +1,60 @@ +using Content.Shared._Sunrise.Lobby; +using Robust.Shared.Configuration; + +namespace Content.Shared._Sunrise.SunriseCCVars; + +public sealed partial class SunriseCCVars +{ + /// + /// ID прототипа набора фонов лобби. + /// All означает, что будут использованы все доступные фоны + /// + public static readonly CVarDef LobbyBackgroundPreset = + CVarDef.Create("lobby.background_preset", "AllAllAll", CVar.SERVER | CVar.REPLICATED); + + /// + /// Определяет, какой тип фона лобби будет использован. + /// Random, Art, Animation или Parallax + /// + /// + /// + /// + public static readonly CVarDef LobbyBackgroundType = + CVarDef.Create("lobby.background", "Random", CVar.CLIENTONLY | CVar.ARCHIVE); + + /// + /// Определяет, какой лобби-арт будет использован. Позволяет игроку выбрать один арт, который будет использован постоянно. + /// Random означает, что будет выбираться случайно из списка + /// + /// + public static readonly CVarDef LobbyArt = + CVarDef.Create("lobby.art", "Random", CVar.CLIENTONLY | CVar.ARCHIVE); + + /// + /// Определяет, какая лобби-анимация будет использована. Позволяет игроку выбрать одну анимацию, который будет использован постоянно. + /// Random означает, что будет выбираться случайно из списка + /// + /// + public static readonly CVarDef LobbyAnimation = + CVarDef.Create("lobby.animation", "Random", CVar.CLIENTONLY | CVar.ARCHIVE); + + /// + /// Определяет, какой лобби-параллакс будет использован. Позволяет игроку выбрать один параллакс, который будет использован постоянно. + /// Random означает, что будет выбираться случайно из списка + /// + /// + public static readonly CVarDef LobbyParallax = + CVarDef.Create("lobby.parallax", "Random", CVar.CLIENTONLY | CVar.ARCHIVE); + + /// + /// Whether to unload lobby resources from video memory when switching backgrounds or entering round. + /// + public static readonly CVarDef LobbyUnloadResources = + CVarDef.Create("lobby.unload_resources", true, CVar.CLIENTONLY | CVar.ARCHIVE); + + /// + /// Прозрачность интерфейса лобби (0.0-1.0) + /// + public static readonly CVarDef LobbyOpacity = + CVarDef.Create("lobby.lobby_opacity", 0.90f, CVar.CLIENTONLY | CVar.ARCHIVE); +} diff --git a/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs b/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs index dbd61c1be3..bd6975971f 100644 --- a/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs +++ b/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs @@ -200,31 +200,6 @@ public sealed partial class SunriseCCVars : CVars public static readonly CVarDef InfoLinksReplays = CVarDef.Create("infolinks.replays", "https://t.me/ss14_replays", CVar.SERVER | CVar.REPLICATED); - /** - * Lobby - */ - - public static readonly CVarDef LobbyBackgroundType = - CVarDef.Create("lobby.background", "Random", CVar.CLIENTONLY | CVar.ARCHIVE); - - public static readonly CVarDef LobbyArt = - CVarDef.Create("lobby.art", "Random", CVar.CLIENTONLY | CVar.ARCHIVE); - - public static readonly CVarDef LobbyAnimation = - CVarDef.Create("lobby.animation", "Random", CVar.CLIENTONLY | CVar.ARCHIVE); - - public static readonly CVarDef LobbyParallax = - CVarDef.Create("lobby.parallax", "Random", CVar.CLIENTONLY | CVar.ARCHIVE); - - /// - /// Whether to unload lobby resources from video memory when switching backgrounds or entering round. - /// - public static readonly CVarDef LobbyUnloadResources = - CVarDef.Create("lobby.unload_resources", true, CVar.CLIENTONLY | CVar.ARCHIVE); - - public static readonly CVarDef LobbyOpacity = - CVarDef.Create("lobby.lobby_opacity", 0.90f, CVar.CLIENTONLY | CVar.ARCHIVE); - public static readonly CVarDef ServerName = CVarDef.Create("lobby.server_name", "Sunrise Station", CVar.SERVER | CVar.REPLICATED); diff --git a/Resources/Prototypes/_Sunrise/Lobby/presets.yml b/Resources/Prototypes/_Sunrise/Lobby/presets.yml new file mode 100644 index 0000000000..efd25339be --- /dev/null +++ b/Resources/Prototypes/_Sunrise/Lobby/presets.yml @@ -0,0 +1,5 @@ +- type: lobbyBackgroundPreset + id: AllAllAll + allArtsAllowed: true + allAnimationsAllowed: true + allParallaxesAllowed: true