Turn arrivals into a planetmap (#21777)

This commit is contained in:
metalgearsloth
2023-12-11 20:34:19 +11:00
committed by GitHub
parent b33906567d
commit 02c8e585f7
2 changed files with 33 additions and 0 deletions

View 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>();

View 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>