mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-21 07:28:31 +03:00
# Description This PR does *some* refactoring of MobState in preparation for adding a more in-depth SoftCritical system, mostly adding code support for the new threshold existing in the first place. Additionally, the MobStateComponent now also includes several DataFields that allow more precise fine tuning of what all mobs are allowed to do in each state, as opposed to hardcoding a majority of these interactions. The actual SoftCritical state isn't currently used by anything, and so is a largely vestigial feature. It would have to be added individually to mobs, such as the BaseMobSpeciesOrganic when the time comes to actually add this feature. # Changelog 🆑 - add: Lots of refactoring of the Mob State Systerm in preparation for implementing a much more detailed Soft Critical state. --------- Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> (cherry picked from commit 1e9cb1ce0bc70d76379e86ff311070c01cb9da06)
112 lines
3.9 KiB
C#
112 lines
3.9 KiB
C#
using Content.Shared.ActionBlocker;
|
|
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;
|
|
|
|
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 SharedPhysicsSystem _physics = 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!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
_sawmill = _logManager.GetSawmill("MobState");
|
|
base.Initialize();
|
|
SubscribeEvents();
|
|
}
|
|
|
|
#region Public API
|
|
|
|
/// <summary>
|
|
/// Check if a Mob is Alive
|
|
/// </summary>
|
|
/// <param name="target">Target Entity</param>
|
|
/// <param name="component">The MobState component owned by the target</param>
|
|
/// <returns>If the entity is alive</returns>
|
|
public bool IsAlive(EntityUid target, MobStateComponent? component = null)
|
|
{
|
|
if (!Resolve(target, ref component, false))
|
|
return false;
|
|
return component.CurrentState == MobState.Alive;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if a Mob is Critical
|
|
/// </summary>
|
|
/// <param name="target">Target Entity</param>
|
|
/// <param name="component">The MobState component owned by the target</param>
|
|
/// <returns>If the entity is Critical</returns>
|
|
public bool IsCritical(EntityUid target, MobStateComponent? component = null)
|
|
{
|
|
if (!Resolve(target, ref component, false))
|
|
return false;
|
|
return component.CurrentState == MobState.Critical;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if a Mob is Dead
|
|
/// </summary>
|
|
/// <param name="target">Target Entity</param>
|
|
/// <param name="component">The MobState component owned by the target</param>
|
|
/// <returns>If the entity is Dead</returns>
|
|
public bool IsDead(EntityUid target, MobStateComponent? component = null)
|
|
{
|
|
if (!Resolve(target, ref component, false))
|
|
return false;
|
|
|
|
return component.CurrentState == MobState.Dead;
|
|
}
|
|
|
|
public bool IsSoftCritical(EntityUid target, MobStateComponent? component = null)
|
|
{
|
|
if (!Resolve(target, ref component, false))
|
|
return false;
|
|
|
|
return component.CurrentState == MobState.SoftCritical;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if a Mob is Critical or Dead or SoftCrit
|
|
/// </summary>
|
|
/// <param name="target">Target Entity</param>
|
|
/// <param name="component">The MobState component owned by the target</param>
|
|
/// <returns>If the entity is Critical or Dead</returns>
|
|
public bool IsIncapacitated(EntityUid target, MobStateComponent? component = null)
|
|
{
|
|
if (!Resolve(target, ref component, false))
|
|
return false;
|
|
return component.CurrentState is MobState.Critical or MobState.Dead or MobState.SoftCritical;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if a Mob is in an Invalid state
|
|
/// </summary>
|
|
/// <param name="target">Target Entity</param>
|
|
/// <param name="component">The MobState component owned by the target</param>
|
|
/// <returns>If the entity is in an Invalid State</returns>
|
|
public bool IsInvalidState(EntityUid target, MobStateComponent? component = null)
|
|
{
|
|
if (!Resolve(target, ref component, false))
|
|
return false;
|
|
return component.CurrentState is MobState.Invalid;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Private Implementation
|
|
|
|
#endregion
|
|
}
|