Лобби коллекции (#3742)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
parent
daf02499d6
commit
dd89700b26
10 changed files with 252 additions and 126 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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<string>? _lobbyParallaxes;
|
||||
|
||||
[ViewVariables]
|
||||
private List<string>? _lobbyArts;
|
||||
|
||||
[ViewVariables]
|
||||
private List<string>? _lobbyAnimations;
|
||||
|
||||
private void InitializeLobbyBackground()
|
||||
{
|
||||
_lobbyArts = _prototypeManager.EnumeratePrototypes<LobbyArtPrototype>()
|
||||
.Select(x => x.ID)
|
||||
.ToList();
|
||||
|
||||
_lobbyParallaxes = _prototypeManager.EnumeratePrototypes<LobbyParallaxPrototype>()
|
||||
.Select(x => x.ID)
|
||||
.ToList();
|
||||
|
||||
_lobbyAnimations = _prototypeManager.EnumeratePrototypes<LobbyAnimationPrototype>()
|
||||
.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
|
||||
}
|
||||
|
|
@ -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<LobbyAnimationPrototype>? LobbyAnimation { get; private set; }
|
||||
|
||||
[ViewVariables]
|
||||
public ProtoId<LobbyParallaxPrototype>? LobbyParallax { get; private set; }
|
||||
|
||||
[ViewVariables]
|
||||
public ProtoId<LobbyArtPrototype>? LobbyArt { get; private set; }
|
||||
|
||||
[ViewVariables]
|
||||
public ProtoId<LobbyBackgroundPresetPrototype> LobbyBackgroundPreset { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
[ViewVariables]
|
||||
private List<string>? _lobbyArts;
|
||||
|
||||
[ViewVariables]
|
||||
private List<string>? _lobbyAnimations;
|
||||
|
||||
[ViewVariables]
|
||||
private List<string>? _lobbyParallaxes;
|
||||
|
||||
#endregion
|
||||
|
||||
private void InitializeLobbyBackground()
|
||||
{
|
||||
Subs.CVar(_cfg, SunriseCCVars.LobbyBackgroundPreset, x => LobbyBackgroundPreset = x, true);
|
||||
var preset = _prototypeManager.Index(LobbyBackgroundPreset);
|
||||
|
||||
_lobbyArts = _prototypeManager.EnumeratePrototypes<LobbyArtPrototype>()
|
||||
.Select(x => x.ID)
|
||||
.Where(x => preset.AllArtsAllowed || preset.WhitelistArts.Contains(x))
|
||||
.ToList();
|
||||
|
||||
_lobbyAnimations = _prototypeManager.EnumeratePrototypes<LobbyAnimationPrototype>()
|
||||
.Select(x => x.ID)
|
||||
.Where(x => preset.AllAnimationsAllowed || preset.WhitelistAnimations.Contains(x))
|
||||
.ToList();
|
||||
|
||||
_lobbyParallaxes = _prototypeManager.EnumeratePrototypes<LobbyParallaxPrototype>()
|
||||
.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<LobbyBackgroundType>();
|
||||
LobbyType = values[_robustRandom.Next(values.Length)].ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
[IdDataField]
|
||||
public string ID { get; set; } = default!;
|
||||
/// <inheritdoc />
|
||||
[ParentDataField(typeof(AbstractPrototypeIdArraySerializer<LobbyAnimationPrototype>))]
|
||||
public string[]? Parents { get; private set; }
|
||||
|
||||
[DataField("animation", required: true)]
|
||||
/// <inheritdoc />
|
||||
[NeverPushInheritance, AbstractDataField]
|
||||
public bool Abstract { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[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";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
/// <inheritdoc />
|
||||
[ParentDataField(typeof(AbstractPrototypeIdArraySerializer<LobbyArtPrototype>))]
|
||||
public string[]? Parents { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[NeverPushInheritance, AbstractDataField]
|
||||
public bool Abstract { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[IdDataField]
|
||||
public string ID { get; set; } = default!;
|
||||
public string ID { get; private set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The sprite path to use as the background. This should ideally be 1920x1080.
|
||||
/// </summary>
|
||||
[DataField("background", required: true)]
|
||||
[DataField(required: true)]
|
||||
public string Background = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The title of the background to be displayed in the lobby.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public LocId Title = "lobby-state-background-unknown-title";
|
||||
|
||||
/// <summary>
|
||||
/// The artist who made the art for the background.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public LocId Artist = "lobby-state-background-unknown-artist";
|
||||
}
|
||||
|
||||
|
|
|
|||
38
Content.Shared/_Sunrise/Lobby/LobbyBackgroundPreset.cs
Normal file
38
Content.Shared/_Sunrise/Lobby/LobbyBackgroundPreset.cs
Normal file
|
|
@ -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
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[ParentDataField(typeof(AbstractPrototypeIdArraySerializer<LobbyBackgroundPresetPrototype>))]
|
||||
public string[]? Parents { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[NeverPushInheritance, AbstractDataField]
|
||||
public bool Abstract { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[IdDataField]
|
||||
public string ID { get; private set; } = default!;
|
||||
|
||||
[DataField]
|
||||
public List<ProtoId<LobbyArtPrototype>> WhitelistArts = [];
|
||||
|
||||
[DataField]
|
||||
public List<ProtoId<LobbyAnimationPrototype>> WhitelistAnimations = [];
|
||||
|
||||
[DataField]
|
||||
public List<ProtoId<LobbyParallaxPrototype>> WhitelistParallaxes = [];
|
||||
|
||||
[DataField]
|
||||
public bool AllArtsAllowed;
|
||||
|
||||
[DataField]
|
||||
public bool AllAnimationsAllowed;
|
||||
|
||||
[DataField]
|
||||
public bool AllParallaxesAllowed;
|
||||
}
|
||||
|
|
@ -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!;
|
||||
/// <inheritdoc />
|
||||
[ParentDataField(typeof(AbstractPrototypeIdArraySerializer<LobbyParallaxPrototype>))]
|
||||
public string[]? Parents { get; private set; }
|
||||
|
||||
[DataField("parallax", required: true)]
|
||||
/// <inheritdoc />
|
||||
[NeverPushInheritance, AbstractDataField]
|
||||
public bool Abstract { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[IdDataField]
|
||||
public string ID { get; private set; } = default!;
|
||||
|
||||
[DataField(required: true)]
|
||||
public string Parallax = default!;
|
||||
}
|
||||
|
|
|
|||
60
Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.Lobby.cs
Normal file
60
Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.Lobby.cs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
using Content.Shared._Sunrise.Lobby;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Content.Shared._Sunrise.SunriseCCVars;
|
||||
|
||||
public sealed partial class SunriseCCVars
|
||||
{
|
||||
/// <summary>
|
||||
/// ID прототипа набора фонов лобби.
|
||||
/// All означает, что будут использованы все доступные фоны
|
||||
/// </summary>
|
||||
public static readonly CVarDef<string> LobbyBackgroundPreset =
|
||||
CVarDef.Create("lobby.background_preset", "AllAllAll", CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// Определяет, какой тип фона лобби будет использован.
|
||||
/// Random, Art, Animation или Parallax
|
||||
/// </summary>
|
||||
/// <seealso cref="LobbyArtPrototype"/>
|
||||
/// <seealso cref="LobbyAnimationPrototype"/>
|
||||
/// <seealso cref="LobbyParallaxPrototype"/>
|
||||
public static readonly CVarDef<string> LobbyBackgroundType =
|
||||
CVarDef.Create("lobby.background", "Random", CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
/// <summary>
|
||||
/// Определяет, какой лобби-арт будет использован. Позволяет игроку выбрать один арт, который будет использован постоянно.
|
||||
/// Random означает, что будет выбираться случайно из списка
|
||||
/// </summary>
|
||||
/// <seealso cref="LobbyArtPrototype"/>
|
||||
public static readonly CVarDef<string> LobbyArt =
|
||||
CVarDef.Create("lobby.art", "Random", CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
/// <summary>
|
||||
/// Определяет, какая лобби-анимация будет использована. Позволяет игроку выбрать одну анимацию, который будет использован постоянно.
|
||||
/// Random означает, что будет выбираться случайно из списка
|
||||
/// </summary>
|
||||
/// <seealso cref="LobbyAnimationPrototype"/>
|
||||
public static readonly CVarDef<string> LobbyAnimation =
|
||||
CVarDef.Create("lobby.animation", "Random", CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
/// <summary>
|
||||
/// Определяет, какой лобби-параллакс будет использован. Позволяет игроку выбрать один параллакс, который будет использован постоянно.
|
||||
/// Random означает, что будет выбираться случайно из списка
|
||||
/// </summary>
|
||||
/// <seealso cref="LobbyParallaxPrototype"/>
|
||||
public static readonly CVarDef<string> LobbyParallax =
|
||||
CVarDef.Create("lobby.parallax", "Random", CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
/// <summary>
|
||||
/// Whether to unload lobby resources from video memory when switching backgrounds or entering round.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> LobbyUnloadResources =
|
||||
CVarDef.Create("lobby.unload_resources", true, CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
/// <summary>
|
||||
/// Прозрачность интерфейса лобби (0.0-1.0)
|
||||
/// </summary>
|
||||
public static readonly CVarDef<float> LobbyOpacity =
|
||||
CVarDef.Create("lobby.lobby_opacity", 0.90f, CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
}
|
||||
|
|
@ -200,31 +200,6 @@ public sealed partial class SunriseCCVars : CVars
|
|||
public static readonly CVarDef<string> InfoLinksReplays =
|
||||
CVarDef.Create("infolinks.replays", "https://t.me/ss14_replays", CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/**
|
||||
* Lobby
|
||||
*/
|
||||
|
||||
public static readonly CVarDef<string> LobbyBackgroundType =
|
||||
CVarDef.Create("lobby.background", "Random", CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
public static readonly CVarDef<string> LobbyArt =
|
||||
CVarDef.Create("lobby.art", "Random", CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
public static readonly CVarDef<string> LobbyAnimation =
|
||||
CVarDef.Create("lobby.animation", "Random", CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
public static readonly CVarDef<string> LobbyParallax =
|
||||
CVarDef.Create("lobby.parallax", "Random", CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
/// <summary>
|
||||
/// Whether to unload lobby resources from video memory when switching backgrounds or entering round.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> LobbyUnloadResources =
|
||||
CVarDef.Create("lobby.unload_resources", true, CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
public static readonly CVarDef<float> LobbyOpacity =
|
||||
CVarDef.Create("lobby.lobby_opacity", 0.90f, CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
public static readonly CVarDef<string> ServerName =
|
||||
CVarDef.Create("lobby.server_name", "Sunrise Station", CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
|
|
|
|||
5
Resources/Prototypes/_Sunrise/Lobby/presets.yml
Normal file
5
Resources/Prototypes/_Sunrise/Lobby/presets.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
- type: lobbyBackgroundPreset
|
||||
id: AllAllAll
|
||||
allArtsAllowed: true
|
||||
allAnimationsAllowed: true
|
||||
allParallaxesAllowed: true
|
||||
Loading…
Add table
Reference in a new issue