From 75c4ed6a093bf85dcd4249e5cbd61db8fdc0ae41 Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Fri, 8 Jan 2021 18:06:36 -0700 Subject: [PATCH] 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 --- .../PowerReceiverUsers/LightBulbComponent.cs | 14 ++++--- .../Entities/Constructible/Walls/windows.yml | 13 ++----- .../Entities/Objects/Consumable/drinks.yml | 2 +- .../Entities/Objects/Power/lights.yml | 39 +++++++++++++++---- .../SoundCollections/glassbreak.yml | 8 ++-- 5 files changed, 48 insertions(+), 28 deletions(-) diff --git a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/LightBulbComponent.cs b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/LightBulbComponent.cs index ed4748fbf1..b7d72b392b 100644 --- a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/LightBulbComponent.cs +++ b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/LightBulbComponent.cs @@ -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. /// [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("glassbreak"); + var soundCollection = _prototypeManager.Index("GlassBreak"); var file = _random.Pick(soundCollection.PickFiles); EntitySystem.Get().PlayFromEntity(file, Owner); State = LightBulbState.Broken; } + + public void OnBreak(BreakageEventArgs eventArgs) + { + State = LightBulbState.Broken; + } } } diff --git a/Resources/Prototypes/Entities/Constructible/Walls/windows.yml b/Resources/Prototypes/Entities/Constructible/Walls/windows.yml index 8c75ec1e95..c63b189159 100644 --- a/Resources/Prototypes/Entities/Constructible/Walls/windows.yml +++ b/Resources/Prototypes/Entities/Constructible/Walls/windows.yml @@ -33,7 +33,7 @@ 15: behaviors: - !type:PlaySoundCollectionBehavior - soundCollection: WindowBreak + soundCollection: GlassBreak - !type:SpawnEntitiesBehavior spawn: ShardGlass: @@ -71,7 +71,7 @@ 75: behaviors: - !type:PlaySoundCollectionBehavior - soundCollection: WindowBreak + soundCollection: GlassBreak - !type:SpawnEntitiesBehavior spawn: ShardGlassReinforced: @@ -103,7 +103,7 @@ 100: behaviors: - !type:PlaySoundCollectionBehavior - soundCollection: WindowBreak + soundCollection: GlassBreak - !type:SpawnEntitiesBehavior spawn: ShardGlassPhoron: @@ -118,10 +118,3 @@ - type: Construction graph: window node: phoronWindow - -- type: soundCollection - id: WindowBreak - files: - - /Audio/Effects/glass_break1.ogg - - /Audio/Effects/glass_break2.ogg - - /Audio/Effects/glass_break3.ogg diff --git a/Resources/Prototypes/Entities/Objects/Consumable/drinks.yml b/Resources/Prototypes/Entities/Objects/Consumable/drinks.yml index ef17deb41c..6f3b454fcf 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/drinks.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/drinks.yml @@ -29,7 +29,7 @@ 5: behaviors: - !type:PlaySoundCollectionBehavior - soundCollection: WindowBreak + soundCollection: GlassBreak - !type:SpawnEntitiesBehavior spawn: ShardGlass: diff --git a/Resources/Prototypes/Entities/Objects/Power/lights.yml b/Resources/Prototypes/Entities/Objects/Power/lights.yml index 103b422032..0037831aa0 100644 --- a/Resources/Prototypes/Entities/Objects/Power/lights.yml +++ b/Resources/Prototypes/Entities/Objects/Power/lights.yml @@ -1,4 +1,35 @@ - type: entity + parent: BaseItem + id: BaseLightbulb + abstract: true + components: + - type: LightBulb + - type: Damageable + - type: DamageOnLand + amount: 5 + - type: DamageOtherOnHit + amount: 5 + - type: Destructible + thresholds: + 5: + behaviors: + - !type:PlaySoundCollectionBehavior + soundCollection: GlassBreak + - !type:DoActsBehavior + acts: [ "Breakage" ] + 10: + behaviors: + - !type:PlaySoundCollectionBehavior + soundCollection: GlassBreak + - !type:SpawnEntitiesBehavior + spawn: + ShardGlass: + min: 1 + max: 1 + - !type:DoActsBehavior + acts: [ "Destruction" ] + +- type: entity parent: BaseLightbulb name: light bulb id: LightBulb @@ -10,14 +41,6 @@ sprite: Objects/Power/light_bulb.rsi state: normal -- type: entity - parent: BaseItem - name: baselightbulb - id: BaseLightbulb - abstract: true - components: - - type: LightBulb - - type: entity parent: BaseLightbulb name: light tube diff --git a/Resources/Prototypes/SoundCollections/glassbreak.yml b/Resources/Prototypes/SoundCollections/glassbreak.yml index 2e62ea1860..67417b22d4 100644 --- a/Resources/Prototypes/SoundCollections/glassbreak.yml +++ b/Resources/Prototypes/SoundCollections/glassbreak.yml @@ -1,6 +1,6 @@ - type: soundCollection - id: glassbreak + id: GlassBreak files: - - /Audio/Effects/glassbreak1.ogg - - /Audio/Effects/glassbreak2.ogg - - /Audio/Effects/glassbreak3.ogg + - /Audio/Effects/glass_break1.ogg + - /Audio/Effects/glass_break2.ogg + - /Audio/Effects/glass_break3.ogg