Added a buncha bloat from teegee (#1203)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
72
Content.Server/GameObjects/Components/Items/ToysComponent.cs
Normal file
72
Content.Server/GameObjects/Components/Items/ToysComponent.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using Content.Server.GameObjects.Components.Sound;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared.Audio;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Items
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class ToysComponent : Component, IActivate, IUse, ILand
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
||||
[Dependency] private readonly IRobustRandom _random;
|
||||
#pragma warning restore 649
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public void Activate(ActivateEventArgs eventArgs)
|
||||
{
|
||||
Squeak();
|
||||
}
|
||||
|
||||
public bool UseEntity(UseEntityEventArgs eventArgs)
|
||||
{
|
||||
Squeak();
|
||||
return false;
|
||||
}
|
||||
public void Land(LandEventArgs eventArgs)
|
||||
{
|
||||
Squeak();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.Audio;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Sound
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple sound emitter that emits sound on use in hand
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class EmitSoundOnThrowComponent : Component, ILand
|
||||
{
|
||||
/// <inheritdoc />
|
||||
///
|
||||
public override string Name => "EmitSoundOnThrow";
|
||||
|
||||
public string _soundName;
|
||||
public float _pitchVariation;
|
||||
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _soundName, "sound", string.Empty);
|
||||
serializer.DataField(ref _pitchVariation, "variation", 0.0f);
|
||||
}
|
||||
public void PlaySoundEffect()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_soundName))
|
||||
{
|
||||
if (_pitchVariation > 0.0)
|
||||
{
|
||||
EntitySystem.Get<AudioSystem>().PlayFromEntity(_soundName, Owner, AudioHelpers.WithVariation(_pitchVariation).WithVolume(-2f));
|
||||
}
|
||||
EntitySystem.Get<AudioSystem>().PlayFromEntity(_soundName, Owner, AudioParams.Default.WithVolume(-2f));
|
||||
}
|
||||
}
|
||||
public void Land(LandEventArgs eventArgs)
|
||||
{
|
||||
PlaySoundEffect();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user