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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
5:
|
||||
behaviors:
|
||||
- !type:PlaySoundCollectionBehavior
|
||||
soundCollection: WindowBreak
|
||||
soundCollection: GlassBreak
|
||||
- !type:SpawnEntitiesBehavior
|
||||
spawn:
|
||||
ShardGlass:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user