Files
tbd-station-14/Content.Server/Transform/Verbs/AttachToGridVerb.cs
2021-06-21 02:13:54 +02:00

55 lines
1.5 KiB
C#

using Content.Shared.Verbs;
using Robust.Server.Console;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
namespace Content.Server.Transform.Verbs
{
[GlobalVerb]
public class AttachToGridVerb : GlobalVerb
{
public override void GetData(IEntity user, IEntity target, VerbData data)
{
data.Visibility = VerbVisibility.Invisible;
if (user == target)
{
return;
}
if (!user.TryGetComponent(out ActorComponent? actor))
{
return;
}
var groupController = IoCManager.Resolve<IConGroupController>();
if (!groupController.CanCommand(actor.PlayerSession, "attachtogrid"))
{
return;
}
data.Visibility = VerbVisibility.Visible;
data.Text = Loc.GetString("attach-to-grid-verb-get-data-text");
data.CategoryData = VerbCategories.Debug;
}
public override void Activate(IEntity user, IEntity target)
{
if (!user.TryGetComponent(out ActorComponent? actor))
{
return;
}
var groupController = IoCManager.Resolve<IConGroupController>();
if (!groupController.CanCommand(actor.PlayerSession, "attachtogrid"))
{
return;
}
target.Transform.AttachToGridOrMap();
}
}
}