Replace BreakableConstructionComponent with ChangeConstructionNodeBehavior
This commit is contained in:
@@ -178,7 +178,6 @@ namespace Content.Client
|
|||||||
"Rehydratable",
|
"Rehydratable",
|
||||||
"Headset",
|
"Headset",
|
||||||
"ComputerBoard",
|
"ComputerBoard",
|
||||||
"BreakableConstruction",
|
|
||||||
"GasCanister",
|
"GasCanister",
|
||||||
"GasCanisterPort",
|
"GasCanisterPort",
|
||||||
"Cleanable",
|
"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
|
!type:DamageTrigger
|
||||||
damage: 100
|
damage: 100
|
||||||
behaviors:
|
behaviors:
|
||||||
|
- !type:ChangeConstructionNodeBehavior
|
||||||
|
node: monitorBroken
|
||||||
- !type:DoActsBehavior
|
- !type:DoActsBehavior
|
||||||
acts: ["Destruction"]
|
acts: ["Destruction"]
|
||||||
- type: BreakableConstruction
|
|
||||||
node: monitorBroken
|
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Constructible/Power/computers.rsi
|
sprite: Constructible/Power/computers.rsi
|
||||||
layers:
|
layers:
|
||||||
|
|||||||
@@ -54,8 +54,18 @@
|
|||||||
- type: Construction
|
- type: Construction
|
||||||
graph: machine
|
graph: machine
|
||||||
node: machine
|
node: machine
|
||||||
- type: BreakableConstruction
|
- type: Damageable
|
||||||
node: machineFrame
|
resistances: metallicResistances
|
||||||
|
- type: Destructible
|
||||||
|
thresholds:
|
||||||
|
- trigger:
|
||||||
|
!type:DamageTrigger
|
||||||
|
damage: 100
|
||||||
|
behaviors:
|
||||||
|
- !type:ChangeConstructionNodeBehavior
|
||||||
|
node: machineFrame
|
||||||
|
- !type:DoActsBehavior
|
||||||
|
acts: ["Destruction"]
|
||||||
- type: Machine
|
- type: Machine
|
||||||
board: AutolatheMachineCircuitboard
|
board: AutolatheMachineCircuitboard
|
||||||
- type: Wires
|
- type: Wires
|
||||||
@@ -109,8 +119,18 @@
|
|||||||
- type: Construction
|
- type: Construction
|
||||||
graph: machine
|
graph: machine
|
||||||
node: machine
|
node: machine
|
||||||
- type: BreakableConstruction
|
- type: Damageable
|
||||||
node: machineFrame
|
resistances: metallicResistances
|
||||||
|
- type: Destructible
|
||||||
|
thresholds:
|
||||||
|
- trigger:
|
||||||
|
!type:DamageTrigger
|
||||||
|
damage: 100
|
||||||
|
behaviors:
|
||||||
|
- !type:ChangeConstructionNodeBehavior
|
||||||
|
node: machineFrame
|
||||||
|
- !type:DoActsBehavior
|
||||||
|
acts: ["Destruction"]
|
||||||
- type: Machine
|
- type: Machine
|
||||||
board: ProtolatheMachineCircuitboard
|
board: ProtolatheMachineCircuitboard
|
||||||
- type: Wires
|
- type: Wires
|
||||||
|
|||||||
@@ -28,8 +28,18 @@
|
|||||||
- type: Construction
|
- type: Construction
|
||||||
graph: machine
|
graph: machine
|
||||||
node: missingWires
|
node: missingWires
|
||||||
- type: BreakableConstruction
|
- type: Damageable
|
||||||
node: start
|
resistances: metallicResistances
|
||||||
|
- type: Destructible
|
||||||
|
thresholds:
|
||||||
|
- trigger:
|
||||||
|
!type:DamageTrigger
|
||||||
|
damage: 100
|
||||||
|
behaviors:
|
||||||
|
- !type:ChangeConstructionNodeBehavior
|
||||||
|
node: start
|
||||||
|
- !type:DoActsBehavior
|
||||||
|
acts: ["Destruction"]
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: "Constructible/Misc/stock_parts.rsi"
|
sprite: "Constructible/Misc/stock_parts.rsi"
|
||||||
state: "box_0"
|
state: "box_0"
|
||||||
@@ -64,8 +74,18 @@
|
|||||||
- type: Construction
|
- type: Construction
|
||||||
graph: machine
|
graph: machine
|
||||||
node: machineFrame
|
node: machineFrame
|
||||||
- type: BreakableConstruction
|
- type: Damageable
|
||||||
node: missingWires
|
resistances: metallicResistances
|
||||||
|
- type: Destructible
|
||||||
|
thresholds:
|
||||||
|
- trigger:
|
||||||
|
!type:DamageTrigger
|
||||||
|
damage: 100
|
||||||
|
behaviors:
|
||||||
|
- !type:DoActsBehavior
|
||||||
|
acts: ["Destruction"]
|
||||||
|
- !type:ChangeConstructionNodeBehavior
|
||||||
|
node: missingWires
|
||||||
- type: MachineFrame
|
- type: MachineFrame
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
netsync: false
|
netsync: false
|
||||||
|
|||||||
@@ -33,10 +33,10 @@
|
|||||||
!type:DamageTrigger
|
!type:DamageTrigger
|
||||||
damage: 100
|
damage: 100
|
||||||
behaviors:
|
behaviors:
|
||||||
|
- !type:ChangeConstructionNodeBehavior
|
||||||
|
node: start
|
||||||
- !type:DoActsBehavior
|
- !type:DoActsBehavior
|
||||||
acts: ["Destruction"]
|
acts: ["Destruction"]
|
||||||
- type: BreakableConstruction
|
|
||||||
node: start
|
|
||||||
- type: SnapGrid
|
- type: SnapGrid
|
||||||
offset: Center
|
offset: Center
|
||||||
- type: Climbable
|
- type: Climbable
|
||||||
|
|||||||
@@ -370,10 +370,10 @@
|
|||||||
!type:DamageTrigger
|
!type:DamageTrigger
|
||||||
damage: 600
|
damage: 600
|
||||||
behaviors:
|
behaviors:
|
||||||
|
- !type:ChangeConstructionNodeBehavior
|
||||||
|
node: girder
|
||||||
- !type:DoActsBehavior
|
- !type:DoActsBehavior
|
||||||
acts: ["Destruction"]
|
acts: ["Destruction"]
|
||||||
- type: BreakableConstruction
|
|
||||||
node: girder
|
|
||||||
- type: ReinforcedWall
|
- type: ReinforcedWall
|
||||||
key: walls
|
key: walls
|
||||||
base: solid
|
base: solid
|
||||||
@@ -488,6 +488,10 @@
|
|||||||
!type:DamageTrigger
|
!type:DamageTrigger
|
||||||
damage: 300
|
damage: 300
|
||||||
behaviors:
|
behaviors:
|
||||||
|
- !type:PlaySoundBehavior
|
||||||
|
sound: /Audio/Effects/metalbreak.ogg
|
||||||
|
- !type:ChangeConstructionNodeBehavior
|
||||||
|
node: girder
|
||||||
- !type:DoActsBehavior
|
- !type:DoActsBehavior
|
||||||
acts: ["Destruction"]
|
acts: ["Destruction"]
|
||||||
- type: BreakableConstruction
|
- type: BreakableConstruction
|
||||||
|
|||||||
Reference in New Issue
Block a user