2020-08-18 14:39:08 +02:00
|
|
|
using System.Threading.Tasks;
|
2020-07-25 15:11:16 +02:00
|
|
|
using Content.Server.GameObjects.Components.Items.Storage;
|
2020-05-27 14:56:24 +02:00
|
|
|
using Content.Shared.Audio;
|
|
|
|
|
using Content.Shared.Interfaces;
|
2020-07-18 22:51:56 -07:00
|
|
|
using Content.Shared.Interfaces.GameObjects.Components;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Server.GameObjects;
|
2020-05-27 14:56:24 +02:00
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
using Robust.Shared.Localization;
|
|
|
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.GameObjects.Components
|
|
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
|
|
|
|
public class PottedPlantHideComponent : Component, IInteractUsing, IInteractHand
|
|
|
|
|
{
|
|
|
|
|
public override string Name => "PottedPlantHide";
|
|
|
|
|
|
2021-01-20 10:02:34 +03:00
|
|
|
[ViewVariables] private SecretStashComponent _secretStash = default!;
|
2020-05-27 14:56:24 +02:00
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2021-01-20 10:02:34 +03:00
|
|
|
_secretStash = Owner.EnsureComponent<SecretStashComponent>();
|
2020-05-27 14:56:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-08-18 14:39:08 +02:00
|
|
|
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
2020-05-27 14:56:24 +02:00
|
|
|
{
|
|
|
|
|
Rustle();
|
2021-01-20 10:02:34 +03:00
|
|
|
return _secretStash.TryHideItem(eventArgs.User, eventArgs.Using);
|
2020-05-27 14:56:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs)
|
|
|
|
|
{
|
|
|
|
|
Rustle();
|
|
|
|
|
|
2021-01-20 10:02:34 +03:00
|
|
|
var gotItem = _secretStash.TryGetItem(eventArgs.User);
|
|
|
|
|
if (!gotItem)
|
2020-05-27 14:56:24 +02:00
|
|
|
{
|
|
|
|
|
Owner.PopupMessage(eventArgs.User, Loc.GetString("You root around in the roots."));
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-20 10:02:34 +03:00
|
|
|
return gotItem;
|
2020-05-27 14:56:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Rustle()
|
|
|
|
|
{
|
|
|
|
|
EntitySystem.Get<AudioSystem>()
|
2020-07-07 13:19:00 -04:00
|
|
|
.PlayFromEntity("/Audio/Effects/plant_rustle.ogg", Owner, AudioHelpers.WithVariation(0.25f));
|
2020-05-27 14:56:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|