Replace VerbTypes with verb classes (#6525)

This commit is contained in:
Leon Friedrich
2022-02-10 15:30:59 +13:00
committed by GitHub
parent 0cd2c2fa9d
commit 1c9ffdc78c
60 changed files with 409 additions and 405 deletions

View File

@@ -16,10 +16,10 @@ namespace Content.Client.Verbs
public override void Initialize() public override void Initialize()
{ {
SubscribeLocalEvent<GetOtherVerbsEvent>(AddAdminVerbs); SubscribeLocalEvent<GetVerbsEvent<Verb>>(AddAdminVerbs);
} }
private void AddAdminVerbs(GetOtherVerbsEvent args) private void AddAdminVerbs(GetVerbsEvent<Verb> args)
{ {
// Currently this is only the ViewVariables verb, but more admin-UI related verbs can be added here. // Currently this is only the ViewVariables verb, but more admin-UI related verbs can be added here.

View File

@@ -41,7 +41,7 @@ namespace Content.Client.Examine
{ {
UpdatesOutsidePrediction = true; UpdatesOutsidePrediction = true;
SubscribeLocalEvent<GetOtherVerbsEvent>(AddExamineVerb); SubscribeLocalEvent<GetVerbsEvent<Verb>>(AddExamineVerb);
CommandBinds.Builder CommandBinds.Builder
.Bind(ContentKeyFunctions.ExamineEntity, new PointerInputCmdHandler(HandleExamine, outsidePrediction: true)) .Bind(ContentKeyFunctions.ExamineEntity, new PointerInputCmdHandler(HandleExamine, outsidePrediction: true))
@@ -90,7 +90,7 @@ namespace Content.Client.Examine
return true; return true;
} }
private void AddExamineVerb(GetOtherVerbsEvent args) private void AddExamineVerb(GetVerbsEvent<Verb> args)
{ {
if (!CanExamine(args.User, args.Target)) if (!CanExamine(args.User, args.Target))
return; return;

View File

@@ -7,6 +7,7 @@ using Content.Client.Resources;
using Content.Client.Targeting; using Content.Client.Targeting;
using Content.Client.UserInterface.Controls; using Content.Client.UserInterface.Controls;
using Content.Client.Verbs.UI; using Content.Client.Verbs.UI;
using Content.Shared.Verbs;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.ResourceManagement; using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
@@ -615,16 +616,16 @@ namespace Content.Client.Stylesheets
.Prop(Control.StylePropertyModulateSelf, ButtonColorContextDisabled), .Prop(Control.StylePropertyModulateSelf, ButtonColorContextDisabled),
// Context Menu Labels // Context Menu Labels
Element<RichTextLabel>().Class(VerbMenuElement.StyleClassVerbInteractionText) Element<RichTextLabel>().Class(InteractionVerb.DefaultTextStyleClass)
.Prop(Label.StylePropertyFont, notoSansBoldItalic12), .Prop(Label.StylePropertyFont, notoSansBoldItalic12),
Element<RichTextLabel>().Class(VerbMenuElement.StyleClassVerbActivationText) Element<RichTextLabel>().Class(ActivationVerb.DefaultTextStyleClass)
.Prop(Label.StylePropertyFont, notoSansBold12), .Prop(Label.StylePropertyFont, notoSansBold12),
Element<RichTextLabel>().Class(VerbMenuElement.StyleClassVerbAlternativeText) Element<RichTextLabel>().Class(AlternativeVerb.DefaultTextStyleClass)
.Prop(Label.StylePropertyFont, notoSansItalic12), .Prop(Label.StylePropertyFont, notoSansItalic12),
Element<RichTextLabel>().Class(VerbMenuElement.StyleClassVerbOtherText) Element<RichTextLabel>().Class(Verb.DefaultTextStyleClass)
.Prop(Label.StylePropertyFont, notoSans12), .Prop(Label.StylePropertyFont, notoSans12),
Element<TextureRect>().Class(ContextMenuElement.StyleClassContextMenuExpansionTexture) Element<TextureRect>().Class(ContextMenuElement.StyleClassContextMenuExpansionTexture)

View File

@@ -10,7 +10,6 @@ public partial class ConfirmationMenuElement : ContextMenuElement
public const string StyleClassConfirmationContextMenuButton = "confirmationContextMenuButton"; public const string StyleClassConfirmationContextMenuButton = "confirmationContextMenuButton";
public readonly Verb Verb; public readonly Verb Verb;
public readonly VerbType Type;
public override string Text public override string Text
{ {
@@ -23,10 +22,9 @@ public partial class ConfirmationMenuElement : ContextMenuElement
} }
} }
public ConfirmationMenuElement(Verb verb, string? text, VerbType type) : base(text) public ConfirmationMenuElement(Verb verb, string? text) : base(text)
{ {
Verb = verb; Verb = verb;
Type = type;
Icon.Visible = false; Icon.Visible = false;
SetOnlyStyleClass(StyleClassConfirmationContextMenuButton); SetOnlyStyleClass(StyleClassConfirmationContextMenuButton);

View File

@@ -1,8 +1,11 @@
using Content.Client.ContextMenu.UI; using Content.Client.ContextMenu.UI;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.Utility; using Robust.Client.Utility;
using Robust.Shared.Utility; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
namespace Content.Client.Verbs.UI namespace Content.Client.Verbs.UI
{ {
@@ -12,10 +15,6 @@ namespace Content.Client.Verbs.UI
/// </summary> /// </summary>
public partial class VerbMenuElement : ContextMenuElement public partial class VerbMenuElement : ContextMenuElement
{ {
public const string StyleClassVerbInteractionText = "InteractionVerb";
public const string StyleClassVerbActivationText = "ActivationVerb";
public const string StyleClassVerbAlternativeText = "AlternativeVerb";
public const string StyleClassVerbOtherText = "OtherVerb";
public const string StyleClassVerbMenuConfirmationTexture = "verbMenuConfirmationTexture"; public const string StyleClassVerbMenuConfirmationTexture = "verbMenuConfirmationTexture";
public const float VerbTooltipDelay = 0.5f; public const float VerbTooltipDelay = 0.5f;
@@ -27,50 +26,37 @@ namespace Content.Client.Verbs.UI
// Top quality variable naming // Top quality variable naming
public Verb? Verb; public Verb? Verb;
public VerbType Type; public VerbMenuElement(Verb verb) : base(verb.Text)
public VerbMenuElement(string? text, SpriteSpecifier? icon, VerbType verbType) : base(text)
{
Icon.AddChild(new TextureRect()
{
Texture = icon?.Frame0(),
Stretch = TextureRect.StretchMode.KeepAspectCentered
});
Type = verbType;
// Set text font style based on verb type
switch (verbType)
{
case VerbType.Interaction:
Label.SetOnlyStyleClass(StyleClassVerbInteractionText);
break;
case VerbType.Activation:
Label.SetOnlyStyleClass(StyleClassVerbActivationText);
break;
case VerbType.Alternative:
Label.SetOnlyStyleClass(StyleClassVerbAlternativeText);
break;
default:
Label.SetOnlyStyleClass(StyleClassVerbOtherText);
break;
}
}
public VerbMenuElement(Verb verb, VerbType verbType) : this(verb.Text, verb.Icon, verbType)
{ {
ToolTip = verb.Message; ToolTip = verb.Message;
TooltipDelay = VerbTooltipDelay; TooltipDelay = VerbTooltipDelay;
Disabled = verb.Disabled; Disabled = verb.Disabled;
Verb = verb; Verb = verb;
Label.SetOnlyStyleClass(verb.TextStyleClass);
if (verb.ConfirmationPopup) if (verb.ConfirmationPopup)
{ {
ExpansionIndicator.SetOnlyStyleClass(StyleClassVerbMenuConfirmationTexture); ExpansionIndicator.SetOnlyStyleClass(StyleClassVerbMenuConfirmationTexture);
ExpansionIndicator.Visible = true; ExpansionIndicator.Visible = true;
} }
Icon.AddChild(new TextureRect()
{
Texture = verb.Icon?.Frame0(),
Stretch = TextureRect.StretchMode.KeepAspectCentered
});
} }
public VerbMenuElement(VerbCategory category, VerbType verbType) : this(category.Text, category.Icon, verbType) { } public VerbMenuElement(VerbCategory category, string styleClass) : base(category.Text)
{
Label.SetOnlyStyleClass(styleClass);
Icon.AddChild(new TextureRect()
{
Texture = category.Icon?.Frame0(),
Stretch = TextureRect.StretchMode.KeepAspectCentered
});
}
} }
} }

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Client.ContextMenu.UI; using Content.Client.ContextMenu.UI;
@@ -30,7 +31,7 @@ namespace Content.Client.Verbs.UI
private readonly VerbSystem _verbSystem; private readonly VerbSystem _verbSystem;
public EntityUid CurrentTarget; public EntityUid CurrentTarget;
public Dictionary<VerbType, SortedSet<Verb>> CurrentVerbs = new(); public SortedSet<Verb> CurrentVerbs = new();
public VerbMenuPresenter(VerbSystem verbSystem) public VerbMenuPresenter(VerbSystem verbSystem)
{ {
@@ -51,7 +52,7 @@ namespace Content.Client.Verbs.UI
Close(); Close();
CurrentTarget = target; CurrentTarget = target;
CurrentVerbs = _verbSystem.GetVerbs(target, user, VerbType.All, force); CurrentVerbs = _verbSystem.GetVerbs(target, user, Verb.VerbTypes, force);
if (!target.IsClientSide()) if (!target.IsClientSide())
{ {
@@ -73,26 +74,17 @@ namespace Content.Client.Verbs.UI
if (RootMenu == null) if (RootMenu == null)
return; return;
// Add verbs to pop-up, grouped by type. Order determined by how types are defined VerbTypes HashSet<string> listedCategories = new();
var types = CurrentVerbs.Keys.ToList(); foreach (var verb in CurrentVerbs)
types.Sort();
foreach (var type in types)
{ {
if (!CurrentVerbs.TryGetValue(type, out var verbs)) if (verb.Category == null)
continue;
HashSet<string> listedCategories = new();
foreach (var verb in verbs)
{ {
if (verb.Category == null) var element = new VerbMenuElement(verb);
{ AddElement(RootMenu, element);
var element = new VerbMenuElement(verb, type);
AddElement(RootMenu, element);
}
else if (listedCategories.Add(verb.Category.Text))
AddVerbCategory(verb.Category, verbs, type);
} }
else if (listedCategories.Add(verb.Category.Text))
AddVerbCategory(verb.Category);
} }
RootMenu.InvalidateMeasure(); RootMenu.InvalidateMeasure();
@@ -101,12 +93,12 @@ namespace Content.Client.Verbs.UI
/// <summary> /// <summary>
/// Add a verb category button to the pop-up /// Add a verb category button to the pop-up
/// </summary> /// </summary>
public void AddVerbCategory(VerbCategory category, SortedSet<Verb> verbs, VerbType type) public void AddVerbCategory(VerbCategory category)
{ {
// Get a list of the verbs in this category // Get a list of the verbs in this category
List<Verb> verbsInCategory = new(); List<Verb> verbsInCategory = new();
var drawIcons = false; var drawIcons = false;
foreach (var verb in verbs) foreach (var verb in CurrentVerbs)
{ {
if (verb.Category?.Text == category.Text) if (verb.Category?.Text == category.Text)
{ {
@@ -118,14 +110,14 @@ namespace Content.Client.Verbs.UI
if (verbsInCategory.Count == 0) if (verbsInCategory.Count == 0)
return; return;
var element = new VerbMenuElement(category, type); var element = new VerbMenuElement(category, verbsInCategory[0].TextStyleClass);
AddElement(RootMenu, element); AddElement(RootMenu, element);
// Create the pop-up that appears when hovering over this element // Create the pop-up that appears when hovering over this element
element.SubMenu = new ContextMenuPopup(this, element); element.SubMenu = new ContextMenuPopup(this, element);
foreach (var verb in verbsInCategory) foreach (var verb in verbsInCategory)
{ {
var subElement = new VerbMenuElement(verb, type) var subElement = new VerbMenuElement(verb)
{ {
IconVisible = drawIcons, IconVisible = drawIcons,
TextVisible = !category.IconsOnly TextVisible = !category.IconsOnly
@@ -140,7 +132,7 @@ namespace Content.Client.Verbs.UI
/// <summary> /// <summary>
/// Add verbs from the server to <see cref="CurrentVerbs"/> and update the verb menu. /// Add verbs from the server to <see cref="CurrentVerbs"/> and update the verb menu.
/// </summary> /// </summary>
public void AddServerVerbs(Dictionary<VerbType, List<Verb>>? verbs) public void AddServerVerbs(List<Verb>? verbs)
{ {
RootMenu.MenuBody.DisposeAllChildren(); RootMenu.MenuBody.DisposeAllChildren();
@@ -152,15 +144,7 @@ namespace Content.Client.Verbs.UI
return; return;
} }
// Add the new server-side verbs. CurrentVerbs.UnionWith(verbs);
foreach (var (verbType, verbSet) in verbs)
{
if (!CurrentVerbs.TryAdd(verbType, new SortedSet<Verb>(verbSet)))
{
CurrentVerbs[verbType].UnionWith(verbSet);
}
}
FillVerbPopup(); FillVerbPopup();
} }
@@ -175,7 +159,7 @@ namespace Content.Client.Verbs.UI
return; return;
args.Handle(); args.Handle();
ExecuteVerb(confElement.Verb, confElement.Type); ExecuteVerb(confElement.Verb);
return; return;
} }
@@ -208,7 +192,7 @@ namespace Content.Client.Verbs.UI
{ {
if (verbElement.SubMenu == null) if (verbElement.SubMenu == null)
{ {
var popupElement = new ConfirmationMenuElement(verb, "Confirm", verbElement.Type); var popupElement = new ConfirmationMenuElement(verb, "Confirm");
verbElement.SubMenu = new ContextMenuPopup(this, verbElement); verbElement.SubMenu = new ContextMenuPopup(this, verbElement);
AddElement(verbElement.SubMenu, popupElement); AddElement(verbElement.SubMenu, popupElement);
} }
@@ -217,13 +201,13 @@ namespace Content.Client.Verbs.UI
} }
else else
{ {
ExecuteVerb(verb, verbElement.Type); ExecuteVerb(verb);
} }
} }
private void ExecuteVerb(Verb verb, VerbType verbType) private void ExecuteVerb(Verb verb)
{ {
_verbSystem.ExecuteVerb(CurrentTarget, verb, verbType); _verbSystem.ExecuteVerb(CurrentTarget, verb);
if (verb.CloseMenu) if (verb.CloseMenu)
_verbSystem.CloseAllMenus(); _verbSystem.CloseAllMenus();
} }

View File

@@ -181,7 +181,7 @@ namespace Content.Client.Verbs
/// Ask the server to send back a list of server-side verbs, and for now return an incomplete list of verbs /// Ask the server to send back a list of server-side verbs, and for now return an incomplete list of verbs
/// (only those defined locally). /// (only those defined locally).
/// </summary> /// </summary>
public Dictionary<VerbType, SortedSet<Verb>> GetVerbs(EntityUid target, EntityUid user, VerbType verbTypes, public SortedSet<Verb> GetVerbs(EntityUid target, EntityUid user, List<Type> verbTypes,
bool force = false) bool force = false)
{ {
if (!target.IsClientSide()) if (!target.IsClientSide())
@@ -198,7 +198,7 @@ namespace Content.Client.Verbs
/// <remarks> /// <remarks>
/// Unless this is a client-exclusive verb, this will also tell the server to run the same verb. /// Unless this is a client-exclusive verb, this will also tell the server to run the same verb.
/// </remarks> /// </remarks>
public void ExecuteVerb(EntityUid target, Verb verb, VerbType verbType) public void ExecuteVerb(EntityUid target, Verb verb)
{ {
var user = _playerManager.LocalPlayer?.ControlledEntity; var user = _playerManager.LocalPlayer?.ControlledEntity;
if (user == null) if (user == null)
@@ -218,10 +218,10 @@ namespace Content.Client.Verbs
// is this a client exclusive (gui) verb? // is this a client exclusive (gui) verb?
ExecuteVerb(verb, user.Value, target); ExecuteVerb(verb, user.Value, target);
else else
EntityManager.RaisePredictiveEvent(new ExecuteVerbEvent(target, verb, verbType)); EntityManager.RaisePredictiveEvent(new ExecuteVerbEvent(target, verb));
} }
public override void ExecuteVerb(Verb verb, EntityUid user, EntityUid target, bool forced = false) public override void ExecuteVerb(Verb verb, EntityUid user, EntityUid target, bool forced = false)
{ {
// invoke any relevant actions // invoke any relevant actions
verb.Act?.Invoke(); verb.Act?.Invoke();

View File

@@ -51,13 +51,13 @@ namespace Content.Server.Administration
public override void Initialize() public override void Initialize()
{ {
SubscribeLocalEvent<GetOtherVerbsEvent>(AddAdminVerbs); SubscribeLocalEvent<GetVerbsEvent<Verb>>(AddAdminVerbs);
SubscribeLocalEvent<GetOtherVerbsEvent>(AddDebugVerbs); SubscribeLocalEvent<GetVerbsEvent<Verb>>(AddDebugVerbs);
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset); SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
SubscribeLocalEvent<SolutionContainerManagerComponent, SolutionChangedEvent>(OnSolutionChanged); SubscribeLocalEvent<SolutionContainerManagerComponent, SolutionChangedEvent>(OnSolutionChanged);
} }
private void AddAdminVerbs(GetOtherVerbsEvent args) private void AddAdminVerbs(GetVerbsEvent<Verb> args)
{ {
if (!EntityManager.TryGetComponent<ActorComponent?>(args.User, out var actor)) if (!EntityManager.TryGetComponent<ActorComponent?>(args.User, out var actor))
return; return;
@@ -121,7 +121,7 @@ namespace Content.Server.Administration
} }
} }
private void AddDebugVerbs(GetOtherVerbsEvent args) private void AddDebugVerbs(GetVerbsEvent<Verb> args)
{ {
if (!EntityManager.TryGetComponent<ActorComponent?>(args.User, out var actor)) if (!EntityManager.TryGetComponent<ActorComponent?>(args.User, out var actor))
return; return;

View File

@@ -26,7 +26,7 @@ namespace Content.Server.Animals.Systems
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<UdderComponent, GetAlternativeVerbsEvent>(AddMilkVerb); SubscribeLocalEvent<UdderComponent, GetVerbsEvent<AlternativeVerb>>(AddMilkVerb);
SubscribeLocalEvent<UdderComponent, MilkingFinishedEvent>(OnMilkingFinished); SubscribeLocalEvent<UdderComponent, MilkingFinishedEvent>(OnMilkingFinished);
SubscribeLocalEvent<UdderComponent, MilkingFailEvent>(OnMilkingFailed); SubscribeLocalEvent<UdderComponent, MilkingFailEvent>(OnMilkingFailed);
} }
@@ -117,14 +117,14 @@ namespace Content.Server.Animals.Systems
component.BeingMilked = false; component.BeingMilked = false;
} }
private void AddMilkVerb(EntityUid uid, UdderComponent component, GetAlternativeVerbsEvent args) private void AddMilkVerb(EntityUid uid, UdderComponent component, GetVerbsEvent<AlternativeVerb> args)
{ {
if (args.Using == null || if (args.Using == null ||
!args.CanInteract || !args.CanInteract ||
!EntityManager.HasComponent<RefillableSolutionComponent>(args.Using.Value)) !EntityManager.HasComponent<RefillableSolutionComponent>(args.Using.Value))
return; return;
Verb verb = new() AlternativeVerb verb = new()
{ {
Act = () => Act = () =>
{ {

View File

@@ -19,15 +19,15 @@ namespace Content.Server.Atmos.EntitySystems
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<GasTankComponent, GetActivationVerbsEvent>(AddOpenUIVerb); SubscribeLocalEvent<GasTankComponent, GetVerbsEvent<ActivationVerb>>(AddOpenUIVerb);
} }
private void AddOpenUIVerb(EntityUid uid, GasTankComponent component, GetActivationVerbsEvent args) private void AddOpenUIVerb(EntityUid uid, GasTankComponent component, GetVerbsEvent<ActivationVerb> args)
{ {
if (!args.CanAccess || !EntityManager.TryGetComponent<ActorComponent?>(args.User, out var actor)) if (!args.CanAccess || !EntityManager.TryGetComponent<ActorComponent?>(args.User, out var actor))
return; return;
Verb verb = new(); ActivationVerb verb = new();
verb.Act = () => component.OpenInterface(actor.PlayerSession); verb.Act = () => component.OpenInterface(actor.PlayerSession);
verb.Text = Loc.GetString("control-verb-open-control-panel-text"); verb.Text = Loc.GetString("control-verb-open-control-panel-text");
// TODO VERBS add "open UI" icon? // TODO VERBS add "open UI" icon?

View File

@@ -34,15 +34,15 @@ namespace Content.Server.Buckle.Systems
SubscribeLocalEvent<BuckleComponent, InteractHandEvent>(HandleInteractHand); SubscribeLocalEvent<BuckleComponent, InteractHandEvent>(HandleInteractHand);
SubscribeLocalEvent<BuckleComponent, GetInteractionVerbsEvent>(AddUnbuckleVerb); SubscribeLocalEvent<BuckleComponent, GetVerbsEvent<InteractionVerb>>(AddUnbuckleVerb);
} }
private void AddUnbuckleVerb(EntityUid uid, BuckleComponent component, GetInteractionVerbsEvent args) private void AddUnbuckleVerb(EntityUid uid, BuckleComponent component, GetVerbsEvent<InteractionVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract || !component.Buckled) if (!args.CanAccess || !args.CanInteract || !component.Buckled)
return; return;
Verb verb = new() InteractionVerb verb = new()
{ {
Act = () => component.TryUnbuckle(args.User), Act = () => component.TryUnbuckle(args.User),
Text = Loc.GetString("verb-categories-unbuckle"), Text = Loc.GetString("verb-categories-unbuckle"),

View File

@@ -22,7 +22,7 @@ namespace Content.Server.Buckle.Systems
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<StrapComponent, GetInteractionVerbsEvent>(AddStrapVerbs); SubscribeLocalEvent<StrapComponent, GetVerbsEvent<InteractionVerb>>(AddStrapVerbs);
SubscribeLocalEvent<StrapComponent, ContainerGettingInsertedAttemptEvent>(OnInsertAttempt); SubscribeLocalEvent<StrapComponent, ContainerGettingInsertedAttemptEvent>(OnInsertAttempt);
} }
@@ -37,7 +37,7 @@ namespace Content.Server.Buckle.Systems
// functions. Whenever these are fully ECSed, maybe do it in a way that allows for these verbs to be handled in // functions. Whenever these are fully ECSed, maybe do it in a way that allows for these verbs to be handled in
// a sensible manner in a single system? // a sensible manner in a single system?
private void AddStrapVerbs(EntityUid uid, StrapComponent component, GetInteractionVerbsEvent args) private void AddStrapVerbs(EntityUid uid, StrapComponent component, GetVerbsEvent<InteractionVerb> args)
{ {
if (args.Hands == null || !args.CanAccess || !args.CanInteract || !component.Enabled) if (args.Hands == null || !args.CanAccess || !args.CanInteract || !component.Enabled)
return; return;
@@ -53,7 +53,7 @@ namespace Content.Server.Buckle.Systems
if (!_interactionSystem.InRangeUnobstructed(args.User, args.Target, range: buckledComp.Range)) if (!_interactionSystem.InRangeUnobstructed(args.User, args.Target, range: buckledComp.Range))
continue; continue;
Verb verb = new() InteractionVerb verb = new()
{ {
Act = () => buckledComp.TryUnbuckle(args.User), Act = () => buckledComp.TryUnbuckle(args.User),
Category = VerbCategory.Unbuckle Category = VerbCategory.Unbuckle
@@ -79,7 +79,7 @@ namespace Content.Server.Buckle.Systems
component.HasSpace(buckle) && component.HasSpace(buckle) &&
_interactionSystem.InRangeUnobstructed(args.User, args.Target, range: buckle.Range)) _interactionSystem.InRangeUnobstructed(args.User, args.Target, range: buckle.Range))
{ {
Verb verb = new() InteractionVerb verb = new()
{ {
Act = () => buckle.TryBuckle(args.User, args.Target), Act = () => buckle.TryBuckle(args.User, args.Target),
Category = VerbCategory.Buckle, Category = VerbCategory.Buckle,
@@ -99,7 +99,7 @@ namespace Content.Server.Buckle.Systems
if (!_interactionSystem.InRangeUnobstructed(@using, args.Target, usingBuckle.Range, predicate: Ignored)) if (!_interactionSystem.InRangeUnobstructed(@using, args.Target, usingBuckle.Range, predicate: Ignored))
return; return;
Verb verb = new() InteractionVerb verb = new()
{ {
Act = () => usingBuckle.TryBuckle(args.User, args.Target), Act = () => usingBuckle.TryBuckle(args.User, args.Target),
Category = VerbCategory.Buckle, Category = VerbCategory.Buckle,

View File

@@ -25,7 +25,7 @@ namespace Content.Server.Cabinet
SubscribeLocalEvent<ItemCabinetComponent, ComponentStartup>(OnComponentStartup); SubscribeLocalEvent<ItemCabinetComponent, ComponentStartup>(OnComponentStartup);
SubscribeLocalEvent<ItemCabinetComponent, ActivateInWorldEvent>(OnActivateInWorld); SubscribeLocalEvent<ItemCabinetComponent, ActivateInWorldEvent>(OnActivateInWorld);
SubscribeLocalEvent<ItemCabinetComponent, GetActivationVerbsEvent>(AddToggleOpenVerb); SubscribeLocalEvent<ItemCabinetComponent, GetVerbsEvent<ActivationVerb>>(AddToggleOpenVerb);
SubscribeLocalEvent<ItemCabinetComponent, EntInsertedIntoContainerMessage>(OnContainerModified); SubscribeLocalEvent<ItemCabinetComponent, EntInsertedIntoContainerMessage>(OnContainerModified);
SubscribeLocalEvent<ItemCabinetComponent, EntRemovedFromContainerMessage>(OnContainerModified); SubscribeLocalEvent<ItemCabinetComponent, EntRemovedFromContainerMessage>(OnContainerModified);
@@ -65,13 +65,13 @@ namespace Content.Server.Cabinet
UpdateAppearance(uid, cabinet); UpdateAppearance(uid, cabinet);
} }
private void AddToggleOpenVerb(EntityUid uid, ItemCabinetComponent cabinet, GetActivationVerbsEvent args) private void AddToggleOpenVerb(EntityUid uid, ItemCabinetComponent cabinet, GetVerbsEvent<ActivationVerb> args)
{ {
if (args.Hands == null || !args.CanAccess || !args.CanInteract) if (args.Hands == null || !args.CanAccess || !args.CanInteract)
return; return;
// Toggle open verb // Toggle open verb
Verb toggleVerb = new(); ActivationVerb toggleVerb = new();
toggleVerb.Act = () => ToggleItemCabinet(uid, cabinet); toggleVerb.Act = () => ToggleItemCabinet(uid, cabinet);
if (cabinet.Opened) if (cabinet.Opened)
{ {

View File

@@ -24,10 +24,10 @@ namespace Content.Server.Chemistry.EntitySystems
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<SolutionTransferComponent, GetAlternativeVerbsEvent>(AddSetTransferVerbs); SubscribeLocalEvent<SolutionTransferComponent, GetVerbsEvent<AlternativeVerb>>(AddSetTransferVerbs);
} }
private void AddSetTransferVerbs(EntityUid uid, SolutionTransferComponent component, GetAlternativeVerbsEvent args) private void AddSetTransferVerbs(EntityUid uid, SolutionTransferComponent component, GetVerbsEvent<AlternativeVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract || !component.CanChangeTransferAmount) if (!args.CanAccess || !args.CanInteract || !component.CanChangeTransferAmount)
return; return;
@@ -36,7 +36,7 @@ namespace Content.Server.Chemistry.EntitySystems
return; return;
// Custom transfer verb // Custom transfer verb
Verb custom = new(); AlternativeVerb custom = new();
custom.Text = Loc.GetString("comp-solution-transfer-verb-custom-amount"); custom.Text = Loc.GetString("comp-solution-transfer-verb-custom-amount");
custom.Category = VerbCategory.SetTransferAmount; custom.Category = VerbCategory.SetTransferAmount;
custom.Act = () => component.UserInterface?.Open(actor.PlayerSession); custom.Act = () => component.UserInterface?.Open(actor.PlayerSession);
@@ -50,7 +50,7 @@ namespace Content.Server.Chemistry.EntitySystems
if ( amount < component.MinimumTransferAmount.Int() || amount > component.MaximumTransferAmount.Int()) if ( amount < component.MinimumTransferAmount.Int() || amount > component.MaximumTransferAmount.Int())
continue; continue;
Verb verb = new(); AlternativeVerb verb = new();
verb.Text = Loc.GetString("comp-solution-transfer-verb-amount", ("amount", amount)); verb.Text = Loc.GetString("comp-solution-transfer-verb-amount", ("amount", amount));
verb.Category = VerbCategory.SetTransferAmount; verb.Category = VerbCategory.SetTransferAmount;
verb.Act = () => verb.Act = () =>

View File

@@ -32,7 +32,7 @@ namespace Content.Server.Climbing
base.Initialize(); base.Initialize();
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset); SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
SubscribeLocalEvent<ClimbableComponent, GetAlternativeVerbsEvent>(AddClimbVerb); SubscribeLocalEvent<ClimbableComponent, GetVerbsEvent<AlternativeVerb>>(AddClimbVerb);
SubscribeLocalEvent<GlassTableComponent, ClimbedOnEvent>(OnGlassClimbed); SubscribeLocalEvent<GlassTableComponent, ClimbedOnEvent>(OnGlassClimbed);
} }
@@ -44,7 +44,7 @@ namespace Content.Server.Climbing
UnsetTransitionBoolAfterBufferTime(uid, component); UnsetTransitionBoolAfterBufferTime(uid, component);
} }
private void AddClimbVerb(EntityUid uid, ClimbableComponent component, GetAlternativeVerbsEvent args) private void AddClimbVerb(EntityUid uid, ClimbableComponent component, GetVerbsEvent<AlternativeVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract || !_actionBlockerSystem.CanMove(args.User)) if (!args.CanAccess || !args.CanInteract || !_actionBlockerSystem.CanMove(args.User))
return; return;
@@ -55,7 +55,7 @@ namespace Content.Server.Climbing
return; return;
// Add a climb verb // Add a climb verb
Verb verb = new(); AlternativeVerb verb = new();
verb.Act = () => component.TryClimb(args.User, args.Target); verb.Act = () => component.TryClimb(args.User, args.Target);
verb.Text = Loc.GetString("comp-climbable-verb-climb"); verb.Text = Loc.GetString("comp-climbable-verb-climb");
// TODO VERBS ICON add a climbing icon? // TODO VERBS ICON add a climbing icon?

View File

@@ -20,7 +20,7 @@ namespace Content.Server.Clothing
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<MagbootsComponent, GetActivationVerbsEvent>(AddToggleVerb); SubscribeLocalEvent<MagbootsComponent, GetVerbsEvent<ActivationVerb>>(AddToggleVerb);
SubscribeLocalEvent<MagbootsComponent, SlipAttemptEvent>(OnSlipAttempt); SubscribeLocalEvent<MagbootsComponent, SlipAttemptEvent>(OnSlipAttempt);
SubscribeLocalEvent<MagbootsComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed); SubscribeLocalEvent<MagbootsComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
SubscribeLocalEvent<MagbootsComponent, GotEquippedEvent>(OnGotEquipped); SubscribeLocalEvent<MagbootsComponent, GotEquippedEvent>(OnGotEquipped);
@@ -69,12 +69,12 @@ namespace Content.Server.Clothing
args.ModifySpeed(component.WalkSpeedModifier, component.SprintSpeedModifier); args.ModifySpeed(component.WalkSpeedModifier, component.SprintSpeedModifier);
} }
private void AddToggleVerb(EntityUid uid, MagbootsComponent component, GetActivationVerbsEvent args) private void AddToggleVerb(EntityUid uid, MagbootsComponent component, GetVerbsEvent<ActivationVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract) if (!args.CanAccess || !args.CanInteract)
return; return;
Verb verb = new(); ActivationVerb verb = new();
verb.Text = Loc.GetString("toggle-magboots-verb-get-data-text"); verb.Text = Loc.GetString("toggle-magboots-verb-get-data-text");
verb.Act = () => component.On = !component.On; verb.Act = () => component.On = !component.On;
// TODO VERB ICON add toggle icon? maybe a computer on/off symbol? // TODO VERB ICON add toggle icon? maybe a computer on/off symbol?

View File

@@ -18,7 +18,7 @@ namespace Content.Server.Construction
private void InitializeGuided() private void InitializeGuided()
{ {
SubscribeNetworkEvent<RequestConstructionGuide>(OnGuideRequested); SubscribeNetworkEvent<RequestConstructionGuide>(OnGuideRequested);
SubscribeLocalEvent<ConstructionComponent, GetOtherVerbsEvent>(AddDeconstructVerb); SubscribeLocalEvent<ConstructionComponent, GetVerbsEvent<Verb>>(AddDeconstructVerb);
SubscribeLocalEvent<ConstructionComponent, ExaminedEvent>(HandleConstructionExamined); SubscribeLocalEvent<ConstructionComponent, ExaminedEvent>(HandleConstructionExamined);
} }
@@ -31,7 +31,7 @@ namespace Content.Server.Construction
RaiseNetworkEvent(new ResponseConstructionGuide(msg.ConstructionId, guide), args.SenderSession.ConnectedClient); RaiseNetworkEvent(new ResponseConstructionGuide(msg.ConstructionId, guide), args.SenderSession.ConnectedClient);
} }
private void AddDeconstructVerb(EntityUid uid, ConstructionComponent component, GetOtherVerbsEvent args) private void AddDeconstructVerb(EntityUid uid, ConstructionComponent component, GetVerbsEvent<Verb> args)
{ {
if (!args.CanAccess || !args.CanInteract) if (!args.CanAccess || !args.CanInteract)
return; return;

View File

@@ -27,10 +27,10 @@ namespace Content.Server.Cuffs
SubscribeLocalEvent<HandCountChangedEvent>(OnHandCountChanged); SubscribeLocalEvent<HandCountChangedEvent>(OnHandCountChanged);
SubscribeLocalEvent<UncuffAttemptEvent>(OnUncuffAttempt); SubscribeLocalEvent<UncuffAttemptEvent>(OnUncuffAttempt);
SubscribeLocalEvent<CuffableComponent, GetOtherVerbsEvent>(AddUncuffVerb); SubscribeLocalEvent<CuffableComponent, GetVerbsEvent<Verb>>(AddUncuffVerb);
} }
private void AddUncuffVerb(EntityUid uid, CuffableComponent component, GetOtherVerbsEvent args) private void AddUncuffVerb(EntityUid uid, CuffableComponent component, GetVerbsEvent<Verb> args)
{ {
// Can the user access the cuffs, and is there even anything to uncuff? // Can the user access the cuffs, and is there even anything to uncuff?
if (!args.CanAccess || component.CuffedHandCount == 0) if (!args.CanAccess || component.CuffedHandCount == 0)

View File

@@ -25,11 +25,11 @@ namespace Content.Server.Disposal.Tube
SubscribeLocalEvent<DisposalTubeComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged); SubscribeLocalEvent<DisposalTubeComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
SubscribeLocalEvent<DisposalTubeComponent, RelayMovementEntityEvent>(OnRelayMovement); SubscribeLocalEvent<DisposalTubeComponent, RelayMovementEntityEvent>(OnRelayMovement);
SubscribeLocalEvent<DisposalTaggerComponent, GetInteractionVerbsEvent>(AddOpenUIVerbs); SubscribeLocalEvent<DisposalTaggerComponent, GetVerbsEvent<InteractionVerb>>(AddOpenUIVerbs);
SubscribeLocalEvent<DisposalRouterComponent, GetInteractionVerbsEvent>(AddOpenUIVerbs); SubscribeLocalEvent<DisposalRouterComponent, GetVerbsEvent<InteractionVerb>>(AddOpenUIVerbs);
} }
private void AddOpenUIVerbs(EntityUid uid, DisposalTaggerComponent component, GetInteractionVerbsEvent args) private void AddOpenUIVerbs(EntityUid uid, DisposalTaggerComponent component, GetVerbsEvent<InteractionVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract) if (!args.CanAccess || !args.CanInteract)
return; return;
@@ -38,14 +38,14 @@ namespace Content.Server.Disposal.Tube
return; return;
var player = actor.PlayerSession; var player = actor.PlayerSession;
Verb verb = new(); InteractionVerb verb = new();
verb.Text = Loc.GetString("configure-verb-get-data-text"); verb.Text = Loc.GetString("configure-verb-get-data-text");
verb.IconTexture = "/Textures/Interface/VerbIcons/settings.svg.192dpi.png"; verb.IconTexture = "/Textures/Interface/VerbIcons/settings.svg.192dpi.png";
verb.Act = () => component.OpenUserInterface(actor); verb.Act = () => component.OpenUserInterface(actor);
args.Verbs.Add(verb); args.Verbs.Add(verb);
} }
private void AddOpenUIVerbs(EntityUid uid, DisposalRouterComponent component, GetInteractionVerbsEvent args) private void AddOpenUIVerbs(EntityUid uid, DisposalRouterComponent component, GetVerbsEvent<InteractionVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract) if (!args.CanAccess || !args.CanInteract)
return; return;
@@ -54,7 +54,7 @@ namespace Content.Server.Disposal.Tube
return; return;
var player = actor.PlayerSession; var player = actor.PlayerSession;
Verb verb = new(); InteractionVerb verb = new();
verb.Text = Loc.GetString("configure-verb-get-data-text"); verb.Text = Loc.GetString("configure-verb-get-data-text");
verb.IconTexture = "/Textures/Interface/VerbIcons/settings.svg.192dpi.png"; verb.IconTexture = "/Textures/Interface/VerbIcons/settings.svg.192dpi.png";
verb.Act = () => component.OpenUserInterface(actor); verb.Act = () => component.OpenUserInterface(actor);

View File

@@ -68,9 +68,9 @@ namespace Content.Server.Disposal.Unit.EntitySystems
SubscribeLocalEvent<DisposalUnitComponent, DestructionEventArgs>(HandleDestruction); SubscribeLocalEvent<DisposalUnitComponent, DestructionEventArgs>(HandleDestruction);
// Verbs // Verbs
SubscribeLocalEvent<DisposalUnitComponent, GetInteractionVerbsEvent>(AddInsertVerb); SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<InteractionVerb>>(AddInsertVerb);
SubscribeLocalEvent<DisposalUnitComponent, GetAlternativeVerbsEvent>(AddFlushEjectVerbs); SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<AlternativeVerb>>(AddFlushEjectVerbs);
SubscribeLocalEvent<DisposalUnitComponent, GetOtherVerbsEvent>(AddClimbInsideVerb); SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<Verb>>(AddClimbInsideVerb);
// Units // Units
SubscribeLocalEvent<DoInsertDisposalUnitEvent>(DoInsertDisposalUnit); SubscribeLocalEvent<DoInsertDisposalUnitEvent>(DoInsertDisposalUnit);
@@ -79,13 +79,13 @@ namespace Content.Server.Disposal.Unit.EntitySystems
SubscribeLocalEvent<DisposalUnitComponent, SharedDisposalUnitComponent.UiButtonPressedMessage>(OnUiButtonPressed); SubscribeLocalEvent<DisposalUnitComponent, SharedDisposalUnitComponent.UiButtonPressedMessage>(OnUiButtonPressed);
} }
private void AddFlushEjectVerbs(EntityUid uid, DisposalUnitComponent component, GetAlternativeVerbsEvent args) private void AddFlushEjectVerbs(EntityUid uid, DisposalUnitComponent component, GetVerbsEvent<AlternativeVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract || component.Container.ContainedEntities.Count == 0) if (!args.CanAccess || !args.CanInteract || component.Container.ContainedEntities.Count == 0)
return; return;
// Verbs to flush the unit // Verbs to flush the unit
Verb flushVerb = new(); AlternativeVerb flushVerb = new();
flushVerb.Act = () => Engage(component); flushVerb.Act = () => Engage(component);
flushVerb.Text = Loc.GetString("disposal-flush-verb-get-data-text"); flushVerb.Text = Loc.GetString("disposal-flush-verb-get-data-text");
flushVerb.IconTexture = "/Textures/Interface/VerbIcons/delete_transparent.svg.192dpi.png"; flushVerb.IconTexture = "/Textures/Interface/VerbIcons/delete_transparent.svg.192dpi.png";
@@ -93,14 +93,14 @@ namespace Content.Server.Disposal.Unit.EntitySystems
args.Verbs.Add(flushVerb); args.Verbs.Add(flushVerb);
// Verb to eject the contents // Verb to eject the contents
Verb ejectVerb = new(); AlternativeVerb ejectVerb = new();
ejectVerb.Act = () => TryEjectContents(component); ejectVerb.Act = () => TryEjectContents(component);
ejectVerb.Category = VerbCategory.Eject; ejectVerb.Category = VerbCategory.Eject;
ejectVerb.Text = Loc.GetString("disposal-eject-verb-contents"); ejectVerb.Text = Loc.GetString("disposal-eject-verb-contents");
args.Verbs.Add(ejectVerb); args.Verbs.Add(ejectVerb);
} }
private void AddClimbInsideVerb(EntityUid uid, DisposalUnitComponent component, GetOtherVerbsEvent args) private void AddClimbInsideVerb(EntityUid uid, DisposalUnitComponent component, GetVerbsEvent<Verb> args)
{ {
// This is not an interaction, activation, or alternative verb type because unfortunately most users are // This is not an interaction, activation, or alternative verb type because unfortunately most users are
// unwilling to accept that this is where they belong and don't want to accidentally climb inside. // unwilling to accept that this is where they belong and don't want to accidentally climb inside.
@@ -123,7 +123,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
args.Verbs.Add(verb); args.Verbs.Add(verb);
} }
private void AddInsertVerb(EntityUid uid, DisposalUnitComponent component, GetInteractionVerbsEvent args) private void AddInsertVerb(EntityUid uid, DisposalUnitComponent component, GetVerbsEvent<InteractionVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract || args.Hands == null || args.Using == null) if (!args.CanAccess || !args.CanInteract || args.Hands == null || args.Using == null)
return; return;
@@ -134,7 +134,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
if (!CanInsert(component, args.Using.Value)) if (!CanInsert(component, args.Using.Value))
return; return;
Verb insertVerb = new() InteractionVerb insertVerb = new()
{ {
Text = Name(args.Using.Value), Text = Name(args.Using.Value),
Category = VerbCategory.Insert, Category = VerbCategory.Insert,

View File

@@ -4,26 +4,24 @@ using Content.Server.Hands.Components;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Content.Shared.Item; using Content.Shared.Item;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Content.Server.Engineering.EntitySystems namespace Content.Server.Engineering.EntitySystems
{ {
[UsedImplicitly] [UsedImplicitly]
public class DisassembleOnAltVerbSystem : EntitySystem public sealed class DisassembleOnAltVerbSystem : EntitySystem
{ {
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<DisassembleOnAltVerbComponent, GetAlternativeVerbsEvent>(AddDisassembleVerb); SubscribeLocalEvent<DisassembleOnAltVerbComponent, GetVerbsEvent<AlternativeVerb>>(AddDisassembleVerb);
} }
private void AddDisassembleVerb(EntityUid uid, DisassembleOnAltVerbComponent component, GetAlternativeVerbsEvent args) private void AddDisassembleVerb(EntityUid uid, DisassembleOnAltVerbComponent component, GetVerbsEvent<AlternativeVerb> args)
{ {
if (!args.CanInteract) if (!args.CanInteract)
return; return;
Verb verb = new() AlternativeVerb verb = new()
{ {
Act = () => Act = () =>
{ {

View File

@@ -31,7 +31,7 @@ public class FireExtinguisherSystem : EntitySystem
SubscribeLocalEvent<FireExtinguisherComponent, DroppedEvent>(OnDropped); SubscribeLocalEvent<FireExtinguisherComponent, DroppedEvent>(OnDropped);
SubscribeLocalEvent<FireExtinguisherComponent, UseInHandEvent>(OnUseInHand); SubscribeLocalEvent<FireExtinguisherComponent, UseInHandEvent>(OnUseInHand);
SubscribeLocalEvent<FireExtinguisherComponent, AfterInteractEvent>(OnAfterInteract); SubscribeLocalEvent<FireExtinguisherComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<FireExtinguisherComponent, GetInteractionVerbsEvent>(OnGetInteractionVerbs); SubscribeLocalEvent<FireExtinguisherComponent, GetVerbsEvent<InteractionVerb>>(OnGetInteractionVerbs);
SubscribeLocalEvent<FireExtinguisherComponent, SprayAttemptEvent>(OnSprayAttempt); SubscribeLocalEvent<FireExtinguisherComponent, SprayAttemptEvent>(OnSprayAttempt);
} }
@@ -103,12 +103,12 @@ public class FireExtinguisherSystem : EntitySystem
} }
} }
private void OnGetInteractionVerbs(EntityUid uid, FireExtinguisherComponent component, GetInteractionVerbsEvent args) private void OnGetInteractionVerbs(EntityUid uid, FireExtinguisherComponent component, GetVerbsEvent<InteractionVerb> args)
{ {
if (!args.CanInteract) if (!args.CanInteract)
return; return;
var verb = new Verb var verb = new InteractionVerb
{ {
Act = () => ToggleSafety(uid, args.User, component), Act = () => ToggleSafety(uid, args.User, component),
Text = Loc.GetString("fire-extinguisher-component-verb-text"), Text = Loc.GetString("fire-extinguisher-component-verb-text"),

View File

@@ -36,7 +36,7 @@ public class SpillableSystem : EntitySystem
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<SpillableComponent, LandEvent>(SpillOnLand); SubscribeLocalEvent<SpillableComponent, LandEvent>(SpillOnLand);
SubscribeLocalEvent<SpillableComponent, GetOtherVerbsEvent>(AddSpillVerb); SubscribeLocalEvent<SpillableComponent, GetVerbsEvent<Verb>>(AddSpillVerb);
SubscribeLocalEvent<SpillableComponent, GotEquippedEvent>(OnGotEquipped); SubscribeLocalEvent<SpillableComponent, GotEquippedEvent>(OnGotEquipped);
} }
@@ -98,7 +98,7 @@ public class SpillableSystem : EntitySystem
SpillAt(drainedSolution, EntityManager.GetComponent<TransformComponent>(uid).Coordinates, "PuddleSmear"); SpillAt(drainedSolution, EntityManager.GetComponent<TransformComponent>(uid).Coordinates, "PuddleSmear");
} }
private void AddSpillVerb(EntityUid uid, SpillableComponent component, GetOtherVerbsEvent args) private void AddSpillVerb(EntityUid uid, SpillableComponent component, GetVerbsEvent<Verb> args)
{ {
if (!args.CanAccess || !args.CanInteract) if (!args.CanAccess || !args.CanInteract)
return; return;

View File

@@ -21,7 +21,7 @@ namespace Content.Server.Foldable
base.Initialize(); base.Initialize();
SubscribeLocalEvent<FoldableComponent, StorageOpenAttemptEvent>(OnFoldableOpenAttempt); SubscribeLocalEvent<FoldableComponent, StorageOpenAttemptEvent>(OnFoldableOpenAttempt);
SubscribeLocalEvent<FoldableComponent, GetAlternativeVerbsEvent>(AddFoldVerb); SubscribeLocalEvent<FoldableComponent, GetVerbsEvent<AlternativeVerb>>(AddFoldVerb);
} }
private void OnFoldableOpenAttempt(EntityUid uid, FoldableComponent component, StorageOpenAttemptEvent args) private void OnFoldableOpenAttempt(EntityUid uid, FoldableComponent component, StorageOpenAttemptEvent args)
@@ -91,12 +91,12 @@ namespace Content.Server.Foldable
#region Verb #region Verb
private void AddFoldVerb(EntityUid uid, FoldableComponent component, GetAlternativeVerbsEvent args) private void AddFoldVerb(EntityUid uid, FoldableComponent component, GetVerbsEvent<AlternativeVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract || !CanToggleFold(uid, component)) if (!args.CanAccess || !args.CanInteract || !CanToggleFold(uid, component))
return; return;
Verb verb = new() AlternativeVerb verb = new()
{ {
Act = () => TryToggleFold(component), Act = () => TryToggleFold(component),
Text = component.IsFolded ? Loc.GetString("unfold-verb") : Loc.GetString("fold-verb"), Text = component.IsFolded ? Loc.GetString("unfold-verb") : Loc.GetString("fold-verb"),

View File

@@ -22,7 +22,7 @@ namespace Content.Server.Light.EntitySystems
SubscribeLocalEvent<ExpendableLightComponent, ComponentInit>(OnExpLightInit); SubscribeLocalEvent<ExpendableLightComponent, ComponentInit>(OnExpLightInit);
SubscribeLocalEvent<ExpendableLightComponent, UseInHandEvent>(OnExpLightUse); SubscribeLocalEvent<ExpendableLightComponent, UseInHandEvent>(OnExpLightUse);
SubscribeLocalEvent<ExpendableLightComponent, GetActivationVerbsEvent>(AddIgniteVerb); SubscribeLocalEvent<ExpendableLightComponent, GetVerbsEvent<ActivationVerb>>(AddIgniteVerb);
} }
public override void Update(float frameTime) public override void Update(float frameTime)
@@ -179,7 +179,7 @@ namespace Content.Server.Light.EntitySystems
args.Handled = true; args.Handled = true;
} }
private void AddIgniteVerb(EntityUid uid, ExpendableLightComponent component, GetActivationVerbsEvent args) private void AddIgniteVerb(EntityUid uid, ExpendableLightComponent component, GetVerbsEvent<ActivationVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract) if (!args.CanAccess || !args.CanInteract)
return; return;
@@ -189,7 +189,7 @@ namespace Content.Server.Light.EntitySystems
// Ignite the flare or make the glowstick glow. // Ignite the flare or make the glowstick glow.
// Also hot damn, those are some shitty glowsticks, we need to get a refund. // Also hot damn, those are some shitty glowsticks, we need to get a refund.
Verb verb = new() ActivationVerb verb = new()
{ {
Text = Loc.GetString("expendable-light-start-verb"), Text = Loc.GetString("expendable-light-start-verb"),
IconTexture = "/Textures/Interface/VerbIcons/light.svg.192dpi.png", IconTexture = "/Textures/Interface/VerbIcons/light.svg.192dpi.png",

View File

@@ -45,7 +45,7 @@ namespace Content.Server.Light.EntitySystems
SubscribeLocalEvent<HandheldLightComponent, ComponentGetState>(OnGetState); SubscribeLocalEvent<HandheldLightComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<HandheldLightComponent, ExaminedEvent>(OnExamine); SubscribeLocalEvent<HandheldLightComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<HandheldLightComponent, GetActivationVerbsEvent>(AddToggleLightVerb); SubscribeLocalEvent<HandheldLightComponent, GetVerbsEvent<ActivationVerb>>(AddToggleLightVerb);
SubscribeLocalEvent<HandheldLightComponent, ActivateInWorldEvent>(OnActivate); SubscribeLocalEvent<HandheldLightComponent, ActivateInWorldEvent>(OnActivate);
} }
@@ -135,11 +135,11 @@ namespace Content.Server.Light.EntitySystems
} }
} }
private void AddToggleLightVerb(EntityUid uid, HandheldLightComponent component, GetActivationVerbsEvent args) private void AddToggleLightVerb(EntityUid uid, HandheldLightComponent component, GetVerbsEvent<ActivationVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract) return; if (!args.CanAccess || !args.CanInteract) return;
Verb verb = new() ActivationVerb verb = new()
{ {
Text = Loc.GetString("verb-common-toggle-light"), Text = Loc.GetString("verb-common-toggle-light"),
IconTexture = "/Textures/Interface/VerbIcons/light.svg.192dpi.png", IconTexture = "/Textures/Interface/VerbIcons/light.svg.192dpi.png",

View File

@@ -18,15 +18,15 @@ namespace Content.Server.Light.EntitySystems
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<UnpoweredFlashlightComponent, GetActivationVerbsEvent>(AddToggleLightVerbs); SubscribeLocalEvent<UnpoweredFlashlightComponent, GetVerbsEvent<ActivationVerb>>(AddToggleLightVerbs);
} }
private void AddToggleLightVerbs(EntityUid uid, UnpoweredFlashlightComponent component, GetActivationVerbsEvent args) private void AddToggleLightVerbs(EntityUid uid, UnpoweredFlashlightComponent component, GetVerbsEvent<ActivationVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract) if (!args.CanAccess || !args.CanInteract)
return; return;
Verb verb = new(); ActivationVerb verb = new();
verb.Text = Loc.GetString("toggle-flashlight-verb-get-data-text"); verb.Text = Loc.GetString("toggle-flashlight-verb-get-data-text");
verb.IconTexture = "/Textures/Interface/VerbIcons/light.svg.192dpi.png"; verb.IconTexture = "/Textures/Interface/VerbIcons/light.svg.192dpi.png";
verb.Act = () => ToggleLight(component); verb.Act = () => ToggleLight(component);

View File

@@ -32,7 +32,7 @@ namespace Content.Server.Lock
SubscribeLocalEvent<LockComponent, ComponentStartup>(OnStartup); SubscribeLocalEvent<LockComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<LockComponent, ActivateInWorldEvent>(OnActivated); SubscribeLocalEvent<LockComponent, ActivateInWorldEvent>(OnActivated);
SubscribeLocalEvent<LockComponent, ExaminedEvent>(OnExamined); SubscribeLocalEvent<LockComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<LockComponent, GetAlternativeVerbsEvent>(AddToggleLockVerb); SubscribeLocalEvent<LockComponent, GetVerbsEvent<AlternativeVerb>>(AddToggleLockVerb);
} }
private void OnStartup(EntityUid uid, LockComponent lockComp, ComponentStartup args) private void OnStartup(EntityUid uid, LockComponent lockComp, ComponentStartup args)
@@ -169,12 +169,12 @@ namespace Content.Server.Lock
return true; return true;
} }
private void AddToggleLockVerb(EntityUid uid, LockComponent component, GetAlternativeVerbsEvent args) private void AddToggleLockVerb(EntityUid uid, LockComponent component, GetVerbsEvent<AlternativeVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract || !CanToggleLock(uid, args.User)) if (!args.CanAccess || !args.CanInteract || !CanToggleLock(uid, args.User))
return; return;
Verb verb = new(); AlternativeVerb verb = new();
verb.Act = component.Locked ? verb.Act = component.Locked ?
() => TryUnlock(uid, args.User, component) : () => TryUnlock(uid, args.User, component) :
() => TryLock(uid, args.User, component); () => TryLock(uid, args.User, component);

View File

@@ -22,11 +22,11 @@ namespace Content.Server.Medical
base.Initialize(); base.Initialize();
SubscribeLocalEvent<MedicalScannerComponent, RelayMovementEntityEvent>(OnRelayMovement); SubscribeLocalEvent<MedicalScannerComponent, RelayMovementEntityEvent>(OnRelayMovement);
SubscribeLocalEvent<MedicalScannerComponent, GetInteractionVerbsEvent>(AddInsertOtherVerb); SubscribeLocalEvent<MedicalScannerComponent, GetVerbsEvent<InteractionVerb>>(AddInsertOtherVerb);
SubscribeLocalEvent<MedicalScannerComponent, GetAlternativeVerbsEvent>(AddAlternativeVerbs); SubscribeLocalEvent<MedicalScannerComponent, GetVerbsEvent<AlternativeVerb>>(AddAlternativeVerbs);
} }
private void AddInsertOtherVerb(EntityUid uid, MedicalScannerComponent component, GetInteractionVerbsEvent args) private void AddInsertOtherVerb(EntityUid uid, MedicalScannerComponent component, GetVerbsEvent<InteractionVerb> args)
{ {
if (args.Using == null || if (args.Using == null ||
!args.CanAccess || !args.CanAccess ||
@@ -35,14 +35,14 @@ namespace Content.Server.Medical
!component.CanInsert(args.Using.Value)) !component.CanInsert(args.Using.Value))
return; return;
Verb verb = new(); InteractionVerb verb = new();
verb.Act = () => component.InsertBody(args.Using.Value); verb.Act = () => component.InsertBody(args.Using.Value);
verb.Category = VerbCategory.Insert; verb.Category = VerbCategory.Insert;
verb.Text = EntityManager.GetComponent<MetaDataComponent>(args.Using.Value).EntityName; verb.Text = EntityManager.GetComponent<MetaDataComponent>(args.Using.Value).EntityName;
args.Verbs.Add(verb); args.Verbs.Add(verb);
} }
private void AddAlternativeVerbs(EntityUid uid, MedicalScannerComponent component, GetAlternativeVerbsEvent args) private void AddAlternativeVerbs(EntityUid uid, MedicalScannerComponent component, GetVerbsEvent<AlternativeVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract) if (!args.CanAccess || !args.CanInteract)
return; return;
@@ -50,7 +50,7 @@ namespace Content.Server.Medical
// Eject verb // Eject verb
if (component.IsOccupied) if (component.IsOccupied)
{ {
Verb verb = new(); AlternativeVerb verb = new();
verb.Act = () => component.EjectBody(); verb.Act = () => component.EjectBody();
verb.Category = VerbCategory.Eject; verb.Category = VerbCategory.Eject;
verb.Text = Loc.GetString("medical-scanner-verb-noun-occupant"); verb.Text = Loc.GetString("medical-scanner-verb-noun-occupant");
@@ -62,7 +62,7 @@ namespace Content.Server.Medical
component.CanInsert(args.User) && component.CanInsert(args.User) &&
_actionBlockerSystem.CanMove(args.User)) _actionBlockerSystem.CanMove(args.User))
{ {
Verb verb = new(); AlternativeVerb verb = new();
verb.Act = () => component.InsertBody(args.User); verb.Act = () => component.InsertBody(args.User);
verb.Text = Loc.GetString("medical-scanner-verb-enter"); verb.Text = Loc.GetString("medical-scanner-verb-enter");
// TODO VERN ICON // TODO VERN ICON

View File

@@ -41,7 +41,7 @@ namespace Content.Server.Medical.SuitSensors
SubscribeLocalEvent<SuitSensorComponent, GotEquippedEvent>(OnEquipped); SubscribeLocalEvent<SuitSensorComponent, GotEquippedEvent>(OnEquipped);
SubscribeLocalEvent<SuitSensorComponent, GotUnequippedEvent>(OnUnequipped); SubscribeLocalEvent<SuitSensorComponent, GotUnequippedEvent>(OnUnequipped);
SubscribeLocalEvent<SuitSensorComponent, ExaminedEvent>(OnExamine); SubscribeLocalEvent<SuitSensorComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<SuitSensorComponent, GetInteractionVerbsEvent>(OnVerb); SubscribeLocalEvent<SuitSensorComponent, GetVerbsEvent<Verb>>(OnVerb);
} }
public override void Update(float frameTime) public override void Update(float frameTime)
@@ -135,7 +135,7 @@ namespace Content.Server.Medical.SuitSensors
args.PushMarkup(Loc.GetString(msg)); args.PushMarkup(Loc.GetString(msg));
} }
private void OnVerb(EntityUid uid, SuitSensorComponent component, GetInteractionVerbsEvent args) private void OnVerb(EntityUid uid, SuitSensorComponent component, GetVerbsEvent<Verb> args)
{ {
// check if user can change sensor // check if user can change sensor
if (component.ControlsLocked) if (component.ControlsLocked)

View File

@@ -18,15 +18,15 @@ namespace Content.Server.Morgue
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<CrematoriumEntityStorageComponent, GetAlternativeVerbsEvent>(AddCremateVerb); SubscribeLocalEvent<CrematoriumEntityStorageComponent, GetVerbsEvent<AlternativeVerb>>(AddCremateVerb);
} }
private void AddCremateVerb(EntityUid uid, CrematoriumEntityStorageComponent component, GetAlternativeVerbsEvent args) private void AddCremateVerb(EntityUid uid, CrematoriumEntityStorageComponent component, GetVerbsEvent<AlternativeVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract || component.Cooking || component.Open) if (!args.CanAccess || !args.CanInteract || component.Cooking || component.Open)
return; return;
Verb verb = new(); AlternativeVerb verb = new();
verb.Text = Loc.GetString("cremate-verb-get-data-text"); verb.Text = Loc.GetString("cremate-verb-get-data-text");
// TODO VERB ICON add flame/burn symbol? // TODO VERB ICON add flame/burn symbol?
verb.Act = () => component.TryCremate(); verb.Act = () => component.TryCremate();

