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.Audio;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.GameObjects.EntitySystems;
|
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.
|
/// Component that represents a light bulb. Can be broken, or burned, which turns them mostly useless.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class LightBulbComponent : Component, ILand
|
public class LightBulbComponent : Component, ILand, IBreakAct
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
@@ -121,15 +122,18 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
|
|||||||
|
|
||||||
public void Land(LandEventArgs eventArgs)
|
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);
|
var file = _random.Pick(soundCollection.PickFiles);
|
||||||
|
|
||||||
EntitySystem.Get<AudioSystem>().PlayFromEntity(file, Owner);
|
EntitySystem.Get<AudioSystem>().PlayFromEntity(file, Owner);
|
||||||
|
|
||||||
State = LightBulbState.Broken;
|
State = LightBulbState.Broken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnBreak(BreakageEventArgs eventArgs)
|
||||||
|
{
|
||||||
|
State = LightBulbState.Broken;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
15:
|
15:
|
||||||
behaviors:
|
behaviors:
|
||||||
- !type:PlaySoundCollectionBehavior
|
- !type:PlaySoundCollectionBehavior
|
||||||
soundCollection: WindowBreak
|
soundCollection: GlassBreak
|
||||||
- !type:SpawnEntitiesBehavior
|
- !type:SpawnEntitiesBehavior
|
||||||
spawn:
|
spawn:
|
||||||
ShardGlass:
|
ShardGlass:
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
75:
|
75:
|
||||||
behaviors:
|
behaviors:
|
||||||
- !type:PlaySoundCollectionBehavior
|
- !type:PlaySoundCollectionBehavior
|
||||||
soundCollection: WindowBreak
|
soundCollection: GlassBreak
|
||||||
- !type:SpawnEntitiesBehavior
|
- !type:SpawnEntitiesBehavior
|
||||||
spawn:
|
spawn:
|
||||||
ShardGlassReinforced:
|
ShardGlassReinforced:
|
||||||
@@ -103,7 +103,7 @@
|
|||||||
100:
|
100:
|
||||||
behaviors:
|
behaviors:
|
||||||
- !type:PlaySoundCollectionBehavior
|
- !type:PlaySoundCollectionBehavior
|
||||||
soundCollection: WindowBreak
|
soundCollection: GlassBreak
|
||||||
- !type:SpawnEntitiesBehavior
|
- !type:SpawnEntitiesBehavior
|
||||||
spawn:
|
spawn:
|
||||||
ShardGlassPhoron:
|
ShardGlassPhoron:
|
||||||
@@ -118,10 +118,3 @@
|
|||||||
- type: Construction
|
- type: Construction
|
||||||
graph: window
|
graph: window
|
||||||
node: phoronWindow
|
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:
|
5:
|
||||||
behaviors:
|
behaviors:
|
||||||
- !type:PlaySoundCollectionBehavior
|
- !type:PlaySoundCollectionBehavior
|
||||||
soundCollection: WindowBreak
|
soundCollection: GlassBreak
|
||||||
- !type:SpawnEntitiesBehavior
|
- !type:SpawnEntitiesBehavior
|
||||||
spawn:
|
spawn:
|
||||||
ShardGlass:
|
ShardGlass:
|
||||||
|
|||||||
@@ -1,4 +1,35 @@
|
|||||||
- type: entity
|
- 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
|
parent: BaseLightbulb
|
||||||
name: light bulb
|
name: light bulb
|
||||||
id: LightBulb
|
id: LightBulb
|
||||||
@@ -10,14 +41,6 @@
|
|||||||
sprite: Objects/Power/light_bulb.rsi
|
sprite: Objects/Power/light_bulb.rsi
|
||||||
state: normal
|
state: normal
|
||||||
|
|
||||||
- type: entity
|
|
||||||
parent: BaseItem
|
|
||||||
name: baselightbulb
|
|
||||||
id: BaseLightbulb
|
|
||||||
abstract: true
|
|
||||||
components:
|
|
||||||
- type: LightBulb
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: BaseLightbulb
|
parent: BaseLightbulb
|
||||||
name: light tube
|
name: light tube
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
- type: soundCollection
|
- type: soundCollection
|
||||||
id: glassbreak
|
id: GlassBreak
|
||||||
files:
|
files:
|
||||||
- /Audio/Effects/glassbreak1.ogg
|
- /Audio/Effects/glass_break1.ogg
|
||||||
- /Audio/Effects/glassbreak2.ogg
|
- /Audio/Effects/glass_break2.ogg
|
||||||
- /Audio/Effects/glassbreak3.ogg
|
- /Audio/Effects/glass_break3.ogg
|
||||||
|
|||||||
Reference in New Issue
Block a user