/// <returns>If the entity can be set to that MobState</returns>
public bool HasState(EntityUid entity, MobState mobState, MobStateComponent? component = null)
{
- return Resolve(entity, ref component, false) && component.AllowedStates.Contains(mobState);
+ return _mobStateQuery.Resolve(entity, ref component, false) &&
+ component.AllowedStates.Contains(mobState);
}
/// <summary>
/// <param name="origin">Entity that caused the state update (if applicable)</param>
public void UpdateMobState(EntityUid entity, MobStateComponent? component = null, EntityUid? origin = null)
{
- if (!Resolve(entity, ref component))
+ if (!_mobStateQuery.Resolve(entity, ref component))
return;
var ev = new UpdateMobStateEvent {Target = entity, Component = component, Origin = origin};
public void ChangeMobState(EntityUid entity, MobState mobState, MobStateComponent? component = null,
EntityUid? origin = null)
{
- if (!Resolve(entity, ref component))
+ if (!_mobStateQuery.Resolve(entity, ref component))
return;
ChangeState(entity, component, mobState, origin: origin);
using Content.Shared.Administration.Logs;
using Content.Shared.Mobs.Components;
using Content.Shared.Standing;
-using Robust.Shared.GameStates;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Timing;
[Dependency] private readonly IGameTiming _timing = default!;
private ISawmill _sawmill = default!;
+ private EntityQuery<MobStateComponent> _mobStateQuery;
+
public override void Initialize()
{
_sawmill = _logManager.GetSawmill("MobState");
+ _mobStateQuery = GetEntityQuery<MobStateComponent>();
base.Initialize();
SubscribeEvents();
}
/// <returns>If the entity is alive</returns>
public bool IsAlive(EntityUid target, MobStateComponent? component = null)
{
- if (!Resolve(target, ref component, false))
+ if (!_mobStateQuery.Resolve(target, ref component, false))
return false;
return component.CurrentState == MobState.Alive;
}
/// <returns>If the entity is Critical</returns>
public bool IsCritical(EntityUid target, MobStateComponent? component = null)
{
- if (!Resolve(target, ref component, false))
+ if (!_mobStateQuery.Resolve(target, ref component, false))
return false;
return component.CurrentState == MobState.Critical;
}
/// <returns>If the entity is Dead</returns>
public bool IsDead(EntityUid target, MobStateComponent? component = null)
{
- if (!Resolve(target, ref component, false))
+ if (!_mobStateQuery.Resolve(target, ref component, false))
return false;
return component.CurrentState == MobState.Dead;
}
/// <returns>If the entity is Critical or Dead</returns>
public bool IsIncapacitated(EntityUid target, MobStateComponent? component = null)
{
- if (!Resolve(target, ref component, false))
+ if (!_mobStateQuery.Resolve(target, ref component, false))
return false;
return component.CurrentState is MobState.Critical or MobState.Dead;
}
/// <returns>If the entity is in an Invalid State</returns>
public bool IsInvalidState(EntityUid target, MobStateComponent? component = null)
{
- if (!Resolve(target, ref component, false))
+ if (!_mobStateQuery.Resolve(target, ref component, false))
return false;
return component.CurrentState is MobState.Invalid;
}
#endregion
-
- #region Private Implementation
-
- #endregion
}