Skip to content

Commit

Permalink
Cleanup lobby manager and gamplay code in regards to player states an…
Browse files Browse the repository at this point in the history
…d making code more readable
  • Loading branch information
cubicgraphics committed Apr 8, 2024
1 parent cd94865 commit 6ea9913
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ namespace BeatTogether.DedicatedServer.Kernel.Managers.Abstractions
public interface ILobbyManager
{
bool AllPlayersReady { get; }
bool SomePlayersReady { get; }
bool AnyPlayersReady { get; }
bool NoPlayersReady { get; }
bool AllPlayersNotWantToPlayNextLevel { get; }
bool DoesEveryoneOwnBeatmap { get; }
bool CanEveryonePlayBeatmap { get; }
BeatmapIdentifier? SelectedBeatmap { get; }
GameplayModifiers SelectedModifiers { get; }
CountdownState CountDownState { get; }
long CountdownEndTime { get; }
GameplayModifiers EmptyModifiers {get; }
public bool SpectatingPlayersUpdated { get; set; }
public bool UpdateSpectatingPlayers { get; set; }
public bool ForceStartSelectedBeatmap { get; set; }

void Update();
Expand Down
10 changes: 7 additions & 3 deletions BeatTogether.DedicatedServer.Kernel/Managers/GameplayManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ public async void StartSong(CancellationToken cancellationToken)
State = GameplayManagerState.SceneLoad;
foreach (var player in _playerRegistry.Players)//Array of players that are playing at the start
{
if (!player.IsSpectating && !player.ForceLateJoin && !player.IsBackgrounded)
if (player.WantsToPlayNextLevel && !player.IsSpectating && !player.IsBackgrounded && !player.ForceLateJoin)
{
PlayersAtStart.Add(player.UserId);
}
//if (!player.IsSpectating && !player.ForceLateJoin && !player.IsBackgrounded)
// PlayersAtStart.Add(player.UserId);
}

// Create level finished tasks (players may send these at any time during gameplay)
Expand Down Expand Up @@ -159,7 +163,7 @@ public async void StartSong(CancellationToken cancellationToken)
{
if (_playerRegistry.TryGetPlayer(UserId, out var p))
{
if (!p.InGameplay || p.InLobby)
if (!p.InGameplay || !p.IsActive)
HandlePlayerLeaveGameplay(p);
StartDelay = Math.Max(StartDelay, p.Latency.CurrentAverage);
}
Expand All @@ -176,7 +180,7 @@ public async void StartSong(CancellationToken cancellationToken)
StartTime = SongStartTime
}, IgnoranceChannelTypes.Reliable);

//Initiates the song start process for forced late joiners
//Initiates the song start process for forced late joiners - try force them to spectate if they were causing issues in countdown
foreach(IPlayer p in _playerRegistry.Players)
{
if (p.ForceLateJoin)
Expand Down
Loading

0 comments on commit 6ea9913

Please sign in to comment.