CatStation/Content.Shared/Abilities/Goliath/GoliathTentacleSystem.cs
Whatstone a88d2c5164
Cleanup: Resolve remaining PopupSystem warnings in Content.Shared (#44685)
* PopupClient to PopupEntity/Coordinates

* PopupPredictedX to PopupEntity/Cursor/Coordinates

* The rest of the damn owl

* nullability fixes

* Buckle cleanup

* cleanup, address PR comments

* ExecutionSystem: one popup method

* correct my filthy lies

* Apply most of ajcm's suggestions

* return user to SharedItemRecallSystem.cs

* Fix lingering Ensnarable broadcast popups

* targeted drain popups

* fix lingering untargeted Guardian popups

I read the comment on GuardianHostRecall.  Oops.

* target stethoscope popups

* fix the PDA vibration popup

* Fix target for encryption key removal popup

* anomaly scanner: args.User, not uid

* disposal unit comment, bcast pda vibration popup
2026-07-16 21:54:33 +00:00

70 lines
2.2 KiB
C#

using Content.Shared.Directions;
using Content.Shared.Maps;
using Content.Shared.Physics;
using Content.Shared.Popups;
using Content.Shared.Stunnable;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Network;
using Robust.Shared.Random;
namespace Content.Shared.Abilities.Goliath;
public sealed partial class GoliathTentacleSystem : EntitySystem
{
[Dependency] private IRobustRandom _random = default!;
[Dependency] private INetManager _net = default!;
[Dependency] private SharedMapSystem _map = default!;
[Dependency] private SharedStunSystem _stun = default!;
[Dependency] private SharedTransformSystem _transform = default!;
[Dependency] private TurfSystem _turf = default!;
[Dependency] private SharedPopupSystem _popup = default!;
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<GoliathSummonTentacleAction>(OnSummonAction);
}
private void OnSummonAction(GoliathSummonTentacleAction args)
{
if (args.Handled)
return;
// TODO: animation
_popup.PopupEntity(Loc.GetString("tentacle-ability-use-popup", ("entity", args.Performer)), args.Performer, type: PopupType.SmallCaution);
_stun.TryAddStunDuration(args.Performer, TimeSpan.FromSeconds(0.8f));
var coords = args.Target;
List<EntityCoordinates> spawnPos = new();
spawnPos.Add(coords);
var dirs = new List<Direction>();
dirs.AddRange(args.OffsetDirections);
for (var i = 0; i < 3; i++)
{
var dir = _random.PickAndTake(dirs);
spawnPos.Add(coords.Offset(dir));
}
if (_transform.GetGrid(coords) is not { } grid || !TryComp<MapGridComponent>(grid, out var gridComp))
return;
foreach (var pos in spawnPos)
{
if (!_map.TryGetTileRef(grid, gridComp, pos, out var tileRef) ||
_turf.IsSpace(tileRef) ||
_turf.IsTileBlocked(tileRef, CollisionGroup.Impassable))
{
continue;
}
if (_net.IsServer)
Spawn(args.EntityId, pos);
}
args.Handled = true;
}
}