Files
tbd-station-14/Content.Server/GameObjects/Components/AnchorableComponent.cs
chairbender b35333d366 Click Drag Functionality + Refactor Interaction Interfaces (#1125)
Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
Co-authored-by: ComicIronic <comicironic@gmail.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2020-07-06 23:27:03 +02:00

35 lines
1.0 KiB
C#

using Content.Server.GameObjects.Components.Interactable;
using Content.Server.Interfaces.GameObjects.Components.Interaction;
using Content.Shared.GameObjects.Components.Interactable;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components;
namespace Content.Server.GameObjects.Components
{
[RegisterComponent]
public class AnchorableComponent : Component, IInteractUsing
{
public override string Name => "Anchorable";
public override void Initialize()
{
base.Initialize();
Owner.EnsureComponent<PhysicsComponent>();
}
public bool InteractUsing(InteractUsingEventArgs eventArgs)
{
if (!Owner.TryGetComponent(out PhysicsComponent physics)
|| !eventArgs.Using.TryGetComponent(out ToolComponent tool))
return false;
if (!tool.UseTool(eventArgs.User, Owner, ToolQuality.Anchoring))
return false;
physics.Anchored = !physics.Anchored;
return true;
}
}
}