mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-02-15 00:54:51 +01:00
* Create TurfSystem equivalent for and obsolete TurfHelpers.GetTileRef * Fix EntitySystem uses of TurfHelpers.GetTileRef * Fix EntitySystem uses of TurfHelpers.TryGetTileRef * Fix construction condition uses of TurfHelpers.GetTileRef * Fix last use of TurfHelpers.IsBlockedTurf * Create TurfSystem equivalent to and obsolete TurfHelpers.GetContentTileDefinition * Fix uses of TurfHelpers.GetContentTileDefinition(TileRef) * Fix uses of TurfHelpers.GetContentTileDefinition(Tile) * Create TurfSystem equivalent to and obsolete TurfHelpers.IsSpace * Fix EntitySystem uses of TurfHelpers.IsSpace(Tile) * Fix EntitySystem uses of TurfHelpers.IsSpace(TileRef) * Fix remaining uses of TurfHelpers.IsSpace * Fix uses of TurfHelpers.GetEntitiesInTile * Delete TurfHelpers.cs * Add GetEntitiesInTile lookup methods * Convert some GetEntitiesInTile methods to LookupSystem extension methods * Use new GetEntitiesInTile methods * Recycle spiderweb hashset * Recycle floor tile hashset
71 lines
2.2 KiB
C#
71 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 class GoliathTentacleSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly INetManager _net = default!;
|
|
[Dependency] private readonly SharedMapSystem _map = default!;
|
|
[Dependency] private readonly SharedStunSystem _stun = default!;
|
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
|
[Dependency] private readonly TurfSystem _turf = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
|
|
|
/// <inheritdoc/>
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<GoliathSummonTentacleAction>(OnSummonAction);
|
|
}
|
|
|
|
private void OnSummonAction(GoliathSummonTentacleAction args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
// TODO: animation
|
|
|
|
_popup.PopupPredicted(Loc.GetString("tentacle-ability-use-popup", ("entity", args.Performer)), args.Performer, args.Performer, type: PopupType.SmallCaution);
|
|
_stun.TryStun(args.Performer, TimeSpan.FromSeconds(0.8f), false);
|
|
|
|
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;
|
|
}
|
|
}
|