From 7bf06a59d45a4a14bdea2e7b37c52a6c4456a280 Mon Sep 17 00:00:00 2001 From: Tad Hardesty Date: Thu, 23 Jan 2020 17:52:44 -0800 Subject: [PATCH] Expend cables when placing them (#547) --- .../Components/Power/WirePlacerComponent.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Content.Server/GameObjects/Components/Power/WirePlacerComponent.cs b/Content.Server/GameObjects/Components/Power/WirePlacerComponent.cs index 6236c444c7..f2eed6a1cc 100644 --- a/Content.Server/GameObjects/Components/Power/WirePlacerComponent.cs +++ b/Content.Server/GameObjects/Components/Power/WirePlacerComponent.cs @@ -1,4 +1,5 @@ -using Content.Server.GameObjects.EntitySystems; +using Content.Server.GameObjects.Components.Stack; +using Content.Server.GameObjects.EntitySystems; using Robust.Server.GameObjects; using Robust.Server.Interfaces.GameObjects; using Robust.Shared.GameObjects; @@ -44,9 +45,13 @@ namespace Content.Server.GameObjects.Components.Power if (found) return; + bool hasItemSpriteComp = Owner.TryGetComponent(out SpriteComponent itemSpriteComp); + + if (Owner.TryGetComponent(out StackComponent stack) && !stack.Use(1)) + return; + var newWire = _entityManager.SpawnEntityAt("Wire", grid.GridTileToLocal(snapPos)); - if (newWire.TryGetComponent(out SpriteComponent wireSpriteComp) - && Owner.TryGetComponent(out SpriteComponent itemSpriteComp)) + if (newWire.TryGetComponent(out SpriteComponent wireSpriteComp) && hasItemSpriteComp) { wireSpriteComp.Color = itemSpriteComp.Color; }