using Content.Shared.ActionBlocker; using Content.Shared.Administration.Logs; using Content.Shared.Mobs.Components; using Content.Shared.Standing; using Robust.Shared.Physics.Systems; using Robust.Shared.Timing; namespace Content.Shared.Mobs.Systems; [Virtual] public partial class MobStateSystem : EntitySystem { [Dependency] private readonly ActionBlockerSystem _blocker = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly StandingStateSystem _standing = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; [Dependency] private readonly ILogManager _logManager = default!; [Dependency] private readonly IGameTiming _timing = default!; private ISawmill _sawmill = default!; private EntityQuery _mobStateQuery; public override void Initialize() { _sawmill = _logManager.GetSawmill("MobState"); _mobStateQuery = GetEntityQuery(); base.Initialize(); SubscribeEvents(); } #region Public API /// /// Check if a Mob is Alive /// /// Target Entity /// The MobState component owned by the target /// If the entity is alive public bool IsAlive(EntityUid target, MobStateComponent? component = null) { if (!_mobStateQuery.Resolve(target, ref component, false)) return false; return component.CurrentState == MobState.Alive; } /// /// Check if a Mob is Critical /// /// Target Entity /// The MobState component owned by the target /// If the entity is Critical public bool IsCritical(EntityUid target, MobStateComponent? component = null) { if (!_mobStateQuery.Resolve(target, ref component, false)) return false; return component.CurrentState == MobState.Critical; } /// /// Check if a Mob is Dead /// /// Target Entity /// The MobState component owned by the target /// If the entity is Dead public bool IsDead(EntityUid target, MobStateComponent? component = null) { if (!_mobStateQuery.Resolve(target, ref component, false)) return false; return component.CurrentState == MobState.Dead; } /// /// Check if a Mob is Critical or Dead /// /// Target Entity /// The MobState component owned by the target /// If the entity is Critical or Dead public bool IsIncapacitated(EntityUid target, MobStateComponent? component = null) { if (!_mobStateQuery.Resolve(target, ref component, false)) return false; return component.CurrentState is MobState.Critical or MobState.Dead; } /// /// Check if a Mob is in an Invalid state /// /// Target Entity /// The MobState component owned by the target /// If the entity is in an Invalid State public bool IsInvalidState(EntityUid target, MobStateComponent? component = null) { if (!_mobStateQuery.Resolve(target, ref component, false)) return false; return component.CurrentState is MobState.Invalid; } #endregion }