From d4d3e058933031151c77a81ce07e249ee37aed92 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 8 Aug 2022 14:43:09 +1000 Subject: [PATCH] Carp rift proximity (#10429) --- Content.Server/Dragon/DragonSystem.cs | 20 ++++++++++++++++++- .../Locale/en-US/actions/actions/dragon.ftl | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) 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.