Add global verbs (#400)
* Add support for global verbs These are verbs that are visible for all entities, regardless of their components. This works by adding a new class `GlobalVerb` and a new attribute `GlobalVerbAttribute`. It works in the same way as current verbs, except you can put the verbs class definition anywhere instead of inside a component. Also moved VerbUtility into it's own file since it now has functions for both verbs and global verbs. * Add view variables verb as an example of global verbs * Implement suggested changes Implemented some suggested changes from code review: - Remove unneeded attribute from `GlobalVerb` - Added some useful attributes to `GlobalVerbAttribute` - Moved constants used by both `Verb` and `GlobalVerb` into `VerbUtility` * Reduce duplicate code in VerbSystem (client & server) Greatly reduced the amount of duplicate code for handling component verbs and global verbs separately. * Update engine submodule Need this so client side permissions checks are available.
This commit is contained in:
committed by
Pieter-Jan Briers
parent
e4f3ea7798
commit
6497cdf8ff
32
Content.Client/GlobalVerbs/ViewVariablesVerb.cs
Normal file
32
Content.Client/GlobalVerbs/ViewVariablesVerb.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Content.Shared.GameObjects;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.ViewVariables;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.GlobalVerbs
|
||||
{
|
||||
/// <summary>
|
||||
/// Global verb that opens a view variables window for the entity in question.
|
||||
/// </summary>
|
||||
[GlobalVerb]
|
||||
class ViewVariablesVerb : GlobalVerb
|
||||
{
|
||||
public override string GetText(IEntity user, IEntity target) => "View variables";
|
||||
public override bool RequireInteractionRange => false;
|
||||
|
||||
public override VerbVisibility GetVisibility(IEntity user, IEntity target)
|
||||
{
|
||||
var groupController = IoCManager.Resolve<IClientConGroupController>();
|
||||
if (groupController.CanViewVar())
|
||||
return VerbVisibility.Visible;
|
||||
return VerbVisibility.Invisible;
|
||||
}
|
||||
|
||||
public override void Activate(IEntity user, IEntity target)
|
||||
{
|
||||
var vvm = IoCManager.Resolve<IViewVariablesManager>();
|
||||
vvm.OpenVV(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user