Fix more errors

This commit is contained in:
DrSmugleaf
2021-12-06 00:52:58 +01:00
parent 2b1fecbe02
commit 215cae5655
55 changed files with 262 additions and 297 deletions

View File

@@ -84,8 +84,7 @@ namespace Content.Server.Mind.Components
if (HasMind)
{
var visiting = Mind?.VisitingEntity;
if (visiting != null)
if (Mind?.VisitingEntity is {Valid: true} visiting)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(visiting, out GhostComponent? ghost))
{

View File

@@ -263,25 +263,25 @@ namespace Content.Server.Mind
/// <exception cref="ArgumentException">
/// Thrown if <paramref name="entity"/> is already owned by another mind.
/// </exception>
public void TransferTo(EntityUid entity = default, bool ghostCheckOverride = false)
public void TransferTo(EntityUid? entity, bool ghostCheckOverride = false)
{
var entMan = IoCManager.Resolve<IEntityManager>();
MindComponent? component = null;
var alreadyAttached = false;
if (entity != default)
if (entity != null)
{
if (!entMan.TryGetComponent<MindComponent>(entity, out component))
if (!entMan.TryGetComponent<MindComponent>(entity.Value, out component))
{
component = entMan.AddComponent<MindComponent>(entity);
component = entMan.AddComponent<MindComponent>(entity.Value);
}
else if (component!.HasMind)
{
EntitySystem.Get<GameTicker>().OnGhostAttempt(component.Mind!, false);
}
if (entMan.TryGetComponent<ActorComponent>(entity, out var actor))
if (entMan.TryGetComponent<ActorComponent>(entity.Value, out var actor))
{
// Happens when transferring to your currently visited entity.
if (actor.PlayerSession != Session)