Merge pull request #139 from frosty-dev/sprite-for-station-records
[фича] Отображение спрайта в консоли учетов
This commit is contained in:
@@ -1,10 +1,19 @@
|
|||||||
using System.Linq;
|
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 Content.Shared.StationRecords;
|
||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Client.StationRecords;
|
namespace Content.Client.StationRecords;
|
||||||
|
|
||||||
@@ -19,6 +28,8 @@ public sealed partial class GeneralStationRecordConsoleWindow : DefaultWindow
|
|||||||
|
|
||||||
private GeneralStationRecordFilterType _currentFilterType;
|
private GeneralStationRecordFilterType _currentFilterType;
|
||||||
|
|
||||||
|
private EntityUid _previewDummy;
|
||||||
|
|
||||||
public GeneralStationRecordConsoleWindow()
|
public GeneralStationRecordConsoleWindow()
|
||||||
{
|
{
|
||||||
RobustXamlLoader.Load(this);
|
RobustXamlLoader.Load(this);
|
||||||
@@ -156,6 +167,7 @@ public sealed partial class GeneralStationRecordConsoleWindow : DefaultWindow
|
|||||||
Text = record.Name,
|
Text = record.Name,
|
||||||
StyleClasses = { "LabelBig" }
|
StyleClasses = { "LabelBig" }
|
||||||
},
|
},
|
||||||
|
SetupCharacterSpriteView(record),
|
||||||
new Label()
|
new Label()
|
||||||
{
|
{
|
||||||
Text = Loc.GetString("general-station-record-console-record-age", ("age", record.Age.ToString()))
|
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<IEntityManager>();
|
||||||
|
IPrototypeManager prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||||
|
HumanoidAppearanceSystem appearanceSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<HumanoidAppearanceSystem>();
|
||||||
|
|
||||||
|
entityManager.DeleteEntity(_previewDummy);
|
||||||
|
|
||||||
|
var profile = record.Profile ?? new HumanoidCharacterProfile();
|
||||||
|
_previewDummy = entityManager.SpawnEntity(prototypeManager.Index<SpeciesPrototype>(profile.Species).DollPrototype, MapCoordinates.Nullspace);
|
||||||
|
appearanceSystem.LoadProfile(_previewDummy, profile);
|
||||||
|
GiveDummyJobClothes(_previewDummy, record.JobPrototype, profile);
|
||||||
|
|
||||||
|
var spriteViewBox = new BoxContainer();
|
||||||
|
var sprite = entityManager.GetComponent<SpriteComponent>(_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<IEntityManager>();
|
||||||
|
IPrototypeManager prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||||
|
ClientInventorySystem inventorySystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ClientInventorySystem>();
|
||||||
|
|
||||||
|
// ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract (what is resharper smoking?)
|
||||||
|
var job = prototypeManager.Index<JobPrototype>(jobPrototype ?? SharedGameTicker.FallbackOverflowJob);
|
||||||
|
|
||||||
|
if (job.StartingGear != null && inventorySystem.TryGetSlots(dummy, out var slots))
|
||||||
|
{
|
||||||
|
var gear = prototypeManager.Index<StartingGearPrototype>(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 = "")
|
private void FilterListingOfRecords(string text = "")
|
||||||
{
|
{
|
||||||
if (!_isPopulating)
|
if (!_isPopulating)
|
||||||
|
|||||||
@@ -127,7 +127,8 @@ public sealed class StationRecordsSystem : SharedStationRecordsSystem
|
|||||||
Gender = gender,
|
Gender = gender,
|
||||||
DisplayPriority = jobPrototype.Weight,
|
DisplayPriority = jobPrototype.Weight,
|
||||||
Fingerprint = mobFingerprint,
|
Fingerprint = mobFingerprint,
|
||||||
DNA = dna
|
DNA = dna,
|
||||||
|
Profile = profile
|
||||||
};
|
};
|
||||||
|
|
||||||
var key = AddRecordEntry(station, record);
|
var key = AddRecordEntry(station, record);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Content.Shared.Preferences;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
@@ -77,4 +78,9 @@ public sealed class GeneralStationRecord
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public string? DNA;
|
public string? DNA;
|
||||||
|
|
||||||
|
/// <sumary>
|
||||||
|
/// HumanoidCharacterProfile
|
||||||
|
/// </sumary>
|
||||||
|
[ViewVariables] public HumanoidCharacterProfile? Profile;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user