Unstable 1.8.4.0
This commit is contained in:
@@ -1,50 +1,27 @@
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Networking;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class PvPMode : MissionMode
|
||||
partial class PvPMode : MissionMode
|
||||
{
|
||||
public PvPMode(GameModePreset preset, IEnumerable<MissionPrefab> missionPrefabs) : base(preset, ValidateMissionPrefabs(missionPrefabs, MissionPrefab.PvPMissionClasses)) { }
|
||||
|
||||
public PvPMode(GameModePreset preset, MissionType missionType, string seed) : base(preset, ValidateMissionType(missionType, MissionPrefab.PvPMissionClasses), seed) { }
|
||||
|
||||
public void AssignTeamIDs(IEnumerable<Client> clients)
|
||||
public PvPMode(GameModePreset preset, IEnumerable<MissionPrefab> missionPrefabs) :
|
||||
base(preset, ValidateMissionPrefabs(missionPrefabs, MissionPrefab.PvPMissionClasses))
|
||||
{
|
||||
int team1Count = 0, team2Count = 0;
|
||||
//if a client has a preference, assign them to that team
|
||||
List<Client> unassignedClients = new List<Client>(clients);
|
||||
for (int i = 0; i < unassignedClients.Count; i++)
|
||||
if (Missions.None())
|
||||
{
|
||||
if (unassignedClients[i].PreferredTeam == CharacterTeamType.Team1 ||
|
||||
unassignedClients[i].PreferredTeam == CharacterTeamType.Team2)
|
||||
{
|
||||
assignTeam(unassignedClients[i], unassignedClients[i].PreferredTeam);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
//assign the rest of the clients to the team that has the least players
|
||||
while (unassignedClients.Any())
|
||||
{
|
||||
var randomClient = unassignedClients.GetRandom(Rand.RandSync.Unsynced);
|
||||
assignTeam(randomClient, team1Count < team2Count ? CharacterTeamType.Team1 : CharacterTeamType.Team2);
|
||||
throw new System.Exception($"Attempted to start {nameof(PvPMode)} without a mission.");
|
||||
}
|
||||
}
|
||||
|
||||
void assignTeam(Client client, CharacterTeamType team)
|
||||
public PvPMode(GameModePreset preset, IEnumerable<Identifier> missionTypes, string seed) :
|
||||
base(preset, ValidateMissionTypes(missionTypes, MissionPrefab.PvPMissionClasses), seed)
|
||||
{
|
||||
if (Missions.None())
|
||||
{
|
||||
client.TeamID = team;
|
||||
unassignedClients.Remove(client);
|
||||
if (team == CharacterTeamType.Team1)
|
||||
{
|
||||
team1Count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
team2Count++;
|
||||
}
|
||||
throw new System.Exception($"Attempted to start {nameof(PvPMode)} without a mission.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user