Damage masks (#9402)
This commit is contained in:
16
Content.Server/MobState/MobStateSystem.Crit.cs
Normal file
16
Content.Server/MobState/MobStateSystem.Crit.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Content.Shared.StatusEffect;
|
||||
|
||||
namespace Content.Server.MobState;
|
||||
|
||||
public sealed partial class MobStateSystem
|
||||
{
|
||||
public override void EnterCritState(EntityUid uid)
|
||||
{
|
||||
base.EnterCritState(uid);
|
||||
|
||||
if (HasComp<StatusEffectsComponent>(uid))
|
||||
{
|
||||
Status.TryRemoveStatusEffect(uid, "Stun");
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Content.Server/MobState/MobStateSystem.Dead.cs
Normal file
19
Content.Server/MobState/MobStateSystem.Dead.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.StatusEffect;
|
||||
|
||||
namespace Content.Server.MobState;
|
||||
|
||||
public sealed partial class MobStateSystem
|
||||
{
|
||||
public override void EnterDeadState(EntityUid uid)
|
||||
{
|
||||
base.EnterDeadState(uid);
|
||||
|
||||
Alerts.ShowAlert(uid, AlertType.HumanDead);
|
||||
|
||||
if (HasComp<StatusEffectsComponent>(uid))
|
||||
{
|
||||
Status.TryRemoveStatusEffect(uid, "Stun");
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Content.Server/MobState/MobStateSystem.Norm.cs
Normal file
29
Content.Server/MobState/MobStateSystem.Norm.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.MobState.Components;
|
||||
|
||||
namespace Content.Server.MobState;
|
||||
|
||||
public sealed partial class MobStateSystem
|
||||
{
|
||||
public override void UpdateNormState(EntityUid entity, FixedPoint2 threshold)
|
||||
{
|
||||
base.UpdateNormState(entity, threshold);
|
||||
|
||||
if (!TryComp<DamageableComponent>(entity, out var damageable))
|
||||
return;
|
||||
|
||||
if (!TryComp<MobStateComponent>(entity, out var stateComponent))
|
||||
return;
|
||||
|
||||
short modifier = 0;
|
||||
|
||||
if (TryGetEarliestIncapacitatedState(stateComponent, threshold, out _, out var earliestThreshold) && damageable.TotalDamage != 0)
|
||||
{
|
||||
modifier = (short)(damageable.TotalDamage / (earliestThreshold / 5) + 1);
|
||||
}
|
||||
|
||||
Alerts.ShowAlert(entity, AlertType.HumanHealth, modifier);
|
||||
}
|
||||
}
|
||||
19
Content.Server/MobState/MobStateSystem.cs
Normal file
19
Content.Server/MobState/MobStateSystem.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.MobState.EntitySystems;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Server.MobState;
|
||||
|
||||
public sealed partial class MobStateSystem : SharedMobStateSystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<MobStateComponent, ComponentGetState>(OnMobGetState);
|
||||
}
|
||||
|
||||
private void OnMobGetState(EntityUid uid, MobStateComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new MobStateComponentState(component.CurrentThreshold);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using Content.Shared.MobState.State;
|
||||
using Content.Shared.StatusEffect;
|
||||
|
||||
namespace Content.Server.MobState.States
|
||||
{
|
||||
public sealed class CriticalMobState : SharedCriticalMobState
|
||||
{
|
||||
public override void EnterState(EntityUid uid, IEntityManager entityManager)
|
||||
{
|
||||
base.EnterState(uid, entityManager);
|
||||
|
||||
if (entityManager.TryGetComponent(uid, out StatusEffectsComponent? stun))
|
||||
{
|
||||
EntitySystem.Get<StatusEffectsSystem>().TryRemoveStatusEffect(uid, "Stun");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.MobState.State;
|
||||
using Content.Shared.StatusEffect;
|
||||
|
||||
namespace Content.Server.MobState.States
|
||||
{
|
||||
public sealed class DeadMobState : SharedDeadMobState
|
||||
{
|
||||
public override void EnterState(EntityUid uid, IEntityManager entityManager)
|
||||
{
|
||||
base.EnterState(uid, entityManager);
|
||||
|
||||
EntitySystem.Get<AlertsSystem>().ShowAlert(uid, AlertType.HumanDead);
|
||||
|
||||
if (entityManager.TryGetComponent(uid, out StatusEffectsComponent? stun))
|
||||
{
|
||||
EntitySystem.Get<StatusEffectsSystem>().TryRemoveStatusEffect(uid, "Stun");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.MobState.State;
|
||||
|
||||
namespace Content.Server.MobState.States
|
||||
{
|
||||
public sealed class NormalMobState : SharedNormalMobState
|
||||
{
|
||||
public override void UpdateState(EntityUid entity, FixedPoint2 threshold, IEntityManager entityManager)
|
||||
{
|
||||
base.UpdateState(entity, threshold, entityManager);
|
||||
|
||||
if (!entityManager.TryGetComponent(entity, out DamageableComponent? damageable))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.TryGetComponent(entity, out MobStateComponent? stateComponent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
short modifier = 0;
|
||||
|
||||
if (stateComponent.TryGetEarliestIncapacitatedState(threshold, out _, out var earliestThreshold) && damageable.TotalDamage != 0)
|
||||
{
|
||||
modifier = (short)(damageable.TotalDamage / (earliestThreshold / 5) + 1);
|
||||
}
|
||||
EntitySystem.Get<AlertsSystem>().ShowAlert(entity, AlertType.HumanHealth, modifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user