Revert "Refactor Game Modes" oh god oh fuck go back it was too good to be true (#5855)

This commit is contained in:
Paul Ritter
2021-12-21 19:25:52 +01:00
committed by GitHub
parent 8831d08229
commit 75721c214c
59 changed files with 1715 additions and 1971 deletions

View File

@@ -63,10 +63,6 @@ namespace Content.Server.GameTicking
private void SpawnPlayer(IPlayerSession player, HumanoidCharacterProfile character, StationId station, string? jobId = null, bool lateJoin = true)
{
// Can't spawn players with a dummy ticker!
if (DummyTicker)
return;
if (station == StationId.Invalid)
{
var stations = _stationSystem.StationInfo.Keys.ToList();
@@ -77,23 +73,16 @@ namespace Content.Server.GameTicking
station = stations[0];
}
// Can't spawn players with a dummy ticker!
if (DummyTicker)
return;
if (lateJoin && DisallowLateJoin)
{
MakeObserve(player);
return;
}
// We raise this event to allow other systems to handle spawning this player themselves. (e.g. late-join wizard, etc)
var bev = new PlayerBeforeSpawnEvent(player, character, jobId, lateJoin, station);
RaiseLocalEvent(bev);
// Do nothing, something else has handled spawning this player for us!
if (bev.Handled)
{
PlayerJoinGame(player);
return;
}
// Pick best job best on prefs.
jobId ??= PickBestAvailableJob(character, station);
// If no job available, just bail out.
@@ -154,9 +143,7 @@ namespace Content.Server.GameTicking
else
_adminLogSystem.Add(LogType.RoundStartJoin, LogImpact.Medium, $"Player {player.Name} joined as {character.Name:characterName} on station {_stationSystem.StationInfo[station].Name:stationName} with {ToPrettyString(mob):entity} as a {job.Name:jobName}.");
// We raise this event directed to the mob, but also broadcast it so game rules can do something now.
var aev = new PlayerSpawnCompleteEvent(mob, player, jobId, lateJoin, station, character);
RaiseLocalEvent(mob, aev);
Preset?.OnSpawnPlayerCompleted(player, mob, lateJoin);
}
public void Respawn(IPlayerSession player)
@@ -368,52 +355,4 @@ namespace Content.Server.GameTicking
}
#endregion
}
/// <summary>
/// Event raised broadcast before a player is spawned by the GameTicker.
/// You can use this event to spawn a player off-station on late-join but also at round start.
/// When this event is handled, the GameTicker will not perform its own player-spawning logic.
/// </summary>
public class PlayerBeforeSpawnEvent : HandledEntityEventArgs
{
public IPlayerSession Player { get; }
public HumanoidCharacterProfile Profile { get; }
public string? JobId { get; }
public bool LateJoin { get; }
public StationId Station { get; }
public PlayerBeforeSpawnEvent(IPlayerSession player, HumanoidCharacterProfile profile, string? jobId, bool lateJoin, StationId station)
{
Player = player;
Profile = profile;
JobId = jobId;
LateJoin = lateJoin;
Station = station;
}
}
/// <summary>
/// Event raised both directed and broadcast when a player has been spawned by the GameTicker.
/// You can use this to handle people late-joining, or to handle people being spawned at round start.
/// Can be used to give random players a role, modify their equipment, etc.
/// </summary>
public class PlayerSpawnCompleteEvent : EntityEventArgs
{
public EntityUid Mob { get; }
public IPlayerSession Player { get; }
public string? JobId { get; }
public bool LateJoin { get; }
public StationId Station { get; }
public HumanoidCharacterProfile Profile { get; }
public PlayerSpawnCompleteEvent(EntityUid mob, IPlayerSession player, string? jobId, bool lateJoin, StationId station, HumanoidCharacterProfile profile)
{
Mob = mob;
Player = player;
JobId = jobId;
LateJoin = lateJoin;
Station = station;
Profile = profile;
}
}
}