Fix being able to place cables on non-subfloor tiles
- Also performs an actionblocker check just in case.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Stack;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Content.Shared.Maps;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
@@ -29,26 +31,35 @@ namespace Content.Server.Power.Components
|
||||
/// <inheritdoc />
|
||||
async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
|
||||
{
|
||||
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(eventArgs.User))
|
||||
return false;
|
||||
|
||||
if (_cablePrototypeID == null)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
if (!eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true))
|
||||
return true;
|
||||
return false;
|
||||
|
||||
if(!_mapManager.TryGetGrid(eventArgs.ClickLocation.GetGridId(Owner.EntityManager), out var grid))
|
||||
return true;
|
||||
return false;
|
||||
|
||||
var snapPos = grid.TileIndicesFor(eventArgs.ClickLocation);
|
||||
if(grid.GetTileRef(snapPos).Tile.IsEmpty)
|
||||
return true;
|
||||
var tileDef = grid.GetTileRef(snapPos).Tile.GetContentTileDefinition();
|
||||
|
||||
if(!tileDef.IsSubFloor || tileDef.IsSpace)
|
||||
return false;
|
||||
|
||||
foreach (var anchored in grid.GetAnchoredEntities(snapPos))
|
||||
{
|
||||
if (Owner.EntityManager.TryGetComponent<CableComponent>(anchored, out var wire) && wire.CableType == _blockingCableType)
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Owner.TryGetComponent<StackComponent>(out var stack)
|
||||
&& !EntitySystem.Get<StackSystem>().Use(Owner.Uid, 1, stack))
|
||||
return true;
|
||||
return false;
|
||||
|
||||
Owner.EntityManager.SpawnEntity(_cablePrototypeID, grid.GridTileToLocal(snapPos));
|
||||
return true;
|
||||
|
||||
4
Resources/Changelog/Parts/cable.yml
Normal file
4
Resources/Changelog/Parts/cable.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
author: Zumorica
|
||||
changes:
|
||||
- type: Fix # One of the following: Add, Remove, Tweak, Fix
|
||||
message: Fix being able to place cables/wires on non-subfloor tiles.
|
||||
Reference in New Issue
Block a user