Damage masks (#9402)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System.Linq;
|
||||
using Content.Server.AI.Components;
|
||||
using Content.Server.MobState.States;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.MobState;
|
||||
using JetBrains.Annotations;
|
||||
@@ -121,11 +120,11 @@ namespace Content.Server.AI.EntitySystems
|
||||
{
|
||||
switch (args.CurrentMobState)
|
||||
{
|
||||
case NormalMobState:
|
||||
case DamageState.Alive:
|
||||
component.Awake = true;
|
||||
break;
|
||||
case CriticalMobState:
|
||||
case DeadMobState:
|
||||
case DamageState.Critical:
|
||||
case DamageState.Dead:
|
||||
component.Awake = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Server.Body.Components;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Disease.Components;
|
||||
using Content.Server.Disease;
|
||||
using Content.Server.MobState;
|
||||
using Content.Server.Nutrition.Components;
|
||||
using Content.Server.Nutrition.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
@@ -57,7 +58,6 @@ namespace Content.Server.Administration.Commands
|
||||
{
|
||||
var targetUid = target;
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
entMan.GetComponentOrNull<MobStateComponent>(targetUid)?.UpdateState(0);
|
||||
entMan.GetComponentOrNull<HungerComponent>(targetUid)?.ResetFood();
|
||||
|
||||
// TODO holy shit make this an event my man!
|
||||
|
||||
@@ -30,6 +30,7 @@ using Content.Shared.Disease;
|
||||
using Content.Shared.Electrocution;
|
||||
using Content.Shared.Interaction.Components;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.MobState;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
|
||||
@@ -7,6 +7,7 @@ using Content.Shared.Alert;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.MobState.EntitySystems;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Content.Shared.Standing;
|
||||
@@ -323,7 +324,8 @@ namespace Content.Server.Buckle.Components
|
||||
EntitySystem.Get<StandingStateSystem>().Stand(Owner);
|
||||
}
|
||||
|
||||
mobState?.CurrentState?.EnterState(Owner, _entMan);
|
||||
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<SharedMobStateSystem>()
|
||||
.EnterState(mobState, mobState?.CurrentState);
|
||||
|
||||
UpdateBuckleStatus();
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ using Content.Server.Popups;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.CharacterAppearance.Components;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.MobState;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.Tag;
|
||||
@@ -12,8 +11,6 @@ using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Player;
|
||||
using System.Threading;
|
||||
using Content.Shared.MobState.State;
|
||||
using Content.Shared.Doors.Components;
|
||||
|
||||
namespace Content.Server.Dragon
|
||||
{
|
||||
@@ -24,7 +21,6 @@ namespace Content.Server.Dragon
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly BloodstreamSystem _bloodstreamSystem = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -127,8 +123,8 @@ namespace Content.Server.Dragon
|
||||
{
|
||||
switch (targetState.CurrentState)
|
||||
{
|
||||
case SharedCriticalMobState:
|
||||
case SharedDeadMobState:
|
||||
case DamageState.Critical:
|
||||
case DamageState.Dead:
|
||||
component.CancelToken = new CancellationTokenSource();
|
||||
|
||||
_doAfterSystem.DoAfter(new DoAfterEventArgs(uid, component.DevourTime, component.CancelToken.Token, target)
|
||||
|
||||
@@ -4,7 +4,6 @@ using Content.Server.Ghost.Components;
|
||||
using Content.Server.Ghost.Roles.Components;
|
||||
using Content.Server.Ghost.Roles.UI;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.MobState.States;
|
||||
using Content.Server.Players;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Database;
|
||||
@@ -57,14 +56,14 @@ namespace Content.Server.Ghost.Roles
|
||||
{
|
||||
switch (args.CurrentMobState)
|
||||
{
|
||||
case NormalMobState:
|
||||
case DamageState.Alive:
|
||||
{
|
||||
if (!component.Taken)
|
||||
RegisterGhostRole(component);
|
||||
break;
|
||||
}
|
||||
case CriticalMobState:
|
||||
case DeadMobState:
|
||||
case DamageState.Critical:
|
||||
case DamageState.Dead:
|
||||
UnregisterGhostRole(component);
|
||||
break;
|
||||
}
|
||||
|
||||
16
Content.Server/MobState/MobStateSystem.Crit.cs
Normal file
16
Content.Server/MobState/MobStateSystem.Crit.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Content.Shared.StatusEffect;
|
||||
|
||||
namespace Content.Server.MobState;
|
||||
|
||||
public sealed partial class MobStateSystem
|
||||
{
|
||||
public override void EnterCritState(EntityUid uid)
|
||||
{
|
||||
base.EnterCritState(uid);
|
||||
|
||||
if (HasComp<StatusEffectsComponent>(uid))
|
||||
{
|
||||
Status.TryRemoveStatusEffect(uid, "Stun");
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Content.Server/MobState/MobStateSystem.Dead.cs
Normal file
19
Content.Server/MobState/MobStateSystem.Dead.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.StatusEffect;
|
||||
|
||||
namespace Content.Server.MobState;
|
||||
|
||||
public sealed partial class MobStateSystem
|
||||
{
|
||||
public override void EnterDeadState(EntityUid uid)
|
||||
{
|
||||
base.EnterDeadState(uid);
|
||||
|
||||
Alerts.ShowAlert(uid, AlertType.HumanDead);
|
||||
|
||||
if (HasComp<StatusEffectsComponent>(uid))
|
||||
{
|
||||
Status.TryRemoveStatusEffect(uid, "Stun");
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Content.Server/MobState/MobStateSystem.Norm.cs
Normal file
29
Content.Server/MobState/MobStateSystem.Norm.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.MobState.Components;
|
||||
|
||||
namespace Content.Server.MobState;
|
||||
|
||||
public sealed partial class MobStateSystem
|
||||
{
|
||||
public override void UpdateNormState(EntityUid entity, FixedPoint2 threshold)
|
||||
{
|
||||
base.UpdateNormState(entity, threshold);
|
||||
|
||||
if (!TryComp<DamageableComponent>(entity, out var damageable))
|
||||
return;
|
||||
|
||||
if (!TryComp<MobStateComponent>(entity, out var stateComponent))
|
||||
return;
|
||||
|
||||
short modifier = 0;
|
||||
|
||||
if (TryGetEarliestIncapacitatedState(stateComponent, threshold, out _, out var earliestThreshold) && damageable.TotalDamage != 0)
|
||||
{
|
||||
modifier = (short)(damageable.TotalDamage / (earliestThreshold / 5) + 1);
|
||||
}
|
||||
|
||||
Alerts.ShowAlert(entity, AlertType.HumanHealth, modifier);
|
||||
}
|
||||
}
|
||||
19
Content.Server/MobState/MobStateSystem.cs
Normal file
19
Content.Server/MobState/MobStateSystem.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.MobState.EntitySystems;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Server.MobState;
|
||||
|
||||
public sealed partial class MobStateSystem : SharedMobStateSystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<MobStateComponent, ComponentGetState>(OnMobGetState);
|
||||
}
|
||||
|
||||
private void OnMobGetState(EntityUid uid, MobStateComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new MobStateComponentState(component.CurrentThreshold);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using Content.Shared.MobState.State;
|
||||
using Content.Shared.StatusEffect;
|
||||
|
||||
namespace Content.Server.MobState.States
|
||||
{
|
||||
public sealed class CriticalMobState : SharedCriticalMobState
|
||||
{
|
||||
public override void EnterState(EntityUid uid, IEntityManager entityManager)
|
||||
{
|
||||
base.EnterState(uid, entityManager);
|
||||
|
||||
if (entityManager.TryGetComponent(uid, out StatusEffectsComponent? stun))
|
||||
{
|
||||
EntitySystem.Get<StatusEffectsSystem>().TryRemoveStatusEffect(uid, "Stun");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.MobState.State;
|
||||
using Content.Shared.StatusEffect;
|
||||
|
||||
namespace Content.Server.MobState.States
|
||||
{
|
||||
public sealed class DeadMobState : SharedDeadMobState
|
||||
{
|
||||
public override void EnterState(EntityUid uid, IEntityManager entityManager)
|
||||
{
|
||||
base.EnterState(uid, entityManager);
|
||||
|
||||
EntitySystem.Get<AlertsSystem>().ShowAlert(uid, AlertType.HumanDead);
|
||||
|
||||
if (entityManager.TryGetComponent(uid, out StatusEffectsComponent? stun))
|
||||
{
|
||||
EntitySystem.Get<StatusEffectsSystem>().TryRemoveStatusEffect(uid, "Stun");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.MobState.State;
|
||||
|
||||
namespace Content.Server.MobState.States
|
||||
{
|
||||
public sealed class NormalMobState : SharedNormalMobState
|
||||
{
|
||||
public override void UpdateState(EntityUid entity, FixedPoint2 threshold, IEntityManager entityManager)
|
||||
{
|
||||
base.UpdateState(entity, threshold, entityManager);
|
||||
|
||||
if (!entityManager.TryGetComponent(entity, out DamageableComponent? damageable))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.TryGetComponent(entity, out MobStateComponent? stateComponent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
short modifier = 0;
|
||||
|
||||
if (stateComponent.TryGetEarliestIncapacitatedState(threshold, out _, out var earliestThreshold) && damageable.TotalDamage != 0)
|
||||
{
|
||||
modifier = (short)(damageable.TotalDamage / (earliestThreshold / 5) + 1);
|
||||
}
|
||||
EntitySystem.Get<AlertsSystem>().ShowAlert(entity, AlertType.HumanHealth, modifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user