Files
crystall-punk-14/Content.Server/GlobalVerbs/PointingVerb.cs
DrSmugleaf 4a8ed41e3a Fix namespaces and optimize imports (#1651)
* Fix namespaces and optimize imports

* Cleanup fixes

* Merge conflict fixes

* Merge conflict fixes

* Merge conflict fixes
2020-08-13 14:40:27 +02:00

54 lines
1.5 KiB
C#

using Content.Server.GameObjects.Components.Pointing;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Verbs;
using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Localization;
namespace Content.Server.GlobalVerbs
{
/// <summary>
/// Global verb that points at an entity.
/// </summary>
[GlobalVerb]
public class PointingVerb : GlobalVerb
{
public override bool RequireInteractionRange => false;
public override void GetData(IEntity user, IEntity target, VerbData data)
{
data.Visibility = VerbVisibility.Invisible;
if (!user.HasComponent<IActorComponent>())
{
return;
}
if (!EntitySystem.Get<PointingSystem>().InRange(user.Transform.GridPosition, target.Transform.GridPosition))
{
return;
}
if (target.HasComponent<PointingArrowComponent>())
{
return;
}
data.Visibility = VerbVisibility.Visible;
data.Text = Loc.GetString("Point at");
}
public override void Activate(IEntity user, IEntity target)
{
if (!user.TryGetComponent(out IActorComponent actor))
{
return;
}
EntitySystem.Get<PointingSystem>().TryPoint(actor.playerSession, target.Transform.GridPosition, target.Uid);
}
}
}