Replace BreakableConstructionComponent with ChangeConstructionNodeBehavior
This commit is contained in:
@@ -178,7 +178,6 @@ namespace Content.Client
|
||||
"Rehydratable",
|
||||
"Headset",
|
||||
"ComputerBoard",
|
||||
"BreakableConstruction",
|
||||
"GasCanister",
|
||||
"GasCanisterPort",
|
||||
"Cleanable",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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:
|
||||
|
||||
@@ -54,8 +54,18 @@
|
||||
- type: Construction
|
||||
graph: machine
|
||||
node: machine
|
||||
- type: BreakableConstruction
|
||||
- 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
|
||||
- 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
|
||||
|
||||
@@ -28,8 +28,18 @@
|
||||
- type: Construction
|
||||
graph: machine
|
||||
node: missingWires
|
||||
- type: BreakableConstruction
|
||||
- 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,7 +74,17 @@
|
||||
- type: Construction
|
||||
graph: machine
|
||||
node: machineFrame
|
||||
- type: BreakableConstruction
|
||||
- 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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user