From 53ca9961152db0078fcebef57f9fc01c59a7680e Mon Sep 17 00:00:00 2001 From: Callmore <22885888+Callmore@users.noreply.github.com> Date: Wed, 23 Oct 2024 18:34:37 +0100 Subject: [PATCH] do a bunch of stuff!!! --- .../UserInterface/SSSStatusUIController.cs | 42 +++++++++++++++---- .../_SSS/UserInterface/SSSStatusUISystem.cs | 28 +++++++++++++ .../UserInterface/Widgets/SSSStatusGui.xaml | 4 -- .../SuspicionRuleSystem.Rules.cs | 1 + .../SuspicionRuleSystem.Spawning.cs | 3 +- .../SuspicionGameRule/SuspicionRuleSystem.cs | 2 + .../Damage/Systems/DamageableSystem.cs | 9 ---- .../Components/SuspicionRuleComponent.cs | 25 ----------- .../SuspicionGameRule/SuspicionRuleEvents.cs | 30 +++++++++++++ 9 files changed, 95 insertions(+), 49 deletions(-) create mode 100644 Content.Client/_SSS/UserInterface/SSSStatusUISystem.cs create mode 100644 Content.Shared/_SSS/SuspicionGameRule/SuspicionRuleEvents.cs diff --git a/Content.Client/_SSS/UserInterface/SSSStatusUIController.cs b/Content.Client/_SSS/UserInterface/SSSStatusUIController.cs index cf6c7b7f46..809056a7d0 100644 --- a/Content.Client/_SSS/UserInterface/SSSStatusUIController.cs +++ b/Content.Client/_SSS/UserInterface/SSSStatusUIController.cs @@ -1,28 +1,28 @@ using Content.Client._SSS.UserInterface.Widgets; +using Content.Client.Gameplay; using Content.Client.GameTicking.Managers; -using Content.Client.Mind; -using Content.Client.Roles; +using Content.Shared._SSS.SuspicionGameRule; using Content.Shared._SSS.SuspicionGameRule.Components; using Content.Shared.Damage; using Content.Shared.Mobs; using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Systems; -using Robust.Client.Graphics; using Robust.Client.Player; +using Robust.Client.State; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controllers; using Robust.Shared.Timing; namespace Content.Client._SSS.UserInterface; -public sealed class SSSStatusUIController : UIController, IOnSystemChanged +public sealed class SSSStatusUIController : UIController, IOnSystemChanged, IOnStateChanged { private ISawmill _log = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; - [UISystemDependency] private readonly MobThresholdSystem? _mobThreshold; - [UISystemDependency] private readonly ClientGameTicker? _clientGameTicker; + [UISystemDependency] private readonly MobThresholdSystem? _mobThreshold = default!; + [UISystemDependency] private readonly ClientGameTicker? _clientGameTicker = default!; public override void Initialize() { @@ -143,7 +143,6 @@ private void UpdateTimer(TimeSpan ts) public void UpdateTimerEnd(SuspicionRuleTimerUpdate ev, EntitySessionEventArgs args) { - _log.Info($"WHAT AT {ev.EndTime}"); _lastEndTime = ev.EndTime; } @@ -215,13 +214,38 @@ public void UpdatePlayerSpawn(SuspicionRulePlayerSpawn ev, EntitySessionEventArg _lastEndTime = ev.EndTime; } - public void OnSystemLoaded(DamageableSystem system) + public void OnSystemLoaded(SSSStatusUISystem system) { system.OnPlayerDamageChanged += UpdateHealth; } - public void OnSystemUnloaded(DamageableSystem system) + public void OnSystemUnloaded(SSSStatusUISystem system) { system.OnPlayerDamageChanged -= UpdateHealth; } + + public void OnStateEntered(GameplayState state) + { + _log.Debug($"Entered: {nameof(GameplayState)}"); + + if (EntityManager.TryGetComponent(_playerManager.LocalEntity!.Value, out var damagable)) + UpdateHealth((_playerManager.LocalEntity!.Value, damagable)); + else + SetHealthBar(0, 100); + + UpdateTimer(TimeSpan.Zero); + + SetRoleUI("-", Color.Black); + } + + public void OnStateExited(GameplayState state) + { + _log.Debug($"Entered: {nameof(GameplayState)}"); + + SetHealthBarUI("-", 0, 100); + + UpdateTimer(TimeSpan.Zero); + + SetRoleUI("-", Color.Black); + } } diff --git a/Content.Client/_SSS/UserInterface/SSSStatusUISystem.cs b/Content.Client/_SSS/UserInterface/SSSStatusUISystem.cs new file mode 100644 index 0000000000..c54e94b7af --- /dev/null +++ b/Content.Client/_SSS/UserInterface/SSSStatusUISystem.cs @@ -0,0 +1,28 @@ +using Content.Shared.Damage; +using Robust.Shared.Player; + +namespace Content.Client._SSS.UserInterface; + +public sealed partial class SSSStatusUISystem : EntitySystem +{ + [Dependency] private readonly ISharedPlayerManager _playerManager = default!; + + public event Action>? OnPlayerDamageChanged; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnDamageChanged); + } + + private void OnDamageChanged(Entity ent, ref DamageChangedEvent args) + { + var (uid, damagable) = ent; + + if (uid == _playerManager.LocalEntity) + { + OnPlayerDamageChanged?.Invoke(ent); + } + } +} diff --git a/Content.Client/_SSS/UserInterface/Widgets/SSSStatusGui.xaml b/Content.Client/_SSS/UserInterface/Widgets/SSSStatusGui.xaml index 02a40d8f45..e7e308d32c 100644 --- a/Content.Client/_SSS/UserInterface/Widgets/SSSStatusGui.xaml +++ b/Content.Client/_SSS/UserInterface/Widgets/SSSStatusGui.xaml @@ -7,10 +7,6 @@ HorizontalAlignment="Right" > - diff --git a/Content.Server/_SSS/SuspicionGameRule/SuspicionRuleSystem.Rules.cs b/Content.Server/_SSS/SuspicionGameRule/SuspicionRuleSystem.Rules.cs index 7074bcfee5..d8ab4a99ed 100644 --- a/Content.Server/_SSS/SuspicionGameRule/SuspicionRuleSystem.Rules.cs +++ b/Content.Server/_SSS/SuspicionGameRule/SuspicionRuleSystem.Rules.cs @@ -3,6 +3,7 @@ using Content.Server.Communications; using Content.Server.Ghost; using Content.Shared._SSS; +using Content.Shared._SSS.SuspicionGameRule; using Content.Shared._SSS.SuspicionGameRule.Components; using Content.Shared.Chat; using Content.Shared.Damage; diff --git a/Content.Server/_SSS/SuspicionGameRule/SuspicionRuleSystem.Spawning.cs b/Content.Server/_SSS/SuspicionGameRule/SuspicionRuleSystem.Spawning.cs index 1b26375a64..e119dd524a 100644 --- a/Content.Server/_SSS/SuspicionGameRule/SuspicionRuleSystem.Spawning.cs +++ b/Content.Server/_SSS/SuspicionGameRule/SuspicionRuleSystem.Spawning.cs @@ -9,6 +9,7 @@ using Content.Server.Temperature.Components; using Content.Server.Traits.Assorted; using Content.Shared._SSS; +using Content.Shared._SSS.SuspicionGameRule; using Content.Shared._SSS.SuspicionGameRule.Components; using Content.Shared.Access; using Content.Shared.Access.Components; @@ -27,8 +28,6 @@ namespace Content.Server._SSS.SuspicionGameRule; public sealed partial class SuspicionRuleSystem { - [Dependency] private readonly GameTicker _gameTicker = default!; - [ValidatePrototypeId] private const string MarkerPrototype = "SSSGridMarker"; diff --git a/Content.Server/_SSS/SuspicionGameRule/SuspicionRuleSystem.cs b/Content.Server/_SSS/SuspicionGameRule/SuspicionRuleSystem.cs index 4f1561425f..cd13d4f57e 100644 --- a/Content.Server/_SSS/SuspicionGameRule/SuspicionRuleSystem.cs +++ b/Content.Server/_SSS/SuspicionGameRule/SuspicionRuleSystem.cs @@ -17,6 +17,7 @@ using Content.Server.Station.Systems; using Content.Server.Store.Systems; using Content.Shared._SSS; +using Content.Shared._SSS.SuspicionGameRule; using Content.Shared._SSS.SuspicionGameRule.Components; using Content.Shared.Damage; using Content.Shared.Examine; @@ -58,6 +59,7 @@ public sealed partial class SuspicionRuleSystem : GameRuleSystem _damageableQuery; private EntityQuery _mindContainerQuery; - public Action>? OnPlayerDamageChanged; - public override void Initialize() { SubscribeLocalEvent(DamageableInit); @@ -113,11 +109,6 @@ public void DamageChanged(EntityUid uid, DamageableComponent component, DamageSp _appearance.SetData(uid, DamageVisualizerKeys.DamageUpdateGroups, data, appearance); } RaiseLocalEvent(uid, new DamageChangedEvent(component, damageDelta, interruptsDoAfters, origin)); - - if (uid == _playerManager.LocalEntity) - { - OnPlayerDamageChanged?.Invoke((uid, component)); - } } /// diff --git a/Content.Shared/_SSS/SuspicionGameRule/Components/SuspicionRuleComponent.cs b/Content.Shared/_SSS/SuspicionGameRule/Components/SuspicionRuleComponent.cs index b30f0cee71..4b7267213e 100644 --- a/Content.Shared/_SSS/SuspicionGameRule/Components/SuspicionRuleComponent.cs +++ b/Content.Shared/_SSS/SuspicionGameRule/Components/SuspicionRuleComponent.cs @@ -107,28 +107,3 @@ public enum SuspicionGameState /// PostRound } - -[Serializable, NetSerializable] -public sealed class SuspicionRuleTimerUpdate(TimeSpan endTime) : EntityEventArgs -{ - public TimeSpan EndTime = endTime; -} - -[Serializable, NetSerializable] -public sealed class SuspicionRulePreroundStarted(TimeSpan preroundEndTime) : EntityEventArgs -{ - public TimeSpan PreroundEndTime = preroundEndTime; -} - -[Serializable, NetSerializable] -public sealed class SuspicionRuleUpdateRole(SuspicionRole newRole) : EntityEventArgs -{ - public readonly SuspicionRole NewRole = newRole; -} - -[Serializable, NetSerializable] -public sealed class SuspicionRulePlayerSpawn : EntityEventArgs -{ - public SuspicionGameState GameState; - public TimeSpan EndTime; -} diff --git a/Content.Shared/_SSS/SuspicionGameRule/SuspicionRuleEvents.cs b/Content.Shared/_SSS/SuspicionGameRule/SuspicionRuleEvents.cs new file mode 100644 index 0000000000..dba69bbf74 --- /dev/null +++ b/Content.Shared/_SSS/SuspicionGameRule/SuspicionRuleEvents.cs @@ -0,0 +1,30 @@ +using Content.Shared._SSS.SuspicionGameRule.Components; +using Robust.Shared.Serialization; + +namespace Content.Shared._SSS.SuspicionGameRule; + + +[Serializable, NetSerializable] +public sealed class SuspicionRuleTimerUpdate(TimeSpan endTime) : EntityEventArgs +{ + public TimeSpan EndTime = endTime; +} + +[Serializable, NetSerializable] +public sealed class SuspicionRulePreroundStarted(TimeSpan preroundEndTime) : EntityEventArgs +{ + public TimeSpan PreroundEndTime = preroundEndTime; +} + +[Serializable, NetSerializable] +public sealed class SuspicionRuleUpdateRole(SuspicionRole newRole) : EntityEventArgs +{ + public readonly SuspicionRole NewRole = newRole; +} + +[Serializable, NetSerializable] +public sealed class SuspicionRulePlayerSpawn : EntityEventArgs +{ + public SuspicionGameState GameState; + public TimeSpan EndTime; +}