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

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