Lobby refactor + species loadouts support (#27576)

* Vox stuff

* Species loadouts and lobby refactor

The control flow for lobby is all over the shop so I pulled it all up from the individual controls so now they handle the bare minimum required and LobbyUIController handles the rest.

* a

* Bulk changes

* a

* weh

* Character import / export

* finalise

* woops this stuff too

* Also datafield exporting

* comments

* Review
This commit is contained in:
metalgearsloth
2024-05-12 09:18:21 +10:00
committed by GitHub
parent 999d044139
commit 332f54a3ae
49 changed files with 1867 additions and 1563 deletions

View File

@@ -1,13 +1,22 @@
using System.IO;
using System.Linq;
using Content.Shared.CCVar;
using Content.Shared.Decals;
using Content.Shared.Examine;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.IdentityManagement;
using Content.Shared.Preferences;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.GameObjects.Components.Localization;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Shared.Humanoid;
@@ -22,8 +31,10 @@ namespace Content.Shared.Humanoid;
/// </summary>
public abstract class SharedHumanoidAppearanceSystem : EntitySystem
{
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
[Dependency] private readonly INetManager _netManager = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly ISerializationManager _serManager = default!;
[Dependency] private readonly MarkingManager _markingManager = default!;
[ValidatePrototypeId<SpeciesPrototype>]
@@ -37,6 +48,37 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
SubscribeLocalEvent<HumanoidAppearanceComponent, ExaminedEvent>(OnExamined);
}
public DataNode ToDataNode(HumanoidCharacterProfile profile)
{
var export = new HumanoidProfileExport()
{
ForkId = _cfgManager.GetCVar(CVars.BuildForkId),
Profile = profile,
};
var dataNode = _serManager.WriteValue(export, alwaysWrite: true, notNullableOverride: true);
return dataNode;
}
public HumanoidCharacterProfile FromStream(Stream stream, ICommonSession session)
{
using var reader = new StreamReader(stream, EncodingHelpers.UTF8);
var yamlStream = new YamlStream();
yamlStream.Load(reader);
var root = yamlStream.Documents[0].RootNode;
var export = _serManager.Read<HumanoidProfileExport>(root.ToDataNode(), notNullableOverride: true);
/*
* Add custom handling here for forks / version numbers if you care.
*/
var profile = export.Profile;
var collection = IoCManager.Instance;
profile.EnsureValid(session, collection!);
return profile;
}
private void OnInit(EntityUid uid, HumanoidAppearanceComponent humanoid, ComponentInit args)
{
if (string.IsNullOrEmpty(humanoid.Species) || _netManager.IsClient && !IsClientSide(uid))