Inline IsValid

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 11:32:53 +01:00
parent 1b13e5e0ec
commit 2d130e31d6
8 changed files with 17 additions and 11 deletions

View File

@@ -146,7 +146,13 @@ namespace Content.Client.DoAfter.UI
{ {
base.FrameUpdate(args); base.FrameUpdate(args);
if (AttachedEntity?.IsValid() != true || IEntity? tempQualifier = AttachedEntity;
if (tempQualifier != null)
{
IoCManager.Resolve<IEntityManager>().EntityExists(tempQualifier.Uid);
}
if (RETURNED_VALUE != true ||
!AttachedEntity.TryGetComponent(out DoAfterComponent? doAfterComponent)) !AttachedEntity.TryGetComponent(out DoAfterComponent? doAfterComponent))
{ {
Visible = false; Visible = false;

View File

@@ -51,7 +51,7 @@ namespace Content.Client.IconSmoothing
// Yes, we updates ALL smoothing entities surrounding us even if they would never smooth with us. // Yes, we updates ALL smoothing entities surrounding us even if they would never smooth with us.
// This is simpler to implement. If you want to optimize it be my guest. // This is simpler to implement. If you want to optimize it be my guest.
var senderEnt = ev.Sender; var senderEnt = ev.Sender;
if (senderEnt.IsValid() && if (IoCManager.Resolve<IEntityManager>().EntityExists(senderEnt.Uid) &&
_mapManager.TryGetGrid(senderEnt.Transform.GridID, out var grid1) && _mapManager.TryGetGrid(senderEnt.Transform.GridID, out var grid1) &&
senderEnt.TryGetComponent(out IconSmoothComponent? iconSmooth) senderEnt.TryGetComponent(out IconSmoothComponent? iconSmooth)
&& iconSmooth.Running) && iconSmooth.Running)

View File

@@ -98,7 +98,7 @@ namespace Content.IntegrationTests.Tests
server.Assert(() => server.Assert(() =>
{ {
Assert.That(mind.CurrentEntity.IsValid(), Is.True); Assert.That(IoCManager.Resolve<IEntityManager>().EntityExists(mind.CurrentEntity.Uid), Is.True);
}); });
await server.WaitIdleAsync(); await server.WaitIdleAsync();
@@ -149,7 +149,7 @@ namespace Content.IntegrationTests.Tests
server.Assert(() => server.Assert(() =>
{ {
Assert.That(mind.CurrentEntity.IsValid(), Is.True); Assert.That(IoCManager.Resolve<IEntityManager>().EntityExists(mind.CurrentEntity.Uid), Is.True);
Assert.That(mind.CurrentEntity, Is.Not.EqualTo(playerEnt)); Assert.That(mind.CurrentEntity, Is.Not.EqualTo(playerEnt));
}); });

View File

@@ -201,7 +201,7 @@ namespace Content.Server.Cargo.Components
private void UpdateUIState() private void UpdateUIState()
{ {
if (_bankAccount == null || !Owner.IsValid()) if (_bankAccount == null || !IoCManager.Resolve<IEntityManager>().EntityExists(Owner.Uid))
{ {
return; return;
} }

View File

@@ -191,7 +191,7 @@ namespace Content.Server.Hands.Systems
var playerEnt = playerSession.AttachedEntity; var playerEnt = playerSession.AttachedEntity;
if (playerEnt == null || !playerEnt.IsValid()) if (playerEnt == null || !IoCManager.Resolve<IEntityManager>().EntityExists(playerEnt.Uid))
return false; return false;
return playerEnt.TryGetComponent(out hands); return playerEnt.TryGetComponent(out hands);
@@ -221,7 +221,7 @@ namespace Content.Server.Hands.Systems
var playerEnt = playerSession.AttachedEntity; var playerEnt = playerSession.AttachedEntity;
if (playerEnt == null || if (playerEnt == null ||
!playerEnt.IsValid() || !IoCManager.Resolve<IEntityManager>().EntityExists(playerEnt.Uid) ||
playerEnt.IsInContainer() || playerEnt.IsInContainer() ||
!playerEnt.TryGetComponent(out SharedHandsComponent? hands) || !playerEnt.TryGetComponent(out SharedHandsComponent? hands) ||
!hands.TryGetActiveHeldEntity(out var throwEnt) || !hands.TryGetActiveHeldEntity(out var throwEnt) ||
@@ -269,7 +269,7 @@ namespace Content.Server.Hands.Systems
var plyEnt = playerSession.AttachedEntity; var plyEnt = playerSession.AttachedEntity;
if (plyEnt == null || !plyEnt.IsValid()) if (plyEnt == null || !IoCManager.Resolve<IEntityManager>().EntityExists(plyEnt.Uid))
return; return;
if (!plyEnt.TryGetComponent(out SharedHandsComponent? hands) || if (!plyEnt.TryGetComponent(out SharedHandsComponent? hands) ||

View File

@@ -90,7 +90,7 @@ namespace Content.Server.Interaction
userEntity = ((IPlayerSession?) session)?.AttachedEntity; userEntity = ((IPlayerSession?) session)?.AttachedEntity;
if (userEntity == null || !userEntity.IsValid()) if (userEntity == null || !IoCManager.Resolve<IEntityManager>().EntityExists(userEntity.Uid))
{ {
Logger.WarningS("system.interaction", Logger.WarningS("system.interaction",
$"Client sent interaction with no attached entity. Session={session}"); $"Client sent interaction with no attached entity. Session={session}");

View File

@@ -151,7 +151,7 @@ namespace Content.Server.Storage.EntitySystems
var attachedEntity = session.AttachedEntity; var attachedEntity = session.AttachedEntity;
// The component manages the set of sessions, so this invalid session should be removed soon. // The component manages the set of sessions, so this invalid session should be removed soon.
if (attachedEntity == null || !attachedEntity.IsValid()) if (attachedEntity == null || !IoCManager.Resolve<IEntityManager>().EntityExists(attachedEntity.Uid))
continue; continue;
if (storageMap != attachedEntity.Transform.MapID) if (storageMap != attachedEntity.Transform.MapID)

View File

@@ -82,7 +82,7 @@ namespace Content.Shared.Movement.EntitySystems
var ent = session?.AttachedEntity; var ent = session?.AttachedEntity;
if (ent == null || !ent.IsValid()) if (ent == null || !IoCManager.Resolve<IEntityManager>().EntityExists(ent.Uid))
return false; return false;
if (!ent.TryGetComponent(out T? comp)) if (!ent.TryGetComponent(out T? comp))