Readded team assignment logic
This commit is contained in:
@@ -2410,16 +2410,18 @@ namespace Barotrauma
|
|||||||
//character with no characterinfo (e.g. some monster)
|
//character with no characterinfo (e.g. some monster)
|
||||||
if (Info == null) return;
|
if (Info == null) return;
|
||||||
|
|
||||||
Client ownerClient = GameMain.Server.ConnectedClients.Find(c => c.Character == this);
|
Client ownerClient = GameMain.Server.ConnectedClients.Find(c => c.Character == this);
|
||||||
if (ownerClient != null)
|
if (ownerClient != null)
|
||||||
{
|
{
|
||||||
msg.Write(true);
|
msg.Write(true);
|
||||||
msg.Write(ownerClient.ID);
|
msg.Write(ownerClient.ID);
|
||||||
|
msg.Write(TeamID);
|
||||||
}
|
}
|
||||||
else if (GameMain.Server.Character == this)
|
else if (GameMain.Server.Character == this)
|
||||||
{
|
{
|
||||||
msg.Write(true);
|
msg.Write(true);
|
||||||
msg.Write((byte)0);
|
msg.Write((byte)0);
|
||||||
|
msg.Write(TeamID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2461,6 +2463,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
bool hasOwner = inc.ReadBoolean();
|
bool hasOwner = inc.ReadBoolean();
|
||||||
int ownerId = hasOwner ? inc.ReadByte() : -1;
|
int ownerId = hasOwner ? inc.ReadByte() : -1;
|
||||||
|
byte teamID = hasOwner ? inc.ReadByte() : (byte)0;
|
||||||
|
|
||||||
string newName = inc.ReadString();
|
string newName = inc.ReadString();
|
||||||
|
|
||||||
@@ -2478,6 +2481,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
character = Character.Create(configPath, position, ch, GameMain.Client.ID != ownerId, hasAi);
|
character = Character.Create(configPath, position, ch, GameMain.Client.ID != ownerId, hasAi);
|
||||||
character.ID = id;
|
character.ID = id;
|
||||||
|
character.TeamID = teamID;
|
||||||
|
|
||||||
if (GameMain.Client.ID == ownerId)
|
if (GameMain.Client.ID == ownerId)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -961,54 +961,65 @@ namespace Barotrauma.Networking
|
|||||||
((MissionMode)GameMain.GameSession.gameMode).Mission.AllowRespawn;
|
((MissionMode)GameMain.GameSession.gameMode).Mission.AllowRespawn;
|
||||||
|
|
||||||
if (AllowRespawn && missionAllowRespawn) respawnManager = new RespawnManager(this, selectedShuttle);
|
if (AllowRespawn && missionAllowRespawn) respawnManager = new RespawnManager(this, selectedShuttle);
|
||||||
|
|
||||||
AssignJobs(connectedClients, characterInfo != null);
|
|
||||||
|
|
||||||
List<CharacterInfo> characterInfos = new List<CharacterInfo>();
|
|
||||||
foreach (Client client in connectedClients)
|
|
||||||
{
|
|
||||||
client.lastRecvEntitySpawnID = 0;
|
|
||||||
|
|
||||||
client.entityEventLastSent.Clear();
|
//assign jobs and spawnpoints separately for each team
|
||||||
client.lastSentEntityEventID = 0;
|
for (int teamID = 1; teamID <= teamCount; teamID++)
|
||||||
client.lastRecvEntityEventID = 0;
|
|
||||||
|
|
||||||
if (client.characterInfo == null)
|
|
||||||
{
|
|
||||||
client.characterInfo = new CharacterInfo(Character.HumanConfigFile, client.name);
|
|
||||||
}
|
|
||||||
characterInfos.Add(client.characterInfo);
|
|
||||||
client.characterInfo.Job = new Job(client.assignedJob);
|
|
||||||
}
|
|
||||||
|
|
||||||
//host's character
|
|
||||||
if (characterInfo != null)
|
|
||||||
{
|
{
|
||||||
characterInfo.Job = new Job(GameMain.NetLobbyScreen.JobPreferences[0]);
|
//find the clients in this team
|
||||||
characterInfos.Add(characterInfo);
|
List<Client> teamClients = teamCount == 1 ? connectedClients : connectedClients.FindAll(c => c.TeamID == teamID);
|
||||||
}
|
|
||||||
|
|
||||||
WayPoint[] assignedWayPoints = WayPoint.SelectCrewSpawnPoints(characterInfos, Submarine.MainSub);
|
|
||||||
for (int i = 0; i < connectedClients.Count; i++)
|
|
||||||
{
|
|
||||||
Character spawnedCharacter = Character.Create(connectedClients[i].characterInfo, assignedWayPoints[i].WorldPosition, true, false);
|
|
||||||
spawnedCharacter.AnimController.Frozen = true;
|
|
||||||
spawnedCharacter.GiveJobItems(assignedWayPoints[i]);
|
|
||||||
|
|
||||||
connectedClients[i].Character = spawnedCharacter;
|
|
||||||
|
|
||||||
GameMain.GameSession.CrewManager.characters.Add(spawnedCharacter);
|
if (!teamClients.Any() && teamID > 1) continue;
|
||||||
|
|
||||||
|
AssignJobs(teamClients, teamID == hostTeam);
|
||||||
|
|
||||||
|
List<CharacterInfo> characterInfos = new List<CharacterInfo>();
|
||||||
|
foreach (Client client in teamClients)
|
||||||
|
{
|
||||||
|
client.lastRecvEntitySpawnID = 0;
|
||||||
|
|
||||||
|
client.entityEventLastSent.Clear();
|
||||||
|
client.lastSentEntityEventID = 0;
|
||||||
|
client.lastRecvEntityEventID = 0;
|
||||||
|
|
||||||
|
if (client.characterInfo == null)
|
||||||
|
{
|
||||||
|
client.characterInfo = new CharacterInfo(Character.HumanConfigFile, client.name);
|
||||||
|
}
|
||||||
|
characterInfos.Add(client.characterInfo);
|
||||||
|
client.characterInfo.Job = new Job(client.assignedJob);
|
||||||
|
}
|
||||||
|
|
||||||
|
//host's character
|
||||||
|
if (characterInfo != null && hostTeam == teamID)
|
||||||
|
{
|
||||||
|
characterInfo.Job = new Job(GameMain.NetLobbyScreen.JobPreferences[0]);
|
||||||
|
characterInfos.Add(characterInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
WayPoint[] assignedWayPoints = WayPoint.SelectCrewSpawnPoints(characterInfos, Submarine.MainSubs[teamID - 1]);
|
||||||
|
for (int i = 0; i < teamClients.Count; i++)
|
||||||
|
{
|
||||||
|
Character spawnedCharacter = Character.Create(teamClients[i].characterInfo, assignedWayPoints[i].WorldPosition, true, false);
|
||||||
|
spawnedCharacter.AnimController.Frozen = true;
|
||||||
|
spawnedCharacter.GiveJobItems(assignedWayPoints[i]);
|
||||||
|
spawnedCharacter.TeamID = (byte)teamID;
|
||||||
|
|
||||||
|
teamClients[i].Character = spawnedCharacter;
|
||||||
|
|
||||||
|
GameMain.GameSession.CrewManager.characters.Add(spawnedCharacter);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (characterInfo != null && hostTeam == teamID)
|
||||||
|
{
|
||||||
|
myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1].WorldPosition, false, false);
|
||||||
|
myCharacter.GiveJobItems(assignedWayPoints.Last());
|
||||||
|
myCharacter.TeamID = (byte)teamID;
|
||||||
|
|
||||||
|
Character.Controlled = myCharacter;
|
||||||
|
GameMain.GameSession.CrewManager.characters.Add(myCharacter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (characterInfo != null)
|
|
||||||
{
|
|
||||||
myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1].WorldPosition, false, false);
|
|
||||||
myCharacter.GiveJobItems(assignedWayPoints.Last());
|
|
||||||
|
|
||||||
Character.Controlled = myCharacter;
|
|
||||||
GameMain.GameSession.CrewManager.characters.Add(myCharacter);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (Character c in GameMain.GameSession.CrewManager.characters)
|
foreach (Character c in GameMain.GameSession.CrewManager.characters)
|
||||||
{
|
{
|
||||||
Entity.Spawner.AddToSpawnedList(c);
|
Entity.Spawner.AddToSpawnedList(c);
|
||||||
|
|||||||
Reference in New Issue
Block a user