Add priority sorting to InteractUsing

This commit is contained in:
juliangiebel
2020-08-12 23:01:30 +02:00
parent f0e9729508
commit ba058ccbdd
2 changed files with 8 additions and 1 deletions

View File

@@ -446,7 +446,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
return;
}
var attackBys = attacked.GetAllComponents<IInteractUsing>().ToList();
var attackBys = attacked.GetAllComponents<IInteractUsing>().OrderByDescending(x => x.Priority);
var attackByEventArgs = new InteractUsingEventArgs
{
User = user, ClickLocation = clickLocation, Using = weapon, Target = attacked

View File

@@ -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
/// </summary>
public interface IInteractUsing
{
/// <summary>
/// The interaction Priority. Higher numbers get called first.
/// </summary>
/// <value>Prority defaults to 0</value>
int Priority { get => 0; }
/// <summary>
/// Called when using one object on another when user is in range of the target entity.
/// </summary>