Fixup playerspawn stuff (#31546)

* Fixup playerspawn stuff

- Also removed arrivals forcing, this should just turn containerspawnpoint off.

* fix this one

* test fix

* really fix
This commit is contained in:
metalgearsloth
2024-08-29 15:27:47 +10:00
committed by GitHub
parent 2fd57c2d4a
commit f0615ec3c8
6 changed files with 14 additions and 61 deletions

View File

@@ -56,27 +56,11 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
private bool _randomizeCharacters;
private Dictionary<SpawnPriorityPreference, Action<PlayerSpawningEvent>> _spawnerCallbacks = new();
/// <inheritdoc/>
public override void Initialize()
{
base.Initialize();
Subs.CVar(_configurationManager, CCVars.ICRandomCharacters, e => _randomizeCharacters = e, true);
_spawnerCallbacks = new Dictionary<SpawnPriorityPreference, Action<PlayerSpawningEvent>>()
{
{ SpawnPriorityPreference.Arrivals, _arrivalsSystem.HandlePlayerSpawning },
{
SpawnPriorityPreference.Cryosleep, ev =>
{
if (_arrivalsSystem.Forced)
_arrivalsSystem.HandlePlayerSpawning(ev);
else
_containerSpawnPointSystem.HandlePlayerSpawning(ev);
}
}
};
}
/// <summary>
@@ -98,33 +82,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
var ev = new PlayerSpawningEvent(job, profile, station);
if (station != null && profile != null)
{
// Try to call the character's preferred spawner first.
if (_spawnerCallbacks.TryGetValue(profile.SpawnPriority, out var preferredSpawner))
{
preferredSpawner(ev);
foreach (var (key, remainingSpawner) in _spawnerCallbacks)
{
if (key == profile.SpawnPriority)
continue;
remainingSpawner(ev);
}
}
else
{
// Call all of them in the typical order.
foreach (var typicalSpawner in _spawnerCallbacks.Values)
{
typicalSpawner(ev);
}
}
}
RaiseLocalEvent(ev);
DebugTools.Assert(ev.SpawnResult is { Valid: true } or null);
return ev.SpawnResult;