2022-01-05 00:19:23 -08:00
|
|
|
using System;
|
2020-12-07 14:52:55 +01:00
|
|
|
using Content.Shared.Alert;
|
2021-09-15 03:07:37 +10:00
|
|
|
using Content.Shared.Damage;
|
2021-11-03 16:48:03 -07:00
|
|
|
using Content.Shared.FixedPoint;
|
2021-11-08 15:11:58 +01:00
|
|
|
using Content.Shared.MobState.Components;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.MobState.State;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2020-12-07 14:52:55 +01:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.MobState.States
|
2020-12-07 14:52:55 +01:00
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class NormalMobState : SharedNormalMobState
|
2020-12-07 14:52:55 +01:00
|
|
|
{
|
2021-11-09 12:15:12 +01:00
|
|
|
public override void UpdateState(EntityUid entity, FixedPoint2 threshold, IEntityManager entityManager)
|
2020-12-07 14:52:55 +01:00
|
|
|
{
|
2021-11-09 12:15:12 +01:00
|
|
|
base.UpdateState(entity, threshold, entityManager);
|
2020-12-07 14:52:55 +01:00
|
|
|
|
2021-11-09 12:15:12 +01:00
|
|
|
if (!entityManager.TryGetComponent(entity, out DamageableComponent? damageable))
|
2020-12-07 14:52:55 +01:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-09 12:15:12 +01:00
|
|
|
if (!entityManager.TryGetComponent(entity, out MobStateComponent? stateComponent))
|
2020-12-07 14:52:55 +01:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
short modifier = 0;
|
|
|
|
|
|
|
|
|
|
if (stateComponent.TryGetEarliestIncapacitatedState(threshold, out _, out var earliestThreshold))
|
|
|
|
|
{
|
|
|
|
|
modifier = (short) (damageable.TotalDamage / (earliestThreshold / 7f));
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-05 00:19:23 -08:00
|
|
|
EntitySystem.Get<AlertsSystem>().ShowAlert(entity, AlertType.HumanHealth, modifier);
|
2020-12-07 14:52:55 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|