Skip to content

Commit

Permalink
Added a witness counter to the essence regen alert
Browse files Browse the repository at this point in the history
  • Loading branch information
TGRCdev committed Sep 19, 2024
1 parent 8441460 commit 23d44f1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
26 changes: 26 additions & 0 deletions Content.Client/Revenant/RevenantRegenModifierSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Content.Client.Alerts;
using Content.Shared.Revenant;
using Content.Shared.Revenant.Components;

namespace Content.Client.Revenant;

public sealed class RevenantRegenModifierSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RevenantRegenModifierComponent, UpdateAlertSpriteEvent>(OnUpdateAlert);
}

private void OnUpdateAlert(Entity<RevenantRegenModifierComponent> ent, ref UpdateAlertSpriteEvent args)
{
if (args.Alert.ID != ent.Comp.Alert)
return;

var sprite = args.SpriteViewEnt.Comp;
var witnesses = Math.Clamp(ent.Comp.Witnesses.Count, 0, 99);
sprite.LayerSetState(RevenantVisualLayers.Digit1, $"{witnesses / 10}");
sprite.LayerSetState(RevenantVisualLayers.Digit2, $"{witnesses % 10}");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


using Content.Shared.Alert;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared.Revenant.Components;

Expand All @@ -9,4 +9,7 @@ public sealed partial class RevenantRegenModifierComponent : Component
{
[ViewVariables, AutoNetworkedField]
public HashSet<NetEntity> Witnesses = new();

[DataField]
public ProtoId<AlertPrototype> Alert = "EssenceRegen";
}
12 changes: 12 additions & 0 deletions Resources/Prototypes/Alerts/revenant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
icons:
- sprite: /Textures/Mobs/Ghosts/revenant.rsi
state: icon
alertViewEntity: AlertEssenceRegenSpriteView

- type: alert
id: Stasis
Expand All @@ -44,3 +45,14 @@
offset: 0.125, 0
- map: [ "enum.RevenantVisualLayers.Digit3" ]
offset: 0.25, 0

- type: entity
id: AlertEssenceRegenSpriteView
components:
- type: Sprite
sprite: /Textures/Interface/Alerts/essence_counter.rsi
layers:
- map: [ "enum.AlertVisualLayers.Base" ]
- map: [ "enum.RevenantVisualLayers.Digit1" ]
- map: [ "enum.RevenantVisualLayers.Digit2" ]
offset: 0.125, 0

0 comments on commit 23d44f1

Please sign in to comment.