From d9732c62646bcd4490bb1bd9802f51750aff94af Mon Sep 17 00:00:00 2001 From: rhailrake <49613070+rhailrake@users.noreply.github.com> Date: Sun, 28 Apr 2024 10:32:52 +0500 Subject: [PATCH 01/36] stats core --- .../Character/CharacterUIController.cs | 46 +++++++- .../Character/Windows/CharacterWindow.xaml | 7 +- Content.Server/_Lfwb/Stats/StatsSystem.cs | 102 ++++++++++++++++++ Content.Shared/Roles/JobPrototype.cs | 7 ++ .../_Lfwb/Stats/JobStatsModification.cs | 13 +++ .../_Lfwb/Stats/SharedStatsSystem.cs | 4 + Content.Shared/_Lfwb/Stats/Stat.cs | 12 +++ Content.Shared/_Lfwb/Stats/StatsComponent.cs | 21 ++++ .../_Lfwb/Stats/StatsPresetPrototype.cs | 13 +++ Resources/Locale/ru-RU/_white/stats.ftl | 4 + Resources/Prototypes/_White/stats.yml | 17 +++ 11 files changed, 243 insertions(+), 3 deletions(-) create mode 100644 Content.Server/_Lfwb/Stats/StatsSystem.cs create mode 100644 Content.Shared/_Lfwb/Stats/JobStatsModification.cs create mode 100644 Content.Shared/_Lfwb/Stats/SharedStatsSystem.cs create mode 100644 Content.Shared/_Lfwb/Stats/Stat.cs create mode 100644 Content.Shared/_Lfwb/Stats/StatsComponent.cs create mode 100644 Content.Shared/_Lfwb/Stats/StatsPresetPrototype.cs create mode 100644 Resources/Locale/ru-RU/_white/stats.ftl create mode 100644 Resources/Prototypes/_White/stats.yml diff --git a/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs b/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs index d13f56c476c..cbe7376322c 100644 --- a/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs +++ b/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs @@ -1,10 +1,10 @@ -using System.Linq; using Content.Client.CharacterInfo; using Content.Client.Gameplay; using Content.Client.UserInterface.Controls; using Content.Client.UserInterface.Systems.Character.Controls; using Content.Client.UserInterface.Systems.Character.Windows; using Content.Client.UserInterface.Systems.Objectives.Controls; +using Content.Shared._Lfwb.Stats; using Content.Shared.Input; using JetBrains.Annotations; using Robust.Client.GameObjects; @@ -23,12 +23,20 @@ namespace Content.Client.UserInterface.Systems.Character; public sealed class CharacterUIController : UIController, IOnStateEntered, IOnStateExited, IOnSystemChanged { [Dependency] private readonly IPlayerManager _player = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; [UISystemDependency] private readonly CharacterInfoSystem _characterInfo = default!; [UISystemDependency] private readonly SpriteSystem _sprite = default!; private CharacterWindow? _window; private MenuButton? CharacterButton => UIManager.GetActiveUIWidgetOrNull()?.CharacterButton; + public override void Initialize() + { + base.Initialize(); + IoCManager.InjectDependencies(this); + } + public void OnStateEntered(GameplayState state) { DebugTools.Assert(_window == null); @@ -184,6 +192,42 @@ private void CharacterUpdated(CharacterData data) _window.RolePlaceholder.Visible = briefing == null && controls.Count == 0 && objectives.Count == 0; _window.MemoriesPlaceholder.Visible = memories.Count == 0; + + FillStat(); + } + + private void FillStat() + { + _window?.StatsLabel.RemoveAllChildren(); + + if (_playerManager == default || _entityManager == default) + return; + + var playerEntity = _playerManager.LocalPlayer!.ControlledEntity; + + if (!playerEntity.HasValue) + return; + + if (!_entityManager.TryGetComponent(playerEntity, out var stats)) + { + _window?.StatsLabel.SetMessage(""); + return; + + } + + var msg = new FormattedMessage(); + + msg.Clear(); + + msg.PushNewline(); + + foreach (var stat in stats.Stats) + { + var statLoc = Loc.GetString($"stat-{stat.Key}"); + msg.AddMarkup($"[color=#7980ad]{statLoc}[/color]: [color=yellow]{stat.Value}[/color]\n"); + } + + _window?.StatsLabel.SetMessage(msg); } private void CharacterDetached(EntityUid uid) diff --git a/Content.Client/UserInterface/Systems/Character/Windows/CharacterWindow.xaml b/Content.Client/UserInterface/Systems/Character/Windows/CharacterWindow.xaml index 5650320cc91..0aecae267e5 100644 --- a/Content.Client/UserInterface/Systems/Character/Windows/CharacterWindow.xaml +++ b/Content.Client/UserInterface/Systems/Character/Windows/CharacterWindow.xaml @@ -16,13 +16,16 @@ -