2020-07-18 22:51:56 -07:00
|
|
|
|
using Content.Shared.Audio;
|
|
|
|
|
|
using Content.Shared.Interfaces.GameObjects.Components;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Server.GameObjects;
|
2020-07-02 14:05:03 +00:00
|
|
|
|
using Robust.Shared.Audio;
|
|
|
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
|
using Robust.Shared.Random;
|
|
|
|
|
|
using Robust.Shared.Serialization;
|
|
|
|
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.GameObjects.Components.Items
|
|
|
|
|
|
{
|
|
|
|
|
|
[RegisterComponent]
|
|
|
|
|
|
public class ToysComponent : Component, IActivate, IUse, ILand
|
|
|
|
|
|
{
|
2020-08-24 14:10:28 +02:00
|
|
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
|
|
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
2020-07-02 14:05:03 +00:00
|
|
|
|
|
|
|
|
|
|
public override string Name => "Toys";
|
|
|
|
|
|
|
|
|
|
|
|
[ViewVariables]
|
|
|
|
|
|
public string _soundCollectionName = "ToySqueak";
|
|
|
|
|
|
|
|
|
|
|
|
public override void ExposeData(ObjectSerializer serializer)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.ExposeData(serializer);
|
|
|
|
|
|
serializer.DataField(ref _soundCollectionName, "toySqueak", "ToySqueak");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Squeak()
|
|
|
|
|
|
{
|
|
|
|
|
|
PlaySqueakEffect();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void PlaySqueakEffect()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(_soundCollectionName))
|
|
|
|
|
|
{
|
|
|
|
|
|
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>(_soundCollectionName);
|
|
|
|
|
|
var file = _random.Pick(soundCollection.PickFiles);
|
|
|
|
|
|
EntitySystem.Get<AudioSystem>().PlayFromEntity(file, Owner, AudioParams.Default);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-02-04 17:44:49 +01:00
|
|
|
|
void IActivate.Activate(ActivateEventArgs eventArgs)
|
2020-07-02 14:05:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
Squeak();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-02-04 17:44:49 +01:00
|
|
|
|
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
|
2020-07-02 14:05:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
Squeak();
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2021-02-04 17:44:49 +01:00
|
|
|
|
|
|
|
|
|
|
void ILand.Land(LandEventArgs eventArgs)
|
2020-07-02 14:05:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
Squeak();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|