Files
tbd-station-14/Content.Server/GameObjects/Components/AnchorableComponent.cs
zumorica 934e69d6e3 Merge branch 'master' into 2020-04-28-tool-component
# Conflicts:
#	Content.Server/GameObjects/Components/AnchorableComponent.cs
#	Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs
#	Content.Server/GameObjects/Components/Doors/AirlockComponent.cs
#	Content.Server/GameObjects/Components/Gravity/GravityGeneratorComponent.cs
#	Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs
#	Content.Server/GameObjects/Components/Power/PowerTransferComponent.cs
#	Content.Server/GameObjects/Components/WiresComponent.cs
2020-05-23 18:00:28 +02:00

40 lines
1.2 KiB
C#

using Content.Server.GameObjects.Components.Interactable;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Components.Interactable;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Utility;
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.AttackWith.TryGetComponent(out ToolComponent tool))
return false;
if (!tool.UseTool(eventArgs.User, Owner, ToolQuality.Anchoring))
return false;
physics.Anchored = !physics.Anchored;
return true;
}
}
}