2019-08-21 22:50:15 +02:00
|
|
|
using Content.Server.GameObjects.Components.Sound;
|
|
|
|
|
using Content.Server.GameObjects.Components.Weapon.Melee;
|
2020-07-06 14:27:03 -07:00
|
|
|
using Content.Server.Interfaces.GameObjects.Components.Interaction;
|
2020-05-23 02:27:31 -07:00
|
|
|
using Content.Server.Utility;
|
2019-08-21 22:50:15 +02:00
|
|
|
using Content.Shared.GameObjects;
|
|
|
|
|
using Robust.Server.GameObjects;
|
2020-05-31 12:40:36 -05:00
|
|
|
using Robust.Server.GameObjects.EntitySystems;
|
2019-08-21 22:50:15 +02:00
|
|
|
using Robust.Shared.Audio;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-05-31 12:40:36 -05:00
|
|
|
using Robust.Shared.GameObjects.Systems;
|
|
|
|
|
using Robust.Shared.Interfaces.GameObjects;
|
2019-08-22 09:28:24 +02:00
|
|
|
using Robust.Shared.Interfaces.Random;
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
using Robust.Shared.Random;
|
2019-08-21 22:50:15 +02:00
|
|
|
|
|
|
|
|
namespace Content.Server.GameObjects.Components.Mining
|
|
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
2020-05-23 17:23:25 +02:00
|
|
|
public class AsteroidRockComponent : Component, IInteractUsing
|
2019-08-21 22:50:15 +02:00
|
|
|
{
|
|
|
|
|
public override string Name => "AsteroidRock";
|
|
|
|
|
private static readonly string[] SpriteStates = {"0", "1", "2", "3", "4"};
|
|
|
|
|
|
2019-08-22 09:28:24 +02:00
|
|
|
#pragma warning disable 649
|
|
|
|
|
[Dependency] private readonly IRobustRandom _random;
|
|
|
|
|
#pragma warning restore 649
|
|
|
|
|
|
2019-08-21 22:50:15 +02:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
var spriteComponent = Owner.GetComponent<SpriteComponent>();
|
2019-08-22 09:28:24 +02:00
|
|
|
spriteComponent.LayerSetState(0, _random.Pick(SpriteStates));
|
2019-08-21 22:50:15 +02:00
|
|
|
}
|
|
|
|
|
|
2020-05-23 17:23:25 +02:00
|
|
|
bool IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
2019-08-21 22:50:15 +02:00
|
|
|
{
|
2020-05-23 17:23:25 +02:00
|
|
|
var item = eventArgs.Using;
|
2019-08-21 22:50:15 +02:00
|
|
|
if (!item.TryGetComponent(out MeleeWeaponComponent meleeWeaponComponent)) return false;
|
|
|
|
|
|
2020-02-13 15:57:40 +01:00
|
|
|
Owner.GetComponent<DamageableComponent>().TakeDamage(DamageType.Brute, meleeWeaponComponent.Damage, item, eventArgs.User);
|
2019-08-21 22:50:15 +02:00
|
|
|
|
|
|
|
|
if (!item.TryGetComponent(out PickaxeComponent pickaxeComponent)) return true;
|
2020-05-31 12:40:36 -05:00
|
|
|
if (!string.IsNullOrWhiteSpace(pickaxeComponent.MiningSound))
|
2019-08-21 22:50:15 +02:00
|
|
|
{
|
2020-06-07 08:55:15 -05:00
|
|
|
EntitySystem.Get<AudioSystem>().PlayFromEntity(pickaxeComponent.MiningSound, Owner, AudioParams.Default);
|
2019-08-21 22:50:15 +02:00
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|