mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 14:07:53 +03:00
47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using Content.Client.Alerts;
|
|
using Content.Client.UserInterface.Systems.Alerts.Controls;
|
|
using Content.Shared.Changeling;
|
|
using Content.Shared.StatusIcon.Components;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.Changeling;
|
|
|
|
public sealed class ChangelingSystem : SharedChangelingSystem
|
|
{
|
|
|
|
private const int MaxChemicalsNormalizer = 18;
|
|
private const int MaxBiomassNormalizer = 16;
|
|
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ChangelingComponent, UpdateAlertSpriteEvent>(OnUpdateAlert);
|
|
SubscribeLocalEvent<ChangelingComponent, GetStatusIconsEvent>(GetChanglingIcon);
|
|
}
|
|
|
|
private void OnUpdateAlert(EntityUid uid, ChangelingComponent comp, ref UpdateAlertSpriteEvent args)
|
|
{
|
|
var stateNormalized = 0f;
|
|
|
|
// hardcoded because uhh umm i don't know. send help.
|
|
switch (args.Alert.AlertKey.AlertType)
|
|
{
|
|
case "ChangelingChemicals":
|
|
stateNormalized = (int) (comp.Chemicals / comp.MaxChemicals * MaxChemicalsNormalizer);
|
|
break;
|
|
|
|
default:
|
|
return;
|
|
}
|
|
var sprite = args.SpriteViewEnt.Comp;
|
|
sprite.LayerSetState(AlertVisualLayers.Base, $"{stateNormalized}");
|
|
}
|
|
|
|
private void GetChanglingIcon(Entity<ChangelingComponent> ent, ref GetStatusIconsEvent args)
|
|
{
|
|
if (HasComp<HivemindComponent>(ent) && _prototype.TryIndex(ent.Comp.StatusIcon, out var iconPrototype))
|
|
args.StatusIcons.Add(iconPrototype);
|
|
}
|
|
}
|