Makes lightbulbs destructible (#2955)
* Renames WindowBreak soundCollection to GlassBreak * Implements destructible lightbulbs moved the parent to the top as well * Fixes the old `glassbreak` soundCollection, renames it * Deletes the windows.yml version of glassbreak * Fixes the sound for bulbs being thrown * Removes name from abstract lightbulb * Implements IDestroyAct for lightbulbs * Implements onBreak for lightbulbs * Lights get damaged by getting hit and throwing * Lights now have an intermediate 'broken' state before destruction
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
@@ -32,7 +33,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
|
||||
/// Component that represents a light bulb. Can be broken, or burned, which turns them mostly useless.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class LightBulbComponent : Component, ILand
|
||||
public class LightBulbComponent : Component, ILand, IBreakAct
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
@@ -121,15 +122,18 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
|
||||
|
||||
public void Land(LandEventArgs eventArgs)
|
||||
{
|
||||
if (State == LightBulbState.Broken)
|
||||
return;
|
||||
|
||||
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>("glassbreak");
|
||||
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>("GlassBreak");
|
||||
var file = _random.Pick(soundCollection.PickFiles);
|
||||
|
||||
EntitySystem.Get<AudioSystem>().PlayFromEntity(file, Owner);
|
||||
|
||||
State = LightBulbState.Broken;
|
||||
}
|
||||
|
||||
public void OnBreak(BreakageEventArgs eventArgs)
|
||||
{
|
||||
State = LightBulbState.Broken;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user