Mobstate Refactor (#13389)

Refactors mobstate and moves mob health thresholds to their own component

Co-authored-by: DrSmugleaf <drsmugleaf@gmail.com>
This commit is contained in:
Jezithyr
2023-01-13 16:57:10 -08:00
committed by GitHub
parent 97e4c477bd
commit eeb5b17b34
148 changed files with 1517 additions and 1290 deletions

View File

@@ -1,10 +1,8 @@
using Content.Shared.Popups;
using Content.Shared.Damage;
using Content.Shared.MobState.Components;
using Content.Server.DoAfter;
using Content.Shared.Revenant;
using Robust.Shared.Random;
using Robust.Shared.Player;
using Robust.Shared.Map;
using Content.Shared.Tag;
using Content.Shared.Maps;
@@ -19,7 +17,6 @@ using Content.Server.Disease;
using Content.Server.Disease.Components;
using Content.Shared.Item;
using Content.Shared.Bed.Sleep;
using Content.Shared.MobState;
using System.Linq;
using Content.Server.Beam;
using Content.Server.Emag;
@@ -29,6 +26,9 @@ using Content.Server.Revenant.Components;
using Content.Server.Store.Components;
using Content.Shared.FixedPoint;
using Content.Shared.Humanoid;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Revenant.Components;
using Robust.Shared.Physics.Components;
using Robust.Shared.Utility;
@@ -43,6 +43,7 @@ public sealed partial class RevenantSystem
[Dependency] private readonly DiseaseSystem _disease = default!;
[Dependency] private readonly EmagSystem _emag = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
[Dependency] private readonly GhostSystem _ghost = default!;
[Dependency] private readonly TileSystem _tile = default!;
@@ -143,7 +144,7 @@ public sealed partial class RevenantSystem
return;
}
if (TryComp<MobStateComponent>(target, out var mobstate) && mobstate.CurrentState == DamageState.Alive && !HasComp<SleepingComponent>(target))
if (TryComp<MobStateComponent>(target, out var mobstate) && mobstate.CurrentState == MobState.Alive && !HasComp<SleepingComponent>(target))
{
_popup.PopupEntity(Loc.GetString("revenant-soul-too-powerful"), target, uid);
return;
@@ -197,8 +198,8 @@ public sealed partial class RevenantSystem
}
//KILL THEMMMM
var damage = _mobState.GetEarliestDeadState(mobstate, 0)?.threshold;
if (damage == null)
if (!_mobThresholdSystem.TryGetThresholdForState(args.Target, MobState.Dead, out var damage))
return;
DamageSpecifier dspec = new();
dspec.DamageDict.Add("Poison", damage.Value);