Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glacier Real (#1169) #728

Merged
merged 10 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Content.IntegrationTests/Tests/PostMapInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public sealed class PostMapInitTest
"Tortuga", //DeltaV
"Arena", //DeltaV
"Asterisk", //DeltaV
"Glacier", //DeltaV
"TheHive", //DeltaV
"Hammurabi", //DeltaV
"Lighthouse", //DeltaV
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Content.Server.Station.Systems;
using Robust.Shared.Utility;

namespace Content.Server.Station.Components;

/// <summary>
/// Loads a surface map on mapinit.
/// </summary>
[RegisterComponent, Access(typeof(StationSurfaceSystem))]
public sealed partial class StationSurfaceComponent : Component
{
/// <summary>
/// Path to the map to load.
/// </summary>
[DataField(required: true)]
public ResPath? MapPath;

/// <summary>
/// The map that was loaded.
/// </summary>
[DataField]
public EntityUid? Map;
}
41 changes: 41 additions & 0 deletions Content.Server/DeltaV/Station/Systems/StationSurfaceSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Content.Server.Parallax;
using Content.Server.Station.Components;
using Robust.Server.GameObjects;

namespace Content.Server.Station.Systems;

public sealed class StationSurfaceSystem : EntitySystem
{
[Dependency] private readonly BiomeSystem _biome = default!;
[Dependency] private readonly MapSystem _map = default!;
[Dependency] private readonly MapLoaderSystem _mapLoader = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<StationSurfaceComponent, MapInitEvent>(OnMapInit);
}

private void OnMapInit(Entity<StationSurfaceComponent> ent, ref MapInitEvent args)
{
if (ent.Comp.MapPath is not {} path)
return;

var map = _map.CreateMap(out var mapId);
if (!_mapLoader.TryLoad(mapId, path.ToString(), out _))
{
Log.Error($"Failed to load surface map {ent.Comp.MapPath}!");
Del(map);
return;
}

// loading replaced the map entity with a new one so get the latest id
map = _map.GetMap(mapId);
_map.SetPaused(map, false);

// Needs a cherrypick, but this system is unused entirely for now
//_biome.SetEnabled(map); // generate the terrain after the grids loaded to prevent it getting hidden under it
ent.Comp.Map = map;
}
}
Loading
Loading