2019-11-06 17:22:55 +01:00
|
|
|
using Content.Server.GameObjects.Components.Interactable.Tools;
|
|
|
|
|
using Content.Server.GameObjects.EntitySystems;
|
2020-05-23 02:27:31 -07:00
|
|
|
using Content.Server.Utility;
|
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-04-24 15:01:30 +02:00
|
|
|
public class WrenchableComponent : Component, IAttackBy
|
2019-11-06 17:22:55 +01:00
|
|
|
{
|
|
|
|
|
public override string Name => "Wrenchable";
|
|
|
|
|
private AudioSystem _audioSystem;
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2020-05-23 02:27:31 -07:00
|
|
|
_audioSystem = EntitySystem.Get<AudioSystem>();
|
2019-11-06 17:22:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool AttackBy(AttackByEventArgs eventArgs)
|
|
|
|
|
{
|
|
|
|
|
if (!eventArgs.AttackWith.HasComponent<WrenchComponent>())
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Owner.TryGetComponent(out PhysicsComponent physics))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
physics.Anchored = !physics.Anchored;
|
|
|
|
|
_audioSystem.Play("/Audio/items/ratchet.ogg", Owner);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|