From 74fe2609f59ad5525faf037e3e1ebe81c9904677 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Wed, 28 Oct 2020 15:03:21 +0100 Subject: [PATCH] Add InRangeUnoccluded verb (#2421) --- .../GlobalVerbs/InRangeUnoccludedVerb.cs | 57 +++++++++++++++++++ Resources/Groups/groups.yml | 2 + 2 files changed, 59 insertions(+) create mode 100644 Content.Server/GlobalVerbs/InRangeUnoccludedVerb.cs diff --git a/Content.Server/GlobalVerbs/InRangeUnoccludedVerb.cs b/Content.Server/GlobalVerbs/InRangeUnoccludedVerb.cs new file mode 100644 index 0000000000..b15ef0516a --- /dev/null +++ b/Content.Server/GlobalVerbs/InRangeUnoccludedVerb.cs @@ -0,0 +1,57 @@ +using Content.Shared.GameObjects.Verbs; +using Content.Shared.Interfaces; +using Content.Shared.Utility; +using Robust.Server.Console; +using Robust.Server.Interfaces.GameObjects; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Localization; + +namespace Content.Server.GlobalVerbs +{ + [GlobalVerb] + public class InRangeUnoccludedVerb : GlobalVerb + { + public override bool RequireInteractionRange => false; + + public override void GetData(IEntity user, IEntity target, VerbData data) + { + data.Visibility = VerbVisibility.Invisible; + + if (!user.TryGetComponent(out IActorComponent actor)) + { + return; + } + + var groupController = IoCManager.Resolve(); + if (!groupController.CanCommand(actor.playerSession, "inrangeunoccluded")) + { + return; + } + + data.Visibility = VerbVisibility.Visible; + data.Text = Loc.GetString("In Range Unoccluded"); + data.CategoryData = VerbCategories.Debug; + } + + public override void Activate(IEntity user, IEntity target) + { + if (!user.TryGetComponent(out IActorComponent actor)) + { + return; + } + + var groupController = IoCManager.Resolve(); + if (!groupController.CanCommand(actor.playerSession, "inrangeunoccluded")) + { + return; + } + + var message = user.InRangeUnOccluded(target) + ? Loc.GetString("Not occluded") + : Loc.GetString("Occluded"); + + target.PopupMessage(user, message); + } + } +} diff --git a/Resources/Groups/groups.yml b/Resources/Groups/groups.yml index 916f74d526..9ca4970747 100644 --- a/Resources/Groups/groups.yml +++ b/Resources/Groups/groups.yml @@ -117,6 +117,7 @@ - attachtoself - attachtogrid - attachtograndparent + - inrangeunoccluded CanViewVar: true CanAdminPlace: true CanAdminMenu: true @@ -227,6 +228,7 @@ - attachtoself - attachtogrid - attachtograndparent + - inrangeunoccluded CanViewVar: true CanAdminPlace: true CanScript: true