Add FTL destinations (#9685)

This commit is contained in:
metalgearsloth
2022-07-15 14:11:41 +10:00
committed by GitHub
parent 5e1d019f17
commit 1251b3aeda
34 changed files with 9133 additions and 227 deletions

View File

@@ -6,6 +6,8 @@ using Content.Server.Nuke;
using Content.Server.Players;
using Content.Server.Roles;
using Content.Server.RoundEnd;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Systems;
using Content.Server.Spawners.Components;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
@@ -185,43 +187,28 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
}
// TODO: Make this a prototype
var map = "/Maps/infiltrator.yml";
// so true PAUL!
var path = "/Maps/nukieplanet.yml";
var shuttlePath = "/Maps/infiltrator.yml";
var mapId = _mapManager.CreateMap();
var center = new Vector2();
var minRadius = 0f;
Box2? aabb = null;
var (_, outpost) = _mapLoader.LoadBlueprint(mapId, "/Maps/nukieplanet.yml");
foreach (var uid in _stationSystem.Stations)
if (outpost == null)
{
if (TryComp<StationDataComponent>(uid, out var stationData))
{
foreach (var grid in stationData.Grids)
{
if (TryComp<IMapGridComponent>(grid, out var gridComp))
aabb = aabb?.Union(gridComp.Grid.WorldAABB) ?? gridComp.Grid.WorldAABB;
}
}
Logger.ErrorS("nukies", $"Error loading map {path} for nukies!");
return;
}
if (aabb != null)
// Listen I just don't want it to overlap.
var (_, shuttleId) = _mapLoader.LoadBlueprint(mapId, shuttlePath, new MapLoadOptions()
{
center = aabb.Value.Center;
minRadius = MathF.Max(aabb.Value.Width, aabb.Value.Height);
}
var (_, gridUid) = _mapLoader.LoadBlueprint(GameTicker.DefaultMap, map, new MapLoadOptions
{
Offset = center + MathF.Max(minRadius, minRadius) + 1000f,
Offset = Vector2.One * 1000f,
});
if (!gridUid.HasValue)
if (TryComp<ShuttleComponent>(shuttleId, out var shuttle))
{
Logger.ErrorS("NUKEOPS", $"Gridid was null when loading \"{map}\", aborting.");
foreach (var session in operatives)
{
ev.PlayerPool.Add(session);
}
return;
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ShuttleSystem>().TryFTLDock(shuttle, outpost.Value);
}
// TODO: Loot table or something
@@ -236,14 +223,18 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
// Forgive me for hardcoding prototypes
foreach (var (_, meta, xform) in EntityManager.EntityQuery<SpawnPointComponent, MetaDataComponent, TransformComponent>(true))
{
if (meta.EntityPrototype?.ID != "SpawnPointNukies" || xform.ParentUid != gridUid) continue;
if (meta.EntityPrototype?.ID != "SpawnPointNukies") continue;
spawns.Add(xform.Coordinates);
if (xform.ParentUid == outpost)
{
spawns.Add(xform.Coordinates);
break;
}
}
if (spawns.Count == 0)
{
spawns.Add(EntityManager.GetComponent<TransformComponent>(gridUid.Value).Coordinates);
spawns.Add(EntityManager.GetComponent<TransformComponent>(outpost.Value).Coordinates);
Logger.WarningS("nukies", $"Fell back to default spawn for nukies!");
}