diff --git a/Content.Client/IgnoredComponents.cs b/Content.Client/IgnoredComponents.cs index bc2fb00fb0..9c659f6673 100644 --- a/Content.Client/IgnoredComponents.cs +++ b/Content.Client/IgnoredComponents.cs @@ -178,7 +178,6 @@ namespace Content.Client "Rehydratable", "Headset", "ComputerBoard", - "BreakableConstruction", "GasCanister", "GasCanisterPort", "Cleanable", diff --git a/Content.Server/GameObjects/Components/Damage/BreakableConstructionComponent.cs b/Content.Server/GameObjects/Components/Damage/BreakableConstructionComponent.cs deleted file mode 100644 index fcfbb9cef3..0000000000 --- a/Content.Server/GameObjects/Components/Damage/BreakableConstructionComponent.cs +++ /dev/null @@ -1,36 +0,0 @@ -#nullable enable -using Content.Server.GameObjects.Components.Construction; -using Content.Shared.GameObjects.EntitySystems; -using Robust.Shared.GameObjects; -using Robust.Shared.GameObjects.Systems; -using Robust.Shared.Serialization; - -namespace Content.Server.GameObjects.Components.Damage -{ - [RegisterComponent] - public class BreakableConstructionComponent : Component, IDestroyAct - { - public override string Name => "BreakableConstruction"; - - public override void ExposeData(ObjectSerializer serializer) - { - base.ExposeData(serializer); - - serializer.DataField(this, x => x.Node, "node", string.Empty); - } - - public string Node { get; private set; } = string.Empty; - - async void IDestroyAct.OnDestroy(DestructionEventArgs eventArgs) - { - if (Owner.Deleted || - !Owner.TryGetComponent(out ConstructionComponent? construction) || - string.IsNullOrEmpty(Node)) - { - return; - } - - await construction.ChangeNode(Node); - } - } -} diff --git a/Content.Server/GameObjects/Components/Destructible/Thresholds/Behaviors/ChangeConstructionNodeBehavior.cs b/Content.Server/GameObjects/Components/Destructible/Thresholds/Behaviors/ChangeConstructionNodeBehavior.cs new file mode 100644 index 0000000000..6d5c41cc27 --- /dev/null +++ b/Content.Server/GameObjects/Components/Destructible/Thresholds/Behaviors/ChangeConstructionNodeBehavior.cs @@ -0,0 +1,32 @@ +#nullable enable +using System; +using Content.Server.GameObjects.Components.Construction; +using Content.Server.GameObjects.EntitySystems; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Interfaces.Serialization; +using Robust.Shared.Serialization; + +namespace Content.Server.GameObjects.Components.Destructible.Thresholds.Behaviors +{ + [Serializable] + public class ChangeConstructionNodeBehavior : IThresholdBehavior + { + public string Node { get; private set; } = string.Empty; + + void IExposeData.ExposeData(ObjectSerializer serializer) + { + serializer.DataField(this, x => x.Node, "node", string.Empty); + } + + public void Execute(IEntity owner, DestructibleSystem system) + { + if (string.IsNullOrEmpty(Node) || + !owner.TryGetComponent(out ConstructionComponent? construction)) + { + return; + } + + construction.ChangeNode(Node); + } + } +} diff --git a/Resources/Prototypes/Entities/Constructible/Power/computers.yml b/Resources/Prototypes/Entities/Constructible/Power/computers.yml index b635a5de10..c48d2c136e 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/computers.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/computers.yml @@ -102,10 +102,10 @@ !type:DamageTrigger damage: 100 behaviors: + - !type:ChangeConstructionNodeBehavior + node: monitorBroken - !type:DoActsBehavior acts: ["Destruction"] - - type: BreakableConstruction - node: monitorBroken - type: Sprite sprite: Constructible/Power/computers.rsi layers: diff --git a/Resources/Prototypes/Entities/Constructible/Power/lathe.yml b/Resources/Prototypes/Entities/Constructible/Power/lathe.yml index 9bfa935619..b8b5069f8e 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/lathe.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/lathe.yml @@ -54,8 +54,18 @@ - type: Construction graph: machine node: machine - - type: BreakableConstruction - node: machineFrame + - type: Damageable + resistances: metallicResistances + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 100 + behaviors: + - !type:ChangeConstructionNodeBehavior + node: machineFrame + - !type:DoActsBehavior + acts: ["Destruction"] - type: Machine board: AutolatheMachineCircuitboard - type: Wires @@ -109,8 +119,18 @@ - type: Construction graph: machine node: machine - - type: BreakableConstruction - node: machineFrame + - type: Damageable + resistances: metallicResistances + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 100 + behaviors: + - !type:ChangeConstructionNodeBehavior + node: machineFrame + - !type:DoActsBehavior + acts: ["Destruction"] - type: Machine board: ProtolatheMachineCircuitboard - type: Wires diff --git a/Resources/Prototypes/Entities/Constructible/Power/machine_frame.yml b/Resources/Prototypes/Entities/Constructible/Power/machine_frame.yml index f94127f6a7..dd979087f5 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/machine_frame.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/machine_frame.yml @@ -28,8 +28,18 @@ - type: Construction graph: machine node: missingWires - - type: BreakableConstruction - node: start + - type: Damageable + resistances: metallicResistances + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 100 + behaviors: + - !type:ChangeConstructionNodeBehavior + node: start + - !type:DoActsBehavior + acts: ["Destruction"] - type: Sprite sprite: "Constructible/Misc/stock_parts.rsi" state: "box_0" @@ -64,8 +74,18 @@ - type: Construction graph: machine node: machineFrame - - type: BreakableConstruction - node: missingWires + - type: Damageable + resistances: metallicResistances + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 100 + behaviors: + - !type:DoActsBehavior + acts: ["Destruction"] + - !type:ChangeConstructionNodeBehavior + node: missingWires - type: MachineFrame - type: Sprite netsync: false diff --git a/Resources/Prototypes/Entities/Constructible/Walls/low_wall.yml b/Resources/Prototypes/Entities/Constructible/Walls/low_wall.yml index 84d2c814e2..0830167dc2 100644 --- a/Resources/Prototypes/Entities/Constructible/Walls/low_wall.yml +++ b/Resources/Prototypes/Entities/Constructible/Walls/low_wall.yml @@ -33,10 +33,10 @@ !type:DamageTrigger damage: 100 behaviors: + - !type:ChangeConstructionNodeBehavior + node: start - !type:DoActsBehavior acts: ["Destruction"] - - type: BreakableConstruction - node: start - type: SnapGrid offset: Center - type: Climbable diff --git a/Resources/Prototypes/Entities/Constructible/Walls/walls.yml b/Resources/Prototypes/Entities/Constructible/Walls/walls.yml index 635831bc3e..a18dc5a5c5 100644 --- a/Resources/Prototypes/Entities/Constructible/Walls/walls.yml +++ b/Resources/Prototypes/Entities/Constructible/Walls/walls.yml @@ -370,10 +370,10 @@ !type:DamageTrigger damage: 600 behaviors: + - !type:ChangeConstructionNodeBehavior + node: girder - !type:DoActsBehavior acts: ["Destruction"] - - type: BreakableConstruction - node: girder - type: ReinforcedWall key: walls base: solid @@ -488,6 +488,10 @@ !type:DamageTrigger damage: 300 behaviors: + - !type:PlaySoundBehavior + sound: /Audio/Effects/metalbreak.ogg + - !type:ChangeConstructionNodeBehavior + node: girder - !type:DoActsBehavior acts: ["Destruction"] - type: BreakableConstruction