Files
wwdpublic/Content.Client/_Goobstation/Changeling/ChangelingSystem.cs
Kai5 e87c5efeae [Fix] Biomass (#409)
* No biomass drain

* Фиксы

* марка

* Тырим у губа

* Фикс линтера
2025-04-04 12:18:39 +03:00

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);
}
}