View File

@@ -49,7 +49,7 @@ namespace Content.Server.Nutrition.EntitySystems
SubscribeLocalEvent<FoodComponent, UseInHandEvent>(OnUseFoodInHand); SubscribeLocalEvent<FoodComponent, UseInHandEvent>(OnUseFoodInHand);
SubscribeLocalEvent<FoodComponent, AfterInteractEvent>(OnFeedFood); SubscribeLocalEvent<FoodComponent, AfterInteractEvent>(OnFeedFood);
SubscribeLocalEvent<FoodComponent, GetInteractionVerbsEvent>(AddEatVerb); SubscribeLocalEvent<FoodComponent, GetVerbsEvent<InteractionVerb>>(AddEatVerb);
SubscribeLocalEvent<SharedBodyComponent, FeedEvent>(OnFeed); SubscribeLocalEvent<SharedBodyComponent, FeedEvent>(OnFeed);
SubscribeLocalEvent<ForceFeedCancelledEvent>(OnFeedCancelled); SubscribeLocalEvent<ForceFeedCancelledEvent>(OnFeedCancelled);
SubscribeLocalEvent<InventoryComponent, IngestionAttemptEvent>(OnInventoryIngestAttempt); SubscribeLocalEvent<InventoryComponent, IngestionAttemptEvent>(OnInventoryIngestAttempt);
@@ -245,7 +245,7 @@ namespace Content.Server.Nutrition.EntitySystems
EntityManager.QueueDeleteEntity(component.Owner); EntityManager.QueueDeleteEntity(component.Owner);
} }
private void AddEatVerb(EntityUid uid, FoodComponent component, GetInteractionVerbsEvent ev) private void AddEatVerb(EntityUid uid, FoodComponent component, GetVerbsEvent<InteractionVerb> ev)
{ {
if (component.CancelToken != null) if (component.CancelToken != null)
return; return;
@@ -260,7 +260,7 @@ namespace Content.Server.Nutrition.EntitySystems
if (EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) && mobState.IsAlive()) if (EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) && mobState.IsAlive())
return; return;
Verb verb = new() InteractionVerb verb = new()
{ {
Act = () => Act = () =>
{ {

View File

@@ -29,7 +29,7 @@ namespace Content.Server.PAI
SubscribeLocalEvent<PAIComponent, UseInHandEvent>(OnUseInHand); SubscribeLocalEvent<PAIComponent, UseInHandEvent>(OnUseInHand);
SubscribeLocalEvent<PAIComponent, MindAddedMessage>(OnMindAdded); SubscribeLocalEvent<PAIComponent, MindAddedMessage>(OnMindAdded);
SubscribeLocalEvent<PAIComponent, MindRemovedMessage>(OnMindRemoved); SubscribeLocalEvent<PAIComponent, MindRemovedMessage>(OnMindRemoved);
SubscribeLocalEvent<PAIComponent, GetActivationVerbsEvent>(AddWipeVerb); SubscribeLocalEvent<PAIComponent, GetVerbsEvent<ActivationVerb>>(AddWipeVerb);
} }
private void OnExamined(EntityUid uid, PAIComponent component, ExaminedEvent args) private void OnExamined(EntityUid uid, PAIComponent component, ExaminedEvent args)
@@ -127,14 +127,14 @@ namespace Content.Server.PAI
} }
} }
private void AddWipeVerb(EntityUid uid, PAIComponent pai, GetActivationVerbsEvent args) private void AddWipeVerb(EntityUid uid, PAIComponent pai, GetVerbsEvent<ActivationVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract) if (!args.CanAccess || !args.CanInteract)
return; return;
if (EntityManager.TryGetComponent<MindComponent>(uid, out var mind) && mind.HasMind) if (EntityManager.TryGetComponent<MindComponent>(uid, out var mind) && mind.HasMind)
{ {
Verb verb = new(); ActivationVerb verb = new();
verb.Text = Loc.GetString("pai-system-wipe-device-verb-text"); verb.Text = Loc.GetString("pai-system-wipe-device-verb-text");
verb.Act = () => { verb.Act = () => {
if (pai.Deleted) if (pai.Deleted)
@@ -153,7 +153,7 @@ namespace Content.Server.PAI
} }
else if (EntityManager.HasComponent<GhostTakeoverAvailableComponent>(uid)) else if (EntityManager.HasComponent<GhostTakeoverAvailableComponent>(uid))
{ {
Verb verb = new(); ActivationVerb verb = new();
verb.Text = Loc.GetString("pai-system-stop-searching-verb-text"); verb.Text = Loc.GetString("pai-system-stop-searching-verb-text");
verb.Act = () => { verb.Act = () => {
if (pai.Deleted) if (pai.Deleted)

View File

@@ -45,8 +45,8 @@ namespace Content.Server.PneumaticCannon
SubscribeLocalEvent<PneumaticCannonComponent, ComponentInit>(OnComponentInit); SubscribeLocalEvent<PneumaticCannonComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<PneumaticCannonComponent, InteractUsingEvent>(OnInteractUsing); SubscribeLocalEvent<PneumaticCannonComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<PneumaticCannonComponent, AfterInteractEvent>(OnAfterInteract); SubscribeLocalEvent<PneumaticCannonComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<PneumaticCannonComponent, GetAlternativeVerbsEvent>(OnAlternativeVerbs); SubscribeLocalEvent<PneumaticCannonComponent, GetVerbsEvent<AlternativeVerb>>(OnAlternativeVerbs);
SubscribeLocalEvent<PneumaticCannonComponent, GetOtherVerbsEvent>(OnOtherVerbs); SubscribeLocalEvent<PneumaticCannonComponent, GetVerbsEvent<Verb>>(OnOtherVerbs);
} }
public override void Update(float frameTime) public override void Update(float frameTime)
@@ -285,20 +285,20 @@ namespace Content.Server.PneumaticCannon
return false; return false;
} }
private void OnAlternativeVerbs(EntityUid uid, PneumaticCannonComponent component, GetAlternativeVerbsEvent args) private void OnAlternativeVerbs(EntityUid uid, PneumaticCannonComponent component, GetVerbsEvent<AlternativeVerb> args)
{ {
if (component.GasTankSlot.ContainedEntities.Count == 0 || !component.GasTankRequired) if (component.GasTankSlot.ContainedEntities.Count == 0 || !component.GasTankRequired)
return; return;
if (!args.CanInteract) if (!args.CanInteract)
return; return;
Verb ejectTank = new(); AlternativeVerb ejectTank = new();
ejectTank.Act = () => TryRemoveGasTank(component, args.User); ejectTank.Act = () => TryRemoveGasTank(component, args.User);
ejectTank.Text = Loc.GetString("pneumatic-cannon-component-verb-gas-tank-name"); ejectTank.Text = Loc.GetString("pneumatic-cannon-component-verb-gas-tank-name");
args.Verbs.Add(ejectTank); args.Verbs.Add(ejectTank);
} }
private void OnOtherVerbs(EntityUid uid, PneumaticCannonComponent component, GetOtherVerbsEvent args) private void OnOtherVerbs(EntityUid uid, PneumaticCannonComponent component, GetVerbsEvent<Verb> args)
{ {
if (!args.CanInteract) if (!args.CanInteract)
return; return;

View File

@@ -194,7 +194,7 @@ namespace Content.Server.Pointing.EntitySystems
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<GetOtherVerbsEvent>(AddPointingVerb); SubscribeLocalEvent<GetVerbsEvent<Verb>>(AddPointingVerb);
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged; _playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
@@ -203,7 +203,7 @@ namespace Content.Server.Pointing.EntitySystems
.Register<PointingSystem>(); .Register<PointingSystem>();
} }
private void AddPointingVerb(GetOtherVerbsEvent args) private void AddPointingVerb(GetVerbsEvent<Verb> args)
{ {
if (args.Hands == null) if (args.Hands == null)
return; return;

View File

@@ -16,11 +16,11 @@ namespace Content.Server.Rotatable
{ {
public override void Initialize() public override void Initialize()
{ {
SubscribeLocalEvent<FlippableComponent, GetOtherVerbsEvent>(AddFlipVerb); SubscribeLocalEvent<FlippableComponent, GetVerbsEvent<Verb>>(AddFlipVerb);
SubscribeLocalEvent<RotatableComponent, GetOtherVerbsEvent>(AddRotateVerbs); SubscribeLocalEvent<RotatableComponent, GetVerbsEvent<Verb>>(AddRotateVerbs);
} }
private void AddFlipVerb(EntityUid uid, FlippableComponent component, GetOtherVerbsEvent args) private void AddFlipVerb(EntityUid uid, FlippableComponent component, GetVerbsEvent<Verb> args)
{ {
if (!args.CanAccess || !args.CanInteract || component.MirrorEntity == null) if (!args.CanAccess || !args.CanInteract || component.MirrorEntity == null)
return; return;
@@ -32,7 +32,7 @@ namespace Content.Server.Rotatable
args.Verbs.Add(verb); args.Verbs.Add(verb);
} }
private void AddRotateVerbs(EntityUid uid, RotatableComponent component, GetOtherVerbsEvent args) private void AddRotateVerbs(EntityUid uid, RotatableComponent component, GetVerbsEvent<Verb> args)
{ {
if (!args.CanAccess || !args.CanInteract) if (!args.CanAccess || !args.CanInteract)
return; return;

View File

@@ -39,7 +39,7 @@ namespace Content.Server.Shuttles.EntitySystems
SubscribeLocalEvent<DockingComponent, PowerChangedEvent>(OnPowerChange); SubscribeLocalEvent<DockingComponent, PowerChangedEvent>(OnPowerChange);
SubscribeLocalEvent<DockingComponent, AnchorStateChangedEvent>(OnAnchorChange); SubscribeLocalEvent<DockingComponent, AnchorStateChangedEvent>(OnAnchorChange);
SubscribeLocalEvent<DockingComponent, GetInteractionVerbsEvent>(OnVerb); SubscribeLocalEvent<DockingComponent, GetVerbsEvent<InteractionVerb>>(OnVerb);
SubscribeLocalEvent<DockingComponent, BeforeDoorAutoCloseEvent>(OnAutoClose); SubscribeLocalEvent<DockingComponent, BeforeDoorAutoCloseEvent>(OnAutoClose);
} }
@@ -50,12 +50,12 @@ namespace Content.Server.Shuttles.EntitySystems
args.Cancel(); args.Cancel();
} }
private void OnVerb(EntityUid uid, DockingComponent component, GetInteractionVerbsEvent args) private void OnVerb(EntityUid uid, DockingComponent component, GetVerbsEvent<InteractionVerb> args)
{ {
if (!args.CanInteract || if (!args.CanInteract ||
!args.CanAccess) return; !args.CanAccess) return;
Verb? verb; InteractionVerb? verb;
// TODO: Have it open the UI and have the UI do this. // TODO: Have it open the UI and have the UI do this.
if (!component.Docked && if (!component.Docked &&
@@ -67,7 +67,7 @@ namespace Content.Server.Shuttles.EntitySystems
if (component.Enabled) if (component.Enabled)
otherDock = GetDockable(body, xform); otherDock = GetDockable(body, xform);
verb = new Verb verb = new InteractionVerb
{ {
Disabled = otherDock == null, Disabled = otherDock == null,
Text = Loc.GetString("docking-component-dock"), Text = Loc.GetString("docking-component-dock"),
@@ -80,7 +80,7 @@ namespace Content.Server.Shuttles.EntitySystems
} }
else if (component.Docked) else if (component.Docked)
{ {
verb = new Verb verb = new InteractionVerb
{ {
Disabled = !component.Docked, Disabled = !component.Docked,
Text = Loc.GetString("docking-component-undock"), Text = Loc.GetString("docking-component-undock"),

View File

@@ -34,13 +34,13 @@ namespace Content.Server.Shuttles.EntitySystems
SubscribeLocalEvent<ShuttleConsoleComponent, ComponentShutdown>(HandleConsoleShutdown); SubscribeLocalEvent<ShuttleConsoleComponent, ComponentShutdown>(HandleConsoleShutdown);
SubscribeLocalEvent<ShuttleConsoleComponent, ActivateInWorldEvent>(HandleConsoleInteract); SubscribeLocalEvent<ShuttleConsoleComponent, ActivateInWorldEvent>(HandleConsoleInteract);
SubscribeLocalEvent<ShuttleConsoleComponent, PowerChangedEvent>(HandlePowerChange); SubscribeLocalEvent<ShuttleConsoleComponent, PowerChangedEvent>(HandlePowerChange);
SubscribeLocalEvent<ShuttleConsoleComponent, GetInteractionVerbsEvent>(OnConsoleInteract); SubscribeLocalEvent<ShuttleConsoleComponent, GetVerbsEvent<InteractionVerb>>(OnConsoleInteract);
SubscribeLocalEvent<PilotComponent, ComponentShutdown>(HandlePilotShutdown); SubscribeLocalEvent<PilotComponent, ComponentShutdown>(HandlePilotShutdown);
SubscribeLocalEvent<PilotComponent, MoveEvent>(HandlePilotMove); SubscribeLocalEvent<PilotComponent, MoveEvent>(HandlePilotMove);
} }
private void OnConsoleInteract(EntityUid uid, ShuttleConsoleComponent component, GetInteractionVerbsEvent args) private void OnConsoleInteract(EntityUid uid, ShuttleConsoleComponent component, GetVerbsEvent<InteractionVerb> args)
{ {
if (!args.CanAccess || if (!args.CanAccess ||
!args.CanInteract) !args.CanInteract)
@@ -52,7 +52,7 @@ namespace Content.Server.Shuttles.EntitySystems
if (!_mapManager.TryGetGrid(xform.GridID, out var grid) || if (!_mapManager.TryGetGrid(xform.GridID, out var grid) ||
!EntityManager.TryGetComponent(grid.GridEntityId, out ShuttleComponent? shuttle)) return; !EntityManager.TryGetComponent(grid.GridEntityId, out ShuttleComponent? shuttle)) return;
Verb verb = new() InteractionVerb verb = new()
{ {
Text = Loc.GetString("shuttle-mode-toggle"), Text = Loc.GetString("shuttle-mode-toggle"),
Act = () => ToggleShuttleMode(args.User, component, shuttle), Act = () => ToggleShuttleMode(args.User, component, shuttle),

View File

@@ -33,7 +33,7 @@ namespace Content.Server.Stack
base.Initialize(); base.Initialize();
SubscribeLocalEvent<StackComponent, InteractUsingEvent>(OnStackInteractUsing); SubscribeLocalEvent<StackComponent, InteractUsingEvent>(OnStackInteractUsing);
SubscribeLocalEvent<StackComponent, GetAlternativeVerbsEvent>(OnStackAlternativeInteract); SubscribeLocalEvent<StackComponent, GetVerbsEvent<AlternativeVerb>>(OnStackAlternativeInteract);
} }
/// <summary> /// <summary>
@@ -126,12 +126,12 @@ namespace Content.Server.Stack
args.Handled = true; args.Handled = true;
} }
private void OnStackAlternativeInteract(EntityUid uid, StackComponent stack, GetAlternativeVerbsEvent args) private void OnStackAlternativeInteract(EntityUid uid, StackComponent stack, GetVerbsEvent<AlternativeVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract) if (!args.CanAccess || !args.CanInteract)
return; return;
Verb halve = new() AlternativeVerb halve = new()
{ {
Text = Loc.GetString("comp-stack-split-halve"), Text = Loc.GetString("comp-stack-split-halve"),
Category = VerbCategory.Split, Category = VerbCategory.Split,
@@ -146,7 +146,7 @@ namespace Content.Server.Stack
if (amount >= stack.Count) if (amount >= stack.Count)
continue; continue;
Verb verb = new() AlternativeVerb verb = new()
{ {
Text = amount.ToString(), Text = amount.ToString(),
Category = VerbCategory.Split, Category = VerbCategory.Split,

View File

@@ -32,8 +32,8 @@ namespace Content.Server.Storage.EntitySystems
SubscribeLocalEvent<EntRemovedFromContainerMessage>(HandleEntityRemovedFromContainer); SubscribeLocalEvent<EntRemovedFromContainerMessage>(HandleEntityRemovedFromContainer);
SubscribeLocalEvent<EntInsertedIntoContainerMessage>(HandleEntityInsertedIntoContainer); SubscribeLocalEvent<EntInsertedIntoContainerMessage>(HandleEntityInsertedIntoContainer);
SubscribeLocalEvent<EntityStorageComponent, GetInteractionVerbsEvent>(AddToggleOpenVerb); SubscribeLocalEvent<EntityStorageComponent, GetVerbsEvent<InteractionVerb>>(AddToggleOpenVerb);
SubscribeLocalEvent<ServerStorageComponent, GetActivationVerbsEvent>(AddOpenUiVerb); SubscribeLocalEvent<ServerStorageComponent, GetVerbsEvent<ActivationVerb>>(AddOpenUiVerb);
SubscribeLocalEvent<EntityStorageComponent, RelayMovementEntityEvent>(OnRelayMovement); SubscribeLocalEvent<EntityStorageComponent, RelayMovementEntityEvent>(OnRelayMovement);
SubscribeLocalEvent<StorageFillComponent, MapInitEvent>(OnStorageFillMapInit); SubscribeLocalEvent<StorageFillComponent, MapInitEvent>(OnStorageFillMapInit);
@@ -63,7 +63,7 @@ namespace Content.Server.Storage.EntitySystems
} }
} }
private void AddToggleOpenVerb(EntityUid uid, EntityStorageComponent component, GetInteractionVerbsEvent args) private void AddToggleOpenVerb(EntityUid uid, EntityStorageComponent component, GetVerbsEvent<InteractionVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract) if (!args.CanAccess || !args.CanInteract)
return; return;
@@ -71,7 +71,7 @@ namespace Content.Server.Storage.EntitySystems
if (!component.CanOpen(args.User, silent: true)) if (!component.CanOpen(args.User, silent: true))
return; return;
Verb verb = new(); InteractionVerb verb = new();
if (component.Open) if (component.Open)
{ {
verb.Text = Loc.GetString("verb-common-close"); verb.Text = Loc.GetString("verb-common-close");
@@ -86,7 +86,7 @@ namespace Content.Server.Storage.EntitySystems
args.Verbs.Add(verb); args.Verbs.Add(verb);
} }
private void AddOpenUiVerb(EntityUid uid, ServerStorageComponent component, GetActivationVerbsEvent args) private void AddOpenUiVerb(EntityUid uid, ServerStorageComponent component, GetVerbsEvent<ActivationVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract) if (!args.CanAccess || !args.CanInteract)
return; return;
@@ -102,7 +102,7 @@ namespace Content.Server.Storage.EntitySystems
// Does this player currently have the storage UI open? // Does this player currently have the storage UI open?
var uiOpen = component.SubscribedSessions.Contains(session); var uiOpen = component.SubscribedSessions.Contains(session);
Verb verb = new(); ActivationVerb verb = new();
verb.Act = () => component.OpenStorageUI(args.User); verb.Act = () => component.OpenStorageUI(args.User);
if (uiOpen) if (uiOpen)
{ {

View File

@@ -20,7 +20,7 @@ namespace Content.Server.Strip
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<StrippableComponent, GetOtherVerbsEvent>(AddStripVerb); SubscribeLocalEvent<StrippableComponent, GetVerbsEvent<Verb>>(AddStripVerb);
SubscribeLocalEvent<StrippableComponent, DidEquipEvent>(OnDidEquip); SubscribeLocalEvent<StrippableComponent, DidEquipEvent>(OnDidEquip);
SubscribeLocalEvent<StrippableComponent, DidUnequipEvent>(OnDidUnequip); SubscribeLocalEvent<StrippableComponent, DidUnequipEvent>(OnDidUnequip);
SubscribeLocalEvent<StrippableComponent, ComponentInit>(OnCompInit); SubscribeLocalEvent<StrippableComponent, ComponentInit>(OnCompInit);
@@ -93,7 +93,7 @@ namespace Content.Server.Strip
strippableComponent.UserInterface.SetState(new StrippingBoundUserInterfaceState(inventory, hands, cuffs)); strippableComponent.UserInterface.SetState(new StrippingBoundUserInterfaceState(inventory, hands, cuffs));
} }
private void AddStripVerb(EntityUid uid, StrippableComponent component, GetOtherVerbsEvent args) private void AddStripVerb(EntityUid uid, StrippableComponent component, GetVerbsEvent<Verb> args)
{ {
if (args.Hands == null || !args.CanAccess || !args.CanInteract || args.Target == args.User) if (args.Hands == null || !args.CanAccess || !args.CanInteract || args.Target == args.User)
return; return;

View File

@@ -28,7 +28,7 @@ namespace Content.Server.Tabletop
SubscribeLocalEvent<TabletopGameComponent, ComponentShutdown>(OnGameShutdown); SubscribeLocalEvent<TabletopGameComponent, ComponentShutdown>(OnGameShutdown);
SubscribeLocalEvent<TabletopGamerComponent, PlayerDetachedEvent>(OnPlayerDetached); SubscribeLocalEvent<TabletopGamerComponent, PlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<TabletopGamerComponent, ComponentShutdown>(OnGamerShutdown); SubscribeLocalEvent<TabletopGamerComponent, ComponentShutdown>(OnGamerShutdown);
SubscribeLocalEvent<TabletopGameComponent, GetActivationVerbsEvent>(AddPlayGameVerb); SubscribeLocalEvent<TabletopGameComponent, GetVerbsEvent<ActivationVerb>>(AddPlayGameVerb);
InitializeMap(); InitializeMap();
InitializeDraggable(); InitializeDraggable();
@@ -37,7 +37,7 @@ namespace Content.Server.Tabletop
/// <summary> /// <summary>
/// Add a verb that allows the player to start playing a tabletop game. /// Add a verb that allows the player to start playing a tabletop game.
/// </summary> /// </summary>
private void AddPlayGameVerb(EntityUid uid, TabletopGameComponent component, GetActivationVerbsEvent args) private void AddPlayGameVerb(EntityUid uid, TabletopGameComponent component, GetVerbsEvent<ActivationVerb> args)
{ {
if (!args.CanAccess || !args.CanInteract) if (!args.CanAccess || !args.CanInteract)
return; return;
@@ -45,7 +45,7 @@ namespace Content.Server.Tabletop
if (!EntityManager.TryGetComponent<ActorComponent?>(args.User, out var actor)) if (!EntityManager.TryGetComponent<ActorComponent?>(args.User, out var actor))
return; return;
Verb verb = new(); ActivationVerb verb = new();
verb.Text = Loc.GetString("tabletop-verb-play-game"); verb.Text = Loc.GetString("tabletop-verb-play-game");
verb.IconTexture = "/Textures/Interface/VerbIcons/die.svg.192dpi.png"; verb.IconTexture = "/Textures/Interface/VerbIcons/die.svg.192dpi.png";
verb.Act = () => OpenSessionFor(actor.PlayerSession, uid); verb.Act = () => OpenSessionFor(actor.PlayerSession, uid);

View File

@@ -33,10 +33,10 @@ namespace Content.Server.UserInterface
SubscribeLocalEvent<ActivatableUIComponent, EntParentChangedMessage>(OnParentChanged); SubscribeLocalEvent<ActivatableUIComponent, EntParentChangedMessage>(OnParentChanged);
SubscribeLocalEvent<ActivatableUIComponent, BoundUIClosedEvent>(OnUIClose); SubscribeLocalEvent<ActivatableUIComponent, BoundUIClosedEvent>(OnUIClose);
SubscribeLocalEvent<ActivatableUIComponent, GetActivationVerbsEvent>(AddOpenUiVerb); SubscribeLocalEvent<ActivatableUIComponent, GetVerbsEvent<ActivationVerb>>(AddOpenUiVerb);
} }
private void AddOpenUiVerb(EntityUid uid, ActivatableUIComponent component, GetActivationVerbsEvent args) private void AddOpenUiVerb(EntityUid uid, ActivatableUIComponent component, GetVerbsEvent<ActivationVerb> args)
{ {
if (!args.CanAccess) if (!args.CanAccess)
return; return;
@@ -44,7 +44,7 @@ namespace Content.Server.UserInterface
if (!args.CanInteract && !HasComp<GhostComponent>(args.User)) if (!args.CanInteract && !HasComp<GhostComponent>(args.User))
return; return;
Verb verb = new(); ActivationVerb verb = new();
verb.Act = () => InteractUI(args.User, component); verb.Act = () => InteractUI(args.User, component);
verb.Text = Loc.GetString("ui-verb-toggle-open"); verb.Text = Loc.GetString("ui-verb-toggle-open");
// TODO VERBS add "open UI" icon? // TODO VERBS add "open UI" icon?

View File

@@ -1,12 +1,8 @@
using System;
using System.Linq; using System.Linq;
using Content.Server.Administration; using Content.Server.Administration;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
namespace Content.Server.Verbs.Commands namespace Content.Server.Verbs.Commands
{ {
@@ -68,28 +64,29 @@ namespace Content.Server.Verbs.Commands
} }
var verbName = args[2].ToLowerInvariant(); var verbName = args[2].ToLowerInvariant();
var verbs = verbSystem.GetLocalVerbs(target, playerEntity.Value, VerbType.All, true); var verbs = verbSystem.GetLocalVerbs(target, playerEntity.Value, Verb.VerbTypes, true);
if ((Enum.TryParse(typeof(VerbType), verbName, ignoreCase: true, out var vtype) &&
vtype is VerbType key) && // if the "verb name" is actually a verb-type, try run any verb of that type.
verbs.TryGetValue(key, out var vset) && var verbType = Verb.VerbTypes.FirstOrDefault(x => x.Name == verbName);
vset.Any()) if (verbType != null)
{ {
verbSystem.ExecuteVerb(vset.First(), playerEntity.Value, target, forced: true); var verb = verbs.FirstOrDefault(v => v.GetType() == verbType);
shell.WriteLine(Loc.GetString("invoke-verb-command-success", ("verb", verbName), ("target", target), ("player", playerEntity))); if (verb != null)
return; {
verbSystem.ExecuteVerb(verb, playerEntity.Value, target, forced: true);
shell.WriteLine(Loc.GetString("invoke-verb-command-success", ("verb", verbName), ("target", target), ("player", playerEntity)));
return;
}
} }
foreach (var (_, set) in verbs) foreach (var verb in verbs)
{ {
foreach (var verb in set) if (verb.Text.ToLowerInvariant() == verbName)
{ {
if (verb.Text.ToLowerInvariant() == verbName) verbSystem.ExecuteVerb(verb, playerEntity.Value, target, forced: true);
{ shell.WriteLine(Loc.GetString("invoke-verb-command-success", ("verb", verb.Text), ("target", target), ("player", playerEntity)));
verbSystem.ExecuteVerb(verb, playerEntity.Value, target, forced: true); return;
shell.WriteLine(Loc.GetString("invoke-verb-command-success", ("verb", verb.Text), ("target", target), ("player", playerEntity)));
return;
}
} }
} }

View File

@@ -1,10 +1,11 @@
using Content.Server.Administration; using Content.Server.Administration;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using System.Linq;
namespace Content.Server.Verbs.Commands namespace Content.Server.Verbs.Commands
{ {
@@ -65,14 +66,11 @@ namespace Content.Server.Verbs.Commands
return; return;
} }
var verbs = verbSystem.GetLocalVerbs(target, playerEntity.Value, VerbType.All, true); var verbs = verbSystem.GetLocalVerbs(target, playerEntity.Value, Verb.VerbTypes);
foreach (var (type, set) in verbs) foreach (var verb in verbs)
{ {
foreach (var verb in set) shell.WriteLine(Loc.GetString("list-verbs-verb-listing", ("type", verb.GetType().Name), ("verb", verb.Text)));
{
shell.WriteLine(Loc.GetString("list-verbs-verb-listing", ("type", type), ("verb", verb.Text)));
}
} }
} }
} }

View File

@@ -6,10 +6,8 @@ using Content.Shared.Database;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Player; using Robust.Shared.Player;
using System.Linq;
namespace Content.Server.Verbs namespace Content.Server.Verbs
{ {
@@ -49,8 +47,19 @@ namespace Content.Server.Verbs
var force = args.AdminRequest && eventArgs.SenderSession is IPlayerSession playerSession && var force = args.AdminRequest && eventArgs.SenderSession is IPlayerSession playerSession &&
_adminMgr.HasAdminFlag(playerSession, AdminFlags.Admin); _adminMgr.HasAdminFlag(playerSession, AdminFlags.Admin);
List<Type> verbTypes = new();
foreach (var key in args.VerbTypes)
{
var type = Verb.VerbTypes.FirstOrDefault(x => x.Name == key);
if (type != null)
verbTypes.Add(type);
else
Logger.Error($"Unknown verb type received: {key}");
}
var response = var response =
new VerbsResponseEvent(args.EntityUid, GetLocalVerbs(args.EntityUid, attached, args.Type, force)); new VerbsResponseEvent(args.EntityUid, GetLocalVerbs(args.EntityUid, attached, verbTypes, force));
RaiseNetworkEvent(response, player.ConnectedClient); RaiseNetworkEvent(response, player.ConnectedClient);
} }

View File

@@ -19,7 +19,7 @@ public sealed partial class GunSystem
{ {
// Probably needs combining with magazines in future given the common functionality. // Probably needs combining with magazines in future given the common functionality.
private void OnAmmoBoxAltVerbs(EntityUid uid, AmmoBoxComponent component, GetAlternativeVerbsEvent args) private void OnAmmoBoxAltVerbs(EntityUid uid, AmmoBoxComponent component, GetVerbsEvent<AlternativeVerb> args)
{ {
if (args.Hands == null || !args.CanAccess || !args.CanInteract) if (args.Hands == null || !args.CanAccess || !args.CanInteract)
return; return;
@@ -27,7 +27,7 @@ public sealed partial class GunSystem
if (component.AmmoLeft == 0) if (component.AmmoLeft == 0)
return; return;
Verb verb = new() AlternativeVerb verb = new()
{ {
Text = Loc.GetString("dump-vert-get-data-text"), Text = Loc.GetString("dump-vert-get-data-text"),
IconTexture = "/Textures/Interface/VerbIcons/eject.svg.192dpi.png", IconTexture = "/Textures/Interface/VerbIcons/eject.svg.192dpi.png",

View File

@@ -17,14 +17,14 @@ namespace Content.Server.Weapon.Ranged;
public sealed partial class GunSystem public sealed partial class GunSystem
{ {
private void AddToggleBoltVerb(EntityUid uid, BoltActionBarrelComponent component, GetInteractionVerbsEvent args) private void AddToggleBoltVerb(EntityUid uid, BoltActionBarrelComponent component, GetVerbsEvent<InteractionVerb> args)
{ {
if (args.Hands == null || if (args.Hands == null ||
!args.CanAccess || !args.CanAccess ||
!args.CanInteract) !args.CanInteract)
return; return;
Verb verb = new() InteractionVerb verb = new()
{ {
Text = component.BoltOpen Text = component.BoltOpen
? Loc.GetString("close-bolt-verb-get-data-text") ? Loc.GetString("close-bolt-verb-get-data-text")

View File

@@ -22,7 +22,7 @@ namespace Content.Server.Weapon.Ranged;
public sealed partial class GunSystem public sealed partial class GunSystem
{ {
private void AddEjectMagazineVerb(EntityUid uid, MagazineBarrelComponent component, GetAlternativeVerbsEvent args) private void AddEjectMagazineVerb(EntityUid uid, MagazineBarrelComponent component, GetVerbsEvent<AlternativeVerb> args)
{ {
if (args.Hands == null || if (args.Hands == null ||
!args.CanAccess || !args.CanAccess ||
@@ -34,7 +34,7 @@ public sealed partial class GunSystem
if (component.MagNeedsOpenBolt && !component.BoltOpen) if (component.MagNeedsOpenBolt && !component.BoltOpen)
return; return;
Verb verb = new() AlternativeVerb verb = new()
{ {
Text = MetaData(component.MagazineContainer.ContainedEntity!.Value).EntityName, Text = MetaData(component.MagazineContainer.ContainedEntity!.Value).EntityName,
Category = VerbCategory.Eject, Category = VerbCategory.Eject,
@@ -43,7 +43,7 @@ public sealed partial class GunSystem
args.Verbs.Add(verb); args.Verbs.Add(verb);
} }
private void AddMagazineInteractionVerbs(EntityUid uid, MagazineBarrelComponent component, GetInteractionVerbsEvent args) private void AddMagazineInteractionVerbs(EntityUid uid, MagazineBarrelComponent component, GetVerbsEvent<InteractionVerb> args)
{ {
if (args.Hands == null || if (args.Hands == null ||
!args.CanAccess || !args.CanAccess ||
@@ -51,7 +51,7 @@ public sealed partial class GunSystem
return; return;
// Toggle bolt verb // Toggle bolt verb
Verb toggleBolt = new() InteractionVerb toggleBolt = new()
{ {
Text = component.BoltOpen Text = component.BoltOpen
? Loc.GetString("close-bolt-verb-get-data-text") ? Loc.GetString("close-bolt-verb-get-data-text")
@@ -67,7 +67,7 @@ public sealed partial class GunSystem
return; return;
// Insert mag verb // Insert mag verb
Verb insert = new() InteractionVerb insert = new()
{ {
Text = MetaData(@using).EntityName, Text = MetaData(@using).EntityName,
Category = VerbCategory.Insert, Category = VerbCategory.Insert,

View File

@@ -175,7 +175,7 @@ public sealed partial class GunSystem
appearance.SetData(AmmoVisuals.AmmoMax, component.Capacity); appearance.SetData(AmmoVisuals.AmmoMax, component.Capacity);
} }
private void AddSpinVerb(EntityUid uid, RevolverBarrelComponent component, GetAlternativeVerbsEvent args) private void AddSpinVerb(EntityUid uid, RevolverBarrelComponent component, GetVerbsEvent<AlternativeVerb> args)
{ {
if (args.Hands == null || !args.CanAccess || !args.CanInteract) if (args.Hands == null || !args.CanAccess || !args.CanInteract)
return; return;
@@ -183,7 +183,7 @@ public sealed partial class GunSystem
if (component.Capacity <= 1 || component.ShotsLeft == 0) if (component.Capacity <= 1 || component.ShotsLeft == 0)
return; return;
Verb verb = new() AlternativeVerb verb = new()
{ {
Text = Loc.GetString("spin-revolver-verb-get-data-text"), Text = Loc.GetString("spin-revolver-verb-get-data-text"),
IconTexture = "/Textures/Interface/VerbIcons/refresh.svg.192dpi.png", IconTexture = "/Textures/Interface/VerbIcons/refresh.svg.192dpi.png",

View File

@@ -70,7 +70,7 @@ public sealed partial class GunSystem : EntitySystem
SubscribeLocalEvent<AmmoBoxComponent, InteractUsingEvent>(OnAmmoBoxInteractUsing); SubscribeLocalEvent<AmmoBoxComponent, InteractUsingEvent>(OnAmmoBoxInteractUsing);
SubscribeLocalEvent<AmmoBoxComponent, UseInHandEvent>(OnAmmoBoxUse); SubscribeLocalEvent<AmmoBoxComponent, UseInHandEvent>(OnAmmoBoxUse);
SubscribeLocalEvent<AmmoBoxComponent, InteractHandEvent>(OnAmmoBoxInteractHand); SubscribeLocalEvent<AmmoBoxComponent, InteractHandEvent>(OnAmmoBoxInteractHand);
SubscribeLocalEvent<AmmoBoxComponent, GetAlternativeVerbsEvent>(OnAmmoBoxAltVerbs); SubscribeLocalEvent<AmmoBoxComponent, GetVerbsEvent<AlternativeVerb>>(OnAmmoBoxAltVerbs);
SubscribeLocalEvent<RangedMagazineComponent, ComponentInit>(OnRangedMagInit); SubscribeLocalEvent<RangedMagazineComponent, ComponentInit>(OnRangedMagInit);
SubscribeLocalEvent<RangedMagazineComponent, MapInitEvent>(OnRangedMagMapInit); SubscribeLocalEvent<RangedMagazineComponent, MapInitEvent>(OnRangedMagMapInit);
@@ -96,7 +96,7 @@ public sealed partial class GunSystem : EntitySystem
SubscribeLocalEvent<BoltActionBarrelComponent, InteractUsingEvent>(OnBoltInteractUsing); SubscribeLocalEvent<BoltActionBarrelComponent, InteractUsingEvent>(OnBoltInteractUsing);
SubscribeLocalEvent<BoltActionBarrelComponent, ComponentGetState>(OnBoltGetState); SubscribeLocalEvent<BoltActionBarrelComponent, ComponentGetState>(OnBoltGetState);
SubscribeLocalEvent<BoltActionBarrelComponent, ExaminedEvent>(OnBoltExamine); SubscribeLocalEvent<BoltActionBarrelComponent, ExaminedEvent>(OnBoltExamine);
SubscribeLocalEvent<BoltActionBarrelComponent, GetInteractionVerbsEvent>(AddToggleBoltVerb); SubscribeLocalEvent<BoltActionBarrelComponent, GetVerbsEvent<InteractionVerb>>(AddToggleBoltVerb);
SubscribeLocalEvent<MagazineBarrelComponent, ComponentInit>(OnMagazineInit); SubscribeLocalEvent<MagazineBarrelComponent, ComponentInit>(OnMagazineInit);
SubscribeLocalEvent<MagazineBarrelComponent, MapInitEvent>(OnMagazineMapInit); SubscribeLocalEvent<MagazineBarrelComponent, MapInitEvent>(OnMagazineMapInit);
@@ -104,8 +104,8 @@ public sealed partial class GunSystem : EntitySystem
SubscribeLocalEvent<MagazineBarrelComponent, UseInHandEvent>(OnMagazineUse); SubscribeLocalEvent<MagazineBarrelComponent, UseInHandEvent>(OnMagazineUse);
SubscribeLocalEvent<MagazineBarrelComponent, InteractUsingEvent>(OnMagazineInteractUsing); SubscribeLocalEvent<MagazineBarrelComponent, InteractUsingEvent>(OnMagazineInteractUsing);
SubscribeLocalEvent<MagazineBarrelComponent, ComponentGetState>(OnMagazineGetState); SubscribeLocalEvent<MagazineBarrelComponent, ComponentGetState>(OnMagazineGetState);
SubscribeLocalEvent<MagazineBarrelComponent, GetInteractionVerbsEvent>(AddMagazineInteractionVerbs); SubscribeLocalEvent<MagazineBarrelComponent, GetVerbsEvent<InteractionVerb>>(AddMagazineInteractionVerbs);
SubscribeLocalEvent<MagazineBarrelComponent, GetAlternativeVerbsEvent>(AddEjectMagazineVerb); SubscribeLocalEvent<MagazineBarrelComponent, GetVerbsEvent<AlternativeVerb>>(AddEjectMagazineVerb);
SubscribeLocalEvent<PumpBarrelComponent, ComponentGetState>(OnPumpGetState); SubscribeLocalEvent<PumpBarrelComponent, ComponentGetState>(OnPumpGetState);
SubscribeLocalEvent<PumpBarrelComponent, ComponentInit>(OnPumpInit); SubscribeLocalEvent<PumpBarrelComponent, ComponentInit>(OnPumpInit);
@@ -118,7 +118,7 @@ public sealed partial class GunSystem : EntitySystem
SubscribeLocalEvent<RevolverBarrelComponent, UseInHandEvent>(OnRevolverUse); SubscribeLocalEvent<RevolverBarrelComponent, UseInHandEvent>(OnRevolverUse);
SubscribeLocalEvent<RevolverBarrelComponent, InteractUsingEvent>(OnRevolverInteractUsing); SubscribeLocalEvent<RevolverBarrelComponent, InteractUsingEvent>(OnRevolverInteractUsing);
SubscribeLocalEvent<RevolverBarrelComponent, ComponentGetState>(OnRevolverGetState); SubscribeLocalEvent<RevolverBarrelComponent, ComponentGetState>(OnRevolverGetState);
SubscribeLocalEvent<RevolverBarrelComponent, GetAlternativeVerbsEvent>(AddSpinVerb); SubscribeLocalEvent<RevolverBarrelComponent, GetVerbsEvent<AlternativeVerb>>(AddSpinVerb);
SubscribeLocalEvent<SpeedLoaderComponent, ComponentInit>(OnSpeedLoaderInit); SubscribeLocalEvent<SpeedLoaderComponent, ComponentInit>(OnSpeedLoaderInit);
SubscribeLocalEvent<SpeedLoaderComponent, MapInitEvent>(OnSpeedLoaderMapInit); SubscribeLocalEvent<SpeedLoaderComponent, MapInitEvent>(OnSpeedLoaderMapInit);

View File

@@ -30,12 +30,12 @@ namespace Content.Server.Wieldable
SubscribeLocalEvent<WieldableComponent, ItemUnwieldedEvent>(OnItemUnwielded); SubscribeLocalEvent<WieldableComponent, ItemUnwieldedEvent>(OnItemUnwielded);
SubscribeLocalEvent<WieldableComponent, UnequippedHandEvent>(OnItemLeaveHand); SubscribeLocalEvent<WieldableComponent, UnequippedHandEvent>(OnItemLeaveHand);
SubscribeLocalEvent<WieldableComponent, VirtualItemDeletedEvent>(OnVirtualItemDeleted); SubscribeLocalEvent<WieldableComponent, VirtualItemDeletedEvent>(OnVirtualItemDeleted);
SubscribeLocalEvent<WieldableComponent, GetInteractionVerbsEvent>(AddToggleWieldVerb); SubscribeLocalEvent<WieldableComponent, GetVerbsEvent<InteractionVerb>>(AddToggleWieldVerb);
SubscribeLocalEvent<IncreaseDamageOnWieldComponent, MeleeHitEvent>(OnMeleeHit); SubscribeLocalEvent<IncreaseDamageOnWieldComponent, MeleeHitEvent>(OnMeleeHit);
} }
private void AddToggleWieldVerb(EntityUid uid, WieldableComponent component, GetInteractionVerbsEvent args) private void AddToggleWieldVerb(EntityUid uid, WieldableComponent component, GetVerbsEvent<InteractionVerb> args)
{ {
if (args.Hands == null || !args.CanAccess || !args.CanInteract) if (args.Hands == null || !args.CanAccess || !args.CanInteract)
return; return;
@@ -44,7 +44,7 @@ namespace Content.Server.Wieldable
// verb. Or just don't add it to the list if the action is not executable. // verb. Or just don't add it to the list if the action is not executable.
// TODO VERBS ICON + localization // TODO VERBS ICON + localization
Verb verb = new() InteractionVerb verb = new()
{ {
Text = component.Wielded ? "Unwield" : "Wield", Text = component.Wielded ? "Unwield" : "Wield",
Act = component.Wielded Act = component.Wielded

View File

@@ -39,8 +39,8 @@ namespace Content.Shared.Containers.ItemSlots
SubscribeLocalEvent<ItemSlotsComponent, InteractHandEvent>(OnInteractHand); SubscribeLocalEvent<ItemSlotsComponent, InteractHandEvent>(OnInteractHand);
SubscribeLocalEvent<ItemSlotsComponent, UseInHandEvent>(OnUseInHand); SubscribeLocalEvent<ItemSlotsComponent, UseInHandEvent>(OnUseInHand);
SubscribeLocalEvent<ItemSlotsComponent, GetAlternativeVerbsEvent>(AddEjectVerbs); SubscribeLocalEvent<ItemSlotsComponent, GetVerbsEvent<AlternativeVerb>>(AddEjectVerbs);
SubscribeLocalEvent<ItemSlotsComponent, GetInteractionVerbsEvent>(AddInteractionVerbsVerbs); SubscribeLocalEvent<ItemSlotsComponent, GetVerbsEvent<InteractionVerb>>(AddInteractionVerbsVerbs);
SubscribeLocalEvent<ItemSlotsComponent, BreakageEventArgs>(OnBreak); SubscribeLocalEvent<ItemSlotsComponent, BreakageEventArgs>(OnBreak);
SubscribeLocalEvent<ItemSlotsComponent, DestructionEventArgs>(OnBreak); SubscribeLocalEvent<ItemSlotsComponent, DestructionEventArgs>(OnBreak);
@@ -380,7 +380,7 @@ namespace Content.Shared.Containers.ItemSlots
#endregion #endregion
#region Verbs #region Verbs
private void AddEjectVerbs(EntityUid uid, ItemSlotsComponent itemSlots, GetAlternativeVerbsEvent args) private void AddEjectVerbs(EntityUid uid, ItemSlotsComponent itemSlots, GetVerbsEvent<AlternativeVerb> args)
{ {
if (args.Hands == null || !args.CanAccess ||!args.CanInteract || if (args.Hands == null || !args.CanAccess ||!args.CanInteract ||
!_actionBlockerSystem.CanPickup(args.User)) !_actionBlockerSystem.CanPickup(args.User))
@@ -402,7 +402,7 @@ namespace Content.Shared.Containers.ItemSlots
? Loc.GetString(slot.Name) ? Loc.GetString(slot.Name)
: EntityManager.GetComponent<MetaDataComponent>(slot.Item!.Value).EntityName ?? string.Empty; : EntityManager.GetComponent<MetaDataComponent>(slot.Item!.Value).EntityName ?? string.Empty;
Verb verb = new(); AlternativeVerb verb = new();
verb.Act = () => TryEjectToHands(uid, slot, args.User, excludeUserAudio: true); verb.Act = () => TryEjectToHands(uid, slot, args.User, excludeUserAudio: true);
if (slot.EjectVerbText == null) if (slot.EjectVerbText == null)
@@ -420,7 +420,7 @@ namespace Content.Shared.Containers.ItemSlots
} }
} }
private void AddInteractionVerbsVerbs(EntityUid uid, ItemSlotsComponent itemSlots, GetInteractionVerbsEvent args) private void AddInteractionVerbsVerbs(EntityUid uid, ItemSlotsComponent itemSlots, GetVerbsEvent<InteractionVerb> args)
{ {
if (args.Hands == null || !args.CanAccess || !args.CanInteract) if (args.Hands == null || !args.CanAccess || !args.CanInteract)
return; return;
@@ -437,7 +437,7 @@ namespace Content.Shared.Containers.ItemSlots
? Loc.GetString(slot.Name) ? Loc.GetString(slot.Name)
: EntityManager.GetComponent<MetaDataComponent>(slot.Item!.Value).EntityName ?? string.Empty; : EntityManager.GetComponent<MetaDataComponent>(slot.Item!.Value).EntityName ?? string.Empty;
Verb takeVerb = new(); InteractionVerb takeVerb = new();
takeVerb.Act = () => TryEjectToHands(uid, slot, args.User, excludeUserAudio: true); takeVerb.Act = () => TryEjectToHands(uid, slot, args.User, excludeUserAudio: true);
takeVerb.IconTexture = "/Textures/Interface/VerbIcons/pickup.svg.192dpi.png"; takeVerb.IconTexture = "/Textures/Interface/VerbIcons/pickup.svg.192dpi.png";
@@ -463,7 +463,7 @@ namespace Content.Shared.Containers.ItemSlots
? Loc.GetString(slot.Name) ? Loc.GetString(slot.Name)
: Name(args.Using.Value) ?? string.Empty; : Name(args.Using.Value) ?? string.Empty;
Verb insertVerb = new(); InteractionVerb insertVerb = new();
insertVerb.Act = () => Insert(uid, slot, args.Using.Value, args.User, excludeUserAudio: true); insertVerb.Act = () => Insert(uid, slot, args.Using.Value, args.User, excludeUserAudio: true);
if (slot.InsertVerbText != null) if (slot.InsertVerbText != null)

View File

@@ -15,12 +15,12 @@ public class FollowerSystem : EntitySystem
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<GetAlternativeVerbsEvent>(OnGetAlternativeVerbs); SubscribeLocalEvent<GetVerbsEvent<AlternativeVerb>>(OnGetAlternativeVerbs);
SubscribeLocalEvent<FollowerComponent, RelayMoveInputEvent>(OnFollowerMove); SubscribeLocalEvent<FollowerComponent, RelayMoveInputEvent>(OnFollowerMove);
SubscribeLocalEvent<FollowedComponent, EntityTerminatingEvent>(OnFollowedTerminating); SubscribeLocalEvent<FollowedComponent, EntityTerminatingEvent>(OnFollowedTerminating);
} }
private void OnGetAlternativeVerbs(GetAlternativeVerbsEvent ev) private void OnGetAlternativeVerbs(GetVerbsEvent<AlternativeVerb> ev)
{ {
if (!HasComp<SharedGhostComponent>(ev.User)) if (!HasComp<SharedGhostComponent>(ev.User))
return; return;
@@ -28,7 +28,7 @@ public class FollowerSystem : EntitySystem
if (ev.User == ev.Target) if (ev.User == ev.Target)
return; return;
var verb = new Verb var verb = new AlternativeVerb
{ {
Priority = 10, Priority = 10,
Act = (() => Act = (() =>

View File

@@ -743,7 +743,7 @@ namespace Content.Shared.Interaction
public bool AltInteract(EntityUid user, EntityUid target) public bool AltInteract(EntityUid user, EntityUid target)
{ {
// Get list of alt-interact verbs // Get list of alt-interact verbs
var verbs = _verbSystem.GetLocalVerbs(target, user, VerbType.Alternative)[VerbType.Alternative]; var verbs = _verbSystem.GetLocalVerbs(target, user, typeof(AlternativeVerb));
if (!verbs.Any()) if (!verbs.Any())
return false; return false;

View File

@@ -12,7 +12,7 @@ namespace Content.Shared.Item
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<SharedItemComponent, GetInteractionVerbsEvent>(AddPickupVerb); SubscribeLocalEvent<SharedItemComponent, GetVerbsEvent<InteractionVerb>>(AddPickupVerb);
SubscribeLocalEvent<SharedSpriteComponent, GotEquippedEvent>(OnEquipped); SubscribeLocalEvent<SharedSpriteComponent, GotEquippedEvent>(OnEquipped);
SubscribeLocalEvent<SharedSpriteComponent, GotUnequippedEvent>(OnUnequipped); SubscribeLocalEvent<SharedSpriteComponent, GotUnequippedEvent>(OnUnequipped);
@@ -52,7 +52,7 @@ namespace Content.Shared.Item
component.Visible = false; component.Visible = false;
} }
private void AddPickupVerb(EntityUid uid, SharedItemComponent component, GetInteractionVerbsEvent args) private void AddPickupVerb(EntityUid uid, SharedItemComponent component, GetVerbsEvent<InteractionVerb> args)
{ {
if (args.Hands == null || if (args.Hands == null ||
args.Using != null || args.Using != null ||
@@ -61,7 +61,7 @@ namespace Content.Shared.Item
!args.Hands.CanPickupEntityToActiveHand(args.Target)) !args.Hands.CanPickupEntityToActiveHand(args.Target))
return; return;
Verb verb = new(); InteractionVerb verb = new();
verb.Act = () => args.Hands.TryPickupEntityToActiveHand(args.Target); verb.Act = () => args.Hands.TryPickupEntityToActiveHand(args.Target);
verb.IconTexture = "/Textures/Interface/VerbIcons/pickup.svg.192dpi.png"; verb.IconTexture = "/Textures/Interface/VerbIcons/pickup.svg.192dpi.png";

View File

@@ -68,14 +68,14 @@ namespace Content.Shared.Pulling
SubscribeLocalEvent<SharedPullableComponent, PullStartedMessage>(PullableHandlePullStarted); SubscribeLocalEvent<SharedPullableComponent, PullStartedMessage>(PullableHandlePullStarted);
SubscribeLocalEvent<SharedPullableComponent, PullStoppedMessage>(PullableHandlePullStopped); SubscribeLocalEvent<SharedPullableComponent, PullStoppedMessage>(PullableHandlePullStopped);
SubscribeLocalEvent<SharedPullableComponent, GetOtherVerbsEvent>(AddPullVerbs); SubscribeLocalEvent<SharedPullableComponent, GetVerbsEvent<Verb>>(AddPullVerbs);
CommandBinds.Builder CommandBinds.Builder
.Bind(ContentKeyFunctions.MovePulledObject, new PointerInputCmdHandler(HandleMovePulledObject)) .Bind(ContentKeyFunctions.MovePulledObject, new PointerInputCmdHandler(HandleMovePulledObject))
.Register<SharedPullingSystem>(); .Register<SharedPullingSystem>();
} }
private void AddPullVerbs(EntityUid uid, SharedPullableComponent component, GetOtherVerbsEvent args) private void AddPullVerbs(EntityUid uid, SharedPullableComponent component, GetVerbsEvent<Verb> args)
{ {
if (args.Hands == null || !args.CanAccess || !args.CanInteract) if (args.Hands == null || !args.CanAccess || !args.CanInteract)
return; return;

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
@@ -5,6 +6,7 @@ using Content.Shared.Interaction;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Utility;
namespace Content.Shared.Verbs namespace Content.Shared.Verbs
{ {
@@ -29,7 +31,7 @@ namespace Content.Shared.Verbs
// Get the list of verbs. This effectively also checks that the requested verb is in fact a valid verb that // Get the list of verbs. This effectively also checks that the requested verb is in fact a valid verb that
// the user can perform. // the user can perform.
var verbs = GetLocalVerbs(args.Target, user.Value, args.Type)[args.Type]; var verbs = GetLocalVerbs(args.Target, user.Value, args.RequestedVerb.GetType());
// Note that GetLocalVerbs might waste time checking & preparing unrelated verbs even though we know // Note that GetLocalVerbs might waste time checking & preparing unrelated verbs even though we know
// precisely which one we want to run. However, MOST entities will only have 1 or 2 verbs of a given type. // precisely which one we want to run. However, MOST entities will only have 1 or 2 verbs of a given type.
@@ -44,9 +46,18 @@ namespace Content.Shared.Verbs
/// Raises a number of events in order to get all verbs of the given type(s) defined in local systems. This /// Raises a number of events in order to get all verbs of the given type(s) defined in local systems. This
/// does not request verbs from the server. /// does not request verbs from the server.
/// </summary> /// </summary>
public virtual Dictionary<VerbType, SortedSet<Verb>> GetLocalVerbs(EntityUid target, EntityUid user, VerbType verbTypes, bool force = false) public SortedSet<Verb> GetLocalVerbs(EntityUid target, EntityUid user, Type type, bool force = false, bool all = false)
{ {
Dictionary<VerbType, SortedSet<Verb>> verbs = new(); return GetLocalVerbs(target, user, new List<Type>() { type }, force, all);
}
/// <summary>
/// Raises a number of events in order to get all verbs of the given type(s) defined in local systems. This
/// does not request verbs from the server.
/// </summary>
public SortedSet<Verb> GetLocalVerbs(EntityUid target, EntityUid user, List<Type> types, bool force = false, bool all = false)
{
SortedSet<Verb> verbs = new();
// accessibility checks // accessibility checks
bool canAccess = false; bool canAccess = false;
@@ -80,32 +91,33 @@ namespace Content.Shared.Verbs
} }
} }
if ((verbTypes & VerbType.Interaction) == VerbType.Interaction) if (types.Contains(typeof(InteractionVerb)))
{ {
GetInteractionVerbsEvent getVerbEvent = new(user, target, @using, hands, canInteract, canAccess); var verbEvent = new GetVerbsEvent<InteractionVerb>(user, target, @using, hands, canInteract, canAccess);
RaiseLocalEvent(target, getVerbEvent); RaiseLocalEvent(target, verbEvent);
verbs.Add(VerbType.Interaction, getVerbEvent.Verbs); verbs.UnionWith(verbEvent.Verbs);
} }
if ((verbTypes & VerbType.Activation) == VerbType.Activation) if (types.Contains(typeof(AlternativeVerb)))
{ {
GetActivationVerbsEvent getVerbEvent = new(user, target, @using, hands, canInteract, canAccess); var verbEvent = new GetVerbsEvent<AlternativeVerb>(user, target, @using, hands, canInteract, canAccess);
RaiseLocalEvent(target, getVerbEvent); RaiseLocalEvent(target, verbEvent);
verbs.Add(VerbType.Activation, getVerbEvent.Verbs); verbs.UnionWith(verbEvent.Verbs);
} }
if ((verbTypes & VerbType.Alternative) == VerbType.Alternative) if (types.Contains(typeof(ActivationVerb)))
{ {
GetAlternativeVerbsEvent getVerbEvent = new(user, target, @using, hands, canInteract, canAccess); var verbEvent = new GetVerbsEvent<ActivationVerb>(user, target, @using, hands, canInteract, canAccess);
RaiseLocalEvent(target, getVerbEvent); RaiseLocalEvent(target, verbEvent);
verbs.Add(VerbType.Alternative, getVerbEvent.Verbs); verbs.UnionWith(verbEvent.Verbs);
} }
if ((verbTypes & VerbType.Other) == VerbType.Other) // generic verbs
if (types.Contains(typeof(Verb)))
{ {
GetOtherVerbsEvent getVerbEvent = new(user, target, @using, hands, canInteract, canAccess); var verbEvent = new GetVerbsEvent<Verb>(user, target, @using, hands, canInteract, canAccess);
RaiseLocalEvent(target, getVerbEvent); RaiseLocalEvent(target, verbEvent);
verbs.Add(VerbType.Other, getVerbEvent.Verbs); verbs.UnionWith(verbEvent.Verbs);
} }
return verbs; return verbs;

View File

@@ -1,30 +1,33 @@
using Content.Shared.Administration.Logs;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using System; using System;
using Content.Shared.Database; using Content.Shared.Database;
using System.Collections.Generic;
namespace Content.Shared.Verbs namespace Content.Shared.Verbs
{ {
[Flags]
public enum VerbType
{
Interaction = 1,
Activation = 2,
Alternative = 4,
Other = 8,
All = 1+2+4+8
}
/// <summary> /// <summary>
/// Verb objects describe actions that a user can take. The actions can be specified via an Action, local /// Verb objects describe actions that a user can take. The actions can be specified via an Action, local
/// events, or networked events. Verbs also provide text, icons, and categories for displaying in the /// events, or networked events. Verbs also provide text, icons, and categories for displaying in the
/// context-menu. /// context-menu.
/// </summary> /// </summary>
[Serializable, NetSerializable] [Serializable, NetSerializable]
public sealed class Verb : IComparable public class Verb : IComparable
{ {
public static string DefaultTextStyleClass = "Verb";
/// <summary>
/// Determines the priority of this type of verb when displaying in the verb-menu. See <see
/// cref="CompareTo"/>.
/// </summary>
public virtual int TypePriority => 0;
/// <summary>
/// Style class for drawing in the context menu
/// </summary>
public string TextStyleClass = DefaultTextStyleClass;
/// <summary> /// <summary>
/// This is an action that will be run when the verb is "acted" out. /// This is an action that will be run when the verb is "acted" out.
/// </summary> /// </summary>
@@ -161,7 +164,11 @@ namespace Content.Shared.Verbs
if (obj is not Verb otherVerb) if (obj is not Verb otherVerb)
return -1; return -1;
// Sort first by priority // Sort first by type-priority
if (TypePriority != otherVerb.TypePriority)
return otherVerb.TypePriority - TypePriority;
// Then by verb-priority
if (Priority != otherVerb.Priority) if (Priority != otherVerb.Priority)
return otherVerb.Priority - Priority; return otherVerb.Priority - Priority;
@@ -180,5 +187,81 @@ namespace Content.Shared.Verbs
// Finally, compare icon texture paths. Note that this matters for verbs that don't have any text (e.g., the rotate-verbs) // Finally, compare icon texture paths. Note that this matters for verbs that don't have any text (e.g., the rotate-verbs)
return string.Compare(IconTexture, otherVerb.IconTexture, StringComparison.CurrentCulture); return string.Compare(IconTexture, otherVerb.IconTexture, StringComparison.CurrentCulture);
} }
/// <summary>
/// Collection of all verb types, along with string keys.
/// </summary>
/// <remarks>
/// Useful when iterating over verb types, though maybe this should be obtained and stored via reflection or
/// something (list of all classes that inherit from Verb). Currently used for networking (apparently Type
/// is not serializable?), and resolving console commands.
/// </remarks>
public static List<Type> VerbTypes = new()
{
{ typeof(Verb) },
{ typeof(InteractionVerb) },
{ typeof(AlternativeVerb) },
{ typeof(ActivationVerb) },
};
}
/// <summary>
/// Primary interaction verbs. This includes both use-in-hand and interacting with external entities.
/// </summary>
/// <remarks>
/// These verbs those that involve using the hands or the currently held item on some entity. These verbs usually
/// correspond to interactions that can be triggered by left-clicking or using 'Z', and often depend on the
/// currently held item. These verbs are collectively shown first in the context menu.
/// </remarks>
[Serializable, NetSerializable]
public sealed class InteractionVerb : Verb
{
public new static string DefaultTextStyleClass = "InteractionVerb";
public override int TypePriority => 4;
public InteractionVerb() : base()
{
TextStyleClass = DefaultTextStyleClass;
}
}
/// <summary>
/// Verbs for alternative-interactions.
/// </summary>
/// <remarks>
/// When interacting with an entity via alt + left-click/E/Z the highest priority alt-interact verb is executed.
/// These verbs are collectively shown second-to-last in the context menu.
/// </remarks>
[Serializable, NetSerializable]
public sealed class AlternativeVerb : Verb
{
public override int TypePriority => 2;
public new static string DefaultTextStyleClass = "AlternativeVerb";
public AlternativeVerb() : base()
{
TextStyleClass = DefaultTextStyleClass;
}
}
/// <summary>
/// Activation-type verbs.
/// </summary>
/// <remarks>
/// These are verbs that activate an item in the world but are independent of the currently held items. For
/// example, opening a door or a GUI. These verbs should correspond to interactions that can be triggered by
/// using 'E', though many of those can also be triggered by left-mouse or 'Z' if there is no other interaction.
/// These verbs are collectively shown second in the context menu.
/// </remarks>
[Serializable, NetSerializable]
public sealed class ActivationVerb : Verb
{
public override int TypePriority => 1;
public new static string DefaultTextStyleClass = "ActivationVerb";
public ActivationVerb() : base()
{
TextStyleClass = DefaultTextStyleClass;
}
} }
} }

View File

@@ -1,19 +1,18 @@
using System;
using System.Collections.Generic;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Robust.Shared.Containers;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Content.Shared.Verbs namespace Content.Shared.Verbs
{ {
[Serializable, NetSerializable] [Serializable, NetSerializable]
public class RequestServerVerbsEvent : EntityEventArgs public sealed class RequestServerVerbsEvent : EntityEventArgs
{ {
public readonly EntityUid EntityUid; public readonly EntityUid EntityUid;
public readonly VerbType Type;
public readonly List<string> VerbTypes = new();
/// <summary> /// <summary>
/// If the target item is inside of some storage (e.g., backpack), this is the entity that owns that item /// If the target item is inside of some storage (e.g., backpack), this is the entity that owns that item
@@ -23,121 +22,60 @@ namespace Content.Shared.Verbs
public readonly bool AdminRequest; public readonly bool AdminRequest;
public RequestServerVerbsEvent(EntityUid entityUid, VerbType type, EntityUid? slotOwner = null, bool adminRequest = false) public RequestServerVerbsEvent(EntityUid entityUid, List<Type> verbTypes, EntityUid? slotOwner = null, bool adminRequest = false)
{ {
EntityUid = entityUid; EntityUid = entityUid;
Type = type;
SlotOwner = slotOwner; SlotOwner = slotOwner;
AdminRequest = adminRequest; AdminRequest = adminRequest;
foreach (var type in verbTypes)
{
DebugTools.Assert(typeof(Verb).IsAssignableFrom(type));
VerbTypes.Add(type.Name);
}
} }
} }
[Serializable, NetSerializable] [Serializable, NetSerializable]
public class VerbsResponseEvent : EntityEventArgs public sealed class VerbsResponseEvent : EntityEventArgs
{ {
public readonly Dictionary<VerbType, List<Verb>>? Verbs; public readonly List<Verb>? Verbs;
public readonly EntityUid Entity; public readonly EntityUid Entity;
public VerbsResponseEvent(EntityUid entity, Dictionary<VerbType, SortedSet<Verb>>? verbs) public VerbsResponseEvent(EntityUid entity, SortedSet<Verb>? verbs)
{ {
Entity = entity; Entity = entity;
if (verbs == null) if (verbs == null)
return; return;
// Apparently SortedSet is not serlializable. Cast to List<Verb>. // Apparently SortedSet is not serializable, so we cast to List<Verb>.
Verbs = new(); Verbs = new(verbs);
foreach (var entry in verbs)
{
Verbs.Add(entry.Key, new List<Verb>(entry.Value));
}
} }
} }
[Serializable, NetSerializable] [Serializable, NetSerializable]
public class ExecuteVerbEvent : EntityEventArgs public sealed class ExecuteVerbEvent : EntityEventArgs
{ {
public readonly EntityUid Target; public readonly EntityUid Target;
public readonly Verb RequestedVerb; public readonly Verb RequestedVerb;
/// <summary> public ExecuteVerbEvent(EntityUid target, Verb requestedVerb)
/// The type of verb to try execute. Avoids having to get a list of all verbs on the receiving end.
/// </summary>
public readonly VerbType Type;
public ExecuteVerbEvent(EntityUid target, Verb requestedVerb, VerbType type)
{ {
Target = target; Target = target;
RequestedVerb = requestedVerb; RequestedVerb = requestedVerb;
Type = type;
} }
} }
/// <summary>
/// Request primary interaction verbs. This includes both use-in-hand and interacting with external entities.
/// </summary>
/// <remarks>
/// These verbs those that involve using the hands or the currently held item on some entity. These verbs usually
/// correspond to interactions that can be triggered by left-clicking or using 'Z', and often depend on the
/// currently held item. These verbs are collectively shown first in the context menu.
/// </remarks>
public class GetInteractionVerbsEvent : GetVerbsEvent
{
public GetInteractionVerbsEvent(EntityUid user, EntityUid target, EntityUid? @using, SharedHandsComponent? hands,
bool canInteract, bool canAccess) : base(user, target, @using, hands, canInteract, canAccess) { }
}
/// <summary>
/// Request activation verbs.
/// </summary>
/// <remarks>
/// These are verbs that activate an item in the world but are independent of the currently held items. For
/// example, opening a door or a GUI. These verbs should correspond to interactions that can be triggered by
/// using 'E', though many of those can also be triggered by left-mouse or 'Z' if there is no other interaction.
/// These verbs are collectively shown second in the context menu.
/// </remarks>
public class GetActivationVerbsEvent : GetVerbsEvent
{
public GetActivationVerbsEvent(EntityUid user, EntityUid target, EntityUid? @using, SharedHandsComponent? hands,
bool canInteract, bool canAccess) : base(user, target, @using, hands, canInteract, canAccess) { }
}
/// <summary>
/// Request alternative-interaction verbs.
/// </summary>
/// <remarks>
/// When interacting with an entity via alt + left-click/E/Z the highest priority alt-interact verb is executed.
/// These verbs are collectively shown second-to-last in the context menu.
/// </remarks>
public class GetAlternativeVerbsEvent : GetVerbsEvent
{
public GetAlternativeVerbsEvent(EntityUid user, EntityUid target, EntityUid? @using, SharedHandsComponent? hands,
bool canInteract, bool canAccess) : base(user, target, @using, hands, canInteract, canAccess) { }
}
/// <summary>
/// Request Miscellaneous verbs.
/// </summary>
/// <remarks>
/// Includes (nearly) global interactions like "examine", "pull", or "debug". These verbs are collectively shown
/// last in the context menu.
/// </remarks>
public class GetOtherVerbsEvent : GetVerbsEvent
{
public GetOtherVerbsEvent(EntityUid user, EntityUid target, EntityUid? @using, SharedHandsComponent? hands,
bool canInteract, bool canAccess) : base(user, target, @using, hands, canInteract, canAccess) { }
}
/// <summary> /// <summary>
/// Directed event that requests verbs from any systems/components on a target entity. /// Directed event that requests verbs from any systems/components on a target entity.
/// </summary> /// </summary>
public class GetVerbsEvent : EntityEventArgs public sealed class GetVerbsEvent<TVerb> : EntityEventArgs where TVerb : Verb
{ {
/// <summary> /// <summary>
/// Event output. Set of verbs that can be executed. /// Event output. Set of verbs that can be executed.
/// </summary> /// </summary>
public readonly SortedSet<Verb> Verbs = new(); public readonly SortedSet<TVerb> Verbs = new();
/// <summary> /// <summary>
/// Can the user physically access the target? /// Can the user physically access the target?
@@ -180,7 +118,7 @@ namespace Content.Shared.Verbs
/// The entity currently being held by the active hand. /// The entity currently being held by the active hand.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This is only ever not null when <see cref="ActionBlockerSystem.CanUse(Robust.Shared.GameObjects.EntityUid)"/> is true and the user /// This is only ever not null when <see cref="ActionBlockerSystem.CanUse(EntityUid)"/> is true and the user
/// has hands. /// has hands.
/// </remarks> /// </remarks>
public readonly EntityUid? Using; public readonly EntityUid? Using;