Cleaned up obsolete properties from MobStateComponent (#13097)

Co-authored-by: Jezithyr <Jezithyr@gmail.com>
This commit is contained in:
Jezithyr
2022-12-19 19:25:35 -08:00
committed by GitHub
parent 7259acfb18
commit 5f9b4adf47
22 changed files with 91 additions and 78 deletions

View File

@@ -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<MobStateComponent>(uid, out var state) && state.IsDead())
if (TryComp<MobStateComponent>(uid, out var state) && _mobStateSystem.IsDead(uid, state))
continue;
// First, let's refresh their blood if possible.

View File

@@ -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<MobStateComponent>(solutionEntityUid.Value, out var state))
{
if (state.IsDead())
if (_mobStateSystem.IsDead(solutionEntityUid.Value, state))
continue;
}

View File

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

View File

@@ -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<MindComponent>(entity) && !HasComp<DroneComponent>(entity) && !HasComp<GhostComponent>(entity))
{
// Filter out dead ghost roles. Dead normal players are intended to block.
if ((TryComp<MobStateComponent>(entity, out var entityMobState) && HasComp<GhostTakeoverAvailableComponent>(entity) && entityMobState.IsDead()))
if ((TryComp<MobStateComponent>(entity, out var entityMobState) && HasComp<GhostTakeoverAvailableComponent>(entity) && _mobStateSystem.IsDead(entity, entityMobState)))
continue;
if (_gameTiming.IsFirstTimePredicted)
_popupSystem.PopupEntity(Loc.GetString("drone-too-close", ("being", Identity.Entity(entity, EntityManager))), uid, uid);

View File

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

View File

@@ -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!

View File

@@ -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;
}

View File

@@ -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<DamageTypePrototype>("Asphyxiation"), 100);
Get<DamageableSystem>().TryChangeDamage(entity, damage, true);
}
else if (!mobState.IsDead())
else if (!_mobStateSystem.IsDead(entity,mobState))
{
if (HasComp<HandsComponent>(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

View File

@@ -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<MobStateComponent>(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

View File

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

View File

@@ -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<RespiratorComponent>(target) || !TryComp<MobStateComponent>(target, out var mobState) || mobState.IsDead())
if (!HasComp<RespiratorComponent>(target) || !TryComp<MobStateComponent>(target, out var mobState) || _mobStateSystem.IsDead(target, mobState))
{
_popupSystem.PopupEntity(Loc.GetString("stethoscope-dead"), target, user);
return;

View File

@@ -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

View File

@@ -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
/// </remarks>
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<Role> _roles = new HashSet<Role>();
private readonly List<Objective> _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<IPlayerManager>();
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<IEntityManager>().GetComponentOrNull<MobStateComponent>(OwnedEntity);
var targetMobState = _entityManager.GetComponentOrNull<MobStateComponent>(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<IEntityManager>().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<IEntityManager>().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<IEntityManager>();
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<MindComponent>(entity.Value);
component = _entityManager.AddComponent<MindComponent>(entity.Value);
}
else if (component!.HasMind)
{
EntitySystem.Get<GameTicker>().OnGhostAttempt(component.Mind!, false);
_gameTickerSystem.OnGhostAttempt(component.Mind!, false);
}
if (entMan.TryGetComponent<ActorComponent>(entity.Value, out var actor))
if (_entityManager.TryGetComponent<ActorComponent>(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<MindSystem>();
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<IEntityManager>().RemoveComponent<VisitingMindComponent>(entity!.Value);
_entityManager.RemoveComponent<VisitingMindComponent>(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<IEntityManager>().AddComponent<VisitingMindComponent>(entity);
var comp = _entityManager.AddComponent<VisitingMindComponent>(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<IEntityManager>();
entities.RemoveComponent<VisitingMindComponent>(oldVisitingEnt);
entities.EventBus.RaiseLocalEvent(oldVisitingEnt, new MindUnvisitedMessage(), true);
_entityManager.RemoveComponent<VisitingMindComponent>(oldVisitingEnt);
_entityManager.EventBus.RaiseLocalEvent(oldVisitingEnt, new MindUnvisitedMessage(), true);
}
public bool TryGetSession([NotNullWhen(true)] out IPlayerSession? session)

View File

@@ -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<MobStateComponent?>(uid, out var state) && state.IsDead();
var dead = TryComp<MobStateComponent?>(uid, out var state) && _mobStateSystem.IsDead(uid, state);
if (dead)
{

View File

@@ -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<StomachComponent>(ev.User, out var stomachs, body))
return;
if (EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) && mobState.IsAlive())
if (EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) && _mobStateSystem.IsAlive(uid, mobState))
return;
AlternativeVerb verb = new()

View File

@@ -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<MobStateComponent>(food.Owner, out var mobState) && mobState.IsAlive()) // Suppresses eating alive mobs
EntityManager.TryGetComponent<MobStateComponent>(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<StomachComponent>(ev.User, out var stomachs, body))
return;
if (EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) && mobState.IsAlive())
if (EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) && _mobStateSystem.IsAlive(uid, mobState))
return;
AlternativeVerb verb = new()

View File

@@ -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<IEntityManager>();
protected MobStateSystem MobStateSystem => IoCManager.Resolve<MobStateSystem>();
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<IEntityManager>().GetComponent<MetaDataComponent>(owned).EntityName;
targetName = EntityManager.GetComponent<MetaDataComponent>(owned).EntityName;
return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName));
}

View File

@@ -13,16 +13,15 @@ namespace Content.Server.Objectives.Conditions
{
public override IObjectiveCondition GetAssigned(Mind.Mind mind)
{
var entityMgr = IoCManager.Resolve<IEntityManager>();
var allHumans = entityMgr.EntityQuery<MindComponent>(true).Where(mc =>
var allHumans = EntityManager.EntityQuery<MindComponent>(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();

View File

@@ -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<MobStateComponent>(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);
}
}

View File

@@ -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<DiseaseCarrierComponent> aliveList = new();
foreach (var (carrier, mobState) in EntityManager.EntityQuery<DiseaseCarrierComponent, MobStateComponent>())
{
if (!mobState.IsDead())
if (!_mobStateSystem.IsDead(mobState.Owner, mobState))
aliveList.Add(carrier);
}
RobustRandom.Shuffle(aliveList);

View File

@@ -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()

View File

@@ -14,6 +14,7 @@ namespace Content.Shared.MobState.Components
/// </summary>
[RegisterComponent]
[NetworkedComponent]
[Access(typeof(SharedMobStateSystem))]
public sealed class MobStateComponent : Component
{
/// <summary>
@@ -34,33 +35,5 @@ namespace Content.Shared.MobState.Components
public FixedPoint2? CurrentThreshold { get; set; }
public IEnumerable<KeyValuePair<int, DamageState>> _highestToLowestStates => _lowestToHighestStates.Reverse();
[Obsolete("Use MobStateSystem")]
public bool IsAlive()
{
return IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<SharedMobStateSystem>()
.IsAlive(Owner, this);
}
[Obsolete("Use MobStateSystem")]
public bool IsCritical()
{
return IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<SharedMobStateSystem>()
.IsCritical(Owner, this);
}
[Obsolete("Use MobStateSystem")]
public bool IsDead()
{
return IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<SharedMobStateSystem>()
.IsDead(Owner, this);
}
[Obsolete("Use MobStateSystem")]
public bool IsIncapacitated()
{
return IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<SharedMobStateSystem>()
.IsIncapacitated(Owner, this);
}
}
}