Fix weird lifestage autorefactors.

This commit is contained in:
Vera Aguilera Puerto
2021-12-09 12:29:27 +01:00
parent 3a9e1ff929
commit 8b09d55b10
43 changed files with 55 additions and 69 deletions

View File

@@ -40,7 +40,7 @@ namespace Content.Client.AI
var deletedEntities = new List<EntityUid>(0); var deletedEntities = new List<EntityUid>(0);
foreach (var (entity, panel) in _aiBoxes) foreach (var (entity, panel) in _aiBoxes)
{ {
if ((!EntityManager.EntityExists(entity) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted) if (Deleted(entity))
{ {
deletedEntities.Add(entity); deletedEntities.Add(entity);
continue; continue;

View File

@@ -118,7 +118,7 @@ namespace Content.Client.Chat.UI
Modulate = Color.White; Modulate = Color.White;
} }
if ((!_entityManager.EntityExists(_senderEntity) ? EntityLifeStage.Deleted : _entityManager.GetComponent<MetaDataComponent>(_senderEntity).EntityLifeStage) >= EntityLifeStage.Deleted || _timeLeft <= 0) if (_entityManager.Deleted(_senderEntity) || _timeLeft <= 0)
{ {
// Timer spawn to prevent concurrent modification exception. // Timer spawn to prevent concurrent modification exception.
Timer.Spawn(0, Die); Timer.Spawn(0, Die);

View File

@@ -187,7 +187,7 @@ namespace Content.Client.ContextMenu.UI
foreach (var entity in Elements.Keys.ToList()) foreach (var entity in Elements.Keys.ToList())
{ {
if ((!_entityManager.EntityExists(entity) ? EntityLifeStage.Deleted : _entityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted || !ignoreFov && !_examineSystem.CanExamine(player, entity)) if (_entityManager.Deleted(entity) || !ignoreFov && !_examineSystem.CanExamine(player, entity))
RemoveEntity(entity); RemoveEntity(entity);
} }
} }
@@ -338,7 +338,7 @@ namespace Content.Client.ContextMenu.UI
if (entityElement.Entity != default) if (entityElement.Entity != default)
{ {
if (!((!_entityManager.EntityExists(entityElement.Entity) ? EntityLifeStage.Deleted : _entityManager.GetComponent<MetaDataComponent>(entityElement.Entity).EntityLifeStage) >= EntityLifeStage.Deleted)) if (!_entityManager.Deleted(entityElement.Entity))
return entityElement.Entity; return entityElement.Entity;
continue; continue;
} }

View File

@@ -51,8 +51,7 @@ namespace Content.Client.DoAfter
var currentTime = _gameTiming.CurTime; var currentTime = _gameTiming.CurTime;
// Can't see any I guess? // Can't see any I guess?
if (_attachedEntity is not {Valid: true} entity || if (_attachedEntity is not {Valid: true} entity || Deleted(entity))
(!EntityManager.EntityExists(_attachedEntity.Value) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted)
return; return;
var viewbox = _eyeManager.GetWorldViewport().Enlarged(2.0f); var viewbox = _eyeManager.GetWorldViewport().Enlarged(2.0f);

View File

@@ -175,7 +175,7 @@ namespace Content.Client.DragDrop
private bool OnBeginDrag() private bool OnBeginDrag()
{ {
if (_dragDropHelper.Dragged == default || (!EntityManager.EntityExists(_dragDropHelper.Dragged) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(_dragDropHelper.Dragged).EntityLifeStage) >= EntityLifeStage.Deleted) if (_dragDropHelper.Dragged == default || Deleted(_dragDropHelper.Dragged))
{ {
// something happened to the clicked entity or we moved the mouse off the target so // something happened to the clicked entity or we moved the mouse off the target so
// we shouldn't replay the original click // we shouldn't replay the original click
@@ -212,7 +212,7 @@ namespace Content.Client.DragDrop
private bool OnContinueDrag(float frameTime) private bool OnContinueDrag(float frameTime)
{ {
if (_dragDropHelper.Dragged == default || (!EntityManager.EntityExists(_dragDropHelper.Dragged) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(_dragDropHelper.Dragged).EntityLifeStage) >= EntityLifeStage.Deleted) if (_dragDropHelper.Dragged == default || Deleted(_dragDropHelper.Dragged))
{ {
return false; return false;
} }
@@ -352,10 +352,8 @@ namespace Content.Client.DragDrop
private void HighlightTargets() private void HighlightTargets()
{ {
if (_dragDropHelper.Dragged == default || if (_dragDropHelper.Dragged == default || Deleted(_dragDropHelper.Dragged) ||
(!EntityManager.EntityExists(_dragDropHelper.Dragged) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(_dragDropHelper.Dragged).EntityLifeStage) >= EntityLifeStage.Deleted || _dragShadow == default || Deleted(_dragShadow))
_dragShadow == default ||
(!EntityManager.EntityExists(_dragShadow) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(_dragShadow).EntityLifeStage) >= EntityLifeStage.Deleted)
{ {
Logger.Warning("Programming error. Can't highlight drag and drop targets, not currently " + Logger.Warning("Programming error. Can't highlight drag and drop targets, not currently " +
"dragging anything or dragged entity / shadow was deleted."); "dragging anything or dragged entity / shadow was deleted.");

View File

@@ -73,7 +73,7 @@ namespace Content.Client.HealthOverlay
return; return;
} }
if (_attachedEntity == null || (!_entities.EntityExists(_attachedEntity.Value) ? EntityLifeStage.Deleted : _entities.GetComponent<MetaDataComponent>(_attachedEntity.Value).EntityLifeStage) >= EntityLifeStage.Deleted) if (_attachedEntity is not {} ent || Deleted(ent))
{ {
return; return;
} }
@@ -84,7 +84,7 @@ namespace Content.Client.HealthOverlay
{ {
var entity = mobState.Owner; var entity = mobState.Owner;
if (_entities.GetComponent<TransformComponent>(_attachedEntity.Value).MapID != _entities.GetComponent<TransformComponent>(entity).MapID || if (_entities.GetComponent<TransformComponent>(ent).MapID != _entities.GetComponent<TransformComponent>(entity).MapID ||
!viewBox.Contains(_entities.GetComponent<TransformComponent>(entity).WorldPosition)) !viewBox.Contains(_entities.GetComponent<TransformComponent>(entity).WorldPosition))
{ {
if (_guis.TryGetValue(entity, out var oldGui)) if (_guis.TryGetValue(entity, out var oldGui))

View File

@@ -73,7 +73,7 @@ namespace Content.Client.HealthOverlay.UI
private void MoreFrameUpdate(FrameEventArgs args) private void MoreFrameUpdate(FrameEventArgs args)
{ {
if ((!_entities.EntityExists(Entity) ? EntityLifeStage.Deleted : _entities.GetComponent<MetaDataComponent>(Entity).EntityLifeStage) >= EntityLifeStage.Deleted) if (_entities.Deleted(Entity))
{ {
return; return;
} }
@@ -139,8 +139,7 @@ namespace Content.Client.HealthOverlay.UI
MoreFrameUpdate(args); MoreFrameUpdate(args);
if ((!_entities.EntityExists(Entity) ? EntityLifeStage.Deleted : _entities.GetComponent<MetaDataComponent>(Entity).EntityLifeStage) >= EntityLifeStage.Deleted || if (_entities.Deleted(Entity) || _eyeManager.CurrentMap != _entities.GetComponent<TransformComponent>(Entity).MapID)
_eyeManager.CurrentMap != _entities.GetComponent<TransformComponent>(Entity).MapID)
{ {
Visible = false; Visible = false;
return; return;

View File

@@ -99,8 +99,7 @@ namespace Content.Client.Items.Managers
return; return;
} }
if (entity == default || if (entity == default || _entityManager.Deleted(entity) ||
(!_entityManager.EntityExists(entity) ? EntityLifeStage.Deleted : _entityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted ||
!_entityManager.TryGetComponent(entity, out ItemCooldownComponent? cooldown) || !_entityManager.TryGetComponent(entity, out ItemCooldownComponent? cooldown) ||
!cooldown.CooldownStart.HasValue || !cooldown.CooldownStart.HasValue ||
!cooldown.CooldownEnd.HasValue) !cooldown.CooldownEnd.HasValue)

View File

@@ -110,16 +110,11 @@ namespace Content.Client.Kitchen.UI
_menu.IngredientsList.Clear(); _menu.IngredientsList.Clear();
foreach (var entity in containedSolids) foreach (var entity in containedSolids)
{ {
if (!_entityManager.EntityExists(entity)) if (_entityManager.Deleted(entity))
{ {
return; return;
} }
if ((!_entityManager.EntityExists(entity) ? EntityLifeStage.Deleted : _entityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted)
{
continue;
}
Texture? texture; Texture? texture;
if (_entityManager.TryGetComponent(entity, out IconComponent? iconComponent)) if (_entityManager.TryGetComponent(entity, out IconComponent? iconComponent))
{ {

View File

@@ -131,7 +131,7 @@ namespace Content.Client.Viewport
return; return;
} }
if (_lastHoveredEntity != default && !((!_entityManager.EntityExists(_lastHoveredEntity) ? EntityLifeStage.Deleted : _entityManager.GetComponent<MetaDataComponent>(_lastHoveredEntity).EntityLifeStage) >= EntityLifeStage.Deleted) && if (_lastHoveredEntity != default && !_entityManager.Deleted(_lastHoveredEntity) &&
_entityManager.TryGetComponent(_lastHoveredEntity, out outline)) _entityManager.TryGetComponent(_lastHoveredEntity, out outline))
{ {
outline.OnMouseLeave(); outline.OnMouseLeave();

View File

@@ -52,7 +52,7 @@ namespace Content.Client.Weapons.Melee
return; return;
} }
if (!((!EntityManager.EntityExists(attacker) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(attacker).EntityLifeStage) >= EntityLifeStage.Deleted)) if (!Deleted(attacker))
{ {
var lunge = attacker.EnsureComponent<MeleeLungeComponent>(); var lunge = attacker.EnsureComponent<MeleeLungeComponent>();
lunge.SetData(msg.Angle); lunge.SetData(msg.Angle);

View File

@@ -32,7 +32,7 @@ namespace Content.Server.AI.Operators.Nutrition
var entities = IoCManager.Resolve<IEntityManager>(); var entities = IoCManager.Resolve<IEntityManager>();
// TODO: Also have this check storage a la backpack etc. // TODO: Also have this check storage a la backpack etc.
if ((!entities.EntityExists(_target) ? EntityLifeStage.Deleted : entities.GetComponent<MetaDataComponent>(_target).EntityLifeStage) >= EntityLifeStage.Deleted || if (entities.Deleted(_target) ||
!entities.TryGetComponent(_owner, out HandsComponent? handsComponent) || !entities.TryGetComponent(_owner, out HandsComponent? handsComponent) ||
!entities.TryGetComponent(_target, out ItemComponent? itemComponent)) !entities.TryGetComponent(_target, out ItemComponent? itemComponent))
{ {

View File

@@ -31,7 +31,7 @@ namespace Content.Server.AI.Operators.Nutrition
var entities = IoCManager.Resolve<IEntityManager>(); var entities = IoCManager.Resolve<IEntityManager>();
// TODO: Also have this check storage a la backpack etc. // TODO: Also have this check storage a la backpack etc.
if ((!entities.EntityExists(_target) ? EntityLifeStage.Deleted : entities.GetComponent<MetaDataComponent>(_target).EntityLifeStage) >= EntityLifeStage.Deleted || if (entities.Deleted(_target) ||
!entities.TryGetComponent(_owner, out HandsComponent? handsComponent) || !entities.TryGetComponent(_owner, out HandsComponent? handsComponent) ||
!entities.TryGetComponent(_target, out ItemComponent? itemComponent)) !entities.TryGetComponent(_target, out ItemComponent? itemComponent))
{ {

View File

@@ -264,7 +264,7 @@ namespace Content.Server.AI.Pathfinding
/// <param name="entity"></param> /// <param name="entity"></param>
private void HandleEntityAdd(EntityUid entity) private void HandleEntityAdd(EntityUid entity)
{ {
if ((!EntityManager.EntityExists(entity) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted || if (Deleted(entity) ||
_lastKnownPositions.ContainsKey(entity) || _lastKnownPositions.ContainsKey(entity) ||
!EntityManager.TryGetComponent(entity, out IPhysBody? physics) || !EntityManager.TryGetComponent(entity, out IPhysBody? physics) ||
!PathfindingNode.IsRelevant(entity, physics)) !PathfindingNode.IsRelevant(entity, physics))

View File

@@ -246,7 +246,7 @@ namespace Content.Server.AI.Steering
private SteeringStatus Steer(EntityUid entity, IAiSteeringRequest steeringRequest, float frameTime) private SteeringStatus Steer(EntityUid entity, IAiSteeringRequest steeringRequest, float frameTime)
{ {
// Main optimisation to be done below is the redundant calls and adding more variables // Main optimisation to be done below is the redundant calls and adding more variables
if ((!EntityManager.EntityExists(entity) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted || if (Deleted(entity) ||
!EntityManager.TryGetComponent(entity, out AiControllerComponent? controller) || !EntityManager.TryGetComponent(entity, out AiControllerComponent? controller) ||
!EntitySystem.Get<ActionBlockerSystem>().CanMove(entity) || !EntitySystem.Get<ActionBlockerSystem>().CanMove(entity) ||
!EntityManager.GetComponent<TransformComponent>(entity).GridID.IsValid()) !EntityManager.GetComponent<TransformComponent>(entity).GridID.IsValid())
@@ -658,7 +658,7 @@ namespace Content.Server.AI.Steering
// err for now we'll just assume the first entity is the center and just add a vector for it // err for now we'll just assume the first entity is the center and just add a vector for it
//Pathfinding updates are deferred so this may not be done yet. //Pathfinding updates are deferred so this may not be done yet.
if ((!EntityManager.EntityExists(physicsEntity) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(physicsEntity).EntityLifeStage) >= EntityLifeStage.Deleted) continue; if (Deleted(physicsEntity)) continue;
// if we're moving in the same direction then ignore // if we're moving in the same direction then ignore
// So if 2 entities are moving towards each other and both detect a collision they'll both move in the same direction // So if 2 entities are moving towards each other and both detect a collision they'll both move in the same direction

View File

@@ -12,8 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Movement
var self = context.GetState<SelfState>().GetValue(); var self = context.GetState<SelfState>().GetValue();
var entities = IoCManager.Resolve<IEntityManager>(); var entities = IoCManager.Resolve<IEntityManager>();
if (context.GetState<TargetEntityState>().GetValue() is not {Valid: true} target || if (context.GetState<TargetEntityState>().GetValue() is not {Valid: true} target || entities.Deleted(target) ||
(!entities.EntityExists(target) ? EntityLifeStage.Deleted : entities.GetComponent<MetaDataComponent>(target).EntityLifeStage) >= EntityLifeStage.Deleted ||
entities.GetComponent<TransformComponent>(target).GridID != entities.GetComponent<TransformComponent>(self).GridID) entities.GetComponent<TransformComponent>(target).GridID != entities.GetComponent<TransformComponent>(self).GridID)
{ {
return 0.0f; return 0.0f;

View File

@@ -232,7 +232,7 @@ namespace Content.Server.Atmos.Components
private InternalsComponent? GetInternalsComponent(EntityUid? owner = null) private InternalsComponent? GetInternalsComponent(EntityUid? owner = null)
{ {
if ((!_entMan.EntityExists(Owner) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted) return null; if (_entMan.Deleted(Owner)) return null;
if (owner != null) return _entMan.GetComponentOrNull<InternalsComponent>(owner.Value); if (owner != null) return _entMan.GetComponentOrNull<InternalsComponent>(owner.Value);
return Owner.TryGetContainer(out var container) return Owner.TryGetContainer(out var container)
? _entMan.GetComponentOrNull<InternalsComponent>(container.Owner) ? _entMan.GetComponentOrNull<InternalsComponent>(container.Owner)

View File

@@ -421,7 +421,7 @@ namespace Content.Server.Botany.Components
public bool DoHarvest(EntityUid user) public bool DoHarvest(EntityUid user)
{ {
if (Seed == null || (!_entMan.EntityExists(user) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(user).EntityLifeStage) >= EntityLifeStage.Deleted || !EntitySystem.Get<ActionBlockerSystem>().CanInteract(user)) if (Seed == null || _entMan.Deleted(user) || !EntitySystem.Get<ActionBlockerSystem>().CanInteract(user))
return false; return false;
if (Harvest && !Dead) if (Harvest && !Dead)

View File

@@ -88,7 +88,7 @@ namespace Content.Server.Cargo.Components
spriteComponent.LayerSetState(0, "idle"); spriteComponent.LayerSetState(0, "idle");
Owner.SpawnTimer((int) (TeleportDelay * 1000), () => Owner.SpawnTimer((int) (TeleportDelay * 1000), () =>
{ {
if (!Deleted && !((!_entMan.EntityExists(Owner) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted) && _currentState == CargoTelepadState.Charging && _teleportQueue.Count > 0) if (!Deleted && !_entMan.Deleted(Owner) && _currentState == CargoTelepadState.Charging && _teleportQueue.Count > 0)
{ {
_currentState = CargoTelepadState.Teleporting; _currentState = CargoTelepadState.Teleporting;
if (_entMan.TryGetComponent<SpriteComponent?>(Owner, out var spriteComponent) && spriteComponent.LayerCount > 0) if (_entMan.TryGetComponent<SpriteComponent?>(Owner, out var spriteComponent) && spriteComponent.LayerCount > 0)

View File

@@ -70,7 +70,7 @@ namespace Content.Server.Chemistry.Components
protected override void OnKill() protected override void OnKill()
{ {
if ((!_entMan.EntityExists(Owner) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted) if (_entMan.Deleted(Owner))
return; return;
if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance)) if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
{ {

View File

@@ -58,7 +58,7 @@ namespace Content.Server.Chemistry.Components
protected override void OnKill() protected override void OnKill()
{ {
if ((!_entMan.EntityExists(Owner) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted) if (_entMan.Deleted(Owner))
return; return;
_entMan.DeleteEntity(Owner); _entMan.DeleteEntity(Owner);
} }

View File

@@ -132,7 +132,7 @@ namespace Content.Server.Conveyor
//todo uuuhhh cache this //todo uuuhhh cache this
foreach (var entity in _entityLookup.GetEntitiesIntersecting(comp.Owner, flags: LookupFlags.Approximate)) foreach (var entity in _entityLookup.GetEntitiesIntersecting(comp.Owner, flags: LookupFlags.Approximate))
{ {
if ((!EntityManager.EntityExists(entity) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted) if (Deleted(entity))
{ {
continue; continue;
} }

View File

@@ -41,7 +41,7 @@ namespace Content.Server.Engineering.EntitySystems
component.TokenSource.Cancel(); component.TokenSource.Cancel();
} }
if (component.Deleted || (!EntityManager.EntityExists(component.Owner) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(component.Owner).EntityLifeStage) >= EntityLifeStage.Deleted) if (component.Deleted || Deleted(component.Owner))
return; return;
var entity = EntityManager.SpawnEntity(component.Prototype, EntityManager.GetComponent<TransformComponent>(component.Owner).Coordinates); var entity = EntityManager.SpawnEntity(component.Prototype, EntityManager.GetComponent<TransformComponent>(component.Owner).Coordinates);

View File

@@ -57,7 +57,7 @@ namespace Content.Server.Engineering.EntitySystems
return; return;
} }
if (component.Deleted || (!EntityManager.EntityExists(component.Owner) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(component.Owner).EntityLifeStage) >= EntityLifeStage.Deleted) if (component.Deleted || Deleted(component.Owner))
return; return;
if (EntityManager.TryGetComponent<SharedStackComponent?>(component.Owner, out var stackComp) if (EntityManager.TryGetComponent<SharedStackComponent?>(component.Owner, out var stackComp)

View File

@@ -94,7 +94,7 @@ namespace Content.Server.Explosion.Components
return false; return false;
Owner.SpawnTimer((int) (_delay * 1000), () => Owner.SpawnTimer((int) (_delay * 1000), () =>
{ {
if ((!_entMan.EntityExists(Owner) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted) if (_entMan.Deleted(Owner))
return; return;
_countDown = true; _countDown = true;
var random = IoCManager.Resolve<IRobustRandom>(); var random = IoCManager.Resolve<IRobustRandom>();

View File

@@ -130,7 +130,7 @@ namespace Content.Server.Explosion.EntitySystems
// and splitted into two lists based on if they are Impassable or not // and splitted into two lists based on if they are Impassable or not
foreach (var entity in entitiesInRange) foreach (var entity in entitiesInRange)
{ {
if ((!EntityManager.EntityExists(entity) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted || entity.IsInContainer()) if (Deleted(entity) || entity.IsInContainer())
{ {
continue; continue;
} }

View File

@@ -88,11 +88,8 @@ namespace Content.Server.Fluids.Components
_currentlyUsing.Remove(eventArgs.Using); _currentlyUsing.Remove(eventArgs.Using);
if (result == DoAfterStatus.Cancelled || if (result == DoAfterStatus.Cancelled || _entMan.Deleted(Owner) || mopComponent.Deleted ||
(!_entMan.EntityExists(Owner) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted || CurrentVolume <= 0 || !Owner.InRangeUnobstructed(mopComponent.Owner))
mopComponent.Deleted ||
CurrentVolume <= 0 ||
!Owner.InRangeUnobstructed(mopComponent.Owner))
return false; return false;
// Top up mops solution given it needs it to annihilate puddles I guess // Top up mops solution given it needs it to annihilate puddles I guess

View File

@@ -130,7 +130,7 @@ namespace Content.Server.Fluids.Components
Mopping = false; Mopping = false;
if (result == DoAfterStatus.Cancelled || if (result == DoAfterStatus.Cancelled ||
(!_entities.EntityExists(Owner) ? EntityLifeStage.Deleted : _entities.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted || _entities.Deleted(Owner) ||
puddleComponent.Deleted) puddleComponent.Deleted)
return false; return false;

View File

@@ -57,7 +57,7 @@ namespace Content.Server.Fluids.EntitySystems
private void UpdateVisuals(EntityUid uid, PuddleComponent puddleComponent) private void UpdateVisuals(EntityUid uid, PuddleComponent puddleComponent)
{ {
if ((!EntityManager.EntityExists(puddleComponent.Owner) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(puddleComponent.Owner).EntityLifeStage) >= EntityLifeStage.Deleted || EmptyHolder(uid, puddleComponent) || if (Deleted(puddleComponent.Owner) || EmptyHolder(uid, puddleComponent) ||
!EntityManager.TryGetComponent<AppearanceComponent>(uid, out var appearanceComponent)) !EntityManager.TryGetComponent<AppearanceComponent>(uid, out var appearanceComponent))
{ {
return; return;

View File

@@ -75,7 +75,7 @@ namespace Content.Server.Ghost
private void OnGhostShutdown(EntityUid uid, GhostComponent component, ComponentShutdown args) private void OnGhostShutdown(EntityUid uid, GhostComponent component, ComponentShutdown args)
{ {
// Perf: If the entity is deleting itself, no reason to change these back. // Perf: If the entity is deleting itself, no reason to change these back.
if ((!EntityManager.EntityExists(component.Owner) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(component.Owner).EntityLifeStage) < EntityLifeStage.Terminating) if (!Terminating(uid))
{ {
// Entity can't be seen by ghosts anymore. // Entity can't be seen by ghosts anymore.
if (EntityManager.TryGetComponent(component.Owner, out VisibilityComponent? visibility)) if (EntityManager.TryGetComponent(component.Owner, out VisibilityComponent? visibility))
@@ -176,9 +176,7 @@ namespace Content.Server.Ghost
private void DeleteEntity(EntityUid uid) private void DeleteEntity(EntityUid uid)
{ {
if (!EntityManager.EntityExists(uid) if (Deleted(uid) || Terminating(uid))
|| (!EntityManager.EntityExists(uid) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(uid).EntityLifeStage) >= EntityLifeStage.Deleted
|| (!EntityManager.EntityExists(uid) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(uid).EntityLifeStage) == EntityLifeStage.Terminating)
return; return;
if (EntityManager.TryGetComponent<MindComponent?>(uid, out var mind)) if (EntityManager.TryGetComponent<MindComponent?>(uid, out var mind))

View File

@@ -16,7 +16,7 @@ namespace Content.Server.Inventory
var user = inventory.Owner; var user = inventory.Owner;
// Let's do nothing if the owner of the inventory has been deleted. // Let's do nothing if the owner of the inventory has been deleted.
if ((!entityManager.EntityExists(user) ? EntityLifeStage.Deleted : entityManager.GetComponent<MetaDataComponent>(user).EntityLifeStage) >= EntityLifeStage.Deleted) if (entityManager.Deleted(user))
return false; return false;
// If we don't have that slot or there's already an item there, we do nothing. // If we don't have that slot or there's already an item there, we do nothing.

View File

@@ -106,7 +106,7 @@ namespace Content.Server.Morgue.Components
_cremateCancelToken = new CancellationTokenSource(); _cremateCancelToken = new CancellationTokenSource();
Owner.SpawnTimer(_burnMilis, () => Owner.SpawnTimer(_burnMilis, () =>
{ {
if ((!_entities.EntityExists(Owner) ? EntityLifeStage.Deleted : _entities.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted) if (_entities.Deleted(Owner))
return; return;
Appearance?.SetData(CrematoriumVisuals.Burning, false); Appearance?.SetData(CrematoriumVisuals.Burning, false);

View File

@@ -16,7 +16,9 @@ namespace Content.Server.Morgue.Components
void IActivate.Activate(ActivateEventArgs eventArgs) void IActivate.Activate(ActivateEventArgs eventArgs)
{ {
if (Morgue != null && !((!IoCManager.Resolve<IEntityManager>().EntityExists(Morgue) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Morgue).EntityLifeStage) >= EntityLifeStage.Deleted) && IoCManager.Resolve<IEntityManager>().TryGetComponent<MorgueEntityStorageComponent?>(Morgue, out var comp)) var entMan = IoCManager.Resolve<IEntityManager>();
if (Morgue != default && !entMan.Deleted(Morgue) && entMan.TryGetComponent<MorgueEntityStorageComponent?>(Morgue, out var comp))
{ {
comp.Activate(new ActivateEventArgs(eventArgs.User, Morgue)); comp.Activate(new ActivateEventArgs(eventArgs.User, Morgue));
} }

View File

@@ -219,7 +219,7 @@ namespace Content.Server.PneumaticCannon
if (!EntityManager.TryGetComponent<ServerStorageComponent?>(comp.Owner, out var storage)) if (!EntityManager.TryGetComponent<ServerStorageComponent?>(comp.Owner, out var storage))
return; return;
if ((!EntityManager.EntityExists(data.User) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(data.User).EntityLifeStage) >= EntityLifeStage.Deleted) if (Deleted(data.User))
return; return;
if (storage.StoredEntities == null) return; if (storage.StoredEntities == null) return;
@@ -243,7 +243,7 @@ namespace Content.Server.PneumaticCannon
&& comp.Power == PneumaticCannonPower.High) && comp.Power == PneumaticCannonPower.High)
{ {
_stun.TryParalyze(data.User, TimeSpan.FromSeconds(comp.HighPowerStunTime), true, status); _stun.TryParalyze(data.User, TimeSpan.FromSeconds(comp.HighPowerStunTime), true, status);
data.User.PopupMessage(Loc.GetString("pneumatic-cannon-component-power-stun", data.User.PopupMessage(Loc.GetString("pneumatic-cannon-component-power-stun",
("cannon", comp.Owner))); ("cannon", comp.Owner)));
} }

View File

@@ -97,7 +97,7 @@ namespace Content.Server.Projectiles.Components
Owner.SpawnTimer((int) _deathTime.TotalMilliseconds, () => Owner.SpawnTimer((int) _deathTime.TotalMilliseconds, () =>
{ {
if (!((!_entMan.EntityExists(Owner) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted)) if (!_entMan.Deleted(Owner))
{ {
_entMan.DeleteEntity(Owner); _entMan.DeleteEntity(Owner);
} }

View File

@@ -108,7 +108,7 @@ namespace Content.Server.Radiation
public void Update(float frameTime) public void Update(float frameTime)
{ {
if (!Decay || (!_entMan.EntityExists(Owner) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted) if (!Decay || _entMan.Deleted(Owner))
return; return;
if (_duration <= 0f) if (_duration <= 0f)

View File

@@ -34,7 +34,7 @@ namespace Content.Server.Radiation
comp.Update(RadiationCooldown); comp.Update(RadiationCooldown);
var ent = comp.Owner; var ent = comp.Owner;
if ((!_entMan.EntityExists(ent) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(ent).EntityLifeStage) >= EntityLifeStage.Deleted) continue; if (Deleted(ent)) continue;
foreach (var entity in _lookup.GetEntitiesInRange(_entMan.GetComponent<TransformComponent>(ent).Coordinates, comp.Range)) foreach (var entity in _lookup.GetEntitiesInRange(_entMan.GetComponent<TransformComponent>(ent).Coordinates, comp.Range))
{ {

View File

@@ -48,7 +48,7 @@ namespace Content.Server.Spawners.Components
return; return;
} }
if(!((!_entMan.EntityExists(Owner) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted)) if(!_entMan.Deleted(Owner))
{ {
var random = IoCManager.Resolve<IRobustRandom>(); var random = IoCManager.Resolve<IRobustRandom>();

View File

@@ -121,7 +121,7 @@ namespace Content.Server.StationEvents.Events
if (!_foundTile || if (!_foundTile ||
_targetGrid == default || _targetGrid == default ||
(!_entityManager.EntityExists(_targetGrid) ? EntityLifeStage.Deleted : _entityManager.GetComponent<MetaDataComponent>(_targetGrid).EntityLifeStage) >= EntityLifeStage.Deleted || _entityManager.Deleted(_targetGrid) ||
!atmosphereSystem.IsSimulatedGrid(_entityManager.GetComponent<TransformComponent>(_targetGrid).GridID)) !atmosphereSystem.IsSimulatedGrid(_entityManager.GetComponent<TransformComponent>(_targetGrid).GridID))
{ {
Running = false; Running = false;

View File

@@ -260,7 +260,7 @@ namespace Content.Server.Weapon.Melee
var hitBloodstreams = new List<BloodstreamComponent>(); var hitBloodstreams = new List<BloodstreamComponent>();
foreach (var entity in args.HitEntities) foreach (var entity in args.HitEntities)
{ {
if ((!EntityManager.EntityExists(entity) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted) if (Deleted(entity))
continue; continue;
if (EntityManager.TryGetComponent<BloodstreamComponent?>(entity, out var bloodstream)) if (EntityManager.TryGetComponent<BloodstreamComponent?>(entity, out var bloodstream))

View File

@@ -61,7 +61,7 @@ namespace Content.Shared.Pulling
RaiseLocalEvent(puller.Owner, message, broadcast: false); RaiseLocalEvent(puller.Owner, message, broadcast: false);
if ((!EntityManager.EntityExists(pullable.Owner) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(pullable.Owner).EntityLifeStage) <= EntityLifeStage.MapInitialized) if (Initialized(pullable.Owner))
RaiseLocalEvent(pullable.Owner, message); RaiseLocalEvent(pullable.Owner, message);
// Networking // Networking

View File

@@ -164,7 +164,7 @@ namespace Content.Shared.Pulling
// The pulled object may have already been deleted. // The pulled object may have already been deleted.
// TODO: Work out why. Monkey + meat spike is a good test for this, // TODO: Work out why. Monkey + meat spike is a good test for this,
// assuming you're still pulling the monkey when it gets gibbed. // assuming you're still pulling the monkey when it gets gibbed.
if ((!EntityManager.EntityExists(pulled.Value) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(pulled.Value).EntityLifeStage) >= EntityLifeStage.Deleted) if (Deleted(pulled.Value))
{ {
return; return;
} }

View File

@@ -114,7 +114,7 @@ namespace Content.Shared.Throwing
public void LandComponent(ThrownItemComponent thrownItem) public void LandComponent(ThrownItemComponent thrownItem)
{ {
if (thrownItem.Deleted || (!EntityManager.EntityExists(thrownItem.Owner) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(thrownItem.Owner).EntityLifeStage) >= EntityLifeStage.Deleted || _containerSystem.IsEntityInContainer(thrownItem.Owner)) return; if (thrownItem.Deleted || Deleted(thrownItem.Owner) || _containerSystem.IsEntityInContainer(thrownItem.Owner)) return;
var landing = thrownItem.Owner; var landing = thrownItem.Owner;