mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 14:07:53 +03:00
# Description Goddamn do I love Adderall. This PR lays the entire groundwork needed for the "Glacier Rework", and it does so by fixing every problem I could think of between FTL and StationBiome that was preventing it from being a reality. Essentially, I'm hitting several birds with one stone by refactoring both systems to be a LOT more flexible. You can technically say that this basically is also partly enabling Lavaland maps, since I conveniently included options in the StationBiomeComponent to generate dungeons. Technically a planet map should probably also have a RestrictedRangeComponent added to it so that players can't wander so far from the station that they generate a truly excessive number of entities. Yes, this does infact mean you can now run Nukie gamemodes on planet maps. <details><summary><h1>Media</h1></summary> <p> https://github.com/user-attachments/assets/7a3730af-c521-42d4-8abd-5aa5989c369c </p> </details> --- # Changelog 🆑 - add: Shuttles can now take off and land from planet surfaces. They however will still respect exclusion zone beacons set by stations. Maybe in the future there might be a special shuttle (drop pod) that is set to ignore these exclusion zones. --------- Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> (cherry picked from commit fb4ca1af6a48eda92f15b5a70273e27c2c352f22)
65 lines
2.8 KiB
C#
65 lines
2.8 KiB
C#
using Content.Server.Parallax;
|
|
using Content.Server.Procedural;
|
|
using Content.Server.Station.Components;
|
|
using Content.Server.Station.Events;
|
|
using Content.Shared.Parallax.Biomes;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Shared.Map.Components;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.Station.Systems;
|
|
public sealed partial class StationBiomeSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly BiomeSystem _biome = default!;
|
|
[Dependency] private readonly IPrototypeManager _proto = default!;
|
|
[Dependency] private readonly StationSystem _station = default!;
|
|
[Dependency] private readonly MapSystem _mapSystem = default!;
|
|
[Dependency] private readonly DungeonSystem _dungeon = default!;
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<StationBiomeComponent, StationPostInitEvent>(OnStationPostInit);
|
|
}
|
|
|
|
private void OnStationPostInit(Entity<StationBiomeComponent> map, ref StationPostInitEvent args)
|
|
{
|
|
if (!TryComp(map, out StationDataComponent? dataComp))
|
|
return;
|
|
|
|
var station = _station.GetLargestGrid(dataComp);
|
|
if (station == null) return;
|
|
|
|
var mapId = Transform(station.Value).MapID;
|
|
if (!_mapSystem.TryGetMap(mapId, out var mapUid)
|
|
|| mapUid is null) // WHAT, IT'S LITERALLY CALLED TRYGET. WHY DO I NEED TO CHECK NULL?
|
|
return;
|
|
|
|
_biome.EnsurePlanet(mapUid!.Value, _proto.Index(map.Comp.Biome), map.Comp.Seed, mapLight: map.Comp.MapLightColor);
|
|
|
|
if (!TryComp<BiomeComponent>(mapUid, out var biomeComp))
|
|
return; // Yea we JUST made a biome component one line above this trycomp. It turns out I need an engine PR to retrieve the component just added.
|
|
// Imagine my frustration. On the other hand AddComps like above aren't guaranteed to return a component anyway.
|
|
|
|
foreach (var layer in map.Comp.BiomeLayers)
|
|
{
|
|
if (biomeComp.MarkerLayers.Contains(layer))
|
|
continue;
|
|
|
|
biomeComp.MarkerLayers.Add(layer);
|
|
biomeComp.ForcedMarkerLayers.Add(layer);
|
|
}
|
|
if (!TryComp(mapUid, out MapGridComponent? mapGrid))
|
|
return;
|
|
|
|
foreach (var dungeonProto in map.Comp.Dungeons)
|
|
{
|
|
// TODO: Pester TCJ about adding a _random.NextVector2i to Supermatter Engine, as well as adding methods for "officially" casting vector 2s as integer vectors.
|
|
var distVector = (Vector2i) _random.NextVector2(map.Comp.DungeonMinDistance, map.Comp.DungeonMaxDistance).Rounded();
|
|
_dungeon.GenerateDungeon(dungeonProto, mapUid!.Value, mapGrid, distVector, _random.Next());
|
|
}
|
|
}
|
|
}
|