* Async Interface * Update Content.Server/GameObjects/Components/Fluids/MopComponent.cs Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> * Changed the glassbeaker * Update Content.Shared/Interfaces/GameObjects/Components/Interaction/IAfterInteract.cs Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> * Update Content.Shared/Interfaces/GameObjects/Components/Interaction/IAfterInteract.cs Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> * Interaction system fix * Removed I from the interface * Changed all implementations of the interface I could find * all public void implementation fixed * All built, no errors should remain * Update Resources/Prototypes/Entities/Objects/Specific/chemistry.yml Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/GameObjects/Components/Portal/TeleporterComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/GameObjects/Components/ActionBlocking/HandcuffComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Commit based off Sloth's commentary * Removed the Rag file from the PR * Reverted sloth's commentary changes on the publcity of the function * Injector component properly implemented interface * Update Content.Server/GameObjects/Components/Fluids/MopComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/GameObjects/Components/Fluids/SprayComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: BlueberryShortcake <rubetskoy234@mail.ru> Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
59 lines
2.2 KiB
C#
59 lines
2.2 KiB
C#
using Content.Server.GameObjects.Components.Stack;
|
|
using Content.Shared.Interfaces.GameObjects.Components;
|
|
using Content.Shared.Utility;
|
|
using Robust.Server.Interfaces.GameObjects;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.GameObjects.Components.Transform;
|
|
using Robust.Shared.Interfaces.Map;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.ViewVariables;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Content.Server.GameObjects.Components.Power
|
|
{
|
|
[RegisterComponent]
|
|
internal class WirePlacerComponent : Component, IAfterInteract
|
|
{
|
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
|
|
|
/// <inheritdoc />
|
|
public override string Name => "WirePlacer";
|
|
|
|
[ViewVariables]
|
|
private string _wirePrototypeID;
|
|
|
|
[ViewVariables]
|
|
private WireType _blockingWireType;
|
|
|
|
public override void ExposeData(ObjectSerializer serializer)
|
|
{
|
|
base.ExposeData(serializer);
|
|
serializer.DataField(ref _wirePrototypeID, "wirePrototypeID", "HVWire");
|
|
serializer.DataField(ref _blockingWireType, "blockingWireType", WireType.HighVoltage);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public async Task AfterInteract(AfterInteractEventArgs eventArgs)
|
|
{
|
|
if (!eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true)) return;
|
|
if(!_mapManager.TryGetGrid(eventArgs.ClickLocation.GetGridId(Owner.EntityManager), out var grid))
|
|
return;
|
|
var snapPos = grid.SnapGridCellFor(eventArgs.ClickLocation, SnapGridOffset.Center);
|
|
var snapCell = grid.GetSnapGridCell(snapPos, SnapGridOffset.Center);
|
|
if(grid.GetTileRef(snapPos).Tile.IsEmpty)
|
|
return;
|
|
foreach (var snapComp in snapCell)
|
|
{
|
|
if (snapComp.Owner.TryGetComponent<WireComponent>(out var wire) && wire.WireType == _blockingWireType)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
if (Owner.TryGetComponent(out StackComponent stack) && !stack.Use(1))
|
|
return;
|
|
Owner.EntityManager.SpawnEntity(_wirePrototypeID, grid.GridTileToLocal(snapPos));
|
|
}
|
|
}
|
|
}
|