LightBulbs now break when thrown

This commit is contained in:
zumorica
2020-04-13 01:44:05 +02:00
parent 0f554996ff
commit e9100db219
5 changed files with 33 additions and 1 deletions

View File

@@ -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;
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,6 @@
- type: sound_collection
id: glassbreak
files:
- /Audio/effects/glassbreak1.ogg
- /Audio/effects/glassbreak2.ogg
- /Audio/effects/glassbreak3.ogg