diff --git a/Content.Server/Dragon/DragonSystem.cs b/Content.Server/Dragon/DragonSystem.cs
index 06806ba93d..dfcfebc3b4 100644
--- a/Content.Server/Dragon/DragonSystem.cs
+++ b/Content.Server/Dragon/DragonSystem.cs
@@ -15,15 +15,19 @@ using Content.Server.GameTicking.Rules;
using Content.Shared.Damage;
using Content.Shared.Dragon;
using Content.Shared.Examine;
+using Content.Shared.Maps;
using Content.Shared.Movement.Systems;
using Robust.Shared.GameStates;
+using Robust.Shared.Map;
using Robust.Shared.Random;
namespace Content.Server.Dragon
{
public sealed partial class DragonSystem : GameRuleSystem
{
+ [Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
+ [Dependency] private readonly ITileDefinitionManager _tileDef = default!;
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
@@ -38,6 +42,11 @@ namespace Content.Server.Dragon
///
private const int RiftRange = 15;
+ ///
+ /// Radius of tiles
+ ///
+ private const int RiftTileRadius = 2;
+
private const int RiftsAllowed = 3;
public override void Initialize()
@@ -219,7 +228,7 @@ namespace Content.Server.Dragon
var xform = Transform(uid);
// Have to be on a grid fam
- if (xform.GridUid == null)
+ if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
{
_popupSystem.PopupEntity(Loc.GetString("carp-rift-anchor"), uid, Filter.Entities(uid));
return;
@@ -234,6 +243,15 @@ namespace Content.Server.Dragon
}
}
+ foreach (var tile in grid.GetTilesIntersecting(new Circle(xform.WorldPosition, RiftTileRadius), false))
+ {
+ if (!tile.IsSpace(_tileDef))
+ continue;
+
+ _popupSystem.PopupEntity(Loc.GetString("carp-rift-space-proximity", ("proximity", RiftTileRadius)), uid, Filter.Entities(uid));
+ return;
+ }
+
var carpUid = Spawn(component.RiftPrototype, xform.MapPosition);
component.Rifts.Add(carpUid);
Comp(carpUid).Dragon = uid;
diff --git a/Resources/Locale/en-US/actions/actions/dragon.ftl b/Resources/Locale/en-US/actions/actions/dragon.ftl
index 7860d4b046..32134279c9 100644
--- a/Resources/Locale/en-US/actions/actions/dragon.ftl
+++ b/Resources/Locale/en-US/actions/actions/dragon.ftl
@@ -18,6 +18,7 @@ carp-rift-examine = It is [color=yellow]{$percentage}%[/color] charged!
carp-rift-max = You have reached your maximum amount of rifts
carp-rift-anchor = Rifts require a stable surface to spawn.
carp-rift-proximity = Too close to a nearby rift! Need to be at least {$proximity}m away.
+carp-rift-space-proximity = Too close to space! Need to be at least {$proximity}m away.
carp-rift-weakened = You are unable to summon more rifts in your weakened state.
carp-rift-destroyed = A rift has been destroyed! You are now weakened temporarily.