Mobstate Refactor (#13389)
Refactors mobstate and moves mob health thresholds to their own component Co-authored-by: DrSmugleaf <drsmugleaf@gmail.com>
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
using Content.Client.IoC;
|
||||
using Content.Client.MobState;
|
||||
using Content.Client.Resources;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -84,11 +85,10 @@ namespace Content.Client.HealthOverlay.UI
|
||||
}
|
||||
|
||||
var mobStateSystem = _entities.EntitySysManager.GetEntitySystem<MobStateSystem>();
|
||||
FixedPoint2 threshold;
|
||||
|
||||
var mobThresholdSystem = _entities.EntitySysManager.GetEntitySystem<MobThresholdSystem>();
|
||||
if (mobStateSystem.IsAlive(mobState.Owner, mobState))
|
||||
{
|
||||
if (!mobStateSystem.TryGetEarliestCriticalState(mobState, damageable.TotalDamage, out _, out threshold))
|
||||
if (!mobThresholdSystem.TryGetThresholdForState(Entity,MobState.Critical, out var threshold))
|
||||
{
|
||||
CritBar.Visible = false;
|
||||
HealthBar.Visible = false;
|
||||
@@ -97,7 +97,7 @@ namespace Content.Client.HealthOverlay.UI
|
||||
|
||||
CritBar.Ratio = 1;
|
||||
CritBar.Visible = true;
|
||||
HealthBar.Ratio = 1 - (damageable.TotalDamage / threshold).Float();
|
||||
HealthBar.Ratio = 1 - ((FixedPoint2)(damageable.TotalDamage / threshold)).Float();
|
||||
HealthBar.Visible = true;
|
||||
}
|
||||
else if (mobStateSystem.IsCritical(mobState.Owner, mobState))
|
||||
@@ -105,8 +105,8 @@ namespace Content.Client.HealthOverlay.UI
|
||||
HealthBar.Ratio = 0;
|
||||
HealthBar.Visible = false;
|
||||
|
||||
if (!mobStateSystem.TryGetPreviousCriticalState(mobState, damageable.TotalDamage, out _, out var critThreshold) ||
|
||||
!mobStateSystem.TryGetEarliestDeadState(mobState, damageable.TotalDamage, out _, out var deadThreshold))
|
||||
if (!mobThresholdSystem.TryGetThresholdForState(Entity, MobState.Critical, out var critThreshold) ||
|
||||
!mobThresholdSystem.TryGetThresholdForState(Entity, MobState.Dead, out var deadThreshold))
|
||||
{
|
||||
CritBar.Visible = false;
|
||||
return;
|
||||
@@ -115,7 +115,7 @@ namespace Content.Client.HealthOverlay.UI
|
||||
CritBar.Visible = true;
|
||||
CritBar.Ratio = 1 -
|
||||
((damageable.TotalDamage - critThreshold) /
|
||||
(deadThreshold - critThreshold)).Float();
|
||||
(deadThreshold - critThreshold)).Value.Float();
|
||||
}
|
||||
else if (mobStateSystem.IsDead(mobState.Owner, mobState))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user