]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Turn arrivals into a planetmap (#21777)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Mon, 11 Dec 2023 09:34:19 +0000 (20:34 +1100)
committerGitHub <noreply@github.com>
Mon, 11 Dec 2023 09:34:19 +0000 (20:34 +1100)
Content.Server/Shuttles/Systems/ArrivalsSystem.cs
Content.Shared/CCVar/CCVars.cs

index 19779c5cfeed838178620f86112930c325138968..53ede9b9245f7c07c9c2ada533dc27a1e793e23e 100644 (file)
@@ -2,6 +2,7 @@ using System.Linq;
 using Content.Server.Administration;
 using Content.Server.GameTicking;
 using Content.Server.GameTicking.Events;
+using Content.Server.Parallax;
 using Content.Server.Shuttles.Components;
 using Content.Server.Shuttles.Events;
 using Content.Server.Spawners.Components;
@@ -12,6 +13,8 @@ using Content.Shared.Administration;
 using Content.Shared.CCVar;
 using Content.Shared.Mobs.Components;
 using Content.Shared.Movement.Components;
+using Content.Shared.Parallax.Biomes;
+using Content.Shared.Salvage;
 using Content.Shared.Shuttles.Components;
 using Robust.Shared.Spawners;
 using Content.Shared.Tiles;
@@ -20,6 +23,7 @@ using Robust.Shared.Collections;
 using Robust.Shared.Configuration;
 using Robust.Shared.Console;
 using Robust.Shared.Map;
+using Robust.Shared.Prototypes;
 using Robust.Shared.Random;
 using Robust.Shared.Timing;
 using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent;
@@ -35,7 +39,9 @@ public sealed class ArrivalsSystem : EntitySystem
     [Dependency] private readonly IConsoleHost _console = default!;
     [Dependency] private readonly IGameTiming _timing = default!;
     [Dependency] private readonly IMapManager _mapManager = default!;
+    [Dependency] private readonly IPrototypeManager _protoManager = default!;
     [Dependency] private readonly IRobustRandom _random = default!;
+    [Dependency] private readonly BiomeSystem _biomes = default!;
     [Dependency] private readonly GameTicker _ticker = default!;
     [Dependency] private readonly MapLoaderSystem _loader = default!;
     [Dependency] private readonly SharedTransformSystem _transform = default!;
@@ -48,6 +54,13 @@ public sealed class ArrivalsSystem : EntitySystem
     /// </summary>
     public bool Enabled { get; private set; }
 
+    private readonly List<ProtoId<BiomeTemplatePrototype>> _arrivalsBiomeOptions = new()
+    {
+        "Grasslands",
+        "LowDesert",
+        "Snow",
+    };
+
     public override void Initialize()
     {
         base.Initialize();
@@ -396,6 +409,8 @@ public sealed class ArrivalsSystem : EntitySystem
     private void SetupArrivalsStation()
     {
         var mapId = _mapManager.CreateMap();
+        var mapUid = _mapManager.GetMapEntityId(mapId);
+        _mapManager.AddUninitializedMap(mapId);
 
         if (!_loader.TryLoad(mapId, _cfgManager.GetCVar(CCVars.ArrivalsMap), out var uids))
         {
@@ -409,6 +424,18 @@ public sealed class ArrivalsSystem : EntitySystem
             EnsureComp<PreventPilotComponent>(id);
         }
 
+        // Setup planet arrivals if relevant
+        if (_cfgManager.GetCVar(CCVars.ArrivalsPlanet))
+        {
+            var template = _random.Pick(_arrivalsBiomeOptions);
+            _biomes.EnsurePlanet(mapUid, _protoManager.Index(template));
+            var range = AddComp<RestrictedRangeComponent>(mapUid);
+            range.Range = 32f;
+            Dirty(mapUid, range);
+        }
+
+        _mapManager.DoMapInitialize(mapId);
+
         // Handle roundstart stations.
         var query = AllEntityQuery<StationArrivalsComponent>();
 
index 32855652c99c1131e9824c1b3146624d3313e1f2..4a6ee046a2b38c980a65b547a52707e8c61df4d9 100644 (file)
@@ -1246,6 +1246,12 @@ namespace Content.Shared.CCVar
         public static readonly CVarDef<bool> CameraRotationLocked =
             CVarDef.Create("shuttle.camera_rotation_locked", false, CVar.REPLICATED);
 
+        /// <summary>
+        /// Whether the arrivals terminal should be on a planet map.
+        /// </summary>
+        public static readonly CVarDef<bool> ArrivalsPlanet =
+            CVarDef.Create("shuttle.arrivals_planet", true, CVar.SERVERONLY);
+
         /// <summary>
         /// Whether the arrivals shuttle is enabled.
         /// </summary>