diff --git a/Content.Server/_CP14/StationDungeonMap/Components/CP14StationAbyssComponent.cs b/Content.Server/_CP14/StationDungeonMap/Components/CP14StationAbyssComponent.cs
new file mode 100644
index 0000000000..0310d85f09
--- /dev/null
+++ b/Content.Server/_CP14/StationDungeonMap/Components/CP14StationAbyssComponent.cs
@@ -0,0 +1,14 @@
+using Content.Server._CP14.StationDungeonMap.EntitySystems;
+using Content.Shared._CP14.StationZLevels;
+
+namespace Content.Server._CP14.StationDungeonMap.Components;
+
+///
+/// Creates a chain of z-levels overloading with time
+///
+[RegisterComponent, Access(typeof(CP14StationAbyssSystem))]
+public sealed partial class CP14StationAbyssComponent : Component
+{
+ [DataField]
+ public Dictionary> Levels = new();
+}
diff --git a/Content.Server/_CP14/StationDungeonMap/EntitySystems/CP14StationAbyssSystem.cs b/Content.Server/_CP14/StationDungeonMap/EntitySystems/CP14StationAbyssSystem.cs
new file mode 100644
index 0000000000..e1fa1cde8e
--- /dev/null
+++ b/Content.Server/_CP14/StationDungeonMap/EntitySystems/CP14StationAbyssSystem.cs
@@ -0,0 +1,11 @@
+namespace Content.Server._CP14.StationDungeonMap.EntitySystems;
+
+public sealed partial class CP14StationAbyssSystem : EntitySystem
+{
+ public override void Initialize()
+ {
+ base.Initialize();
+
+
+ }
+}
diff --git a/Content.Server/_CP14/StationDungeonMap/EntitySystems/CP14StationZLevelsSystem.AutoPortal.cs b/Content.Server/_CP14/StationDungeonMap/EntitySystems/CP14StationZLevelsSystem.AutoPortal.cs
new file mode 100644
index 0000000000..bb7b23cf04
--- /dev/null
+++ b/Content.Server/_CP14/StationDungeonMap/EntitySystems/CP14StationZLevelsSystem.AutoPortal.cs
@@ -0,0 +1,37 @@
+using Content.Server._CP14.StationDungeonMap.Components;
+using Robust.Shared.Map;
+
+namespace Content.Server._CP14.StationDungeonMap.EntitySystems;
+
+public sealed partial class CP14StationZLevelsSystem
+{
+ private void AutoPortalInitialize()
+ {
+ SubscribeLocalEvent(OnPortalMapInit);
+ }
+
+ private void OnPortalMapInit(Entity autoPortal, ref MapInitEvent args)
+ {
+ InitPortal(autoPortal);
+ }
+
+ private void InitPortal(Entity autoPortal)
+ {
+ var mapId = Transform(autoPortal).MapUid;
+ if (mapId is null)
+ return;
+
+ var offsetMap = GetMapOffset(mapId.Value, autoPortal.Comp.ZLevelOffset);
+
+ if (offsetMap is null)
+ return;
+
+ var currentWorldPos = _transform.GetWorldPosition(autoPortal);
+ var targetMapPos = new MapCoordinates(currentWorldPos, offsetMap.Value);
+
+ var otherSidePortal = Spawn(autoPortal.Comp.OtherSideProto, targetMapPos);
+
+ if (_linkedEntity.TryLink(autoPortal, otherSidePortal, true))
+ RemComp(autoPortal);
+ }
+}
diff --git a/Content.Server/_CP14/StationDungeonMap/EntitySystems/CP14StationZLevelsSystem.cs b/Content.Server/_CP14/StationDungeonMap/EntitySystems/CP14StationZLevelsSystem.cs
index ae7c1ae11b..f74b575082 100644
--- a/Content.Server/_CP14/StationDungeonMap/EntitySystems/CP14StationZLevelsSystem.cs
+++ b/Content.Server/_CP14/StationDungeonMap/EntitySystems/CP14StationZLevelsSystem.cs
@@ -10,6 +10,7 @@ using Robust.Server.GameObjects;
using Robust.Server.Maps;
using Robust.Shared.Map;
using Robust.Shared.Random;
+using Robust.Shared.Utility;
namespace Content.Server._CP14.StationDungeonMap.EntitySystems;
@@ -19,17 +20,14 @@ public sealed partial class CP14StationZLevelsSystem : EntitySystem
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly MapLoaderSystem _mapLoader = default!;
[Dependency] private readonly TransformSystem _transform = default!;
- [Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
- [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly TileSystem _tile = default!;
- [Dependency] private readonly SharedMapSystem _maps = default!;
[Dependency] private readonly LinkedEntitySystem _linkedEntity = default!;
public override void Initialize()
{
base.Initialize();
+ AutoPortalInitialize();
- SubscribeLocalEvent(OnPortalMapInit);
SubscribeLocalEvent(OnRoundStart);
SubscribeLocalEvent(OnStationPostInit);
}
@@ -66,61 +64,56 @@ public sealed partial class CP14StationZLevelsSystem : EntitySystem
ent.Comp.Initialized = true;
- foreach (var (map, level) in ent.Comp.Levels)
+ foreach (var (zLevel, level) in ent.Comp.Levels)
{
- if (ent.Comp.LevelEntities.ContainsValue(map))
- {
- Log.Error($"Key duplication for CP14StationZLevelsSystem at level {map}!");
- continue;
- }
-
var path = level.Path.ToString();
- if (path is null)
+ if (level.Path is null)
{
- Log.Error($"path {path} for CP14StationZLevelsSystem at level {map} don't exist!");
+ Log.Error($"path {path} for CP14StationZLevelsSystem at level {zLevel} don't exist!");
continue;
}
- var mapUid = _map.CreateMap(out var mapId);
- var member = EnsureComp(mapUid);
- member.Station = ent;
-
- Log.Info($"Created map {mapId} for CP14StationZLevelsSystem at level {map}");
- var options = new MapLoadOptions { LoadMap = true };
-
- if (!_mapLoader.TryLoad(mapId, path, out var grids, options))
- {
- Log.Error($"Failed to load map for CP14StationZLevelsSystem at level {map}!");
- Del(mapUid);
- continue;
- }
- ent.Comp.LevelEntities.Add(mapId, map);
+ SetZLevel(ent, zLevel, level.Path.Value);
}
}
- private void OnPortalMapInit(Entity autoPortal, ref MapInitEvent args)
+ public MapId? SetZLevel(Entity ent, int zLevel, ResPath resPath, bool force = false)
{
- InitPortal(autoPortal);
- }
+ if (ent.Comp.LevelEntities.ContainsValue(zLevel))
+ {
+ if (!force)
+ {
+ Log.Error($"Key duplication for CP14StationZLevelsSystem at level {zLevel}!");
+ return null;
+ }
- private void InitPortal(Entity autoPortal)
- {
- var mapId = Transform(autoPortal).MapUid;
- if (mapId is null)
- return;
+ foreach (var (key, value) in ent.Comp.LevelEntities)
+ {
+ if (value == zLevel && _map.MapExists(key))
+ {
+ ent.Comp.LevelEntities.Remove(key);
+ Del(_map.GetMap(key));
+ }
+ }
+ }
- var offsetMap = GetMapOffset(mapId.Value, autoPortal.Comp.ZLevelOffset);
+ var mapUid = _map.CreateMap(out var mapId);
+ var member = EnsureComp(mapUid);
+ member.Station = ent;
- if (offsetMap is null)
- return;
+ Log.Info($"Created map {mapId} for CP14StationZLevelsSystem at level {zLevel}");
- var currentWorldPos = _transform.GetWorldPosition(autoPortal);
- var targetMapPos = new MapCoordinates(currentWorldPos, offsetMap.Value);
+ var options = new MapLoadOptions { LoadMap = true };
- var otherSidePortal = Spawn(autoPortal.Comp.OtherSideProto, targetMapPos);
+ if (!_mapLoader.TryLoad(mapId, resPath.ToString(), out var grids, options))
+ {
+ Log.Error($"Failed to load map for CP14StationZLevelsSystem at level {zLevel}!");
+ Del(mapUid);
+ return null;
+ }
+ ent.Comp.LevelEntities.TryAdd(mapId, zLevel);
- if (_linkedEntity.TryLink(autoPortal, otherSidePortal, true))
- RemComp(autoPortal);
+ return mapId;
}
public MapId? GetMapOffset(EntityUid mapUid, int offset)
diff --git a/Content.Shared/_CP14/StationZLevels/CP14ZLevelPrototype.cs b/Content.Shared/_CP14/StationZLevels/CP14ZLevelPrototype.cs
new file mode 100644
index 0000000000..1d929a5ee9
--- /dev/null
+++ b/Content.Shared/_CP14/StationZLevels/CP14ZLevelPrototype.cs
@@ -0,0 +1,25 @@
+using Robust.Shared.Prototypes;
+using Robust.Shared.Utility;
+
+namespace Content.Shared._CP14.StationZLevels;
+
+///
+/// Prototype “floor type”. Refers to a certain group of cards united by a common style and some common rules
+///
+[Prototype("zLevel")]
+public sealed partial class CP14ZLevelPrototype : IPrototype
+{
+ [IdDataField] public string ID { get; } = default!;
+
+ ///
+ /// the name of the floor that players can see.
+ ///
+ [DataField(required: true)]
+ public LocId Name = string.Empty;
+
+ ///
+ /// all possible floor layouts
+ ///
+ [DataField]
+ public HashSet Maps = new();
+}