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

@@ -54,7 +54,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{
if (damageVisComp.Thresholds.Count < 1)
{
Logger.ErrorS(SawmillName, $"Thresholds were invalid for entity {entity}. Thresholds: {damageVisComp.Thresholds}");
Logger.ErrorS(SawmillName, $"ThresholdsLookup were invalid for entity {entity}. ThresholdsLookup: {damageVisComp.Thresholds}");
damageVisComp.Valid = false;
return;
}
@@ -144,7 +144,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
if (damageVisComp.Thresholds[0] != 0)
{
Logger.ErrorS(SawmillName, $"Thresholds were invalid for entity {entity}. Thresholds: {damageVisComp.Thresholds}");
Logger.ErrorS(SawmillName, $"ThresholdsLookup were invalid for entity {entity}. ThresholdsLookup: {damageVisComp.Thresholds}");
damageVisComp.Valid = false;
return;
}

View File

@@ -1,8 +1,8 @@
using Content.Shared.MobState;
using Content.Shared.Mobs;
using Robust.Client.GameObjects;
using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
namespace Content.Client.MobState;
namespace Content.Client.DamageState;
public sealed class DamageStateVisualizerSystem : VisualizerSystem<DamageStateVisualsComponent>
{
@@ -10,7 +10,7 @@ public sealed class DamageStateVisualizerSystem : VisualizerSystem<DamageStateVi
{
var sprite = args.Sprite;
if (sprite == null || !args.Component.TryGetData(DamageStateVisuals.State, out DamageState data))
if (sprite == null || !args.Component.TryGetData(MobStateVisuals.State, out MobState data))
{
return;
}
@@ -24,8 +24,8 @@ public sealed class DamageStateVisualizerSystem : VisualizerSystem<DamageStateVi
{
sprite.NoRotation = data switch
{
DamageState.Critical => false,
DamageState.Dead => false,
MobState.Critical => false,
MobState.Dead => false,
_ => true
};
}
@@ -48,7 +48,7 @@ public sealed class DamageStateVisualizerSystem : VisualizerSystem<DamageStateVi
}
// So they don't draw over mobs anymore
if (data == DamageState.Dead)
if (data == MobState.Dead)
{
if (sprite.DrawDepth > (int) DrawDepth.FloorObjects)
{

View File

@@ -1,13 +1,13 @@
using Content.Shared.MobState;
using Content.Shared.Mobs;
namespace Content.Client.MobState;
namespace Content.Client.DamageState;
[RegisterComponent]
public sealed class DamageStateVisualsComponent : Component
{
public int? OriginalDrawDepth;
[DataField("states")] public Dictionary<DamageState, Dictionary<DamageStateVisualLayers, string>> States = new();
[DataField("states")] public Dictionary<MobState, Dictionary<DamageStateVisualLayers, string>> States = new();
/// <summary>
/// Should noRot be turned off when crit / dead.

View File

@@ -2,7 +2,7 @@ using System.Collections.Generic;
using Content.Client.HealthOverlay.UI;
using Content.Shared.Damage;
using Content.Shared.GameTicking;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;

View File

@@ -1,9 +1,10 @@
using Content.Client.IoC;
using Content.Client.MobState;
using Content.Client.Resources;
using Content.Shared.Damage;
using Content.Shared.FixedPoint;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;
@@ -84,11 +85,10 @@ namespace Content.Client.HealthOverlay.UI
}
var mobStateSystem = _entities.EntitySysManager.GetEntitySystem<MobStateSystem>();
FixedPoint2 threshold;
var mobThresholdSystem = _entities.EntitySysManager.GetEntitySystem<MobThresholdSystem>();
if (mobStateSystem.IsAlive(mobState.Owner, mobState))
{
if (!mobStateSystem.TryGetEarliestCriticalState(mobState, damageable.TotalDamage, out _, out threshold))
if (!mobThresholdSystem.TryGetThresholdForState(Entity,MobState.Critical, out var threshold))
{
CritBar.Visible = false;
HealthBar.Visible = false;
@@ -97,7 +97,7 @@ namespace Content.Client.HealthOverlay.UI
CritBar.Ratio = 1;
CritBar.Visible = true;
HealthBar.Ratio = 1 - (damageable.TotalDamage / threshold).Float();
HealthBar.Ratio = 1 - ((FixedPoint2)(damageable.TotalDamage / threshold)).Float();
HealthBar.Visible = true;
}
else if (mobStateSystem.IsCritical(mobState.Owner, mobState))
@@ -105,8 +105,8 @@ namespace Content.Client.HealthOverlay.UI
HealthBar.Ratio = 0;
HealthBar.Visible = false;
if (!mobStateSystem.TryGetPreviousCriticalState(mobState, damageable.TotalDamage, out _, out var critThreshold) ||
!mobStateSystem.TryGetEarliestDeadState(mobState, damageable.TotalDamage, out _, out var deadThreshold))
if (!mobThresholdSystem.TryGetThresholdForState(Entity, MobState.Critical, out var critThreshold) ||
!mobThresholdSystem.TryGetThresholdForState(Entity, MobState.Dead, out var deadThreshold))
{
CritBar.Visible = false;
return;
@@ -115,7 +115,7 @@ namespace Content.Client.HealthOverlay.UI
CritBar.Visible = true;
CritBar.Ratio = 1 -
((damageable.TotalDamage - critThreshold) /
(deadThreshold - critThreshold)).Float();
(deadThreshold - critThreshold)).Value.Float();
}
else if (mobStateSystem.IsDead(mobState.Owner, mobState))
{

View File

@@ -1,146 +0,0 @@
using Content.Shared.Damage;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction.Events;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.MobState.EntitySystems;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.GameStates;
namespace Content.Client.MobState;
public sealed partial class MobStateSystem : SharedMobStateSystem
{
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
private Overlays.DamageOverlay _overlay = default!;
public override void Initialize()
{
base.Initialize();
_overlay = new Overlays.DamageOverlay();
_overlayManager.AddOverlay(_overlay);
SubscribeLocalEvent<PlayerAttachedEvent>(OnPlayerAttach);
SubscribeLocalEvent<PlayerDetachedEvent>(OnPlayerDetach);
SubscribeLocalEvent<MobStateComponent, ComponentHandleState>(OnMobHandleState);
SubscribeLocalEvent<MobStateComponent, AttackAttemptEvent>(OnAttack);
}
private void OnAttack(EntityUid uid, MobStateComponent component, AttackAttemptEvent args)
{
if (IsIncapacitated(uid, component))
args.Cancel();
}
public override void Shutdown()
{
base.Shutdown();
_overlayManager.RemoveOverlay(_overlay);
}
private void OnMobHandleState(EntityUid uid, MobStateComponent component, ref ComponentHandleState args)
{
if (args.Current is not MobStateComponentState state) return;
if (component.CurrentThreshold == state.CurrentThreshold)
return;
if (state.CurrentThreshold == null)
{
RemoveState(component);
}
else
{
UpdateState(component, state.CurrentThreshold.Value);
}
}
private void OnPlayerAttach(PlayerAttachedEvent ev)
{
if (TryComp<MobStateComponent>(ev.Entity, out var mobState) && TryComp<DamageableComponent>(ev.Entity, out var damageable))
{
_overlay.DeadLevel = 0f;
SetLevel(mobState, damageable.TotalDamage);
}
else
{
ClearOverlay();
}
}
private void OnPlayerDetach(PlayerDetachedEvent ev)
{
ClearOverlay();
}
private void ClearOverlay()
{
_overlay.State = DamageState.Alive;
_overlay.BruteLevel = 0f;
_overlay.OxygenLevel = 0f;
_overlay.CritLevel = 0f;
}
protected override void UpdateState(MobStateComponent component, DamageState? state, FixedPoint2 threshold)
{
base.UpdateState(component, state, threshold);
SetLevel(component, threshold);
}
private void SetLevel(MobStateComponent stateComponent, FixedPoint2 threshold)
{
var uid = stateComponent.Owner;
if (_playerManager.LocalPlayer?.ControlledEntity != uid) return;
ClearOverlay();
if (!TryComp<DamageableComponent>(uid, out var damageable))
return;
switch (stateComponent.CurrentState)
{
case DamageState.Dead:
_overlay.State = DamageState.Dead;
return;
}
var bruteLevel = 0f;
var oxyLevel = 0f;
var critLevel = 0f;
if (TryGetEarliestIncapacitatedState(stateComponent, threshold, out _, out var earliestThreshold) && damageable.TotalDamage != 0)
{
if (damageable.DamagePerGroup.TryGetValue("Brute", out var bruteDamage))
{
bruteLevel = MathF.Min(1f, (bruteDamage / earliestThreshold).Float());
}
if (damageable.Damage.DamageDict.TryGetValue("Asphyxiation", out var oxyDamage))
{
oxyLevel = MathF.Min(1f, (oxyDamage / earliestThreshold).Float());
}
if (threshold >= earliestThreshold && TryGetEarliestDeadState(stateComponent, threshold, out _, out var earliestDeadHold))
{
critLevel = (float) Math.Clamp((damageable.TotalDamage - earliestThreshold).Double() / (earliestDeadHold - earliestThreshold).Double(), 0.1, 1);
}
}
// Don't show damage overlay if they're near enough to max.
if (bruteLevel < 0.05f)
{
bruteLevel = 0f;
}
_overlay.State = critLevel > 0f ? DamageState.Critical : DamageState.Alive;
_overlay.BruteLevel = bruteLevel;
_overlay.OxygenLevel = oxyLevel;
_overlay.CritLevel = critLevel;
}
}

View File

@@ -1,5 +1,5 @@
using Content.Client.Pointing.Components;
using Content.Shared.MobState.EntitySystems;
using Content.Shared.Mobs.Systems;
using Content.Shared.Pointing;
using Content.Shared.Verbs;
using Robust.Client.Animations;
@@ -12,7 +12,7 @@ namespace Content.Client.Pointing;
public sealed class PointingSystem : SharedPointingSystem
{
[Dependency] private readonly AnimationPlayerSystem _player = default!;
[Dependency] private readonly SharedMobStateSystem _mobState = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
private const string AnimationKey = "pointingarrow";

View File

@@ -0,0 +1,142 @@
using Content.Client.Alerts;
using Content.Client.Gameplay;
using Content.Shared.Damage;
using Content.Shared.FixedPoint;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
namespace Content.Client.UserInterface.Systems.DamageOverlays;
[UsedImplicitly]
public sealed class DamageOverlayUiController : UIController, IOnStateChanged<GameplayState>
{
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[UISystemDependency] private readonly ClientAlertsSystem _alertsSystem = default!;
[UISystemDependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
private Overlays.DamageOverlay _overlay = default!;
public override void Initialize()
{
_overlay = new Overlays.DamageOverlay();
SubscribeLocalEvent<PlayerAttachedEvent>(OnPlayerAttach);
SubscribeLocalEvent<PlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<MobStateChangedEvent>(OnMobStateChanged);
SubscribeLocalEvent<MobThresholdChecked>(OnThresholdCheck);
}
public void OnStateEntered(GameplayState state)
{
_overlayManager.AddOverlay(_overlay);
}
public void OnStateExited(GameplayState state)
{
_overlayManager.RemoveOverlay(_overlay);
}
private void OnPlayerAttach(PlayerAttachedEvent args)
{
ClearOverlay();
if (!EntityManager.TryGetComponent<MobStateComponent>(args.Entity, out var mobState))
return;
if (mobState.CurrentState != MobState.Dead)
UpdateOverlays(args.Entity, mobState);
_overlayManager.AddOverlay(_overlay);
}
private void OnPlayerDetached(PlayerDetachedEvent args)
{
_overlayManager.RemoveOverlay(_overlay);
ClearOverlay();
}
private void OnMobStateChanged(MobStateChangedEvent args)
{
if (args.Target != _playerManager.LocalPlayer?.ControlledEntity)
return;
UpdateOverlays(args.Target, args.Component);
}
private void OnThresholdCheck(ref MobThresholdChecked args)
{
if (args.Target != _playerManager.LocalPlayer?.ControlledEntity)
return;
UpdateOverlays(args.Target, args.MobState, args.Damageable, args.Threshold);
}
private void ClearOverlay()
{
_overlay.DeadLevel = 0f;
_overlay.CritLevel = 0f;
_overlay.BruteLevel = 0f;
_overlay.OxygenLevel = 0f;
}
//TODO: Jezi: adjust oxygen and hp overlays to use appropriate systems once bodysim is implemented
private void UpdateOverlays(EntityUid entity, MobStateComponent? mobState, DamageableComponent? damageable = null, MobThresholdsComponent? thresholds = null)
{
if (mobState == null && !EntityManager.TryGetComponent(entity, out mobState) ||
thresholds == null && !EntityManager.TryGetComponent(entity, out thresholds) ||
damageable == null && !EntityManager.TryGetComponent(entity, out damageable))
return;
if (!_mobThresholdSystem.TryGetIncapThreshold(entity, out var foundThreshold, thresholds))
return; //this entity cannot die or crit!!
var critThreshold = foundThreshold.Value;
_overlay.State = mobState.CurrentState;
switch (mobState.CurrentState)
{
case MobState.Alive:
{
if (damageable.DamagePerGroup.TryGetValue("Brute", out var bruteDamage))
{
_overlay.BruteLevel = FixedPoint2.Min(1f, bruteDamage / critThreshold).Float();
}
if (damageable.DamagePerGroup.TryGetValue("Airloss", out var oxyDamage))
{
_overlay.OxygenLevel = FixedPoint2.Min(1f, oxyDamage / critThreshold).Float();
}
if (_overlay.BruteLevel < 0.05f) // Don't show damage overlay if they're near enough to max.
{
_overlay.BruteLevel = 0;
}
_overlay.CritLevel = 0;
_overlay.DeadLevel = 0;
break;
}
case MobState.Critical:
{
if (!_mobThresholdSystem.TryGetDeadPercentage(entity,
FixedPoint2.Max(0.0, damageable.TotalDamage), out var critLevel))
return;
_overlay.CritLevel = critLevel.Value.Float();
_overlay.BruteLevel = 0;
_overlay.DeadLevel = 0;
break;
}
case MobState.Dead:
{
_overlay.BruteLevel = 0;
_overlay.CritLevel = 0;
break;
}
}
}
}

View File

@@ -1,4 +1,4 @@
using Content.Shared.MobState;
using Content.Shared.Mobs;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
@@ -6,7 +6,7 @@ using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
namespace Content.Client.MobState.Overlays;
namespace Content.Client.UserInterface.Systems.DamageOverlays.Overlays;
public sealed class DamageOverlay : Overlay
{
@@ -21,7 +21,7 @@ public sealed class DamageOverlay : Overlay
private readonly ShaderInstance _oxygenShader;
private readonly ShaderInstance _bruteShader;
public DamageState State = DamageState.Alive;
public MobState State = MobState.Alive;
/// <summary>
/// Handles the red pulsing overlay
@@ -79,7 +79,7 @@ public sealed class DamageOverlay : Overlay
var lastFrameTime = (float) _timing.FrameTime.TotalSeconds;
// If they just died then lerp out the white overlay.
if (State != DamageState.Dead)
if (State != MobState.Dead)
{
DeadLevel = 1f;
}
@@ -169,7 +169,7 @@ public sealed class DamageOverlay : Overlay
_oldBruteLevel = BruteLevel;
}
level = State != DamageState.Critical ? _oldOxygenLevel : 1f;
level = State != MobState.Critical ? _oldOxygenLevel : 1f;
if (level > 0f)
{
@@ -215,7 +215,7 @@ public sealed class DamageOverlay : Overlay
handle.DrawRect(viewport, Color.White);
}
level = State != DamageState.Dead ? _oldCritLevel : DeadLevel;
level = State != MobState.Dead ? _oldCritLevel : DeadLevel;
if (level > 0f)
{

View File

@@ -1,7 +1,7 @@
using Content.Client.CombatMode;
using Content.Client.Gameplay;
using Content.Client.Hands;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.StatusEffect;

View File

@@ -25,8 +25,9 @@ namespace Content.IntegrationTests.Tests.Body
- type: Body
prototype: Human
- type: MobState
thresholds:
0: Alive
allowedStates:
- Alive
- type: Damageable
- type: ThermalRegulator
metabolismHeat: 5000
radiatedHeat: 400

View File

@@ -3,7 +3,8 @@ using Content.Server.Administration.Commands;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
@@ -23,6 +24,7 @@ namespace Content.IntegrationTests.Tests.Commands
- type: Damageable
damageContainer: Biological
- type: MobState
- type: MobThresholds
thresholds:
0: Alive
100: Critical
@@ -37,7 +39,7 @@ namespace Content.IntegrationTests.Tests.Commands
var entManager = server.ResolveDependency<IEntityManager>();
var mapManager = server.ResolveDependency<IMapManager>();
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
var mobStateSystem = entManager.EntitySysManager.GetEntitySystem<Server.MobState.MobStateSystem>();
var mobStateSystem = entManager.EntitySysManager.GetEntitySystem<MobStateSystem>();
var damSystem = entManager.EntitySysManager.GetEntitySystem<DamageableSystem>();
await server.WaitAssertion(() =>

View File

@@ -133,7 +133,7 @@ namespace Content.IntegrationTests.Tests.Destructible
// Heal the entity for 40 damage, down to 60
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage*-4, true);
// Thresholds don't work backwards
// ThresholdsLookup don't work backwards
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
// Damage for 10, up to 70
@@ -145,7 +145,7 @@ namespace Content.IntegrationTests.Tests.Destructible
// Heal by 30, down to 40
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage*-3, true);
// Thresholds don't work backwards
// ThresholdsLookup don't work backwards
Assert.That(sTestThresholdListenerSystem.ThresholdsReached, Is.Empty);
// Damage up to 50 again

View File

@@ -79,6 +79,11 @@ namespace Content.IntegrationTests.Tests.Disposal
- type: Body
prototype: Human
- type: MobState
- type: MobThresholds
thresholds:
0: Alive
100: Critical
200: Dead
- type: Damageable
damageContainer: Biological
- type: Physics

View File

@@ -6,7 +6,7 @@ using Content.Shared.Alert;
using Content.Shared.Physics;
using Content.Shared.Doors.Components;
using Content.Shared.Maps;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Robust.Shared.Player;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;

View File

@@ -1,4 +1,3 @@
using System.Linq;
using System.Threading;
using Content.Server.Administration.Commands;
using Content.Server.Administration.Components;
@@ -6,7 +5,6 @@ using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Clothing.Components;
using Content.Server.Damage.Systems;
using Content.Server.Disease;
using Content.Server.Disease.Components;
@@ -35,8 +33,9 @@ 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.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Nutrition.Components;
@@ -50,7 +49,6 @@ using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Timer = Robust.Shared.Timing.Timer;
namespace Content.Server.Administration.Systems;
@@ -70,6 +68,8 @@ public sealed partial class AdminVerbSystem
[Dependency] private readonly GodmodeSystem _godmodeSystem = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly PolymorphableSystem _polymorphableSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly TabletopSystem _tabletopSystem = default!;
[Dependency] private readonly VomitSystem _vomitSystem = default!;
@@ -218,19 +218,16 @@ public sealed partial class AdminVerbSystem
Act = () =>
{
int damageToDeal;
var critState = mobState._highestToLowestStates.Where(x => x.Value == DamageState.Critical).FirstOrNull();
if (critState is null)
{
if (!_mobThresholdSystem.TryGetThresholdForState(args.Target, MobState.Critical, out var criticalThreshold)) {
// We can't crit them so try killing them.
var deadState = mobState._highestToLowestStates.Where(x => x.Value == DamageState.Dead).FirstOrNull();
if (deadState is null)
return; // whelp.
damageToDeal = deadState.Value.Key - (int) damageable.TotalDamage;
if (!_mobThresholdSystem.TryGetThresholdForState(args.Target, MobState.Dead,
out var deadThreshold))
return;// whelp.
damageToDeal = deadThreshold.Value.Int() - (int) damageable.TotalDamage;
}
else
{
damageToDeal = critState.Value.Key - (int) damageable.TotalDamage;
damageToDeal = criticalThreshold.Value.Int() - (int) damageable.TotalDamage;
}
if (damageToDeal <= 0)

View File

@@ -1,7 +1,7 @@
using Content.Server.Atmos.Components;
using Content.Shared.Atmos;
using Content.Shared.Audio;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Physics;
using Robust.Shared.Audio;
using Robust.Shared.Map;

View File

@@ -1,12 +1,12 @@
using Content.Shared.MobState;
using Content.Shared.Damage;
using Content.Shared.Atmos;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Temperature.Systems;
using Content.Server.Body.Components;
using Content.Shared.Examine;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Systems;
using Content.Shared.Rejuvenate;
using Content.Shared.MobState.EntitySystems;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.Physics.Components;
@@ -20,7 +20,7 @@ namespace Content.Server.Atmos.Miasma
[Dependency] private readonly TransformSystem _transformSystem = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly SharedMobStateSystem _mobState = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly MetaDataSystem _metaDataSystem = default!;
[Dependency] private readonly IGameTiming _timing = default!;

View File

@@ -2,7 +2,6 @@ using Content.Server.Actions;
using Content.Server.Bed.Components;
using Content.Server.Bed.Sleep;
using Content.Server.Body.Systems;
using Content.Server.MobState;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.Actions.ActionTypes;
@@ -13,6 +12,7 @@ using Content.Shared.Buckle.Components;
using Content.Shared.Damage;
using Content.Shared.Emag.Systems;
using Content.Server.Construction;
using Content.Shared.Mobs.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;

View File

@@ -8,8 +8,8 @@ using Content.Shared.Damage;
using Content.Shared.Examine;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Slippery;
using Content.Shared.Stunnable;
using Content.Shared.Verbs;
@@ -112,14 +112,14 @@ namespace Content.Server.Bed.Sleep
/// </summary>
private void OnMobStateChanged(EntityUid uid, SleepingComponent component, MobStateChangedEvent args)
{
if (args.CurrentMobState == DamageState.Dead)
if (args.NewMobState == MobState.Dead)
{
RemComp<SpamEmitSoundComponent>(uid);
RemComp<SleepingComponent>(uid);
return;
}
if (TryComp<SpamEmitSoundComponent>(uid, out var spam))
spam.Enabled = (args.CurrentMobState == DamageState.Alive) ? true : false;
spam.Enabled = (args.NewMobState == MobState.Alive) ? true : false;
}
private void AddWakeVerb(EntityUid uid, SleepingComponent component, GetVerbsEvent<AlternativeVerb> args)

View File

@@ -1,21 +1,21 @@
using Content.Shared.Interaction;
using Content.Shared.Inventory;
using Content.Shared.MobState;
using Content.Shared.Damage;
using Content.Shared.Verbs;
using Content.Shared.ActionBlocker;
using Content.Shared.Actions;
using Content.Server.Bible.Components;
using Content.Server.MobState;
using Content.Server.Popups;
using Content.Server.Ghost.Roles.Components;
using Content.Server.Ghost.Roles.Events;
using Content.Server.Popups;
using Content.Shared.ActionBlocker;
using Content.Shared.Actions;
using Content.Shared.Damage;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Inventory;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Systems;
using Content.Shared.Popups;
using Content.Shared.Timing;
using Robust.Shared.Random;
using Content.Shared.Verbs;
using Robust.Shared.Audio;
using Robust.Shared.Player;
using Robust.Shared.Random;
namespace Content.Server.Bible
{
@@ -192,7 +192,7 @@ namespace Content.Server.Bible
/// </summary>
private void OnFamiliarDeath(EntityUid uid, FamiliarComponent component, MobStateChangedEvent args)
{
if (args.CurrentMobState != DamageState.Dead || component.Source == null)
if (args.NewMobState != MobState.Dead || component.Source == null)
return;
var source = component.Source;

View File

@@ -3,7 +3,6 @@ using Content.Server.Chemistry.EntitySystems;
using Content.Server.Chemistry.ReactionEffects;
using Content.Server.Fluids.EntitySystems;
using Content.Server.HealthExaminable;
using Content.Server.MobState;
using Content.Server.Popups;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction;
@@ -11,9 +10,10 @@ using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using Content.Shared.IdentityManagement;
using Content.Shared.MobState.Components;
using Content.Shared.Popups;
using Content.Shared.Drunk;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Rejuvenate;
using Robust.Shared.Audio;
using Robust.Shared.Player;

View File

@@ -5,13 +5,13 @@ using Content.Server.GameTicking;
using Content.Server.Humanoid;
using Content.Server.Kitchen.Components;
using Content.Server.Mind.Components;
using Content.Server.MobState;
using Content.Shared.Body.Components;
using Content.Shared.Body.Part;
using Content.Shared.Body.Prototypes;
using Content.Shared.Body.Systems;
using Content.Shared.Coordinates;
using Content.Shared.Humanoid;
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Events;
using Content.Shared.Random.Helpers;
using Robust.Shared.Audio;

View File

@@ -2,14 +2,14 @@ using System.Linq;
using Content.Server.Body.Components;
using Content.Server.Chemistry.Components.SolutionManager;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.MobState;
using Content.Shared.Administration.Logs;
using Content.Shared.Body.Organ;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Database;
using Content.Shared.FixedPoint;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;

View File

@@ -8,7 +8,7 @@ using Content.Shared.Atmos;
using Content.Shared.Body.Components;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.MobState.EntitySystems;
using Content.Shared.Mobs.Systems;
using JetBrains.Annotations;
using Robust.Shared.Player;
using Robust.Shared.Timing;
@@ -26,7 +26,7 @@ namespace Content.Server.Body.Systems
[Dependency] private readonly DamageableSystem _damageableSys = default!;
[Dependency] private readonly LungSystem _lungSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedMobStateSystem _mobState = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
public override void Initialize()
{

View File

@@ -9,7 +9,7 @@ using Content.Shared.DragDrop;
using Content.Shared.Hands.Components;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Pulling.Components;
using Content.Shared.Stunnable;
using Content.Shared.Vehicle.Components;
@@ -360,8 +360,10 @@ public sealed partial class BuckleSystem
_standing.Stand(buckleId);
}
_mobState.EnterState(mobState, mobState?.CurrentState);
if (_mobState.IsIncapacitated(buckleId, mobState))
{
_standing.Down(buckleId);
}
// Sync StrapComponent data
_appearance.SetData(oldBuckledTo.Owner, StrapVisuals.State, false);
if (oldBuckledTo.BuckledEntities.Remove(buckleId))

View File

@@ -4,7 +4,7 @@ using Content.Server.Pulling;
using Content.Shared.ActionBlocker;
using Content.Shared.Alert;
using Content.Shared.Buckle;
using Content.Shared.MobState.EntitySystems;
using Content.Shared.Mobs.Systems;
using JetBrains.Annotations;
using Robust.Server.Containers;
using Robust.Server.GameObjects;
@@ -23,7 +23,7 @@ public sealed partial class BuckleSystem : SharedBuckleSystem
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly ContainerSystem _containers = default!;
[Dependency] private readonly InteractionSystem _interactions = default!;
[Dependency] private readonly SharedMobStateSystem _mobState = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly PopupSystem _popups = default!;
[Dependency] private readonly PullingSystem _pulling = default!;
[Dependency] private readonly Shared.Standing.StandingStateSystem _standing = default!;

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Content.Server.Cargo.Components;
using Content.Server.Labels.Components;
using Content.Server.MobState;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Events;
using Content.Server.UserInterface;
@@ -16,7 +15,8 @@ using Content.Shared.Cargo.Prototypes;
using Content.Shared.CCVar;
using Content.Shared.Dataset;
using Content.Shared.GameTicking;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Robust.Server.GameObjects;
using Robust.Server.Maps;
using Robust.Shared.Audio;

View File

@@ -3,13 +3,13 @@ using Content.Server.Administration;
using Content.Server.Body.Systems;
using Content.Server.Cargo.Components;
using Content.Server.Chemistry.Components.SolutionManager;
using Content.Server.MobState;
using Content.Server.Stack;
using Content.Shared.Administration;
using Content.Shared.Body.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Materials;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Stacks;
using Robust.Shared.Console;
using Robust.Shared.Containers;

View File

@@ -1,13 +1,13 @@
using Content.Server.Administration.Logs;
using Content.Server.Hands.Components;
using Content.Server.MobState;
using Content.Server.Popups;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Database;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Popups;
using Content.Shared.Tag;
using Robust.Shared.Prototypes;

View File

@@ -5,7 +5,6 @@ using Content.Server.Administration.Managers;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking;
using Content.Server.Ghost.Components;
using Content.Server.MobState;
using Content.Server.Players;
using Content.Server.Popups;
using Content.Server.Station.Components;
@@ -16,6 +15,7 @@ using Content.Shared.Chat;
using Content.Shared.Database;
using Content.Shared.IdentityManagement;
using Content.Shared.Inventory;
using Content.Shared.Mobs.Systems;
using Content.Shared.Radio;
using Robust.Server.GameObjects;
using Robust.Server.Player;

View File

@@ -11,10 +11,10 @@ using Content.Shared.Hands;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.MobState.Components;
using Robust.Shared.GameStates;
using Robust.Shared.Player;
using System.Threading;
using Content.Shared.Mobs.Components;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
using Content.Shared.Popups;

View File

@@ -5,7 +5,7 @@ using Content.Server.Interaction;
using Content.Server.Popups;
using Content.Shared.CombatMode;
using Content.Shared.Chemistry;
using Content.Shared.MobState.EntitySystems;
using Content.Shared.Mobs.Systems;
namespace Content.Server.Chemistry.EntitySystems;
@@ -19,7 +19,7 @@ public sealed partial class ChemistrySystem : EntitySystem
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly ReactiveSystem _reactiveSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedMobStateSystem _mobState = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedCombatModeSystem _combat = default!;
[Dependency] private readonly SolutionContainerSystem _solutions = default!;

View File

@@ -9,7 +9,7 @@ using Content.Shared.FixedPoint;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Player;

View File

@@ -8,8 +8,6 @@ using Content.Server.Mind.Components;
using Content.Server.MachineLinking.System;
using Content.Server.MachineLinking.Events;
using Content.Server.UserInterface;
using Content.Server.MobState;
using Content.Shared.MobState.Components;
using Content.Server.Power.EntitySystems;
using Robust.Server.GameObjects;
using Robust.Server.Player;
@@ -17,6 +15,8 @@ using Content.Shared.Cloning.CloningConsole;
using Content.Shared.Cloning;
using Content.Shared.MachineLinking.Events;
using Content.Shared.IdentityManagement;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
namespace Content.Server.Cloning
{

View File

@@ -12,7 +12,6 @@ using Content.Server.EUI;
using Content.Server.Humanoid;
using Content.Server.MachineLinking.System;
using Content.Server.MachineLinking.Events;
using Content.Server.MobState;
using Content.Shared.Chemistry.Components;
using Content.Server.Fluids.EntitySystems;
using Content.Server.Chat.Systems;
@@ -22,6 +21,7 @@ using Content.Server.Stack;
using Content.Server.Jobs;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Mobs.Systems;
using Robust.Server.GameObjects;
using Robust.Server.Containers;
using Robust.Server.Player;

View File

@@ -1,8 +1,7 @@
using Content.Shared.Damage;
using Content.Shared.MobState.EntitySystems;
using Content.Shared.MobState.Components;
using Content.Server.Damage.Components;
using Content.Shared.Damage.Components;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Systems;
using Robust.Shared.Physics.Components;
namespace Content.Server.Contests
@@ -16,10 +15,11 @@ namespace Content.Server.Contests
/// <1 = Advantage to target
/// Roller should be the entity with an advantage from being bigger/healthier/more skilled, etc.
/// </summary>
///
public sealed class ContestsSystem : EntitySystem
{
[Dependency] private readonly SharedMobStateSystem _mobStateSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
/// <summary>
/// Returns the roller's mass divided by the target's.
/// </summary>
@@ -46,20 +46,37 @@ namespace Content.Server.Contests
return 1f;
// First, we'll see what health they go into crit at.
float rollerThreshold = 100f;
float targetThreshold = 100f;
if (TryComp<MobStateComponent>(roller, out var rollerState) &&
_mobStateSystem.TryGetEarliestIncapacitatedState(rollerState, 10000, out _, out var rollerCritThreshold))
rollerThreshold = (float) rollerCritThreshold;
if (TryComp<MobStateComponent>(target, out var targetState) &&
_mobStateSystem.TryGetEarliestIncapacitatedState(targetState, 10000, out _, out var targetCritThreshold))
targetThreshold = (float) targetCritThreshold;
//TODO: refactor this entire system.... Why does this exist, this shouldn't be calculated off health
var rollerThreshold = 100f;
if (!_mobThresholdSystem.TryGetThresholdForState(roller, MobState.Critical, out var rollerCritThreshold))
{
if (_mobThresholdSystem.TryGetThresholdForState(roller, MobState.Critical,
out var rollerdeadThreshold))
{
rollerThreshold = rollerdeadThreshold.Value.Float();
}
}
else
{
rollerThreshold = rollerCritThreshold.Value.Float();
}
var targetThreshold = 100f;
if (!_mobThresholdSystem.TryGetThresholdForState(roller, MobState.Critical, out var targetCritThreshold))
{
if (_mobThresholdSystem.TryGetThresholdForState(roller, MobState.Critical,
out var targetdeadThreshold))
{
targetThreshold = targetdeadThreshold.Value.Float();
}
}
else
{
targetThreshold = targetCritThreshold.Value.Float();
}
// Next, we'll see how their damage compares
float rollerDamageScore = (float) rollerDamage.TotalDamage / rollerThreshold;
float targetDamageScore = (float) targetDamage.TotalDamage / targetThreshold;
var rollerDamageScore = (float) rollerDamage.TotalDamage / rollerThreshold;
var targetDamageScore = (float) targetDamage.TotalDamage / targetThreshold;
return DamageThresholdConverter(rollerDamageScore) / DamageThresholdConverter(targetDamageScore);
}

View File

@@ -13,7 +13,7 @@ using Content.Shared.Interaction;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Content.Server.Hands.Systems;
using Content.Shared.MobState.EntitySystems;
using Content.Shared.Mobs.Systems;
namespace Content.Server.Cuffs
{
@@ -23,7 +23,7 @@ namespace Content.Server.Cuffs
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
[Dependency] private readonly HandVirtualItemSystem _virtualSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedMobStateSystem _mobState = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
public override void Initialize()

View File

@@ -2,7 +2,7 @@ using Content.Server.Administration.Logs;
using Content.Server.Damage.Components;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Throwing;
namespace Content.Server.Damage.Systems

View File

@@ -3,7 +3,6 @@ using Content.Server.Body.Systems;
using Content.Server.Chat.Systems;
using Content.Server.Disease.Components;
using Content.Server.DoAfter;
using Content.Server.MobState;
using Content.Server.Nutrition.EntitySystems;
using Content.Server.Popups;
using Content.Shared.Clothing.Components;
@@ -16,7 +15,8 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Rejuvenate;
using Robust.Shared.Audio;
using Robust.Server.GameObjects;

View File

@@ -2,7 +2,7 @@ using System.Linq;
using System.Threading.Tasks;
using Content.Shared.Damage;
using Content.Shared.DoAfter;
using Content.Shared.MobState;
using Content.Shared.Mobs;
using JetBrains.Annotations;
using Robust.Shared.GameStates;
@@ -90,7 +90,7 @@ namespace Content.Server.DoAfter
private void OnStateChanged(EntityUid uid, DoAfterComponent component, MobStateChangedEvent args)
{
if (!args.CurrentMobState.IsIncapacitated())
if (args.NewMobState == MobState.Alive)
return;
foreach (var (doAfter, _) in component.DoAfters)

View File

@@ -1,3 +1,4 @@
using Content.Server.Atmos.Monitor.Components;
using Content.Shared.Doors.Components;
namespace Content.Server.Doors.Components

View File

@@ -3,14 +3,13 @@ using Content.Server.DoAfter;
using Content.Server.Popups;
using Content.Shared.Actions;
using Content.Shared.Chemistry.Components;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Robust.Shared.Containers;
using Robust.Shared.Player;
using System.Threading;
using Content.Server.Chat.Systems;
using Content.Server.GameTicking;
using Content.Server.GameTicking.Rules;
using Content.Server.Humanoid;
using Content.Server.NPC;
using Content.Shared.Damage;
using Content.Shared.Dragon;
@@ -22,6 +21,8 @@ using Robust.Shared.Map;
using Robust.Shared.Random;
using Content.Server.NPC.Systems;
using Content.Shared.Humanoid;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
namespace Content.Server.Dragon
{
@@ -275,7 +276,7 @@ namespace Content.Server.Dragon
{
//Empties the stomach upon death
//TODO: Do this when the dragon gets butchered instead
if (args.CurrentMobState == DamageState.Dead)
if (args.NewMobState == MobState.Dead)
{
if (component.SoundDeath != null)
_audioSystem.PlayPvs(component.SoundDeath, uid, component.SoundDeath.Params);
@@ -365,8 +366,8 @@ namespace Content.Server.Dragon
{
switch (targetState.CurrentState)
{
case DamageState.Critical:
case DamageState.Dead:
case MobState.Critical:
case MobState.Dead:
component.CancelToken = new CancellationTokenSource();
_doAfterSystem.DoAfter(new DoAfterEventArgs(uid, component.DevourTime, component.CancelToken.Token, target)

View File

@@ -3,7 +3,6 @@ using Content.Server.Drone.Components;
using Content.Server.Ghost.Components;
using Content.Server.Ghost.Roles.Components;
using Content.Server.Mind.Components;
using Content.Server.MobState;
using Content.Server.Popups;
using Content.Server.Tools.Innate;
using Content.Server.UserInterface;
@@ -15,8 +14,9 @@ using Content.Shared.IdentityManagement;
using Content.Shared.Interaction.Components;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Popups;
using Content.Shared.Tag;
using Content.Shared.Throwing;
@@ -82,7 +82,7 @@ namespace Content.Server.Drone
private void OnMobStateChanged(EntityUid uid, DroneComponent drone, MobStateChangedEvent args)
{
if (args.CurrentMobState == DamageState.Dead)
if (args.NewMobState == MobState.Dead)
{
if (TryComp<InnateToolComponent>(uid, out var innate))
_innateToolSystem.Cleanup(uid, innate);

View File

@@ -1,4 +1,3 @@
using Content.Shared.MobState;
using Robust.Shared.Audio;
namespace Content.Server.Explosion.Components

View File

@@ -1,4 +1,4 @@
using Content.Shared.MobState;
using Content.Shared.Mobs;
namespace Content.Server.Explosion.Components;
@@ -13,7 +13,7 @@ public sealed class TriggerOnMobstateChangeComponent : Component
/// </summary>
[ViewVariables]
[DataField("mobState", required: true)]
public DamageState MobState = DamageState.Alive;
public MobState MobState = MobState.Alive;
/// <summary>
/// If true, prevents suicide attempts for the trigger to prevent cheese.

View File

@@ -1,6 +1,6 @@
using Content.Server.Explosion.Components;
using Content.Shared.Interaction.Events;
using Content.Shared.MobState;
using Content.Shared.Mobs;
using Robust.Shared.Player;
namespace Content.Server.Explosion.EntitySystems;
@@ -15,7 +15,7 @@ public sealed partial class TriggerSystem
private void OnMobStateChanged(EntityUid uid, TriggerOnMobstateChangeComponent component, MobStateChangedEvent args)
{
if (component.MobState < args.CurrentMobState)
if (component.MobState < args.NewMobState)
return;
//This chains Mobstate Changed triggers with OnUseTimerTrigger if they have it

View File

@@ -3,12 +3,12 @@ using System.Linq;
using Content.Server.GameTicking.Presets;
using Content.Server.GameTicking.Rules;
using Content.Server.Ghost.Components;
using Content.Server.MobState;
using Content.Shared.CCVar;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Database;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Robust.Server.Player;
namespace Content.Server.GameTicking
@@ -17,6 +17,8 @@ namespace Content.Server.GameTicking
{
public const float PresetFailedCooldownIncrease = 30f;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
public GamePresetPrototype? Preset { get; private set; }
private bool StartPreset(IPlayerSession[] origReadyPlayers, bool force)
@@ -193,7 +195,7 @@ namespace Content.Server.GameTicking
if (canReturnGlobal && TryComp(playerEntity, out MobStateComponent? mobState))
{
if (_mobState.IsCritical(playerEntity.Value, mobState))
if (_mobStateSystem.IsCritical(playerEntity.Value, mobState))
{
canReturn = true;

View File

@@ -13,7 +13,7 @@ using Content.Server.Station.Systems;
using Content.Shared.Chat;
using Content.Shared.Damage;
using Content.Shared.GameTicking;
using Content.Shared.MobState.EntitySystems;
using Content.Shared.Mobs.Systems;
using Content.Shared.Roles;
using Robust.Server;
using Robust.Server.GameObjects;
@@ -35,7 +35,7 @@ namespace Content.Server.GameTicking
public sealed partial class GameTicker : SharedGameTicker
{
[Dependency] private readonly MapLoaderSystem _map = default!;
[Dependency] private readonly SharedMobStateSystem _mobState = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[ViewVariables] private bool _initialized;

View File

@@ -1,9 +1,9 @@
using Content.Server.Chat.Managers;
using Content.Server.GameTicking.Rules.Configurations;
using Content.Server.MobState;
using Content.Shared.CCVar;
using Content.Shared.Damage;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;

View File

@@ -19,8 +19,8 @@ using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Server.Traitor;
using Content.Shared.Dataset;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Nuke;
using Content.Shared.Preferences;
using Content.Shared.Roles;
@@ -310,7 +310,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
var allAlive = true;
foreach (var (_, state) in EntityQuery<NukeOperativeComponent, MobStateComponent>())
{
if (state.CurrentState is DamageState.Alive)
if (state.CurrentState is MobState.Alive)
{
continue;
}
@@ -415,7 +415,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
.Where(ent =>
ent.Item3.MapID == shuttleMapId
|| ent.Item3.MapID == targetStationMap)
.Any(ent => ent.Item2.CurrentState == DamageState.Alive && ent.Item1.Running);
.Any(ent => ent.Item2.CurrentState == MobState.Alive && ent.Item1.Running);
if (operativesAlive)
return; // There are living operatives than can access the shuttle, or are still on the station's map.
@@ -446,7 +446,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
private void OnMobStateChanged(EntityUid uid, NukeOperativeComponent component, MobStateChangedEvent ev)
{
if(ev.CurrentMobState == DamageState.Dead)
if(ev.NewMobState == MobState.Dead)
CheckRoundShouldEnd();
}

View File

@@ -2,7 +2,6 @@ using System.Linq;
using System.Threading;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking.Rules.Configurations;
using Content.Server.MobState;
using Content.Server.Players;
using Content.Server.Roles;
using Content.Server.Station.Components;
@@ -14,7 +13,8 @@ using Content.Shared.Doors.Systems;
using Content.Shared.EntityList;
using Content.Shared.GameTicking;
using Content.Shared.Maps;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Roles;
using Content.Shared.Suspicion;
using Robust.Server.GameObjects;

View File

@@ -3,7 +3,6 @@ using Content.Server.Atmos.EntitySystems;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking.Rules.Configurations;
using Content.Server.Hands.Components;
using Content.Server.MobState;
using Content.Server.PDA;
using Content.Server.Players;
using Content.Server.Spawners.Components;
@@ -16,7 +15,8 @@ using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using Content.Shared.Inventory;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.PDA;
using Content.Shared.Roles;
using Robust.Server.GameObjects;

View File

@@ -5,10 +5,10 @@ using Content.Server.Players;
using Content.Server.Roles;
using Content.Server.Traitor;
using Content.Server.Traitor.Uplink;
using Content.Server.MobState;
using Content.Server.NPC.Systems;
using Content.Shared.CCVar;
using Content.Shared.Dataset;
using Content.Shared.Mobs.Systems;
using Content.Shared.Roles;
using Robust.Server.Player;
using Robust.Shared.Audio;

View File

@@ -3,8 +3,8 @@ using Content.Server.Actions;
using Content.Server.Chat.Managers;
using Content.Server.Disease;
using Content.Server.Disease.Components;
using Content.Server.Humanoid;
using Content.Server.Mind.Components;
using Content.Server.MobState;
using Content.Server.Players;
using Content.Server.Popups;
using Content.Server.Preferences.Managers;
@@ -14,8 +14,9 @@ using Content.Server.Zombies;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.CCVar;
using Content.Shared.Humanoid;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.Zombies;
@@ -129,7 +130,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem
{
if (!RuleAdded)
return;
CheckRoundEnd(ev.Entity);
CheckRoundEnd(ev.Target);
}
private void OnEntityZombified(EntityZombifiedEvent ev)

View File

@@ -3,7 +3,6 @@ using Content.Server.GameTicking;
using Content.Server.Ghost.Components;
using Content.Server.Mind;
using Content.Server.Mind.Components;
using Content.Server.MobState;
using Content.Server.Players;
using Content.Server.Storage.Components;
using Content.Server.Visible;
@@ -13,7 +12,8 @@ using Content.Shared.Administration;
using Content.Shared.Examine;
using Content.Shared.Follower;
using Content.Shared.Ghost;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Events;
using JetBrains.Annotations;
using Robust.Server.GameObjects;

View File

@@ -11,7 +11,7 @@ using Content.Shared.Follower;
using Content.Shared.GameTicking;
using Content.Shared.Ghost;
using Content.Shared.Ghost.Roles;
using Content.Shared.MobState;
using Content.Shared.Mobs;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Server.Player;
@@ -56,16 +56,16 @@ namespace Content.Server.Ghost.Roles
private void OnMobStateChanged(EntityUid uid, GhostRoleComponent component, MobStateChangedEvent args)
{
switch (args.CurrentMobState)
switch (args.NewMobState)
{
case DamageState.Alive:
case MobState.Alive:
{
if (!component.Taken)
RegisterGhostRole(component);
break;
}
case DamageState.Critical:
case DamageState.Dead:
case MobState.Critical:
case MobState.Dead:
UnregisterGhostRole(component);
break;
}

View File

@@ -7,7 +7,7 @@ using Content.Shared.Examine;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.MobState;
using Content.Shared.Mobs;
using Content.Shared.Popups;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
@@ -224,12 +224,12 @@ namespace Content.Server.Guardian
{
if (component.HostedGuardian == null) return;
if (args.CurrentMobState.IsCritical())
if (args.NewMobState == MobState.Critical)
{
_popupSystem.PopupEntity(Loc.GetString("guardian-critical-warn"), component.HostedGuardian.Value, component.HostedGuardian.Value);
SoundSystem.Play("/Audio/Effects/guardian_warn.ogg", Filter.Pvs(component.HostedGuardian.Value), component.HostedGuardian.Value);
}
else if (args.CurrentMobState.IsDead())
else if (args.NewMobState == MobState.Dead)
{
SoundSystem.Play("/Audio/Voice/Human/malescream_guardian.ogg", Filter.Pvs(uid), uid, AudioHelpers.WithVariation(0.20f));
EntityManager.RemoveComponent<GuardianHostComponent>(uid);

View File

@@ -7,7 +7,7 @@ using Content.Shared.IdentityManagement;
using Content.Shared.Implants;
using Content.Shared.Implants.Components;
using Content.Shared.Interaction;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Popups;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;

View File

@@ -2,7 +2,7 @@
using Content.Shared.Implants;
using Content.Shared.Implants.Components;
using Content.Shared.Interaction.Events;
using Content.Shared.MobState;
using Content.Shared.Mobs;
using Robust.Shared.Containers;
namespace Content.Server.Implants;
@@ -34,19 +34,28 @@ public sealed class SubdermalImplantSystem : SharedSubdermalImplantSystem
#region Relays
//Relays from the implanted to the implant
private void RelayToImplantEvent<T>(EntityUid uid, ImplantedComponent component, T args) where T : EntityEventArgs
private void RelayToImplantEvent<T>(EntityUid uid, ImplantedComponent component, T args) where T: notnull
{
if (!_container.TryGetContainer(uid, ImplanterComponent.ImplantSlotId, out var implantContainer))
return;
foreach (var implant in implantContainer.ContainedEntities)
{
RaiseLocalEvent(implant, args);
}
}
//Relays from the implanted to the implant
private void RelayToImplantEventByRef<T>(EntityUid uid, ImplantedComponent component, ref T args) where T: notnull
{
if (!_container.TryGetContainer(uid, ImplanterComponent.ImplantSlotId, out var implantContainer))
return;
foreach (var implant in implantContainer.ContainedEntities)
{
RaiseLocalEvent(implant,ref args);
}
}
//Relays from the implant to the implanted
private void RelayToImplantedEvent<T>(EntityUid uid, SubdermalImplantComponent component, T args) where T : EntityEventArgs
{
@@ -56,5 +65,13 @@ public sealed class SubdermalImplantSystem : SharedSubdermalImplantSystem
}
}
private void RelayToImplantedEventByRef<T>(EntityUid uid, SubdermalImplantComponent component, ref T args) where T : EntityEventArgs
{
if (component.ImplantedEntity != null)
{
RaiseLocalEvent(component.ImplantedEntity.Value, ref args);
}
}
#endregion
}

View File

@@ -1,10 +1,10 @@
using Content.Server.Interaction.Components;
using Content.Server.MobState;
using Content.Server.Popups;
using Content.Shared.Bed.Sleep;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Robust.Shared.Audio;
using Robust.Shared.Player;
using Robust.Shared.Random;

View File

@@ -1,7 +1,6 @@
using Content.Server.Administration.Logs;
using Content.Server.DoAfter;
using Content.Server.Kitchen.Components;
using Content.Server.MobState;
using Content.Server.Nutrition.Components;
using Content.Server.Popups;
using Content.Shared.Administration.Logs;
@@ -9,7 +8,6 @@ using Content.Shared.Database;
using Content.Shared.DragDrop;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.MobState.Components;
using Content.Shared.Nutrition.Components;
using Robust.Shared.Audio;
using Robust.Shared.Player;
@@ -17,6 +15,8 @@ using Content.Shared.Storage;
using Robust.Shared.Random;
using static Content.Shared.Kitchen.Components.SharedKitchenSpikeComponent;
using Content.Shared.Interaction.Events;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Popups;
namespace Content.Server.Kitchen.EntitySystems

View File

@@ -1,15 +1,15 @@
using Content.Server.Body.Systems;
using Content.Server.DoAfter;
using Content.Server.Kitchen.Components;
using Content.Server.MobState;
using Content.Shared.Body.Components;
using Content.Shared.Interaction;
using Content.Shared.MobState.Components;
using Content.Shared.Nutrition.Components;
using Content.Shared.Popups;
using Content.Shared.Storage;
using Content.Shared.Verbs;
using Content.Shared.Destructible;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Robust.Server.Containers;
using Robust.Shared.Player;
using Robust.Shared.Random;

View File

@@ -1,4 +1,5 @@
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Light;
using Robust.Shared.Audio;
namespace Content.Server.Light.Components

View File

@@ -7,7 +7,7 @@ using Content.Server.Mech.Systems;
using Content.Shared.Interaction;
using Content.Shared.Mech;
using Content.Shared.Mech.Equipment.Components;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Wall;
using Robust.Shared.Containers;
using Robust.Shared.Map;

View File

@@ -1,5 +1,4 @@
using System.Threading;
using Content.Shared.MobState.Components;
using Content.Shared.Interaction;
using Content.Shared.Audio;
using Content.Shared.Jittering;
@@ -10,7 +9,6 @@ using Content.Shared.Nutrition.Components;
using Content.Shared.Administration.Logs;
using Content.Shared.CCVar;
using Content.Shared.Database;
using Content.Server.MobState;
using Content.Server.Power.Components;
using Content.Server.Fluids.EntitySystems;
using Content.Server.Body.Components;
@@ -21,6 +19,8 @@ using Content.Server.Materials;
using Content.Server.Mind.Components;
using Content.Shared.Humanoid;
using Content.Shared.Interaction.Events;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Popups;
using Robust.Shared.Random;
using Robust.Shared.Configuration;

View File

@@ -4,13 +4,14 @@ using Content.Server.Body.Systems;
using Content.Server.DoAfter;
using Content.Server.Medical.Components;
using Content.Server.Stack;
using Content.Server.MobState;
using Content.Shared.Audio;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Stacks;
using Robust.Shared.Random;
@@ -27,6 +28,7 @@ public sealed class HealingSystem : EntitySystem
[Dependency] private readonly StackSystem _stacks = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
public override void Initialize()
{
@@ -175,10 +177,15 @@ public sealed class HealingSystem : EntitySystem
public float GetScaledHealingPenalty(EntityUid uid, HealingComponent component)
{
var output = component.Delay;
if (!TryComp<MobStateComponent>(uid, out var mobState) || !TryComp<DamageableComponent>(uid, out var damageable))
if (!TryComp<MobThresholdsComponent>(uid, out var mobThreshold) || !TryComp<DamageableComponent>(uid, out var damageable))
return output;
_mobStateSystem.TryGetEarliestCriticalState(mobState, 0, out var _, out var amount);
if (!_mobThresholdSystem.TryGetThresholdForState(uid, MobState.Critical, out var amount,
mobThreshold))
{
return 1;
}
var percentDamage = (float) (damageable.TotalDamage / amount);
//basically make it scale from 1 to the multiplier.
var modifier = percentDamage * (component.SelfHealPenaltyMultiplier - 1) + 1;

View File

@@ -6,7 +6,7 @@ using Content.Server.Popups;
using Content.Shared.Damage;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Audio;
using Robust.Server.GameObjects;
using Robust.Shared.Player;

View File

@@ -5,7 +5,6 @@ using Content.Server.Power.Components;
using Content.Shared.Destructible;
using Content.Shared.ActionBlocker;
using Content.Shared.DragDrop;
using Content.Shared.MobState.Components;
using Content.Shared.Movement.Events;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
@@ -13,7 +12,8 @@ using Content.Server.MachineLinking.System;
using Content.Server.MachineLinking.Events;
using Content.Server.Cloning.Components;
using Content.Server.Construction;
using Content.Server.MobState;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Robust.Server.Containers;
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent; /// Hmm...

View File

@@ -7,11 +7,11 @@ using Content.Shared.Clothing.Components;
using Content.Shared.Damage;
using Content.Shared.FixedPoint;
using Content.Shared.Inventory.Events;
using Content.Shared.MobState.Components;
using Content.Shared.Verbs;
using Robust.Shared.Player;
using System.Threading;
using Content.Server.MobState;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
namespace Content.Server.Medical
{

View File

@@ -2,13 +2,13 @@ using Content.Server.Access.Systems;
using Content.Server.DeviceNetwork;
using Content.Server.DeviceNetwork.Components;
using Content.Server.DeviceNetwork.Systems;
using Content.Server.MobState;
using Content.Server.Popups;
using Content.Shared.Damage;
using Content.Shared.Examine;
using Content.Shared.Inventory.Events;
using Content.Shared.Medical.SuitSensor;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
using Robust.Shared.Map;

View File

@@ -4,12 +4,12 @@ using Content.Server.Administration.Logs;
using Content.Server.GameTicking;
using Content.Server.Ghost.Components;
using Content.Server.Mind.Components;
using Content.Server.MobState;
using Content.Server.Objectives;
using Content.Server.Players;
using Content.Server.Roles;
using Content.Shared.Database;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Network;

View File

@@ -2,9 +2,9 @@ using Content.Server.GameTicking;
using Content.Server.Ghost;
using Content.Server.Ghost.Components;
using Content.Server.Mind.Components;
using Content.Server.MobState;
using Content.Shared.Examine;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Robust.Shared.Map;
using Robust.Shared.Timing;

View File

@@ -1,16 +0,0 @@
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");
}
}
}

View File

@@ -1,19 +0,0 @@
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");
}
}
}

View File

@@ -1,29 +0,0 @@
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);
}
}

View File

@@ -1,19 +0,0 @@
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);
}
}

View File

@@ -1,8 +1,8 @@
using System.Threading;
using System.Threading.Tasks;
using Content.Server.NPC.Components;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Melee;
@@ -23,7 +23,7 @@ public sealed class MeleeOperator : HTNOperator
/// Minimum damage state that the target has to be in for us to consider attacking.
/// </summary>
[DataField("targetState")]
public DamageState TargetState = DamageState.Alive;
public MobState TargetState = MobState.Alive;
// Like movement we add a component and pass it off to the dedicated system.

View File

@@ -5,8 +5,8 @@ using Content.Server.NPC.Pathfinding;
using Content.Server.NPC.Systems;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Robust.Shared.Map;
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators;
@@ -91,7 +91,7 @@ public abstract class NPCCombatOperator : HTNOperator
.GetNearbyHostiles(owner, radius))
{
if (mobQuery.TryGetComponent(target, out var mobState) &&
mobState.CurrentState > DamageState.Alive ||
mobState.CurrentState > MobState.Alive ||
target == existingTarget ||
target == owner)
{

View File

@@ -1,8 +1,8 @@
using System.Threading;
using System.Threading.Tasks;
using Content.Server.NPC.Components;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Robust.Shared.Audio;
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Ranged;
@@ -21,7 +21,7 @@ public sealed class RangedOperator : HTNOperator
/// Minimum damage state that the target has to be in for us to consider attacking.
/// </summary>
[DataField("targetState")]
public DamageState TargetState = DamageState.Alive;
public MobState TargetState = MobState.Alive;
// Like movement we add a component and pass it off to the dedicated system.

View File

@@ -5,7 +5,7 @@ using Content.Server.NPC.Components;
using Content.Server.NPC.Pathfinding;
using Content.Shared.Damage;
using Content.Shared.Interaction;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Specific;

View File

@@ -1,8 +1,8 @@
using Content.Server.MobState;
using Content.Server.NPC.Components;
using Content.Server.NPC.HTN;
using Content.Shared.CCVar;
using Content.Shared.MobState;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Systems;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Configuration;
@@ -131,13 +131,13 @@ namespace Content.Server.NPC.Systems
if (HasComp<ActorComponent>(uid))
return;
switch (args.CurrentMobState)
switch (args.NewMobState)
{
case DamageState.Alive:
case MobState.Alive:
WakeNPC(uid, component);
break;
case DamageState.Critical:
case DamageState.Dead:
case MobState.Critical:
case MobState.Dead:
SleepNPC(uid, component);
break;
}

View File

@@ -1,4 +1,5 @@
using System.Threading;
using Content.Server.Explosion.EntitySystems;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Explosion;
using Content.Shared.Nuke;

View File

@@ -5,7 +5,6 @@ using Content.Server.Chemistry.Components.SolutionManager;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.DoAfter;
using Content.Server.Fluids.EntitySystems;
using Content.Server.MobState;
using Content.Server.Nutrition.Components;
using Content.Server.Popups;
using Content.Shared.Administration.Logs;
@@ -17,7 +16,8 @@ using Content.Shared.FixedPoint;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Nutrition.Components;
using Content.Shared.Throwing;
using Content.Shared.Verbs;

View File

@@ -4,7 +4,6 @@ using Content.Server.Body.Systems;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.DoAfter;
using Content.Server.Hands.Components;
using Content.Server.MobState;
using Content.Server.Nutrition.Components;
using Content.Server.Popups;
using Content.Shared.Administration.Logs;
@@ -17,7 +16,8 @@ using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Inventory;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Verbs;
using Robust.Shared.Audio;
using Robust.Shared.Player;

View File

@@ -1,5 +1,5 @@
using Content.Server.MobState;
using Content.Server.Objectives.Interfaces;
using Content.Shared.Mobs.Systems;
using Robust.Shared.Utility;
namespace Content.Server.Objectives.Conditions

View File

@@ -1,7 +1,7 @@
using System.Linq;
using Content.Server.Mind.Components;
using Content.Server.Objectives.Interfaces;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using JetBrains.Annotations;
using Robust.Shared.Random;

View File

@@ -5,8 +5,8 @@ using Content.Server.GameTicking;
using Content.Server.Roles;
using Content.Shared.CCVar;
using Content.Shared.GameTicking;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Players.PlayTimeTracking;
using Content.Shared.Roles;
using Robust.Server.GameObjects;
@@ -74,7 +74,7 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
if (!TryComp<MobStateComponent>(attached, out var state))
return false;
return state.CurrentState is DamageState.Alive or DamageState.Critical;
return state.CurrentState is MobState.Alive or MobState.Critical;
}
public IEnumerable<string> GetTimedRoles(Mind.Mind mind)
@@ -142,7 +142,7 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
private void OnMobStateChanged(MobStateChangedEvent ev)
{
if (!TryComp(ev.Entity, out ActorComponent? actor))
if (!TryComp(ev.Target, out ActorComponent? actor))
return;
_tracking.QueueRefreshTrackers(actor.PlayerSession);

View File

@@ -1,4 +1,3 @@
using System;
using System.Linq;
using Content.Server.Administration.Logs;
using Content.Server.Ghost.Components;
@@ -11,7 +10,7 @@ using Content.Shared.IdentityManagement;
using Content.Shared.Input;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
using Content.Shared.MobState.EntitySystems;
using Content.Shared.Mobs.Systems;
using Content.Shared.Pointing;
using Content.Shared.Popups;
using JetBrains.Annotations;
@@ -36,7 +35,7 @@ namespace Content.Server.Pointing.EntitySystems
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly RotateToFaceSystem _rotateToFaceSystem = default!;
[Dependency] private readonly SharedMobStateSystem _mobState = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly VisibilitySystem _visibilitySystem = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Content.Server.Explosion.EntitySystems;
using Content.Server.Pointing.Components;
using Content.Shared.MobState.Components;
using Content.Shared.Pointing.Components;
using JetBrains.Annotations;
using Robust.Server.GameObjects;

View File

@@ -9,6 +9,7 @@ using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Damage;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Mobs.Systems;
using Content.Shared.Polymorph;
using Robust.Server.Containers;
using Robust.Shared.Containers;
@@ -29,6 +30,7 @@ namespace Content.Server.Polymorph.Systems
[Dependency] private readonly ServerInventorySystem _inventory = default!;
[Dependency] private readonly SharedHandsSystem _sharedHands = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly HumanoidSystem _humanoid = default!;
[Dependency] private readonly ContainerSystem _container = default!;
@@ -114,7 +116,7 @@ namespace Content.Server.Polymorph.Systems
//Transfers all damage from the original to the new one
if (proto.TransferDamage &&
TryComp<DamageableComponent>(child, out var damageParent) &&
_damageable.GetScaledDamage(target, child, out var damage) &&
_mobThresholdSystem.GetScaledDamage(target, child, out var damage) &&
damage != null)
{
_damageable.SetDamage(damageParent, damage);

View File

@@ -1,7 +1,6 @@
using Content.Server.Actions;
using Content.Server.Inventory;
using Content.Server.Mind.Components;
using Content.Server.MobState;
using Content.Server.Polymorph.Components;
using Content.Server.Popups;
using Content.Shared.Actions;
@@ -9,7 +8,8 @@ using Content.Shared.Actions.ActionTypes;
using Content.Shared.Damage;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.IdentityManagement;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Polymorph;
using Robust.Server.Containers;
using Robust.Shared.Containers;
@@ -23,6 +23,7 @@ namespace Content.Server.Polymorph.Systems
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly ActionsSystem _actions = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly ServerInventorySystem _inventory = default!;
[Dependency] private readonly SharedHandsSystem _sharedHands = default!;
@@ -75,7 +76,7 @@ namespace Content.Server.Polymorph.Systems
if (proto.TransferDamage &&
TryComp<DamageableComponent>(component.Parent, out var damageParent) &&
_damageable.GetScaledDamage(uid, component.Parent, out var damage) &&
_mobThresholdSystem.GetScaledDamage(uid, component.Parent, out var damage) &&
damage != null)
{
_damageable.SetDamage(damageParent, damage);

View File

@@ -1,8 +1,8 @@
using Content.Server.Mind.Components;
using Content.Server.Revenant.Components;
using Content.Shared.Examine;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Revenant.Components;
using Robust.Shared.Random;
@@ -20,13 +20,18 @@ public sealed class EssenceSystem : EntitySystem
{
base.Initialize();
SubscribeLocalEvent<EssenceComponent, ComponentStartup>(UpdateEssenceAmount);
SubscribeLocalEvent<EssenceComponent, MobStateChangedEvent>(UpdateEssenceAmount);
SubscribeLocalEvent<EssenceComponent, MindAddedMessage>(UpdateEssenceAmount);
SubscribeLocalEvent<EssenceComponent, MindRemovedMessage>(UpdateEssenceAmount);
SubscribeLocalEvent<EssenceComponent, ComponentStartup>(OnEssenceEventReceived);
SubscribeLocalEvent<EssenceComponent, MobStateChangedEvent>(OnMobstateChanged);
SubscribeLocalEvent<EssenceComponent, MindAddedMessage>(OnEssenceEventReceived);
SubscribeLocalEvent<EssenceComponent, MindRemovedMessage>(OnEssenceEventReceived);
SubscribeLocalEvent<EssenceComponent, ExaminedEvent>(OnExamine);
}
private void OnMobstateChanged(EntityUid uid, EssenceComponent component, MobStateChangedEvent args)
{
UpdateEssenceAmount(uid, component);
}
private void OnExamine(EntityUid uid, EssenceComponent component, ExaminedEvent args)
{
if (!component.SearchComplete || !HasComp<RevenantComponent>(args.Examiner))
@@ -49,23 +54,28 @@ public sealed class EssenceSystem : EntitySystem
args.PushMarkup(Loc.GetString(message, ("target", uid)));
}
private void UpdateEssenceAmount(EntityUid uid, EssenceComponent component, EntityEventArgs args)
private void OnEssenceEventReceived(EntityUid uid, EssenceComponent component, EntityEventArgs args)
{
UpdateEssenceAmount(uid, component);
}
private void UpdateEssenceAmount(EntityUid uid, EssenceComponent component)
{
if (!TryComp<MobStateComponent>(uid, out var mob))
return;
switch (mob.CurrentState)
{
case DamageState.Alive:
case MobState.Alive:
if (TryComp<MindComponent>(uid, out var mind) && mind.Mind != null)
component.EssenceAmount = _random.NextFloat(75f, 100f);
else
component.EssenceAmount = _random.NextFloat(45f, 70f);
break;
case DamageState.Critical:
case MobState.Critical:
component.EssenceAmount = _random.NextFloat(35f, 50f);
break;
case DamageState.Dead:
case MobState.Dead:
component.EssenceAmount = _random.NextFloat(15f, 20f);
break;
}

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);

View File

@@ -10,7 +10,6 @@ using Content.Shared.Revenant;
using Robust.Server.GameObjects;
using Robust.Shared.Random;
using Content.Shared.StatusEffect;
using Content.Server.MobState;
using Content.Server.Visible;
using Content.Shared.Examine;
using Robust.Shared.Prototypes;
@@ -21,6 +20,7 @@ using Content.Server.Store.Systems;
using Content.Shared.FixedPoint;
using Robust.Shared.Player;
using Content.Shared.Maps;
using Content.Shared.Mobs.Systems;
using Content.Shared.Physics;
using Content.Shared.Revenant.Components;

View File

@@ -1,7 +1,7 @@
using Content.Server.Body.Systems;
using Content.Server.MobState;
using Content.Shared.Body.Components;
using Content.Shared.Damage;
using Content.Shared.Mobs.Systems;
namespace Content.Server.Salvage;

View File

@@ -1,9 +1,8 @@
using Content.Server.Disease;
using Content.Server.Disease.Components;
using Content.Server.MobState;
using Content.Server.Station.Systems;
using Content.Shared.Disease;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Robust.Shared.Random;
namespace Content.Server.StationEvents.Events;

View File

@@ -1,6 +1,7 @@
using Content.Server.Storage.EntitySystems;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Item;
using Content.Shared.Toilet;
using Robust.Shared.Containers;
namespace Content.Server.Storage.Components

View File

@@ -1,10 +1,10 @@
using System.Linq;
using Content.Server.GameTicking.Rules;
using Content.Server.Mind.Components;
using Content.Server.MobState;
using Content.Server.Roles;
using Content.Server.Suspicion.Roles;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Suspicion;
namespace Content.Server.Suspicion
@@ -13,7 +13,6 @@ namespace Content.Server.Suspicion
public sealed class SuspicionRoleComponent : SharedSuspicionRoleComponent
{
[Dependency] private readonly IEntityManager _entMan = default!;
private Role? _role;
[ViewVariables]
private readonly HashSet<SuspicionRoleComponent> _allies = new();

View File

@@ -1,6 +1,6 @@
using Content.Server.Standing;
using Content.Shared.Hands;
using Content.Shared.MobState;
using Content.Shared.Mobs;
using Content.Shared.Vehicle.Components;
using Robust.Shared.GameStates;
@@ -48,7 +48,7 @@ namespace Content.Server.Vehicle
/// </summary>
private void OnMobStateChanged(EntityUid uid, RiderComponent rider, MobStateChangedEvent args)
{
if (args.CurrentMobState is DamageState.Critical or DamageState.Dead)
if (args.NewMobState is MobState.Critical or MobState.Dead)
{
UnbuckleFromVehicle(uid);
}

Some files were not shown because too many files have changed in this diff Show More