Inline LifeStage

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 11:13:18 +01:00
parent 5e177ae734
commit cd43196ea8
3 changed files with 5 additions and 4 deletions

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 (component.Owner.LifeStage < EntityLifeStage.Terminating) if ((!IoCManager.Resolve<IEntityManager>().EntityExists(component.Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(component.Owner.Uid).EntityLifeStage) < EntityLifeStage.Terminating)
{ {
// Entity can't be seen by ghosts anymore. // Entity can't be seen by ghosts anymore.
if (component.Owner.TryGetComponent(out VisibilityComponent? visibility)) if (component.Owner.TryGetComponent(out VisibilityComponent? visibility))
@@ -182,7 +182,7 @@ namespace Content.Server.Ghost
{ {
if (!EntityManager.TryGetEntity(uid, out var entity) if (!EntityManager.TryGetEntity(uid, out var entity)
|| entity.Deleted || entity.Deleted
|| entity.LifeStage == EntityLifeStage.Terminating) || (!IoCManager.Resolve<IEntityManager>().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityLifeStage) == EntityLifeStage.Terminating)
return; return;
if (entity.TryGetComponent<MindComponent>(out var mind)) if (entity.TryGetComponent<MindComponent>(out var mind))

View File

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

View File

@@ -79,7 +79,8 @@ namespace Content.Shared.SubFloor
private void OnSubFloorTerminating(EntityUid uid, SubFloorHideComponent component, ComponentShutdown _) private void OnSubFloorTerminating(EntityUid uid, SubFloorHideComponent component, ComponentShutdown _)
{ {
// If component is being deleted don't need to worry about updating any component stuff because it won't matter very shortly. // If component is being deleted don't need to worry about updating any component stuff because it won't matter very shortly.
if (EntityManager.GetEntity(uid).LifeStage >= EntityLifeStage.Terminating) return; IEntity tempQualifier = EntityManager.GetEntity(uid);
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(tempQualifier.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(tempQualifier.Uid).EntityLifeStage) >= EntityLifeStage.Terminating) return;
// Regardless of whether we're on a subfloor or not, unhide. // Regardless of whether we're on a subfloor or not, unhide.
UpdateEntity(uid, true); UpdateEntity(uid, true);