Skip to content

Commit

Permalink
do a bunch of stuff!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
Callmore committed Oct 23, 2024
1 parent 7f5a891 commit 53ca996
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 49 deletions.
42 changes: 33 additions & 9 deletions Content.Client/_SSS/UserInterface/SSSStatusUIController.cs
Original file line number Diff line number Diff line change
@@ -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<DamageableSystem>
public sealed class SSSStatusUIController : UIController, IOnSystemChanged<SSSStatusUISystem>, IOnStateChanged<GameplayState>
{
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()
{
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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<DamageableComponent>(_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);
}
}
28 changes: 28 additions & 0 deletions Content.Client/_SSS/UserInterface/SSSStatusUISystem.cs
Original file line number Diff line number Diff line change
@@ -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<Entity<DamageableComponent>>? OnPlayerDamageChanged;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<DamageableComponent, DamageChangedEvent>(OnDamageChanged);
}

private void OnDamageChanged(Entity<DamageableComponent> ent, ref DamageChangedEvent args)
{
var (uid, damagable) = ent;

if (uid == _playerManager.LocalEntity)
{
OnPlayerDamageChanged?.Invoke(ent);
}
}
}
4 changes: 0 additions & 4 deletions Content.Client/_SSS/UserInterface/Widgets/SSSStatusGui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
HorizontalAlignment="Right"
>

<!--
VerticalExpand="True"
Orientation="Horizontal"
-->
<Control>

<PanelContainer StyleClasses="AngleRect" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,8 +28,6 @@ namespace Content.Server._SSS.SuspicionGameRule;

public sealed partial class SuspicionRuleSystem
{
[Dependency] private readonly GameTicker _gameTicker = default!;

[ValidatePrototypeId<EntityPrototype>]
private const string MarkerPrototype = "SSSGridMarker";

Expand Down
2 changes: 2 additions & 0 deletions Content.Server/_SSS/SuspicionGameRule/SuspicionRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -58,6 +59,7 @@ public sealed partial class SuspicionRuleSystem : GameRuleSystem<SuspicionRuleCo
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly ContainerSystem _containerSystem = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;

private readonly SoundSpecifier _traitorStartSound = new SoundPathSpecifier("/Audio/Ambience/Antag/traitor_start.ogg");

Expand Down
9 changes: 0 additions & 9 deletions Content.Shared/Damage/Systems/DamageableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
using Content.Shared.Rejuvenate;
using Robust.Shared.GameStates;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;

namespace Content.Shared.Damage
{
public sealed class DamageableSystem : EntitySystem
{
[Dependency] private readonly ISharedPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly INetManager _netMan = default!;
Expand All @@ -27,8 +25,6 @@ public sealed class DamageableSystem : EntitySystem
private EntityQuery<DamageableComponent> _damageableQuery;
private EntityQuery<MindContainerComponent> _mindContainerQuery;

public Action<Entity<DamageableComponent>>? OnPlayerDamageChanged;

public override void Initialize()
{
SubscribeLocalEvent<DamageableComponent, ComponentInit>(DamageableInit);
Expand Down Expand Up @@ -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));
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,28 +107,3 @@ public enum SuspicionGameState
/// </summary>
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;
}
30 changes: 30 additions & 0 deletions Content.Shared/_SSS/SuspicionGameRule/SuspicionRuleEvents.cs
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 53ca996

Please sign in to comment.