dynamic alert sprites (#25452)

* dynamic alert sprite

* fix fat cooldowns
This commit is contained in:
Nemanja
2024-03-28 02:32:56 -04:00
committed by GitHub
parent 6863a7cc26
commit d576f5cbbb
38 changed files with 154 additions and 84 deletions

View File

@@ -1,3 +1,5 @@
using Content.Client.Alerts;
using Content.Shared.Alert;
using Content.Shared.Revenant;
using Content.Shared.Revenant.Components;
using Robust.Client.GameObjects;
@@ -13,6 +15,7 @@ public sealed class RevenantSystem : EntitySystem
base.Initialize();
SubscribeLocalEvent<RevenantComponent, AppearanceChangeEvent>(OnAppearanceChange);
SubscribeLocalEvent<RevenantComponent, UpdateAlertSpriteEvent>(OnUpdateAlert);
}
private void OnAppearanceChange(EntityUid uid, RevenantComponent component, ref AppearanceChangeEvent args)
@@ -36,4 +39,16 @@ public sealed class RevenantSystem : EntitySystem
args.Sprite.LayerSetState(0, component.State);
}
}
private void OnUpdateAlert(Entity<RevenantComponent> ent, ref UpdateAlertSpriteEvent args)
{
if (args.Alert.AlertType != AlertType.Essence)
return;
var sprite = args.SpriteViewEnt.Comp;
var essence = Math.Clamp(ent.Comp.Essence.Int(), 0, 999);
sprite.LayerSetState(RevenantVisualLayers.Digit1, $"{(essence / 100) % 10}");
sprite.LayerSetState(RevenantVisualLayers.Digit2, $"{(essence / 10) % 10}");
sprite.LayerSetState(RevenantVisualLayers.Digit3, $"{essence % 10}");
}
}