using System.Linq;
using Content.Shared.Damage;
using Content.Shared.FixedPoint;
using Content.Shared.MobState.EntitySystems;
using Robust.Shared.GameStates;
namespace Content.Shared.MobState.Components
{
///
/// When attached to an ,
/// this component will handle critical and death behaviors for mobs.
/// Additionally, it handles sending effects to clients
/// (such as blur effect for unconsciousness) and managing the health HUD.
///
[RegisterComponent]
[NetworkedComponent]
public sealed class MobStateComponent : Component
{
///
/// States that this mapped to
/// the amount of damage at which they are triggered.
/// A threshold is reached when the total damage of an entity is equal
/// to or higher than the int key, but lower than the next threshold.
/// Ordered from lowest to highest.
///
[ViewVariables]
[DataField("thresholds")]
public readonly SortedDictionary _lowestToHighestStates = new();
// TODO Remove Nullability?
[ViewVariables]
public DamageState? CurrentState { get; set; }
[ViewVariables]
public FixedPoint2? CurrentThreshold { get; set; }
public IEnumerable> _highestToLowestStates => _lowestToHighestStates.Reverse();
[Obsolete("Use MobStateSystem")]
public bool IsAlive()
{
return IoCManager.Resolve().GetEntitySystem()
.IsAlive(Owner, this);
}
[Obsolete("Use MobStateSystem")]
public bool IsCritical()
{
return IoCManager.Resolve().GetEntitySystem()
.IsCritical(Owner, this);
}
[Obsolete("Use MobStateSystem")]
public bool IsDead()
{
return IoCManager.Resolve().GetEntitySystem()
.IsDead(Owner, this);
}
[Obsolete("Use MobStateSystem")]
public bool IsIncapacitated()
{
return IoCManager.Resolve().GetEntitySystem()
.IsIncapacitated(Owner, this);
}
}
}