From e6bbc3900f68485419c782ad23f60906f4b51ba7 Mon Sep 17 00:00:00 2001 From: Ed <96445749+TheShuEd@users.noreply.github.com> Date: Tue, 29 Oct 2024 12:15:16 +0300 Subject: [PATCH] Delete CP14ExpeditionSystem --- .../Station/Systems/StationSpawningSystem.cs | 3 - .../_CP14/Shuttles/CP14ExpeditionSystem.cs | 155 ------------------ .../Components/CP14ExpeditionShipComponent.cs | 9 - .../CP14ExpeditionShipFTLTargetComponent.cs | 9 - .../CP14StationExpeditionTargetComponent.cs | 15 -- Content.Shared/CCVar/CCVars.cs | 13 -- 6 files changed, 204 deletions(-) delete mode 100644 Content.Server/_CP14/Shuttles/CP14ExpeditionSystem.cs delete mode 100644 Content.Server/_CP14/Shuttles/Components/CP14ExpeditionShipComponent.cs delete mode 100644 Content.Server/_CP14/Shuttles/Components/CP14ExpeditionShipFTLTargetComponent.cs delete mode 100644 Content.Server/_CP14/Shuttles/Components/CP14StationExpeditionTargetComponent.cs diff --git a/Content.Server/Station/Systems/StationSpawningSystem.cs b/Content.Server/Station/Systems/StationSpawningSystem.cs index 7f0dce2104..3dd4995371 100644 --- a/Content.Server/Station/Systems/StationSpawningSystem.cs +++ b/Content.Server/Station/Systems/StationSpawningSystem.cs @@ -1,5 +1,3 @@ -using System.Linq; -using Content.Server._CP14.Shuttles; using Content.Server.Access.Systems; using Content.Server.DetailExaminable; using Content.Server.Humanoid; @@ -42,7 +40,6 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem [Dependency] private readonly SharedAccessSystem _accessSystem = default!; [Dependency] private readonly ActorSystem _actors = default!; [Dependency] private readonly ArrivalsSystem _arrivalsSystem = default!; - [Dependency] private readonly CP14ExpeditionSystem _CP14expedition = default!; [Dependency] private readonly IdCardSystem _cardSystem = default!; [Dependency] private readonly IConfigurationManager _configurationManager = default!; [Dependency] private readonly ContainerSpawnPointSystem _containerSpawnPointSystem = default!; diff --git a/Content.Server/_CP14/Shuttles/CP14ExpeditionSystem.cs b/Content.Server/_CP14/Shuttles/CP14ExpeditionSystem.cs deleted file mode 100644 index 2b4172dfca..0000000000 --- a/Content.Server/_CP14/Shuttles/CP14ExpeditionSystem.cs +++ /dev/null @@ -1,155 +0,0 @@ -using Content.Server._CP14.Shuttles.Components; -using Content.Server.Shuttles.Components; -using Content.Server.Shuttles.Events; -using Content.Server.Shuttles.Systems; -using Content.Server.Spawners.Components; -using Content.Server.Spawners.EntitySystems; -using Content.Server.Station.Events; -using Content.Server.Station.Systems; -using Content.Shared.CCVar; -using Content.Shared.Movement.Components; -using Robust.Server.GameObjects; -using Robust.Shared.Configuration; -using Robust.Shared.Map; -using Robust.Shared.Random; - -namespace Content.Server._CP14.Shuttles; - -public sealed class CP14ExpeditionSystem : EntitySystem -{ - [Dependency] private readonly IConfigurationManager _cfgManager = default!; - [Dependency] private readonly IMapManager _mapManager = default!; - [Dependency] private readonly IRobustRandom _random = default!; - [Dependency] private readonly MapLoaderSystem _loader = default!; - [Dependency] private readonly SharedTransformSystem _transform = default!; - [Dependency] private readonly ShuttleSystem _shuttles = default!; - [Dependency] private readonly StationSpawningSystem _stationSpawning = default!; - - /// - /// Flags if all players must arrive via the Arrivals system, or if they can spawn in other ways. - /// - public float ArrivalTime { get; private set; } - - /// - /// If enabled then spawns players on an expedition ship. - /// - public bool Enabled { get; private set; } - - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnPostInitSetupExpeditionShip); - - SubscribeLocalEvent(OnExpeditionShipLanded); - - SubscribeLocalEvent(HandlePlayerSpawning, before: new []{ typeof(SpawnPointSystem) }); - - ArrivalTime = _cfgManager.GetCVar(CCVars.CP14ExpeditionArrivalTime); - Enabled = _cfgManager.GetCVar(CCVars.CP14ExpeditionShip); - - _cfgManager.OnValueChanged(CCVars.CP14ExpeditionArrivalTime, time => ArrivalTime = time, true); - _cfgManager.OnValueChanged(CCVars.CP14ExpeditionShip, value => Enabled = value, true); - } - - private void OnPostInitSetupExpeditionShip(Entity station, ref StationPostInitEvent args) - { - if (!Enabled) - return; - - if (!Deleted(station.Comp.Shuttle)) - return; - - var dummyMap = _mapManager.CreateMap(); - - if (_loader.TryLoad(dummyMap, station.Comp.ShuttlePath.ToString(), out var shuttleUids)) - { - var shuttle = shuttleUids[0]; - station.Comp.Shuttle = shuttle; - var shuttleComp = Comp(station.Comp.Shuttle); - var expeditionShipComp = EnsureComp(station.Comp.Shuttle); - expeditionShipComp.Station = station; - - var targetPoints = new List(); - var targetEnumerator = EntityQueryEnumerator(); - while (targetEnumerator.MoveNext(out var uid, out _, out _)) - { - targetPoints.Add(uid); - } - var target = _random.Pick(targetPoints); - if (!HasComp(shuttle)) - return; - - var targetPos = _transform.GetWorldPosition(target); - var mapUid = _transform.GetMap(target); - if (mapUid == null) - return; - - _shuttles.FTLToCoordinates(shuttle, shuttleComp, new EntityCoordinates(mapUid.Value, targetPos), Angle.Zero, hyperspaceTime: ArrivalTime, startupTime: 0.5f); - } - } - - private void OnExpeditionShipLanded(Entity ent, ref FTLCompletedEvent args) - { - //Some announsement logic? - } - - public bool TryGetExpeditionShip(out EntityUid? uid) - { - uid = null; - var arrivalsQuery = EntityQueryEnumerator(); - - while (arrivalsQuery.MoveNext(out var tempUid, out _)) - { - uid = tempUid; - return true; - } - - return false; - } - - public void HandlePlayerSpawning(PlayerSpawningEvent ev) - { - if (!Enabled) - return; - - if (ev.SpawnResult != null) - return; - - if (!HasComp(ev.Station)) - return; - - TryGetExpeditionShip(out var ship); - - if (!TryComp(ship, out TransformComponent? shipXform)) - return; - - var gridUid = shipXform.GridUid; - - var points = EntityQueryEnumerator(); - var possiblePositions = new List(); - while (points.MoveNext(out var uid, out var spawnPoint, out var xform)) - { - if (ev.Job != null && spawnPoint.Job != ev.Job.Value) - continue; - - if (xform.GridUid != gridUid) - continue; - - possiblePositions.Add(xform.Coordinates); - } - - if (possiblePositions.Count <= 0) - return; - - var spawnLoc = _random.Pick(possiblePositions); - ev.SpawnResult = _stationSpawning.SpawnPlayerMob( - spawnLoc, - ev.Job, - ev.HumanoidCharacterProfile, - ev.Station); - - EnsureComp(ev.SpawnResult.Value); - EnsureComp(ev.SpawnResult.Value); - } -} diff --git a/Content.Server/_CP14/Shuttles/Components/CP14ExpeditionShipComponent.cs b/Content.Server/_CP14/Shuttles/Components/CP14ExpeditionShipComponent.cs deleted file mode 100644 index 322818cd7e..0000000000 --- a/Content.Server/_CP14/Shuttles/Components/CP14ExpeditionShipComponent.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Content.Server._CP14.Shuttles.Components; - -[RegisterComponent, Access(typeof(CP14ExpeditionSystem)), AutoGenerateComponentPause] -public sealed partial class CP14ExpeditionShipComponent : Component -{ - [DataField] - public EntityUid Station; -} - diff --git a/Content.Server/_CP14/Shuttles/Components/CP14ExpeditionShipFTLTargetComponent.cs b/Content.Server/_CP14/Shuttles/Components/CP14ExpeditionShipFTLTargetComponent.cs deleted file mode 100644 index 22e30b757a..0000000000 --- a/Content.Server/_CP14/Shuttles/Components/CP14ExpeditionShipFTLTargetComponent.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Content.Server._CP14.Shuttles.Components; - -/// -/// One of the possible points where an elemental ship might land at the start of a round -/// -[RegisterComponent, Access(typeof(CP14ExpeditionSystem))] -public sealed partial class CP14ExpeditionShipFTLTargetComponent : Component -{ -} diff --git a/Content.Server/_CP14/Shuttles/Components/CP14StationExpeditionTargetComponent.cs b/Content.Server/_CP14/Shuttles/Components/CP14StationExpeditionTargetComponent.cs deleted file mode 100644 index c377231c8f..0000000000 --- a/Content.Server/_CP14/Shuttles/Components/CP14StationExpeditionTargetComponent.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Robust.Shared.Utility; - -namespace Content.Server._CP14.Shuttles.Components; - -/// -/// Added to a station to start the round with an elemental ship arriving on this map -/// -[RegisterComponent, Access(typeof(CP14ExpeditionSystem))] -public sealed partial class CP14StationExpeditionTargetComponent : Component -{ - [DataField] - public EntityUid Shuttle; - - [DataField] public ResPath ShuttlePath = new("/Maps/Shuttles/arrivals.yml"); -} diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index f75ea5c43e..2543c04f27 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -10,19 +10,6 @@ namespace Content.Shared.CCVar [CVarDefs] public sealed class CCVars : CVars { - #region CP14 - /// - /// how long does it take to fly an expedition ship to an expedition point? - /// - public static readonly CVarDef CP14ExpeditionArrivalTime = - CVarDef.Create("cp14.arrival_time", 180f, CVar.SERVERONLY); - - /// - /// is the expedition ship's system enabled? - /// - public static readonly CVarDef CP14ExpeditionShip = - CVarDef.Create("cp14.arrivals_ship", true, CVar.SERVERONLY); - #endregion /* * Server */