Delete CP14ExpeditionSystem

This commit is contained in:
Ed
2024-10-29 12:15:16 +03:00
parent f5503352b9
commit e6bbc3900f
6 changed files with 0 additions and 204 deletions

View File

@@ -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!;

View File

@@ -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!;
/// <summary>
/// Flags if all players must arrive via the Arrivals system, or if they can spawn in other ways.
/// </summary>
public float ArrivalTime { get; private set; }
/// <summary>
/// If enabled then spawns players on an expedition ship.
/// </summary>
public bool Enabled { get; private set; }
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CP14StationExpeditionTargetComponent, StationPostInitEvent>(OnPostInitSetupExpeditionShip);
SubscribeLocalEvent<CP14StationExpeditionTargetComponent, FTLCompletedEvent>(OnExpeditionShipLanded);
SubscribeLocalEvent<PlayerSpawningEvent>(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<CP14StationExpeditionTargetComponent> 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<ShuttleComponent>(station.Comp.Shuttle);
var expeditionShipComp = EnsureComp<CP14ExpeditionShipComponent>(station.Comp.Shuttle);
expeditionShipComp.Station = station;
var targetPoints = new List<EntityUid>();
var targetEnumerator = EntityQueryEnumerator<CP14ExpeditionShipFTLTargetComponent, TransformComponent>();
while (targetEnumerator.MoveNext(out var uid, out _, out _))
{
targetPoints.Add(uid);
}
var target = _random.Pick(targetPoints);
if (!HasComp<TransformComponent>(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<CP14StationExpeditionTargetComponent> ent, ref FTLCompletedEvent args)
{
//Some announsement logic?
}
public bool TryGetExpeditionShip(out EntityUid? uid)
{
uid = null;
var arrivalsQuery = EntityQueryEnumerator<CP14ExpeditionShipComponent>();
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<CP14StationExpeditionTargetComponent>(ev.Station))
return;
TryGetExpeditionShip(out var ship);
if (!TryComp(ship, out TransformComponent? shipXform))
return;
var gridUid = shipXform.GridUid;
var points = EntityQueryEnumerator<SpawnPointComponent, TransformComponent>();
var possiblePositions = new List<EntityCoordinates>();
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<PendingClockInComponent>(ev.SpawnResult.Value);
EnsureComp<AutoOrientComponent>(ev.SpawnResult.Value);
}
}

View File

@@ -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;
}

View File

@@ -1,9 +0,0 @@
namespace Content.Server._CP14.Shuttles.Components;
/// <summary>
/// One of the possible points where an elemental ship might land at the start of a round
/// </summary>
[RegisterComponent, Access(typeof(CP14ExpeditionSystem))]
public sealed partial class CP14ExpeditionShipFTLTargetComponent : Component
{
}

View File

@@ -1,15 +0,0 @@
using Robust.Shared.Utility;
namespace Content.Server._CP14.Shuttles.Components;
/// <summary>
/// Added to a station to start the round with an elemental ship arriving on this map
/// </summary>
[RegisterComponent, Access(typeof(CP14ExpeditionSystem))]
public sealed partial class CP14StationExpeditionTargetComponent : Component
{
[DataField]
public EntityUid Shuttle;
[DataField] public ResPath ShuttlePath = new("/Maps/Shuttles/arrivals.yml");
}

View File

@@ -10,19 +10,6 @@ namespace Content.Shared.CCVar
[CVarDefs]
public sealed class CCVars : CVars
{
#region CP14
/// <summary>
/// how long does it take to fly an expedition ship to an expedition point?
/// </summary>
public static readonly CVarDef<float> CP14ExpeditionArrivalTime =
CVarDef.Create("cp14.arrival_time", 180f, CVar.SERVERONLY);
/// <summary>
/// is the expedition ship's system enabled?
/// </summary>
public static readonly CVarDef<bool> CP14ExpeditionShip =
CVarDef.Create("cp14.arrivals_ship", true, CVar.SERVERONLY);
#endregion
/*
* Server
*/