diff --git a/Subsurface/Source/GameSession/CrewManager.cs b/Subsurface/Source/GameSession/CrewManager.cs index b4ff9b8ca..36a0a7119 100644 --- a/Subsurface/Source/GameSession/CrewManager.cs +++ b/Subsurface/Source/GameSession/CrewManager.cs @@ -208,35 +208,48 @@ namespace Barotrauma public void CreateCrewFrame(List crew, GUIFrame crewFrame) { - //crewFrame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), GUI.Style); - //crewFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f); + List teamIDs = crew.Select(c => c.TeamID).Distinct().ToList(); - GUIListBox crewList = new GUIListBox(new Rectangle(0, 0, 280, 300), Color.White * 0.7f, GUI.Style, crewFrame); - crewList.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f); - crewList.OnSelected = SelectCrewCharacter; + if (!teamIDs.Any()) teamIDs.Add(0); - foreach (Character character in crew) + int listBoxHeight = 300 / teamIDs.Count; + + int y = 20; + for (int i = 0; i < teamIDs.Count; i++) { - GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 40), Color.Transparent, null, crewList); - frame.UserData = character; - frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f); - frame.Color = (GameMain.NetworkMember != null && GameMain.NetworkMember.Character == character) ? Color.Gold * 0.2f : Color.Transparent; - frame.HoverColor = Color.LightGray * 0.5f; - frame.SelectedColor = Color.Gold * 0.5f; + if (teamIDs.Count > 1) + { + new GUITextBlock(new Rectangle(0,y-20,100,20),"Team "+teamIDs[i], GUI.Style, crewFrame); + } - GUITextBlock textBlock = new GUITextBlock( - new Rectangle(40, 0, 0, 25), - character.Info.Name + " (" + character.Info.Job.Name + ")", - Color.Transparent, Color.White, - Alignment.Left, Alignment.Left, - null, frame); - textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f); + GUIListBox crewList = new GUIListBox(new Rectangle(0, y, 280, listBoxHeight), Color.White * 0.7f, GUI.Style, crewFrame); + crewList.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f); + crewList.OnSelected = SelectCrewCharacter; + + foreach (Character character in crew.FindAll(c => c.TeamID == teamIDs[i])) + { + GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 40), Color.Transparent, null, crewList); + frame.UserData = character; + frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f); + frame.Color = (GameMain.NetworkMember != null && GameMain.NetworkMember.Character == character) ? Color.Gold * 0.2f : Color.Transparent; + frame.HoverColor = Color.LightGray * 0.5f; + frame.SelectedColor = Color.Gold * 0.5f; - new GUIImage(new Rectangle(-10, 0, 0, 0), character.AnimController.Limbs[0].sprite, Alignment.Left, frame); + GUITextBlock textBlock = new GUITextBlock( + new Rectangle(40, 0, 0, 25), + character.Info.Name + " (" + character.Info.Job.Name + ")", + Color.Transparent, Color.White, + Alignment.Left, Alignment.Left, + null, frame); + textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f); + + new GUIImage(new Rectangle(-10, 0, 0, 0), character.AnimController.Limbs[0].sprite, Alignment.Left, frame); + } + + y += crewList.Rect.Height + 30; } - //var closeButton = new GUIButton(new Rectangle(0, 0, 80, 20), "Close", Alignment.BottomCenter, GUI.Style, crewFrame); - //closeButton.OnClicked = ToggleCrewFrame; + } protected virtual bool SelectCrewCharacter(GUIComponent component, object obj) diff --git a/Subsurface/Source/GameSession/ShiftSummary.cs b/Subsurface/Source/GameSession/ShiftSummary.cs index b430a5147..1816d5554 100644 --- a/Subsurface/Source/GameSession/ShiftSummary.cs +++ b/Subsurface/Source/GameSession/ShiftSummary.cs @@ -66,46 +66,48 @@ namespace Barotrauma int x = 0; foreach (Character character in gameSession.CrewManager.characters) { - if (singleplayer || character.TeamID == GameMain.GameSession.CrewManager.WinningTeam) + if (GameMain.GameSession.Mission is CombatMission && + character.TeamID != GameMain.GameSession.CrewManager.WinningTeam) { - var characterFrame = new GUIFrame(new Rectangle(x, y, 170, 70), Color.Transparent, GUI.Style, listBox); - characterFrame.OutlineColor = Color.Transparent; - characterFrame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f); - characterFrame.CanBeFocused = false; - - character.Info.CreateCharacterFrame(characterFrame, - character.Info.Job != null ? (character.Info.Name + '\n' + "(" + character.Info.Job.Name + ")") : character.Info.Name, null); - - - string statusText = "OK"; - Color statusColor = Color.DarkGreen; - - if (character.IsDead) - { - statusText = InfoTextManager.GetInfoText("CauseOfDeath." + character.CauseOfDeath.ToString()); - statusColor = Color.DarkRed; - } - else - { - - if (character.IsUnconscious) - { - statusText = "Unconscious"; - statusColor = Color.DarkOrange; - } - else if (character.Health / character.MaxHealth < 0.8f) - { - statusText = "Injured"; - statusColor = Color.DarkOrange; - } - - } - - new GUITextBlock(new Rectangle(0, 0, 0, 20), statusText, - GUI.Style, Alignment.BottomLeft, Alignment.TopCenter, characterFrame, true, GUI.SmallFont).Color = statusColor * 0.7f; - - x += characterFrame.Rect.Width + 10; + continue; } + + var characterFrame = new GUIFrame(new Rectangle(x, y, 170, 70), Color.Transparent, GUI.Style, listBox); + characterFrame.OutlineColor = Color.Transparent; + characterFrame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f); + characterFrame.CanBeFocused = false; + + character.Info.CreateCharacterFrame(characterFrame, + character.Info.Job != null ? (character.Info.Name + '\n' + "(" + character.Info.Job.Name + ")") : character.Info.Name, null); + + string statusText = "OK"; + Color statusColor = Color.DarkGreen; + + if (character.IsDead) + { + statusText = InfoTextManager.GetInfoText("CauseOfDeath." + character.CauseOfDeath.ToString()); + statusColor = Color.DarkRed; + } + else + { + + if (character.IsUnconscious) + { + statusText = "Unconscious"; + statusColor = Color.DarkOrange; + } + else if (character.Health / character.MaxHealth < 0.8f) + { + statusText = "Injured"; + statusColor = Color.DarkOrange; + } + + } + + new GUITextBlock(new Rectangle(0, 0, 0, 20), statusText, + GUI.Style, Alignment.BottomLeft, Alignment.TopCenter, characterFrame, true, GUI.SmallFont).Color = statusColor * 0.7f; + + x += characterFrame.Rect.Width + 10; } y += 120; diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index 2158ede65..b9683a597 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -907,12 +907,13 @@ namespace Barotrauma.Networking if (AllowRespawn) respawnManager = new RespawnManager(this, selectedShuttle); - for (int j = 1; j <= teamCount; j++) + for (int teamID = 1; teamID <= teamCount; teamID++) { - List teamClients = connectedClients.FindAll(c => c.TeamID == j); - if (!teamClients.Any() && j!=1) continue; + List teamClients = teamCount == 1 ? connectedClients : connectedClients.FindAll(c => c.TeamID == teamID); - AssignJobs(teamClients); + if (!teamClients.Any() && teamID > 1) continue; + + AssignJobs(teamClients, teamID==1); List characterInfos = new List(); @@ -929,13 +930,14 @@ namespace Barotrauma.Networking client.characterInfo.Job = new Job(client.assignedJob); } - if (characterInfo != null && j == 1) + //host's character + if (characterInfo != null && teamID == 1) { characterInfo.Job = new Job(GameMain.NetLobbyScreen.JobPreferences[0]); characterInfos.Add(characterInfo); } - WayPoint[] assignedWayPoints = WayPoint.SelectCrewSpawnPoints(characterInfos, Submarine.MainSubs[j - 1]); + WayPoint[] assignedWayPoints = WayPoint.SelectCrewSpawnPoints(characterInfos, Submarine.MainSubs[teamID - 1]); for (int i = 0; i < teamClients.Count; i++) { @@ -945,17 +947,17 @@ namespace Barotrauma.Networking GameMain.GameSession.CrewManager.characters.Add(teamClients[i].Character); - teamClients[i].Character.TeamID = teamClients[i].TeamID; + teamClients[i].Character.TeamID = (byte)teamID; } //host plays in team 1 - if (characterInfo != null && j == 1) + if (characterInfo != null && teamID == 1) { - myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1].WorldPosition, false, false); - Character.Controlled = myCharacter; - + myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1].WorldPosition, false, false); myCharacter.GiveJobItems(assignedWayPoints[assignedWayPoints.Length - 1]); + myCharacter.TeamID = (byte)teamID; + Character.Controlled = myCharacter; GameMain.GameSession.CrewManager.characters.Add(myCharacter); } } @@ -1781,13 +1783,13 @@ namespace Barotrauma.Networking SendMessage(message, NetDeliveryMethod.ReliableOrdered, recipients); } - public void AssignJobs(List unassigned) + public void AssignJobs(List unassigned, bool assignHost) { unassigned = new List(unassigned); int[] assignedClientCount = new int[JobPrefab.List.Count]; - if (characterInfo!=null) + if (characterInfo!=null && assignHost) { assignedClientCount[JobPrefab.List.FindIndex(jp => jp == GameMain.NetLobbyScreen.JobPreferences[0])]=1; } diff --git a/Subsurface/Source/Networking/GameServerSettings.cs b/Subsurface/Source/Networking/GameServerSettings.cs index 6ecf872fc..1fb8db2c6 100644 --- a/Subsurface/Source/Networking/GameServerSettings.cs +++ b/Subsurface/Source/Networking/GameServerSettings.cs @@ -503,81 +503,76 @@ namespace Barotrauma.Networking return true; }; - var allitems = new List(); - foreach (MapEntityCategory category in Enum.GetValues(typeof(MapEntityCategory))) + + foreach (MapEntityPrefab pf in MapEntityPrefab.list) { - if (category == MapEntityCategory.Machine || category == MapEntityCategory.Structure) continue; - var items = MapEntityPrefab.list.FindAll(ep => ep is ItemPrefab && (ep.Price > 0.0f || ep.tags.Contains("smallitem")) && ep.Category.HasFlag(category)); - DebugConsole.NewMessage(category.ToString() + " " + items.Count.ToString(), Color.Lime); - items.RemoveAll(ep => allitems.Contains(ep)); - allitems.AddRange(items); - foreach (MapEntityPrefab pf in items) + if (pf.Price <= 0.0f) continue; + + GUITextBlock textBlock = new GUITextBlock( + new Rectangle(0, 0, 260, 25), + pf.Name, + GUI.Style, + Alignment.Left, Alignment.Left, cargoFrame); + textBlock.Padding = new Vector4(30.0f, 3.0f, 0.0f, 0.0f); + textBlock.UserData = cargoFrame; + textBlock.CanBeFocused = false; + + if (pf.sprite != null) { - GUITextBlock textBlock = new GUITextBlock( - new Rectangle(0, 0, 260, 25), - pf.Name, - GUI.Style, - Alignment.Left, Alignment.Left, cargoFrame); - textBlock.Padding = new Vector4(30.0f, 3.0f, 0.0f, 0.0f); - textBlock.UserData = cargoFrame; - textBlock.CanBeFocused = false; + float scale = Math.Min(Math.Min(30.0f / pf.sprite.SourceRect.Width, 30.0f / pf.sprite.SourceRect.Height), 1.0f); + GUIImage img = new GUIImage(new Rectangle(-15-(int)(pf.sprite.SourceRect.Width*scale*0.5f), 12-(int)(pf.sprite.SourceRect.Height*scale*0.5f), 40, 40), pf.sprite, Alignment.Left, textBlock); + img.Color = pf.SpriteColor; + img.Scale = scale; + } - if (pf.sprite != null) + int cargoVal = 0; + extraCargo.TryGetValue(pf.Name, out cargoVal); + var countText = new GUITextBlock( + new Rectangle(180, 0, 50, 25), + cargoVal.ToString(), + GUI.Style, + Alignment.Left, Alignment.Center, textBlock); + + var incButton = new GUIButton(new Rectangle(220, 5, 10, 15), ">", GUI.Style, textBlock); + incButton.UserData = countText; + incButton.OnClicked = (button, obj) => + { + int val; + if (extraCargo.TryGetValue(pf.Name, out val)) { - float scale = Math.Min(Math.Min(30.0f / pf.sprite.SourceRect.Width, 30.0f / pf.sprite.SourceRect.Height), 1.0f); - GUIImage img = new GUIImage(new Rectangle(-15-(int)(pf.sprite.SourceRect.Width*scale*0.5f), 12-(int)(pf.sprite.SourceRect.Height*scale*0.5f), 40, 40), pf.sprite, Alignment.Left, textBlock); - img.Color = pf.SpriteColor; - img.Scale = scale; + extraCargo[pf.Name]++; val = extraCargo[pf.Name]; } - - int cargoVal = 0; - extraCargo.TryGetValue(pf.Name, out cargoVal); - var countText = new GUITextBlock( - new Rectangle(180, 0, 50, 25), - cargoVal.ToString(), - GUI.Style, - Alignment.Left, Alignment.Center, textBlock); - - var incButton = new GUIButton(new Rectangle(220, 5, 10, 15), ">", GUI.Style, textBlock); - incButton.UserData = countText; - incButton.OnClicked = (button, obj) => + else { - int val; - if (extraCargo.TryGetValue(pf.Name, out val)) + extraCargo.Add(pf.Name,1); val = 1; + } + ((GUITextBlock)obj).Text = val.ToString(); + ((GUITextBlock)obj).SetTextPos(); + return true; + }; + + var decButton = new GUIButton(new Rectangle(180, 5, 10, 15), "<", GUI.Style, textBlock); + decButton.UserData = countText; + decButton.OnClicked = (button, obj) => + { + int val; + if (extraCargo.TryGetValue(pf.Name, out val)) + { + extraCargo[pf.Name]--; + val = extraCargo[pf.Name]; + if (val <= 0) { - extraCargo[pf.Name]++; val = extraCargo[pf.Name]; - } - else - { - extraCargo.Add(pf.Name,1); val = 1; + extraCargo.Remove(pf.Name); + val = 0; } ((GUITextBlock)obj).Text = val.ToString(); ((GUITextBlock)obj).SetTextPos(); - return true; - }; - - var decButton = new GUIButton(new Rectangle(180, 5, 10, 15), "<", GUI.Style, textBlock); - decButton.UserData = countText; - decButton.OnClicked = (button, obj) => - { - int val; - if (extraCargo.TryGetValue(pf.Name, out val)) - { - extraCargo[pf.Name]--; - val = extraCargo[pf.Name]; - if (val <= 0) - { - extraCargo.Remove(pf.Name); - val = 0; - } - ((GUITextBlock)obj).Text = val.ToString(); - ((GUITextBlock)obj).SetTextPos(); - } + } - return true; - }; - } + return true; + }; } + //-------------------------------------------------------------------------------- // server settings diff --git a/Subsurface/Source/Networking/RespawnManager.cs b/Subsurface/Source/Networking/RespawnManager.cs index f10a63004..0a1be059b 100644 --- a/Subsurface/Source/Networking/RespawnManager.cs +++ b/Subsurface/Source/Networking/RespawnManager.cs @@ -392,12 +392,12 @@ namespace Barotrauma.Networking var clients = GetClientsToRespawn(); - server.AssignJobs(clients); - clients.ForEach(c => c.characterInfo.Job = new Job(c.assignedJob)); - List characterInfos = clients.Select(c => c.characterInfo).ToList(); if (server.Character != null && server.Character.IsDead) characterInfos.Add(server.CharacterInfo); + server.AssignJobs(clients, server.Character != null && server.Character.IsDead); + clients.ForEach(c => c.characterInfo.Job = new Job(c.assignedJob)); + //the spawnpoints where the characters will spawn var shuttleSpawnPoints = WayPoint.SelectCrewSpawnPoints(characterInfos, respawnShuttle); //the spawnpoints where they would spawn if they were spawned inside the main sub