diff --git a/Content.Server/Body/Systems/BloodstreamSystem.cs b/Content.Server/Body/Systems/BloodstreamSystem.cs index 293b70fb6b..dc652c0f61 100644 --- a/Content.Server/Body/Systems/BloodstreamSystem.cs +++ b/Content.Server/Body/Systems/BloodstreamSystem.cs @@ -3,6 +3,7 @@ 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; @@ -27,6 +28,7 @@ public sealed class BloodstreamSystem : EntitySystem [Dependency] private readonly DamageableSystem _damageableSystem = default!; [Dependency] private readonly SpillableSystem _spillableSystem = default!; [Dependency] private readonly PopupSystem _popupSystem = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!; @@ -90,7 +92,7 @@ public sealed class BloodstreamSystem : EntitySystem bloodstream.AccumulatedFrametime -= bloodstream.UpdateInterval; var uid = bloodstream.Owner; - if (TryComp(uid, out var state) && state.IsDead()) + if (TryComp(uid, out var state) && _mobStateSystem.IsDead(uid, state)) continue; // First, let's refresh their blood if possible. diff --git a/Content.Server/Body/Systems/MetabolizerSystem.cs b/Content.Server/Body/Systems/MetabolizerSystem.cs index 42257c4230..2c6c93fcbe 100644 --- a/Content.Server/Body/Systems/MetabolizerSystem.cs +++ b/Content.Server/Body/Systems/MetabolizerSystem.cs @@ -2,6 +2,7 @@ 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; @@ -22,6 +23,7 @@ namespace Content.Server.Body.Systems [Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; public override void Initialize() @@ -159,7 +161,7 @@ namespace Content.Server.Body.Systems // still remove reagents if (EntityManager.TryGetComponent(solutionEntityUid.Value, out var state)) { - if (state.IsDead()) + if (_mobStateSystem.IsDead(solutionEntityUid.Value, state)) continue; } diff --git a/Content.Server/Cargo/Systems/PricingSystem.cs b/Content.Server/Cargo/Systems/PricingSystem.cs index eaa836530e..ee3c4d2e71 100644 --- a/Content.Server/Cargo/Systems/PricingSystem.cs +++ b/Content.Server/Cargo/Systems/PricingSystem.cs @@ -3,6 +3,7 @@ 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; @@ -24,6 +25,7 @@ public sealed class PricingSystem : EntitySystem { [Dependency] private readonly IConsoleHost _consoleHost = default!; [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly BodySystem _bodySystem = default!; @@ -98,7 +100,7 @@ public sealed class PricingSystem : EntitySystem var partRatio = totalPartsPresent / (double) totalParts; var partPenalty = component.Price * (1 - partRatio) * component.MissingBodyPartPenalty; - args.Price += (component.Price - partPenalty) * (state.IsAlive() ? 1.0 : component.DeathPenalty); + args.Price += (component.Price - partPenalty) * (_mobStateSystem.IsAlive(uid, state) ? 1.0 : component.DeathPenalty); } private void CalculateStackPrice(EntityUid uid, StackPriceComponent component, ref PriceCalculationEvent args) diff --git a/Content.Server/Drone/DroneSystem.cs b/Content.Server/Drone/DroneSystem.cs index 97b0b5bfad..f2cc53c71c 100644 --- a/Content.Server/Drone/DroneSystem.cs +++ b/Content.Server/Drone/DroneSystem.cs @@ -3,6 +3,7 @@ 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; @@ -32,6 +33,7 @@ namespace Content.Server.Drone [Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly InnateToolSystem _innateToolSystem = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; public override void Initialize() { @@ -131,7 +133,7 @@ namespace Content.Server.Drone if (HasComp(entity) && !HasComp(entity) && !HasComp(entity)) { // Filter out dead ghost roles. Dead normal players are intended to block. - if ((TryComp(entity, out var entityMobState) && HasComp(entity) && entityMobState.IsDead())) + if ((TryComp(entity, out var entityMobState) && HasComp(entity) && _mobStateSystem.IsDead(entity, entityMobState))) continue; if (_gameTiming.IsFirstTimePredicted) _popupSystem.PopupEntity(Loc.GetString("drone-too-close", ("being", Identity.Entity(entity, EntityManager))), uid, uid); diff --git a/Content.Server/GameTicking/GameTicker.GamePreset.cs b/Content.Server/GameTicking/GameTicker.GamePreset.cs index be8eabd8c3..b5636b6f7d 100644 --- a/Content.Server/GameTicking/GameTicker.GamePreset.cs +++ b/Content.Server/GameTicking/GameTicker.GamePreset.cs @@ -3,6 +3,7 @@ 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; @@ -15,6 +16,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) @@ -180,7 +183,7 @@ namespace Content.Server.GameTicking if (canReturnGlobal && TryComp(playerEntity, out MobStateComponent? mobState)) { - if (mobState.IsCritical()) + if (_mobStateSystem.IsCritical(playerEntity.Value, mobState)) { canReturn = true; diff --git a/Content.Server/GameTicking/Rules/DeathMatchRuleSystem.cs b/Content.Server/GameTicking/Rules/DeathMatchRuleSystem.cs index a0d1fa94c0..2cdda7ea6d 100644 --- a/Content.Server/GameTicking/Rules/DeathMatchRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/DeathMatchRuleSystem.cs @@ -1,5 +1,6 @@ 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; @@ -19,6 +20,7 @@ public sealed class DeathMatchRuleSystem : GameRuleSystem [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IChatManager _chatManager = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly IConfigurationManager _cfg = default!; private const float RestartDelay = 10f; @@ -106,7 +108,7 @@ public sealed class DeathMatchRuleSystem : GameRuleSystem || !TryComp(playerEntity, out MobStateComponent? state)) continue; - if (!state.IsAlive()) + if (!_mobStateSystem.IsAlive(playerEntity, state)) continue; // Found a second person alive, nothing decided yet! diff --git a/Content.Server/GameTicking/Rules/SuspicionRuleSystem.cs b/Content.Server/GameTicking/Rules/SuspicionRuleSystem.cs index 22d27d24b7..8a6598434f 100644 --- a/Content.Server/GameTicking/Rules/SuspicionRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/SuspicionRuleSystem.cs @@ -2,6 +2,7 @@ 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; @@ -44,6 +45,7 @@ public sealed class SuspicionRuleSystem : GameRuleSystem [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly ITileDefinitionManager _tileDefMan = default!; [Dependency] private readonly SharedDoorSystem _doorSystem = default!; [Dependency] private readonly EntityLookupSystem _lookupSystem = default!; @@ -294,7 +296,7 @@ public sealed class SuspicionRuleSystem : GameRuleSystem continue; } - if (!mobState.IsAlive()) + if (!_mobStateSystem.IsAlive(playerEntity, mobState)) { continue; } diff --git a/Content.Server/GameTicking/Rules/TraitorDeathMatchRuleSystem.cs b/Content.Server/GameTicking/Rules/TraitorDeathMatchRuleSystem.cs index 1cd87250c4..5df12de47b 100644 --- a/Content.Server/GameTicking/Rules/TraitorDeathMatchRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/TraitorDeathMatchRuleSystem.cs @@ -3,6 +3,7 @@ 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; @@ -36,6 +37,7 @@ public sealed class TraitorDeathMatchRuleSystem : GameRuleSystem [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly MaxTimeRestartRuleSystem _restarter = default!; [Dependency] private readonly InventorySystem _inventory = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; [Dependency] private readonly TransformSystem _transformSystem = default!; [Dependency] private readonly UplinkSystem _uplink = default!; @@ -148,13 +150,13 @@ public sealed class TraitorDeathMatchRuleSystem : GameRuleSystem if (mind.OwnedEntity is {Valid: true} entity && TryComp(entity, out MobStateComponent? mobState)) { - if (mobState.IsCritical()) + if (_mobStateSystem.IsCritical(entity, mobState)) { // TODO BODY SYSTEM KILL var damage = new DamageSpecifier(_prototypeManager.Index("Asphyxiation"), 100); Get().TryChangeDamage(entity, damage, true); } - else if (!mobState.IsDead()) + else if (!_mobStateSystem.IsDead(entity,mobState)) { if (HasComp(entity)) { @@ -225,7 +227,7 @@ public sealed class TraitorDeathMatchRuleSystem : GameRuleSystem if (TryComp(avoidMeEntity.Value, out MobStateComponent? mobState)) { // Does have mob state component; if critical or dead, they don't really matter for spawn checks - if (mobState.IsCritical() || mobState.IsDead()) + if (_mobStateSystem.IsCritical(avoidMeEntity.Value, mobState) || _mobStateSystem.IsDead(avoidMeEntity.Value, mobState)) continue; } else diff --git a/Content.Server/Interaction/InteractionPopupSystem.cs b/Content.Server/Interaction/InteractionPopupSystem.cs index 3820baeba1..aad73eca22 100644 --- a/Content.Server/Interaction/InteractionPopupSystem.cs +++ b/Content.Server/Interaction/InteractionPopupSystem.cs @@ -1,4 +1,5 @@ using Content.Server.Interaction.Components; +using Content.Server.MobState; using Content.Server.Popups; using Content.Shared.Bed.Sleep; using Content.Shared.IdentityManagement; @@ -15,6 +16,7 @@ public sealed class InteractionPopupSystem : EntitySystem { [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly PopupSystem _popupSystem = default!; public override void Initialize() @@ -38,7 +40,7 @@ public sealed class InteractionPopupSystem : EntitySystem return; if (TryComp(uid, out var state) // if it has a MobStateComponent, - && !state.IsAlive()) // AND if that state is not Alive (e.g. dead/incapacitated/critical) + && !_mobStateSystem.IsAlive(uid, state)) // AND if that state is not Alive (e.g. dead/incapacitated/critical) return; // TODO: Should be an attempt event diff --git a/Content.Server/Kitchen/EntitySystems/KitchenSpikeSystem.cs b/Content.Server/Kitchen/EntitySystems/KitchenSpikeSystem.cs index c8692194d1..4bf145dd51 100644 --- a/Content.Server/Kitchen/EntitySystems/KitchenSpikeSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/KitchenSpikeSystem.cs @@ -1,6 +1,7 @@ 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; @@ -25,6 +26,7 @@ namespace Content.Server.Kitchen.EntitySystems [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly DoAfterSystem _doAfter = default!; [Dependency] private readonly IAdminLogManager _logger = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly IRobustRandom _random = default!; public override void Initialize() @@ -213,7 +215,7 @@ namespace Content.Server.Kitchen.EntitySystems // THE WHAT? (again) // Prevent dead from being spiked TODO: Maybe remove when rounds can be played and DOT is implemented if (Resolve(victimUid, ref mobState, false) && - !mobState.IsDead()) + _mobStateSystem.IsAlive(victimUid, mobState)) { _popupSystem.PopupEntity(Loc.GetString("comp-kitchen-spike-deny-not-dead", ("victim", Identity.Entity(victimUid, EntityManager))), victimUid, userUid); diff --git a/Content.Server/Medical/Stethoscope/StethoscopeSystem.cs b/Content.Server/Medical/Stethoscope/StethoscopeSystem.cs index e8e0b4aa28..be691d9e64 100644 --- a/Content.Server/Medical/Stethoscope/StethoscopeSystem.cs +++ b/Content.Server/Medical/Stethoscope/StethoscopeSystem.cs @@ -11,6 +11,7 @@ using Content.Shared.MobState.Components; using Content.Shared.Verbs; using Robust.Shared.Player; using System.Threading; +using Content.Server.MobState; namespace Content.Server.Medical { @@ -18,6 +19,7 @@ namespace Content.Server.Medical { [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly DoAfterSystem _doAfterSystem = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; public override void Initialize() { @@ -135,7 +137,7 @@ namespace Content.Server.Medical public void ExamineWithStethoscope(EntityUid user, EntityUid target) { /// The mob check seems a bit redundant but (1) they could conceivably have lost it since when the doafter started and (2) I need it for .IsDead() - if (!HasComp(target) || !TryComp(target, out var mobState) || mobState.IsDead()) + if (!HasComp(target) || !TryComp(target, out var mobState) || _mobStateSystem.IsDead(target, mobState)) { _popupSystem.PopupEntity(Loc.GetString("stethoscope-dead"), target, user); return; diff --git a/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs b/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs index 7664f69404..ddb5d2bc2a 100644 --- a/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs +++ b/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs @@ -2,6 +2,7 @@ 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; @@ -22,6 +23,7 @@ namespace Content.Server.Medical.SuitSensors [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IdCardSystem _idCardSystem = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly DeviceNetworkSystem _deviceNetworkSystem = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; @@ -244,7 +246,7 @@ namespace Content.Server.Medical.SuitSensors var isAlive = false; if (EntityManager.TryGetComponent(sensor.User.Value, out MobStateComponent? mobState)) { - isAlive = mobState.IsAlive(); + isAlive = _mobStateSystem.IsAlive(sensor.User.Value, mobState); } // get mob total damage diff --git a/Content.Server/Mind/Mind.cs b/Content.Server/Mind/Mind.cs index c89d396c14..1b87bedfa2 100644 --- a/Content.Server/Mind/Mind.cs +++ b/Content.Server/Mind/Mind.cs @@ -3,6 +3,7 @@ using System.Linq; 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; @@ -26,6 +27,12 @@ namespace Content.Server.Mind /// public sealed class Mind { + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; + [Dependency] private readonly GameTicker _gameTickerSystem = default!; + [Dependency] private readonly MindSystem _mindSystem = default!; + private readonly ISet _roles = new HashSet(); private readonly List _objectives = new(); @@ -41,6 +48,7 @@ namespace Content.Server.Mind public Mind(NetUserId userId) { OriginalOwnerUserId = userId; + IoCManager.InjectDependencies(this); } // TODO: This session should be able to be changed, probably. @@ -114,8 +122,7 @@ namespace Content.Server.Mind { return null; } - var playerMgr = IoCManager.Resolve(); - playerMgr.TryGetSessionById(UserId.Value, out var ret); + _playerManager.TryGetSessionById(UserId.Value, out var ret); return ret; } } @@ -150,13 +157,13 @@ namespace Content.Server.Mind // (If being a borg or AI counts as dead, then this is highly likely, as it's still the same Mind for practical purposes.) // This can be null if they're deleted (spike / brain nom) - var targetMobState = IoCManager.Resolve().GetComponentOrNull(OwnedEntity); + var targetMobState = _entityManager.GetComponentOrNull(OwnedEntity); // This can be null if it's a brain (this happens very often) // Brains are the result of gibbing so should definitely count as dead if (targetMobState == null) return true; // They might actually be alive. - return targetMobState.IsDead(); + return _mobStateSystem.IsDead(OwnedEntity!.Value, targetMobState); } } @@ -181,7 +188,7 @@ namespace Content.Server.Mind var message = new RoleAddedEvent(this, role); if (OwnedEntity != null) { - IoCManager.Resolve().EventBus.RaiseLocalEvent(OwnedEntity.Value, message, true); + _entityManager.EventBus.RaiseLocalEvent(OwnedEntity.Value, message, true); } return role; @@ -207,7 +214,7 @@ namespace Content.Server.Mind if (OwnedEntity != null) { - IoCManager.Resolve().EventBus.RaiseLocalEvent(OwnedEntity.Value, message, true); + _entityManager.EventBus.RaiseLocalEvent(OwnedEntity.Value, message, true); } } @@ -272,23 +279,21 @@ namespace Content.Server.Mind return; } - var entMan = IoCManager.Resolve(); - MindComponent? component = null; var alreadyAttached = false; if (entity != null) { - if (!entMan.TryGetComponent(entity.Value, out component)) + if (!_entityManager.TryGetComponent(entity.Value, out component)) { - component = entMan.AddComponent(entity.Value); + component = _entityManager.AddComponent(entity.Value); } else if (component!.HasMind) { - EntitySystem.Get().OnGhostAttempt(component.Mind!, false); + _gameTickerSystem.OnGhostAttempt(component.Mind!, false); } - if (entMan.TryGetComponent(entity.Value, out var actor)) + if (_entityManager.TryGetComponent(entity.Value, out var actor)) { // Happens when transferring to your currently visited entity. if (actor.PlayerSession != Session) @@ -300,14 +305,12 @@ namespace Content.Server.Mind } } - var mindSystem = EntitySystem.Get(); - if(OwnedComponent != null) - mindSystem.InternalEjectMind(OwnedComponent.Owner, OwnedComponent); + _mindSystem.InternalEjectMind(OwnedComponent.Owner, OwnedComponent); OwnedComponent = component; if(OwnedComponent != null) - mindSystem.InternalAssignMind(OwnedComponent.Owner, this, OwnedComponent); + _mindSystem.InternalAssignMind(OwnedComponent.Owner, this, OwnedComponent); // Don't do the full deletion cleanup if we're transferring to our visitingentity if (alreadyAttached) @@ -315,11 +318,11 @@ namespace Content.Server.Mind // Set VisitingEntity null first so the removal of VisitingMind doesn't get through Unvisit() and delete what we're visiting. // Yes this control flow sucks. VisitingEntity = null; - IoCManager.Resolve().RemoveComponent(entity!.Value); + _entityManager.RemoveComponent(entity!.Value); } else if (VisitingEntity != null && (ghostCheckOverride // to force mind transfer, for example from ControlMobVerb - || !entMan.TryGetComponent(VisitingEntity!, out GhostComponent? ghostComponent) // visiting entity is not a Ghost + || !_entityManager.TryGetComponent(VisitingEntity!, out GhostComponent? ghostComponent) // visiting entity is not a Ghost || !ghostComponent.CanReturnToBody)) // it is a ghost, but cannot return to body anyway, so it's okay { RemoveVisitingEntity(); @@ -380,7 +383,7 @@ namespace Content.Server.Mind Session?.AttachToEntity(entity); VisitingEntity = entity; - var comp = IoCManager.Resolve().AddComponent(entity); + var comp = _entityManager.AddComponent(entity); comp.Mind = this; Logger.Info($"Session {Session?.Name} visiting entity {entity}."); @@ -408,10 +411,8 @@ namespace Content.Server.Mind VisitingEntity = null; DebugTools.AssertNotNull(oldVisitingEnt); - - var entities = IoCManager.Resolve(); - entities.RemoveComponent(oldVisitingEnt); - entities.EventBus.RaiseLocalEvent(oldVisitingEnt, new MindUnvisitedMessage(), true); + _entityManager.RemoveComponent(oldVisitingEnt); + _entityManager.EventBus.RaiseLocalEvent(oldVisitingEnt, new MindUnvisitedMessage(), true); } public bool TryGetSession([NotNullWhen(true)] out IPlayerSession? session) diff --git a/Content.Server/Mind/MindSystem.cs b/Content.Server/Mind/MindSystem.cs index be7656a6b9..232170d368 100644 --- a/Content.Server/Mind/MindSystem.cs +++ b/Content.Server/Mind/MindSystem.cs @@ -2,6 +2,7 @@ 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 Robust.Shared.Map; @@ -13,6 +14,7 @@ public sealed class MindSystem : EntitySystem { [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly GameTicker _gameTicker = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly GhostSystem _ghostSystem = default!; public override void Initialize() @@ -131,7 +133,7 @@ public sealed class MindSystem : EntitySystem return; } - var dead = TryComp(uid, out var state) && state.IsDead(); + var dead = TryComp(uid, out var state) && _mobStateSystem.IsDead(uid, state); if (dead) { diff --git a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs index 37e173e4ee..463b488ea5 100644 --- a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs @@ -5,6 +5,7 @@ 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; @@ -40,6 +41,7 @@ namespace Content.Server.Nutrition.EntitySystems [Dependency] private readonly StomachSystem _stomachSystem = default!; [Dependency] private readonly DoAfterSystem _doAfterSystem = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly SpillableSystem _spillableSystem = default!; [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; @@ -395,7 +397,7 @@ namespace Content.Server.Nutrition.EntitySystems !_bodySystem.TryGetBodyOrganComponents(ev.User, out var stomachs, body)) return; - if (EntityManager.TryGetComponent(uid, out var mobState) && mobState.IsAlive()) + if (EntityManager.TryGetComponent(uid, out var mobState) && _mobStateSystem.IsAlive(uid, mobState)) return; AlternativeVerb verb = new() diff --git a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs index 72f8678441..dc4938ff1e 100644 --- a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs @@ -4,6 +4,7 @@ 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; @@ -34,6 +35,7 @@ namespace Content.Server.Nutrition.EntitySystems [Dependency] private readonly BodySystem _bodySystem = default!; [Dependency] private readonly StomachSystem _stomachSystem = default!; [Dependency] private readonly PopupSystem _popupSystem = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly UtensilSystem _utensilSystem = default!; [Dependency] private readonly DoAfterSystem _doAfterSystem = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; @@ -84,7 +86,7 @@ namespace Content.Server.Nutrition.EntitySystems } if (food.Owner == user || //Suppresses self-eating - EntityManager.TryGetComponent(food.Owner, out var mobState) && mobState.IsAlive()) // Suppresses eating alive mobs + EntityManager.TryGetComponent(food.Owner, out var mobState) && _mobStateSystem.IsAlive(food.Owner, mobState)) // Suppresses eating alive mobs return false; // Target can't be fed @@ -258,7 +260,7 @@ namespace Content.Server.Nutrition.EntitySystems !_bodySystem.TryGetBodyOrganComponents(ev.User, out var stomachs, body)) return; - if (EntityManager.TryGetComponent(uid, out var mobState) && mobState.IsAlive()) + if (EntityManager.TryGetComponent(uid, out var mobState) && _mobStateSystem.IsAlive(uid, mobState)) return; AlternativeVerb verb = new() diff --git a/Content.Server/Objectives/Conditions/KillPersonCondition.cs b/Content.Server/Objectives/Conditions/KillPersonCondition.cs index 86f28feb2f..7b1301a42c 100644 --- a/Content.Server/Objectives/Conditions/KillPersonCondition.cs +++ b/Content.Server/Objectives/Conditions/KillPersonCondition.cs @@ -1,3 +1,4 @@ +using Content.Server.MobState; using Content.Server.Objectives.Interfaces; using Robust.Shared.Utility; @@ -5,6 +6,8 @@ namespace Content.Server.Objectives.Conditions { public abstract class KillPersonCondition : IObjectiveCondition { + protected IEntityManager EntityManager => IoCManager.Resolve(); + protected MobStateSystem MobStateSystem => IoCManager.Resolve(); protected Mind.Mind? Target; public abstract IObjectiveCondition GetAssigned(Mind.Mind mind); @@ -19,7 +22,7 @@ namespace Content.Server.Objectives.Conditions return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName)); if (Target.OwnedEntity is {Valid: true} owned) - targetName = IoCManager.Resolve().GetComponent(owned).EntityName; + targetName = EntityManager.GetComponent(owned).EntityName; return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName)); } diff --git a/Content.Server/Objectives/Conditions/KillRandomPersonCondition.cs b/Content.Server/Objectives/Conditions/KillRandomPersonCondition.cs index 3655f0e471..ed08937dc6 100644 --- a/Content.Server/Objectives/Conditions/KillRandomPersonCondition.cs +++ b/Content.Server/Objectives/Conditions/KillRandomPersonCondition.cs @@ -13,16 +13,15 @@ namespace Content.Server.Objectives.Conditions { public override IObjectiveCondition GetAssigned(Mind.Mind mind) { - var entityMgr = IoCManager.Resolve(); - var allHumans = entityMgr.EntityQuery(true).Where(mc => + var allHumans = EntityManager.EntityQuery(true).Where(mc => { var entity = mc.Mind?.OwnedEntity; if (entity == default) return false; - return entityMgr.TryGetComponent(entity, out MobStateComponent? mobState) && - mobState.IsAlive() && + return EntityManager.TryGetComponent(entity, out MobStateComponent? mobState) && + MobStateSystem.IsAlive(entity.Value, mobState) && mc.Mind != mind; }).Select(mc => mc.Mind).ToList(); diff --git a/Content.Server/Polymorph/Systems/PolymorphedEntitySystem.cs b/Content.Server/Polymorph/Systems/PolymorphedEntitySystem.cs index 7b4e2c0429..fb58ac2135 100644 --- a/Content.Server/Polymorph/Systems/PolymorphedEntitySystem.cs +++ b/Content.Server/Polymorph/Systems/PolymorphedEntitySystem.cs @@ -1,6 +1,7 @@ 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; @@ -25,6 +26,7 @@ namespace Content.Server.Polymorph.Systems [Dependency] private readonly PopupSystem _popup = default!; [Dependency] private readonly ServerInventorySystem _inventory = default!; [Dependency] private readonly SharedHandsSystem _sharedHands = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly ContainerSystem _container = default!; public override void Initialize() @@ -157,8 +159,8 @@ namespace Content.Server.Polymorph.Systems if (!TryComp(comp.Owner, out var mob)) continue; - if ((proto.RevertOnDeath && mob.IsDead()) || - (proto.RevertOnCrit && mob.IsCritical())) + if ((proto.RevertOnDeath && _mobStateSystem.IsDead(comp.Owner, mob)) || + (proto.RevertOnCrit && _mobStateSystem.IsCritical(comp.Owner, mob))) Revert(comp.Owner); } } diff --git a/Content.Server/StationEvents/Events/DiseaseOutbreak.cs b/Content.Server/StationEvents/Events/DiseaseOutbreak.cs index bf2d64e1be..30fe26f31e 100644 --- a/Content.Server/StationEvents/Events/DiseaseOutbreak.cs +++ b/Content.Server/StationEvents/Events/DiseaseOutbreak.cs @@ -1,5 +1,6 @@ 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; @@ -13,6 +14,7 @@ namespace Content.Server.StationEvents.Events; public sealed class DiseaseOutbreak : StationEventSystem { [Dependency] private readonly DiseaseSystem _diseaseSystem = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; public override string Prototype => "DiseaseOutbreak"; @@ -42,7 +44,7 @@ public sealed class DiseaseOutbreak : StationEventSystem List aliveList = new(); foreach (var (carrier, mobState) in EntityManager.EntityQuery()) { - if (!mobState.IsDead()) + if (!_mobStateSystem.IsDead(mobState.Owner, mobState)) aliveList.Add(carrier); } RobustRandom.Shuffle(aliveList); diff --git a/Content.Server/Suspicion/SuspicionRoleComponent.cs b/Content.Server/Suspicion/SuspicionRoleComponent.cs index c5726c76f3..85e781a30f 100644 --- a/Content.Server/Suspicion/SuspicionRoleComponent.cs +++ b/Content.Server/Suspicion/SuspicionRoleComponent.cs @@ -1,6 +1,7 @@ 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; @@ -12,6 +13,7 @@ namespace Content.Server.Suspicion public sealed class SuspicionRoleComponent : SharedSuspicionRoleComponent { [Dependency] private readonly IEntityManager _entMan = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; private Role? _role; [ViewVariables] @@ -52,7 +54,7 @@ namespace Content.Server.Suspicion public bool IsDead() { return _entMan.TryGetComponent(Owner, out MobStateComponent? state) && - state.IsDead(); + _mobStateSystem.IsDead(Owner, state); } public bool IsInnocent() diff --git a/Content.Shared/MobState/Components/MobStateComponent.cs b/Content.Shared/MobState/Components/MobStateComponent.cs index 932c27e803..25f2749384 100644 --- a/Content.Shared/MobState/Components/MobStateComponent.cs +++ b/Content.Shared/MobState/Components/MobStateComponent.cs @@ -14,6 +14,7 @@ namespace Content.Shared.MobState.Components /// [RegisterComponent] [NetworkedComponent] + [Access(typeof(SharedMobStateSystem))] public sealed class MobStateComponent : Component { /// @@ -34,33 +35,5 @@ namespace Content.Shared.MobState.Components public FixedPoint2? CurrentThreshold { get; set; } public IEnumerable> _highestToLowestStates => _lowestToHighestStates.Reverse(); - - [Obsolete("Use MobStateSystem")] - public bool IsAlive() - { - return IoCManager.Resolve().GetEntitySystem() - .IsAlive(Owner, this); - } - - [Obsolete("Use MobStateSystem")] - public bool IsCritical() - { - return IoCManager.Resolve().GetEntitySystem() - .IsCritical(Owner, this); - } - - [Obsolete("Use MobStateSystem")] - public bool IsDead() - { - return IoCManager.Resolve().GetEntitySystem() - .IsDead(Owner, this); - } - - [Obsolete("Use MobStateSystem")] - public bool IsIncapacitated() - { - return IoCManager.Resolve().GetEntitySystem() - .IsIncapacitated(Owner, this); - } } }