From 82d6fe07fedbe40cb6544754ed347b8db5d4a1a6 Mon Sep 17 00:00:00 2001 From: Ed Date: Sun, 16 Feb 2025 22:56:10 +0300 Subject: [PATCH] roof adapt --- Content.Client/_CP14/Roof/CP14RoofSystem.cs | 23 +++++++++++++++++++ Content.Server/_CP14/Cargo/CP14CargoSystem.cs | 11 +++++---- .../EntitySystems/CP14StationZLevelsSystem.cs | 11 ++++----- Resources/Maps/_CP14/comoss.yml | 1 + Resources/Prototypes/_CP14/Maps/centcomm.yml | 14 ----------- 5 files changed, 35 insertions(+), 25 deletions(-) delete mode 100644 Resources/Prototypes/_CP14/Maps/centcomm.yml diff --git a/Content.Client/_CP14/Roof/CP14RoofSystem.cs b/Content.Client/_CP14/Roof/CP14RoofSystem.cs index 3210da3972..d0f91dd614 100644 --- a/Content.Client/_CP14/Roof/CP14RoofSystem.cs +++ b/Content.Client/_CP14/Roof/CP14RoofSystem.cs @@ -17,6 +17,7 @@ public sealed class CP14RoofSystem : EntitySystem private bool _roofVisible = true; public bool DisabledByCommand = false; + private EntityQuery _gridQuery; private EntityQuery _ghostQuery; private EntityQuery _xformQuery; @@ -36,8 +37,11 @@ public sealed class CP14RoofSystem : EntitySystem _ghostQuery = GetEntityQuery(); _xformQuery = GetEntityQuery(); + _gridQuery = GetEntityQuery(); SubscribeLocalEvent(RoofStartup); + SubscribeLocalEvent(RoofRemove); + SubscribeLocalEvent(OnToggleRoof); } @@ -95,6 +99,25 @@ public sealed class CP14RoofSystem : EntitySystem return; UpdateVisibility(ent, sprite); + + var xform = Transform(ent); + + if (_gridQuery.TryComp(xform.GridUid, out var grid)) + { + var index = _map.LocalToTile(xform.GridUid.Value, grid, xform.Coordinates); + _roof.SetRoof((xform.GridUid.Value, grid, null), index, true); + } + } + + private void RoofRemove(Entity ent, ref ComponentRemove args) + { + var xform = Transform(ent); + + if (_gridQuery.TryComp(xform.GridUid, out var grid)) + { + var index = _map.LocalToTile(xform.GridUid.Value, grid, xform.Coordinates); + _roof.SetRoof((xform.GridUid.Value, grid, null), index, false); + } } private void UpdateVisibility(Entity ent, SpriteComponent sprite) diff --git a/Content.Server/_CP14/Cargo/CP14CargoSystem.cs b/Content.Server/_CP14/Cargo/CP14CargoSystem.cs index 01667c7265..4ad65e20d7 100644 --- a/Content.Server/_CP14/Cargo/CP14CargoSystem.cs +++ b/Content.Server/_CP14/Cargo/CP14CargoSystem.cs @@ -1,3 +1,4 @@ +using System.Linq; using Content.Server._CP14.Currency; using Content.Server._CP14.RoundRemoveShuttle; using Content.Server.Shuttles.Systems; @@ -13,6 +14,7 @@ using Content.Shared.Storage; using Content.Shared.Storage.EntitySystems; using JetBrains.Annotations; using Robust.Server.GameObjects; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Map; using Robust.Shared.Prototypes; using Robust.Shared.Random; @@ -87,14 +89,13 @@ public sealed partial class CP14CargoSystem : CP14SharedCargoSystem if (!Deleted(station.Comp.Shuttle)) return; - var tradepostMap = _mapManager.CreateMap(); - - if (!_loader.TryLoad(tradepostMap, station.Comp.ShuttlePath.ToString(), out var shuttleUids)) + if (!_loader.TryLoadMap(station.Comp.ShuttlePath, out var tradepostMap, out var shuttleUids)) return; - var shuttle = shuttleUids[0]; + + var shuttle = shuttleUids.First(); station.Comp.Shuttle = shuttle; - station.Comp.TradePostMap = _mapManager.GetMapEntityId(tradepostMap); + station.Comp.TradePostMap = _mapManager.GetMapEntityId(tradepostMap.Value.Comp.MapId); var travelingStoreShipComp = EnsureComp(station.Comp.Shuttle.Value); travelingStoreShipComp.Station = station; diff --git a/Content.Server/_CP14/ZLevels/EntitySystems/CP14StationZLevelsSystem.cs b/Content.Server/_CP14/ZLevels/EntitySystems/CP14StationZLevelsSystem.cs index b8531b9f9b..51ca8bf8a6 100644 --- a/Content.Server/_CP14/ZLevels/EntitySystems/CP14StationZLevelsSystem.cs +++ b/Content.Server/_CP14/ZLevels/EntitySystems/CP14StationZLevelsSystem.cs @@ -5,7 +5,8 @@ using Content.Server.Station.Systems; using Content.Shared.Maps; using Content.Shared.Station.Components; using Robust.Server.GameObjects; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Map; namespace Content.Server._CP14.ZLevels.EntitySystems; @@ -60,10 +61,9 @@ public sealed partial class CP14StationZLevelsSystem : EntitySystem 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 {level.Path.ToString()} for CP14StationZLevelsSystem at level {map} don't exist!"); continue; } @@ -72,9 +72,8 @@ public sealed partial class CP14StationZLevelsSystem : EntitySystem 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)) + if (!_mapLoader.TryLoadMap(level.Path.Value, out var mapEnt, out var grids)) { Log.Error($"Failed to load map for CP14StationZLevelsSystem at level {map}!"); Del(mapUid); diff --git a/Resources/Maps/_CP14/comoss.yml b/Resources/Maps/_CP14/comoss.yml index 88647bd4c7..81b13c6897 100644 --- a/Resources/Maps/_CP14/comoss.yml +++ b/Resources/Maps/_CP14/comoss.yml @@ -85,6 +85,7 @@ entities: components: - type: MetaData name: grid + - type: Roof - type: Transform parent: 1 - type: BecomesStation diff --git a/Resources/Prototypes/_CP14/Maps/centcomm.yml b/Resources/Prototypes/_CP14/Maps/centcomm.yml deleted file mode 100644 index 47dc5ca1f3..0000000000 --- a/Resources/Prototypes/_CP14/Maps/centcomm.yml +++ /dev/null @@ -1,14 +0,0 @@ -- type: gameMap - id: CentComm - mapName: 'Central Command' - mapPath: /Maps/centcomm.yml - minPlayers: 10 - stations: - centcomm: - stationProto: NanotrasenCentralCommand - components: - - type: StationNameSetup - mapNameTemplate: '{0} Central Command {1}' - nameGenerator: - !type:NanotrasenNameGenerator - prefixCreator: 'TG'