From b8b33b97af4920aef77ed055096f5fb81096dc3d Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Tue, 19 Nov 2024 21:15:15 -0800 Subject: [PATCH] Move PlayerBeforeSpawnEvent and PlayerSpawnCompleteEvent to Shared --- .../GameTicking/GameTicker.Spawning.cs | 69 +------------------ .../GameTicking/PlayerBeforeSpawnEvent.cs | 33 +++++++++ .../GameTicking/PlayerSpawnCompleteEvent.cs | 44 ++++++++++++ 3 files changed, 78 insertions(+), 68 deletions(-) create mode 100644 Content.Shared/GameTicking/PlayerBeforeSpawnEvent.cs create mode 100644 Content.Shared/GameTicking/PlayerSpawnCompleteEvent.cs diff --git a/Content.Server/GameTicking/GameTicker.Spawning.cs b/Content.Server/GameTicking/GameTicker.Spawning.cs index 9c8b04770f..4bda391ae2 100644 --- a/Content.Server/GameTicking/GameTicker.Spawning.cs +++ b/Content.Server/GameTicking/GameTicker.Spawning.cs @@ -7,12 +7,12 @@ using Content.Server.Spawners.Components; using Content.Server.Speech.Components; using Content.Server.Station.Components; using Content.Shared.Database; +using Content.Shared.GameTicking; using Content.Shared.Mind; using Content.Shared.Players; using Content.Shared.Preferences; using Content.Shared.Roles; using Content.Shared.Roles.Jobs; -using JetBrains.Annotations; using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Network; @@ -455,71 +455,4 @@ namespace Content.Server.GameTicking #endregion } - - /// - /// 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. - /// - [PublicAPI] - public sealed class PlayerBeforeSpawnEvent : HandledEntityEventArgs - { - public ICommonSession Player { get; } - public HumanoidCharacterProfile Profile { get; } - public string? JobId { get; } - public bool LateJoin { get; } - public EntityUid Station { get; } - - public PlayerBeforeSpawnEvent(ICommonSession player, - HumanoidCharacterProfile profile, - string? jobId, - bool lateJoin, - EntityUid station) - { - Player = player; - Profile = profile; - JobId = jobId; - LateJoin = lateJoin; - Station = station; - } - } - - /// - /// 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. - /// - [PublicAPI] - public sealed class PlayerSpawnCompleteEvent : EntityEventArgs - { - public EntityUid Mob { get; } - public ICommonSession Player { get; } - public string? JobId { get; } - public bool LateJoin { get; } - public bool Silent { get; } - public EntityUid Station { get; } - public HumanoidCharacterProfile Profile { get; } - - // Ex. If this is the 27th person to join, this will be 27. - public int JoinOrder { get; } - - public PlayerSpawnCompleteEvent(EntityUid mob, - ICommonSession player, - string? jobId, - bool lateJoin, - bool silent, - int joinOrder, - EntityUid station, - HumanoidCharacterProfile profile) - { - Mob = mob; - Player = player; - JobId = jobId; - LateJoin = lateJoin; - Silent = silent; - Station = station; - Profile = profile; - JoinOrder = joinOrder; - } - } } diff --git a/Content.Shared/GameTicking/PlayerBeforeSpawnEvent.cs b/Content.Shared/GameTicking/PlayerBeforeSpawnEvent.cs new file mode 100644 index 0000000000..48623ecf8e --- /dev/null +++ b/Content.Shared/GameTicking/PlayerBeforeSpawnEvent.cs @@ -0,0 +1,33 @@ +using Content.Shared.Preferences; +using JetBrains.Annotations; +using Robust.Shared.Player; + +namespace Content.Shared.GameTicking; + +/// +/// 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. +/// +[PublicAPI] +public sealed class PlayerBeforeSpawnEvent : HandledEntityEventArgs +{ + public ICommonSession Player { get; } + public HumanoidCharacterProfile Profile { get; } + public string? JobId { get; } + public bool LateJoin { get; } + public EntityUid Station { get; } + + public PlayerBeforeSpawnEvent(ICommonSession player, + HumanoidCharacterProfile profile, + string? jobId, + bool lateJoin, + EntityUid station) + { + Player = player; + Profile = profile; + JobId = jobId; + LateJoin = lateJoin; + Station = station; + } +} diff --git a/Content.Shared/GameTicking/PlayerSpawnCompleteEvent.cs b/Content.Shared/GameTicking/PlayerSpawnCompleteEvent.cs new file mode 100644 index 0000000000..034b76beeb --- /dev/null +++ b/Content.Shared/GameTicking/PlayerSpawnCompleteEvent.cs @@ -0,0 +1,44 @@ +using Content.Shared.Preferences; +using JetBrains.Annotations; +using Robust.Shared.Player; + +namespace Content.Shared.GameTicking; + +/// +/// 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. +/// +[PublicAPI] +public sealed class PlayerSpawnCompleteEvent : EntityEventArgs +{ + public EntityUid Mob { get; } + public ICommonSession Player { get; } + public string? JobId { get; } + public bool LateJoin { get; } + public bool Silent { get; } + public EntityUid Station { get; } + public HumanoidCharacterProfile Profile { get; } + + // Ex. If this is the 27th person to join, this will be 27. + public int JoinOrder { get; } + + public PlayerSpawnCompleteEvent(EntityUid mob, + ICommonSession player, + string? jobId, + bool lateJoin, + bool silent, + int joinOrder, + EntityUid station, + HumanoidCharacterProfile profile) + { + Mob = mob; + Player = player; + JobId = jobId; + LateJoin = lateJoin; + Silent = silent; + Station = station; + Profile = profile; + JoinOrder = joinOrder; + } +}