LightBulbs now break when thrown
This commit is contained in:
@@ -1,7 +1,15 @@
|
||||
using System;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.Audio;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -24,9 +32,14 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
/// Component that represents a light bulb. Can be broken, or burned, which turns them mostly useless.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class LightBulbComponent : Component
|
||||
public class LightBulbComponent : Component, ILand
|
||||
{
|
||||
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
||||
[Dependency] private readonly IRobustRandom _random;
|
||||
#pragma warning restore 649
|
||||
|
||||
/// <summary>
|
||||
/// Invoked whenever the state of the light bulb changes.
|
||||
/// </summary>
|
||||
@@ -104,5 +117,18 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
base.Initialize();
|
||||
UpdateColor();
|
||||
}
|
||||
|
||||
public void Land(LandEventArgs eventArgs)
|
||||
{
|
||||
if (State == LightBulbState.Broken)
|
||||
return;
|
||||
|
||||
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>("glassbreak");
|
||||
var file = _random.Pick(soundCollection.PickFiles);
|
||||
|
||||
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>().Play(file, Owner);
|
||||
|
||||
State = LightBulbState.Broken;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
Resources/Audio/effects/glassbreak1.ogg
Normal file
BIN
Resources/Audio/effects/glassbreak1.ogg
Normal file
Binary file not shown.
BIN
Resources/Audio/effects/glassbreak2.ogg
Normal file
BIN
Resources/Audio/effects/glassbreak2.ogg
Normal file
Binary file not shown.
BIN
Resources/Audio/effects/glassbreak3.ogg
Normal file
BIN
Resources/Audio/effects/glassbreak3.ogg
Normal file
Binary file not shown.
6
Resources/Prototypes/SoundCollections/glassbreak.yml
Normal file
6
Resources/Prototypes/SoundCollections/glassbreak.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
- type: sound_collection
|
||||
id: glassbreak
|
||||
files:
|
||||
- /Audio/effects/glassbreak1.ogg
|
||||
- /Audio/effects/glassbreak2.ogg
|
||||
- /Audio/effects/glassbreak3.ogg
|
||||
Reference in New Issue
Block a user