2020-04-29 13:43:07 +02:00
|
|
|
using Content.Server.GameObjects.Components.Interactable;
|
2019-11-06 17:22:55 +01:00
|
|
|
using Content.Server.GameObjects.EntitySystems;
|
2020-04-29 13:43:07 +02:00
|
|
|
using Content.Shared.GameObjects.Components.Interactable;
|
2019-11-06 17:22:55 +01:00
|
|
|
using Robust.Server.GameObjects;
|
|
|
|
|
using Robust.Server.GameObjects.EntitySystems;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-05-23 02:27:31 -07:00
|
|
|
using Robust.Shared.GameObjects.Systems;
|
2019-11-06 17:22:55 +01:00
|
|
|
using Robust.Shared.Interfaces.GameObjects;
|
|
|
|
|
using Robust.Shared.IoC;
|
2020-05-23 02:27:31 -07:00
|
|
|
using Robust.Shared.Utility;
|
2019-11-06 17:22:55 +01:00
|
|
|
|
|
|
|
|
namespace Content.Server.GameObjects.Components
|
|
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
2020-05-23 18:00:28 +02:00
|
|
|
public class AnchorableComponent : Component, IInteractUsing
|
2019-11-06 17:22:55 +01:00
|
|
|
{
|
2020-04-29 13:43:07 +02:00
|
|
|
public override string Name => "Anchorable";
|
2019-11-06 17:22:55 +01:00
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2020-04-29 13:43:07 +02:00
|
|
|
Owner.EnsureComponent<PhysicsComponent>();
|
2019-11-06 17:22:55 +01:00
|
|
|
}
|
|
|
|
|
|
2020-05-23 17:23:25 +02:00
|
|
|
public bool InteractUsing(InteractUsingEventArgs eventArgs)
|
2019-11-06 17:22:55 +01:00
|
|
|
{
|
2020-05-19 13:55:52 +02:00
|
|
|
if (!Owner.TryGetComponent(out PhysicsComponent physics)
|
2020-05-24 13:47:13 +02:00
|
|
|
|| !eventArgs.Using.TryGetComponent(out ToolComponent tool))
|
2020-05-19 13:55:52 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!tool.UseTool(eventArgs.User, Owner, ToolQuality.Anchoring))
|
2019-11-06 17:22:55 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
physics.Anchored = !physics.Anchored;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|