From 72cff220cf296c789bdc10a7563c479d95add6b2 Mon Sep 17 00:00:00 2001 From: Acruid Date: Sun, 15 Dec 2019 19:58:24 -0800 Subject: [PATCH] Wires are now broken in explosions, and drop cables. Using the wire cutters on a wire drops a cable. Fix bug where bullets raise an exception when the hit object deletes itself. --- .../GameObjects/Components/Power/PowerTransferComponent.cs | 6 ++++++ .../Components/Projectiles/ProjectileComponent.cs | 2 +- Resources/Prototypes/Entities/buildings/power.yml | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/Power/PowerTransferComponent.cs b/Content.Server/GameObjects/Components/Power/PowerTransferComponent.cs index 79771febfa..d9764afafb 100644 --- a/Content.Server/GameObjects/Components/Power/PowerTransferComponent.cs +++ b/Content.Server/GameObjects/Components/Power/PowerTransferComponent.cs @@ -1,5 +1,6 @@ using System.Linq; using Content.Server.GameObjects.Components.Interactable.Tools; +using Content.Server.GameObjects.Components.Stack; using Content.Server.GameObjects.EntitySystems; using Robust.Server.Interfaces.GameObjects; using Robust.Shared.GameObjects; @@ -137,6 +138,11 @@ namespace Content.Server.GameObjects.Components.Power if (eventArgs.AttackWith.TryGetComponent(out WirecutterComponent wirecutter)) { Owner.Delete(); + var droppedEnt = Owner.EntityManager.SpawnEntityAt("CableStack", eventArgs.ClickLocation); + + if (droppedEnt.TryGetComponent(out var stackComp)) + stackComp.Count = 1; + return true; } return false; diff --git a/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs b/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs index f0e1a82ea0..589b7c2efc 100644 --- a/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs +++ b/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs @@ -77,7 +77,7 @@ namespace Content.Server.GameObjects.Components.Projectiles } } - if (entity.TryGetComponent(out CameraRecoilComponent recoilComponent) + if (!entity.Deleted && entity.TryGetComponent(out CameraRecoilComponent recoilComponent) && Owner.TryGetComponent(out PhysicsComponent physicsComponent)) { var direction = physicsComponent.LinearVelocity.Normalized; diff --git a/Resources/Prototypes/Entities/buildings/power.yml b/Resources/Prototypes/Entities/buildings/power.yml index 07ad94665e..4fa6a28b7c 100644 --- a/Resources/Prototypes/Entities/buildings/power.yml +++ b/Resources/Prototypes/Entities/buildings/power.yml @@ -22,6 +22,9 @@ key: power_cables mode: CardinalFlags - type: SubFloorHide + - type: Destructible + thresholdvalue: 100 + spawnondestroy: CableStack snap: - Wire