Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions GGJ26/Assets/01. Scripts/Network/FusionRoleAssignmentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,22 @@ public PlayerRef GetDeterministicSeeker(NetworkRunner runner)
return default;
}

string sessionName = runner.SessionInfo.IsValid ? runner.SessionInfo.Name : string.Empty;
if (seekerLocked && string.Equals(lockedSessionName, sessionName))
var players = runner.ActivePlayers.OrderBy(p => p.RawEncoded).ToList();
if (players.Count == 0)
{
return lockedSeeker;
return default;
}

if (runner.ActivePlayers.Count() < 2)
// Solo sessions always assign the only participant as seeker.
if (players.Count == 1)
{
return default;
return players[0];
}

var players = runner.ActivePlayers.OrderBy(p => p.RawEncoded).ToList();
if (players.Count == 0)
string sessionName = runner.SessionInfo.IsValid ? runner.SessionInfo.Name : string.Empty;
if (seekerLocked && string.Equals(lockedSessionName, sessionName) && players.Contains(lockedSeeker))
{
return default;
return lockedSeeker;
}

// Stable random by session so all peers pick the same seeker.
Expand Down
7 changes: 4 additions & 3 deletions GGJ26/Assets/01. Scripts/Network/FusionSpawnService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class FusionSpawnService : MonoBehaviour
private NetworkObject greenNpcPrefab;
private int npcsPerColor;
private int maxPlayers;
private int minPlayersToAssignRoles = 2;
private int minPlayersToAssignRoles = 1;

private bool spawnLayoutRoutineRunning;
private bool pendingLocalSpawn;
Expand Down Expand Up @@ -99,7 +99,7 @@ public void Configure(
this.greenNpcPrefab = greenNpcPrefab;
this.npcsPerColor = npcsPerColor;
this.maxPlayers = Mathf.Max(1, maxPlayers);
this.minPlayersToAssignRoles = Mathf.Max(2, minPlayersToAssignRoles);
this.minPlayersToAssignRoles = Mathf.Max(1, minPlayersToAssignRoles);
}

public void SetMaxPlayers(int value)
Expand Down Expand Up @@ -286,7 +286,8 @@ private bool TrySpawnLocalPlayer(PlayerRef player)
return false;
}

if (runner.ActivePlayers.Count() < minPlayersToAssignRoles)
int activePlayerCount = runner.ActivePlayers.Count();
if (activePlayerCount < minPlayersToAssignRoles)
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion GGJ26/Assets/01. Scripts/Network/PlayerRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void TryAssignRole()

if (RoleAssigned == false)
{
if (Runner == null || GetActivePlayerCount() < 2)
if (Runner == null || GetActivePlayerCount() == 0)
{
return;
}
Expand Down