Enable nullability in Content.Server (#3685)

This commit is contained in:
DrSmugleaf
2021-03-16 15:50:20 +01:00
committed by GitHub
parent 90fec0ed24
commit a5ade526b7
306 changed files with 1616 additions and 1441 deletions

View File

@@ -7,6 +7,7 @@ using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Utility;
namespace Content.Server.Administration.Commands
{
@@ -33,7 +34,6 @@ namespace Content.Server.Administration.Commands
}
var mind = player.ContentData().Mind;
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!int.TryParse(args[0], out var targetId))
@@ -51,20 +51,25 @@ namespace Content.Server.Administration.Commands
}
var target = entityManager.GetEntity(eUid);
if (!target.TryGetComponent(out MindComponent mindComponent))
if (!target.TryGetComponent(out MindComponent? mindComponent))
{
shell.WriteLine(Loc.GetString("Target entity is not a mob!"));
return;
}
var oldEntity = mind.CurrentEntity;
var mind = player.ContentData()?.Mind;
DebugTools.AssertNotNull(mind);
var oldEntity = mind!.CurrentEntity;
mindComponent.Mind?.TransferTo(null);
mind.TransferTo(target);
if(oldEntity.HasComponent<GhostComponent>())
oldEntity.Delete();
DebugTools.AssertNotNull(oldEntity);
if (oldEntity!.HasComponent<GhostComponent>())
oldEntity.Delete();
}
}
}