+using Content.Shared.Atmos.Rotting;
using Content.Shared.Damage;
using Content.Shared.Inventory.Events;
+using Content.Shared.Mobs.Components;
using Content.Shared.Overlays;
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
public HashSet<string> DamageContainers = new();
- [ValidatePrototypeId<StatusIconPrototype>]
- private const string HealthIconFine = "HealthIconFine";
-
public override void Initialize()
{
base.Initialize();
DamageContainers.Clear();
}
- private void OnGetStatusIconsEvent(EntityUid uid, DamageableComponent damageableComponent, ref GetStatusIconsEvent args)
+ private void OnGetStatusIconsEvent(Entity<DamageableComponent> entity, ref GetStatusIconsEvent args)
{
if (!IsActive || args.InContainer)
return;
- var healthIcons = DecideHealthIcons(damageableComponent);
+ var healthIcons = DecideHealthIcons(entity);
args.StatusIcons.AddRange(healthIcons);
}
- private IReadOnlyList<StatusIconPrototype> DecideHealthIcons(DamageableComponent damageableComponent)
+ private IReadOnlyList<StatusIconPrototype> DecideHealthIcons(Entity<DamageableComponent> entity)
{
+ var damageableComponent = entity.Comp;
+
if (damageableComponent.DamageContainerID == null ||
!DamageContainers.Contains(damageableComponent.DamageContainerID))
{
var result = new List<StatusIconPrototype>();
// Here you could check health status, diseases, mind status, etc. and pick a good icon, or multiple depending on whatever.
- if (damageableComponent?.DamageContainerID == "Biological" &&
- _prototypeMan.TryIndex<StatusIconPrototype>(HealthIconFine, out var healthyIcon))
+ if (damageableComponent?.DamageContainerID == "Biological")
{
- result.Add(healthyIcon);
+ if (TryComp<MobStateComponent>(entity, out var state))
+ {
+ // Since there is no MobState for a rotting mob, we have to deal with this case first.
+ if (HasComp<RottingComponent>(entity) && _prototypeMan.TryIndex(damageableComponent.RottingIcon, out var rottingIcon))
+ result.Add(rottingIcon);
+ else if (damageableComponent.HealthIcons.TryGetValue(state.CurrentState, out var value) && _prototypeMan.TryIndex(value, out var icon))
+ result.Add(icon);
+ }
}
return result;
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
+using Content.Shared.Mobs;
+using Content.Shared.StatusIcon;
using Robust.Shared.GameStates;
+using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
public FixedPoint2 TotalDamage;
[DataField("radiationDamageTypes", customTypeSerializer: typeof(PrototypeIdListSerializer<DamageTypePrototype>))]
- public List<string> RadiationDamageTypeIDs = new() {"Radiation"};
+ public List<string> RadiationDamageTypeIDs = new() { "Radiation" };
+
+ [DataField]
+ public Dictionary<MobState, ProtoId<StatusIconPrototype>> HealthIcons = new()
+ {
+ { MobState.Alive, "HealthIconFine" },
+ { MobState.Critical, "HealthIconCritical" },
+ { MobState.Dead, "HealthIconDead" },
+ };
+
+ [DataField]
+ public ProtoId<StatusIconPrototype> RottingIcon = "HealthIconRotting";
}
[Serializable, NetSerializable]
icon:
sprite: /Textures/Interface/Misc/health_icons.rsi
state: Fine
- locationPreference: Right
\ No newline at end of file
+ locationPreference: Right
+
+- type: statusIcon
+ id: HealthIconCritical
+ priority: 1
+ icon:
+ sprite: /Textures/Interface/Misc/health_icons.rsi
+ state: Critical
+ locationPreference: Right
+
+- type: statusIcon
+ id: HealthIconDead
+ priority: 1
+ icon:
+ sprite: /Textures/Interface/Misc/health_icons.rsi
+ state: Dead
+ locationPreference: Right
+
+- type: statusIcon
+ id: HealthIconRotting
+ priority: 1
+ icon:
+ sprite: /Textures/Interface/Misc/health_icons.rsi
+ state: Rotting
+ locationPreference: Right
+