From 8d4799e6116a5d408ff457aeae0a23dead66b55c Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Mon, 6 Dec 2021 16:40:04 +0100 Subject: [PATCH] Fixes some integration tests --- Content.Client/Actions/UI/ActionSlot.cs | 10 +++++----- .../Components/Mobs/ActionsComponentTests.cs | 4 ++-- Content.Server/Interaction/InteractionSystem.cs | 3 ++- Content.Server/Mind/Mind.cs | 14 +++++++------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Content.Client/Actions/UI/ActionSlot.cs b/Content.Client/Actions/UI/ActionSlot.cs index f363c1f067..b6fc2bb2c4 100644 --- a/Content.Client/Actions/UI/ActionSlot.cs +++ b/Content.Client/Actions/UI/ActionSlot.cs @@ -62,7 +62,7 @@ namespace Content.Client.Actions.UI /// Item the action is provided by, only valid if Action is an ItemActionPrototype. May be null /// if the item action is not yet tied to an item. /// - public EntityUid Item { get; private set; } + public EntityUid? Item { get; private set; } /// /// Whether the action in this slot should be shown as toggled on. Separate from Depressed. @@ -231,8 +231,8 @@ namespace Content.Client.Actions.UI { ActionPrototype actionPrototype => new ActionAttempt(actionPrototype), ItemActionPrototype itemActionPrototype => - (Item != default && IoCManager.Resolve().TryGetComponent(Item, out var itemActions)) ? - new ItemActionAttempt(itemActionPrototype, Item, itemActions) : null, + (Item != null && IoCManager.Resolve().TryGetComponent(Item, out var itemActions)) ? + new ItemActionAttempt(itemActionPrototype, Item.Value, itemActions) : null, _ => null }; return attempt; @@ -245,8 +245,8 @@ namespace Content.Client.Actions.UI _beingHovered = true; DrawModeChanged(); if (Action is not ItemActionPrototype) return; - if (Item == default) return; - _actionsComponent.HighlightItemSlot(Item); + if (Item == null) return; + _actionsComponent.HighlightItemSlot(Item.Value); } protected override void MouseExited() diff --git a/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs b/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs index fe7614d904..8afc0d2820 100644 --- a/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs +++ b/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs @@ -66,9 +66,9 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs await server.WaitIdleAsync(); await client.WaitIdleAsync(); - var cEntities = IoCManager.Resolve(); + var cEntities = client.ResolveDependency(); - var sEntities = IoCManager.Resolve(); + var sEntities = server.ResolveDependency(); var serverPlayerManager = server.ResolveDependency(); var innateActions = new List(); diff --git a/Content.Server/Interaction/InteractionSystem.cs b/Content.Server/Interaction/InteractionSystem.cs index 8237cb3435..11c4e4071f 100644 --- a/Content.Server/Interaction/InteractionSystem.cs +++ b/Content.Server/Interaction/InteractionSystem.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Content.Server.Administration.Logs; using Content.Server.CombatMode; using Content.Server.Hands.Components; +using Content.Server.Items; using Content.Server.Pulling; using Content.Server.Storage.Components; using Content.Shared.ActionBlocker; @@ -507,7 +508,7 @@ namespace Content.Server.Interaction } } } - else if (!wideAttack && targetUid != default) + else if (!wideAttack && targetUid != default && _entityManager.HasComponent(targetUid)) { // We pick up items if our hand is empty, even if we're in combat mode. InteractHand(user, targetUid); diff --git a/Content.Server/Mind/Mind.cs b/Content.Server/Mind/Mind.cs index e2981f8bcb..22fb9ea7e9 100644 --- a/Content.Server/Mind/Mind.cs +++ b/Content.Server/Mind/Mind.cs @@ -62,12 +62,12 @@ namespace Content.Server.Mind public NetUserId OriginalOwnerUserId { get; } [ViewVariables] - public bool IsVisitingEntity => VisitingEntity != default; + public bool IsVisitingEntity => VisitingEntity != null; [ViewVariables] - public EntityUid VisitingEntity { get; private set; } + public EntityUid? VisitingEntity { get; private set; } - [ViewVariables] public EntityUid? CurrentEntity => VisitingEntity.IsValid() ? VisitingEntity : OwnedEntity; + [ViewVariables] public EntityUid? CurrentEntity => VisitingEntity ?? OwnedEntity; [ViewVariables(VVAccess.ReadWrite)] public string? CharacterName { get; set; } @@ -296,7 +296,7 @@ namespace Content.Server.Mind OwnedComponent = component; OwnedComponent?.InternalAssignMind(this); - if (IsVisitingEntity + if (VisitingEntity != null && (ghostCheckOverride // to force mind transfer, for example from ControlMobVerb || !entMan.TryGetComponent(VisitingEntity!, out GhostComponent? ghostComponent) // visiting entity is not a Ghost || !ghostComponent.CanReturnToBody)) // it is a ghost, but cannot return to body anyway, so it's okay @@ -367,20 +367,20 @@ namespace Content.Server.Mind public void UnVisit() { - if (!IsVisitingEntity) + if (VisitingEntity == null) { return; } Session?.AttachToEntity(OwnedEntity); - var oldVisitingEnt = VisitingEntity; + var oldVisitingEnt = VisitingEntity.Value; // Null this before removing the component to avoid any infinite loops. VisitingEntity = default; DebugTools.AssertNotNull(oldVisitingEnt); var entities = IoCManager.Resolve(); - if (entities.HasComponent(oldVisitingEnt!)) + if (entities.HasComponent(oldVisitingEnt)) { entities.RemoveComponent(oldVisitingEnt); }