* Offbrand medical * what if we regrade * zombies are mostly there thats it thats a wrap xd * here's changeling * some bonus gut punches * start working on the guidebook * fix rsi and yaml lints * my agrichem so fits * we stay rejuvenated * my china so laked * debrute * fix suicide * fix the suicide tests * my surgery so requires laying down * the guidebook continues * READ KEB PAGES * keb vascular recoupler * read keb medicine * fix yaml lint * fix the EntityRemoveConstructionGraphStep * fix overlay init * scalpels are not a food tool * return of the programmer art * my line so nieuw * boxes deserve veins too * mrrrp yaml * what if we redid brain damage alerts * bloot pressure * kill mannitol drowsiness * get licensed * my read so me * get feedbacked nerd * fine-tune the heart stoppage conditions * cryostasis adjustments, guidebook adjustments, fix negative strain issues * my surgery so table * fix heart surgery and guidebook * medicine & defibrillator pass * iv bags and stands * prefills * janet gets very sidetracked * mostly finished iv stuff * what if we fixed the guidebook * halve decapoid cryostasis * my medicines so IV * finetune cryostasis * less logspam * metabolism-aware iv stands and cryopods * give people painkillers * yaml lint real * fix blood build * finish rebase * tidy up localization * clean up my yaml beasties... * soft curve after exceeding maximum damage * husks/bonedeaths Grabbag of Offmed fixes & improvements (#3461) * CPR moment * Mob AI fix * Fix brain oxygenation not updating on regeneration * sorry gamers you cannot resist the pull * Troll combat abilities more in softcrit praying rn (#3467) dont have CPR be 50% (#3468) Make offbrand murder easier to contend with (#3473) * e * disrupt people in softcrit when attacking them * ok gamers we're gaming * forgor Hopefully final pass before Offbrand merge (#3475) First pass of Offbrand adjustments (#3477) Swap blood pressure values in health analyzer (#3476) Systolic over diastolic Co-authored-by: Kip <32859367+kipdotnet@users.noreply.github.com> Offbrand pass 2: Mostly bugfixes (#3480) Fix zeds causing PVS reloads (#3482) Offbrand pass 3: I hate surgery I hate surgery I hate surgery I (#3481) * set up surgery ui * test fail real Pain/braingasps (#3487) Offmed bundle 5 - the evil one (#3489) * Evil cavity surgery * les borgues * nicotine moment * epinephrine RNG * legalese * test fail real * ok jamers cope with c4 Pass 6
125 lines
4.3 KiB
C#
125 lines
4.3 KiB
C#
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;
|
|
using Robust.Shared.Prototypes;
|
|
using System.Linq;
|
|
using Content.Shared._Offbrand.Wounds; // Offbrand
|
|
using Content.Shared.Mobs; // Offbrand
|
|
|
|
namespace Content.Client.Overlays;
|
|
|
|
/// <summary>
|
|
/// Shows a healthy icon on mobs.
|
|
/// </summary>
|
|
public sealed class ShowHealthIconsSystem : EquipmentHudSystem<ShowHealthIconsComponent>
|
|
{
|
|
[Dependency] private readonly IPrototypeManager _prototypeMan = default!;
|
|
|
|
[ViewVariables]
|
|
public HashSet<string> DamageContainers = new();
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<DamageableComponent, GetStatusIconsEvent>(OnGetStatusIconsEvent);
|
|
SubscribeLocalEvent<ShowHealthIconsComponent, AfterAutoHandleStateEvent>(OnHandleState);
|
|
}
|
|
|
|
protected override void UpdateInternal(RefreshEquipmentHudEvent<ShowHealthIconsComponent> component)
|
|
{
|
|
base.UpdateInternal(component);
|
|
|
|
foreach (var damageContainerId in component.Components.SelectMany(x => x.DamageContainers))
|
|
{
|
|
DamageContainers.Add(damageContainerId);
|
|
}
|
|
}
|
|
|
|
protected override void DeactivateInternal()
|
|
{
|
|
base.DeactivateInternal();
|
|
|
|
DamageContainers.Clear();
|
|
}
|
|
|
|
private void OnHandleState(Entity<ShowHealthIconsComponent> ent, ref AfterAutoHandleStateEvent args)
|
|
{
|
|
RefreshOverlay();
|
|
}
|
|
|
|
private void OnGetStatusIconsEvent(Entity<DamageableComponent> entity, ref GetStatusIconsEvent args)
|
|
{
|
|
if (!IsActive)
|
|
return;
|
|
|
|
var healthIcons = DecideHealthIcons(entity);
|
|
|
|
args.StatusIcons.AddRange(healthIcons);
|
|
}
|
|
|
|
// Begin Offbrand
|
|
private List<HealthIconPrototype> DecideBrainHealthIcons(Entity<BrainDamageComponent, BrainDamageThresholdsComponent> ent)
|
|
{
|
|
if (ent.Comp2.CurrentState == MobState.Dead)
|
|
{
|
|
return new() { _prototypeMan.Index(ent.Comp2.DeadIcon) };
|
|
}
|
|
|
|
var current = ent.Comp1.Damage;
|
|
var max = ent.Comp1.MaxDamage;
|
|
|
|
if (ent.Comp2.CurrentState == MobState.Critical || ent.Comp1.Oxygen == 0)
|
|
{
|
|
var amount = ent.Comp2.CriticalDamageIcons.Count;
|
|
var idx = Math.Clamp((int)Math.Floor(amount - (amount / max.Double()) * current.Double()), 0, amount-1);
|
|
return new() { _prototypeMan.Index(ent.Comp2.CriticalDamageIcons[idx]) };
|
|
}
|
|
else
|
|
{
|
|
var amount = ent.Comp2.AliveDamageIcons.Count;
|
|
var idx = Math.Clamp((int)Math.Floor(amount - (amount / max.Double()) * current.Double()), 0, amount-1);
|
|
return new() { _prototypeMan.Index(ent.Comp2.AliveDamageIcons[idx]) };
|
|
}
|
|
}
|
|
// End Offbrand
|
|
|
|
private IReadOnlyList<HealthIconPrototype> DecideHealthIcons(Entity<DamageableComponent> entity)
|
|
{
|
|
if (TryComp<BrainDamageComponent>(entity, out var brain) &&
|
|
TryComp<BrainDamageThresholdsComponent>(entity, out var thresholds))
|
|
{
|
|
return DecideBrainHealthIcons((entity.Owner, brain, thresholds));
|
|
}
|
|
|
|
var damageableComponent = entity.Comp;
|
|
|
|
if (damageableComponent.DamageContainerID == null ||
|
|
!DamageContainers.Contains(damageableComponent.DamageContainerID))
|
|
{
|
|
return Array.Empty<HealthIconPrototype>();
|
|
}
|
|
|
|
var result = new List<HealthIconPrototype>();
|
|
|
|
// Here you could check health status, diseases, mind status, etc. and pick a good icon, or multiple depending on whatever.
|
|
if (damageableComponent?.DamageContainerID == "Biological")
|
|
{
|
|
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.Resolve(damageableComponent.RottingIcon, out var rottingIcon))
|
|
result.Add(rottingIcon);
|
|
else if (damageableComponent.HealthIcons.TryGetValue(state.CurrentState, out var value) && _prototypeMan.Resolve(value, out var icon))
|
|
result.Add(icon);
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|