diff --git a/Content.Client/StationRecords/GeneralStationRecordConsoleWindow.xaml.cs b/Content.Client/StationRecords/GeneralStationRecordConsoleWindow.xaml.cs index c71b115c7a..71f15f46d5 100644 --- a/Content.Client/StationRecords/GeneralStationRecordConsoleWindow.xaml.cs +++ b/Content.Client/StationRecords/GeneralStationRecordConsoleWindow.xaml.cs @@ -1,10 +1,19 @@ using System.Linq; +using Content.Client.Humanoid; +using Content.Client.Inventory; +using Content.Shared.GameTicking; +using Content.Shared.Humanoid.Prototypes; +using Content.Shared.Preferences; +using Content.Shared.Roles; using Content.Shared.StationRecords; using Robust.Client.AutoGenerated; +using Robust.Client.GameObjects; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.XAML; +using Robust.Shared.Map; +using Robust.Shared.Prototypes; namespace Content.Client.StationRecords; @@ -19,6 +28,8 @@ public sealed partial class GeneralStationRecordConsoleWindow : DefaultWindow private GeneralStationRecordFilterType _currentFilterType; + private EntityUid _previewDummy; + public GeneralStationRecordConsoleWindow() { RobustXamlLoader.Load(this); @@ -156,6 +167,7 @@ public sealed partial class GeneralStationRecordConsoleWindow : DefaultWindow Text = record.Name, StyleClasses = { "LabelBig" } }, + SetupCharacterSpriteView(record), new Label() { Text = Loc.GetString("general-station-record-console-record-age", ("age", record.Age.ToString())) @@ -189,6 +201,57 @@ public sealed partial class GeneralStationRecordConsoleWindow : DefaultWindow } } + private BoxContainer SetupCharacterSpriteView(GeneralStationRecord record) + { + IEntityManager entityManager = IoCManager.Resolve(); + IPrototypeManager prototypeManager = IoCManager.Resolve(); + HumanoidAppearanceSystem appearanceSystem = IoCManager.Resolve().GetEntitySystem(); + + entityManager.DeleteEntity(_previewDummy); + + var profile = record.Profile ?? new HumanoidCharacterProfile(); + _previewDummy = entityManager.SpawnEntity(prototypeManager.Index(profile.Species).DollPrototype, MapCoordinates.Nullspace); + appearanceSystem.LoadProfile(_previewDummy, profile); + GiveDummyJobClothes(_previewDummy, record.JobPrototype, profile); + + var spriteViewBox = new BoxContainer(); + var sprite = entityManager.GetComponent(_previewDummy); + + spriteViewBox.AddChild(new SpriteView() { Sprite = sprite, Scale = (5, 5)}); + spriteViewBox.AddChild(new SpriteView() { Sprite = sprite, Scale = (5, 5), OverrideDirection = Direction.East}); + + return spriteViewBox; + } + private void GiveDummyJobClothes(EntityUid dummy, string jobPrototype, HumanoidCharacterProfile profile) + { + IEntityManager entityManager = IoCManager.Resolve(); + IPrototypeManager prototypeManager = IoCManager.Resolve(); + ClientInventorySystem inventorySystem = IoCManager.Resolve().GetEntitySystem(); + + // ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract (what is resharper smoking?) + var job = prototypeManager.Index(jobPrototype ?? SharedGameTicker.FallbackOverflowJob); + + if (job.StartingGear != null && inventorySystem.TryGetSlots(dummy, out var slots)) + { + var gear = prototypeManager.Index(job.StartingGear); + + foreach (var slot in slots) + { + var itemType = gear.GetGear(slot.Name, profile); + if (inventorySystem.TryUnequip(dummy, slot.Name, out var unequippedItem, true, true)) + { + entityManager.DeleteEntity(unequippedItem.Value); + } + + if (itemType != string.Empty) + { + var item = entityManager.SpawnEntity(itemType, MapCoordinates.Nullspace); + inventorySystem.TryEquip(dummy, item, slot.Name, true, true); + } + } + } + } + private void FilterListingOfRecords(string text = "") { if (!_isPopulating) diff --git a/Content.Server/StationRecords/Systems/StationRecordsSystem.cs b/Content.Server/StationRecords/Systems/StationRecordsSystem.cs index 0970411298..97026c0215 100644 --- a/Content.Server/StationRecords/Systems/StationRecordsSystem.cs +++ b/Content.Server/StationRecords/Systems/StationRecordsSystem.cs @@ -127,7 +127,8 @@ public sealed class StationRecordsSystem : SharedStationRecordsSystem Gender = gender, DisplayPriority = jobPrototype.Weight, Fingerprint = mobFingerprint, - DNA = dna + DNA = dna, + Profile = profile }; var key = AddRecordEntry(station, record); diff --git a/Content.Shared/StationRecords/GeneralStationRecord.cs b/Content.Shared/StationRecords/GeneralStationRecord.cs index 38a3ebcf1b..b90615d748 100644 --- a/Content.Shared/StationRecords/GeneralStationRecord.cs +++ b/Content.Shared/StationRecords/GeneralStationRecord.cs @@ -1,3 +1,4 @@ +using Content.Shared.Preferences; using Robust.Shared.Enums; using Robust.Shared.Serialization; @@ -77,4 +78,9 @@ public sealed class GeneralStationRecord /// [ViewVariables] public string? DNA; + + /// + /// HumanoidCharacterProfile + /// + [ViewVariables] public HumanoidCharacterProfile? Profile; }