From ba058ccbddeb792ea4e532b8bf13af7fec726aaa Mon Sep 17 00:00:00 2001 From: juliangiebel Date: Wed, 12 Aug 2020 23:01:30 +0200 Subject: [PATCH 1/6] Add priority sorting to `InteractUsing` --- .../GameObjects/EntitySystems/Click/InteractionSystem.cs | 2 +- .../GameObjects/Components/Interaction/IInteractUsing.cs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index 478f0123d2..fd73d86a3a 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -446,7 +446,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click return; } - var attackBys = attacked.GetAllComponents().ToList(); + var attackBys = attacked.GetAllComponents().OrderByDescending(x => x.Priority); var attackByEventArgs = new InteractUsingEventArgs { User = user, ClickLocation = clickLocation, Using = weapon, Target = attacked diff --git a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs index 79890756a0..1589b00493 100644 --- a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs +++ b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; @@ -12,6 +13,12 @@ namespace Content.Shared.Interfaces.GameObjects.Components /// public interface IInteractUsing { + /// + /// The interaction Priority. Higher numbers get called first. + /// + /// Prority defaults to 0 + int Priority { get => 0; } + /// /// Called when using one object on another when user is in range of the target entity. /// From 3b894c7de4bd9f5360999ea6fb47cb6e2fa5dd84 Mon Sep 17 00:00:00 2001 From: juliangiebel Date: Wed, 12 Aug 2020 23:41:09 +0200 Subject: [PATCH 2/6] Add higher interaction priority to --- Content.Server/GameObjects/Components/AnchorableComponent.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Content.Server/GameObjects/Components/AnchorableComponent.cs b/Content.Server/GameObjects/Components/AnchorableComponent.cs index 6ad088bdbe..5ab4989660 100644 --- a/Content.Server/GameObjects/Components/AnchorableComponent.cs +++ b/Content.Server/GameObjects/Components/AnchorableComponent.cs @@ -14,6 +14,8 @@ namespace Content.Server.GameObjects.Components { public override string Name => "Anchorable"; + int IInteractUsing.Priority { get => 1; } + /// /// Checks if a tool can change the anchored status. /// From a41e2d100208b7ff32f15ae98ce194ba3febb945 Mon Sep 17 00:00:00 2001 From: Julian Giebel Date: Thu, 13 Aug 2020 09:54:27 +0200 Subject: [PATCH 3/6] Fix typos in doc comment --- .../GameObjects/Components/Interaction/IInteractUsing.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs index 1589b00493..f036e91314 100644 --- a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs +++ b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs @@ -14,9 +14,9 @@ namespace Content.Shared.Interfaces.GameObjects.Components public interface IInteractUsing { /// - /// The interaction Priority. Higher numbers get called first. + /// The interaction priority. Higher numbers get called first. /// - /// Prority defaults to 0 + /// Priority defaults to 0 int Priority { get => 0; } /// From 781faae98a5bb1609b50991a547f008f8a428b02 Mon Sep 17 00:00:00 2001 From: juliangiebel Date: Thu, 13 Aug 2020 20:14:07 +0200 Subject: [PATCH 4/6] Set interaction priority of PlacableSurfaceComponent to 1 --- .../GameObjects/Components/PlaceableSurfaceComponent.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/PlaceableSurfaceComponent.cs b/Content.Server/GameObjects/Components/PlaceableSurfaceComponent.cs index 3ac23365fe..34e41ed1a9 100644 --- a/Content.Server/GameObjects/Components/PlaceableSurfaceComponent.cs +++ b/Content.Server/GameObjects/Components/PlaceableSurfaceComponent.cs @@ -1,4 +1,4 @@ -using Content.Server.GameObjects.Components.GUI; +using Content.Server.GameObjects.Components.GUI; using Content.Shared.GameObjects.Components; using Content.Shared.Interfaces.GameObjects.Components; using Robust.Shared.GameObjects; @@ -12,6 +12,8 @@ namespace Content.Server.GameObjects.Components private bool _isPlaceable; public bool IsPlaceable { get => _isPlaceable; set => _isPlaceable = value; } + int IInteractUsing.Priority { get => 1; } + public override void ExposeData(ObjectSerializer serializer) { base.ExposeData(serializer); From 43606b061703b92cbc94000d53d91b6ebdd2794e Mon Sep 17 00:00:00 2001 From: Julian Giebel Date: Sun, 16 Aug 2020 14:58:36 +0200 Subject: [PATCH 5/6] Change formating --- Content.Server/GameObjects/Components/AnchorableComponent.cs | 2 +- .../GameObjects/Components/PlaceableSurfaceComponent.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/GameObjects/Components/AnchorableComponent.cs b/Content.Server/GameObjects/Components/AnchorableComponent.cs index 5ab4989660..b1d07fbc60 100644 --- a/Content.Server/GameObjects/Components/AnchorableComponent.cs +++ b/Content.Server/GameObjects/Components/AnchorableComponent.cs @@ -14,7 +14,7 @@ namespace Content.Server.GameObjects.Components { public override string Name => "Anchorable"; - int IInteractUsing.Priority { get => 1; } + int IInteractUsing.Priority => 1; /// /// Checks if a tool can change the anchored status. diff --git a/Content.Server/GameObjects/Components/PlaceableSurfaceComponent.cs b/Content.Server/GameObjects/Components/PlaceableSurfaceComponent.cs index 34e41ed1a9..54469fb856 100644 --- a/Content.Server/GameObjects/Components/PlaceableSurfaceComponent.cs +++ b/Content.Server/GameObjects/Components/PlaceableSurfaceComponent.cs @@ -12,7 +12,7 @@ namespace Content.Server.GameObjects.Components private bool _isPlaceable; public bool IsPlaceable { get => _isPlaceable; set => _isPlaceable = value; } - int IInteractUsing.Priority { get => 1; } + int IInteractUsing.Priority => 1; public override void ExposeData(ObjectSerializer serializer) { From 2c853ea5723c3a68d5eb696e8707973c6530c5df Mon Sep 17 00:00:00 2001 From: Julian Giebel Date: Sun, 16 Aug 2020 17:45:15 +0200 Subject: [PATCH 6/6] Update IInteractUsing.cs --- .../GameObjects/Components/Interaction/IInteractUsing.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs index f036e91314..21c0dacedb 100644 --- a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs +++ b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs @@ -17,7 +17,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components /// The interaction priority. Higher numbers get called first. /// /// Priority defaults to 0 - int Priority { get => 0; } + int Priority => 0; /// /// Called when using one object on another when user is in range of the target entity.