mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 21:48:58 +03:00
Uses the following Cherry-Picks: https://github.com/space-wizards/space-station-14/pull/26994 https://github.com/space-wizards/space-station-14/pull/26518 https://github.com/space-wizards/space-station-14/pull/26279 https://github.com/space-wizards/space-station-14/pull/24946 https://github.com/space-wizards/space-station-14/pull/27188 Requires: https://github.com/Simple-Station/Einstein-Engines/pull/535 https://github.com/Simple-Station/Einstein-Engines/pull/534 --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Co-authored-by: Jake Huxell <JakeHuxell@pm.me> Co-authored-by: Tayrtahn <tayrtahn@gmail.com> Co-authored-by: 0x6273 <0x40@keemail.me> Co-authored-by: DEATHB4DEFEAT <zachcaffee@outlook.com>
53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using Content.Server.Administration.Logs;
|
|
using Content.Server.Power.Components;
|
|
using Content.Shared.Database;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Maps;
|
|
using Content.Shared.Stacks;
|
|
using Robust.Shared.Map.Components;
|
|
|
|
namespace Content.Server.Power.EntitySystems;
|
|
|
|
public sealed partial class CableSystem
|
|
{
|
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
|
|
|
private void InitializeCablePlacer()
|
|
{
|
|
SubscribeLocalEvent<CablePlacerComponent, AfterInteractEvent>(OnCablePlacerAfterInteract);
|
|
}
|
|
|
|
private void OnCablePlacerAfterInteract(Entity<CablePlacerComponent> placer, ref AfterInteractEvent args)
|
|
{
|
|
if (args.Handled || !args.CanReach)
|
|
return;
|
|
|
|
var component = placer.Comp;
|
|
if (component.CablePrototypeId == null)
|
|
return;
|
|
|
|
if(!TryComp<MapGridComponent>(args.ClickLocation.GetGridUid(EntityManager), out var grid))
|
|
return;
|
|
|
|
var snapPos = grid.TileIndicesFor(args.ClickLocation);
|
|
var tileDef = (ContentTileDefinition) _tileManager[grid.GetTileRef(snapPos).Tile.TypeId];
|
|
|
|
if (!tileDef.IsSubFloor || !tileDef.Sturdy)
|
|
return;
|
|
|
|
foreach (var anchored in grid.GetAnchoredEntities(snapPos))
|
|
{
|
|
if (TryComp<CableComponent>(anchored, out var wire) && wire.CableType == component.BlockingCableType)
|
|
return;
|
|
}
|
|
|
|
if (TryComp<StackComponent>(placer, out var stack) && !_stack.Use(placer, 1, stack))
|
|
return;
|
|
|
|
var newCable = EntityManager.SpawnEntity(component.CablePrototypeId, grid.GridTileToLocal(snapPos));
|
|
_adminLogger.Add(LogType.Construction, LogImpact.Low,
|
|
$"{ToPrettyString(args.User):player} placed {ToPrettyString(newCable):cable} at {Transform(newCable).Coordinates}");
|
|
args.Handled = true;
|
|
}
|
|
}
|