v1.6.17.0 (Unto the Breach update)
This commit is contained in:
@@ -549,6 +549,33 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
public void ClientRead(IReadMessage msg)
|
||||
{
|
||||
if (GameMain.GameSession.IsRunning && !GameMain.Instance.LoadingScreenOpen)
|
||||
{
|
||||
ClientApplyNetworkMessage(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if the game session is not currently running (round still loading),
|
||||
//we need to wait because the entities the status effect / conversation / etc targets may not exist yet
|
||||
CoroutineManager.StartCoroutine(ApplyNetworkMessageWhenRoundLoaded(msg));
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<CoroutineStatus> ApplyNetworkMessageWhenRoundLoaded(IReadMessage msg)
|
||||
{
|
||||
while (GameMain.GameSession is { IsRunning: false } || GameMain.Instance.LoadingScreenOpen)
|
||||
{
|
||||
yield return new WaitForSeconds(1.0f);
|
||||
}
|
||||
if (GameMain.GameSession != null && GameMain.Client != null)
|
||||
{
|
||||
ClientApplyNetworkMessage(msg);
|
||||
}
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
public void ClientApplyNetworkMessage(IReadMessage msg)
|
||||
{
|
||||
NetworkEventType eventType = (NetworkEventType)msg.ReadByte();
|
||||
switch (eventType)
|
||||
|
||||
@@ -59,10 +59,13 @@ namespace Barotrauma
|
||||
if (character.Submarine != null && character.AIController is EnemyAIController enemyAi)
|
||||
{
|
||||
enemyAi.UnattackableSubmarines.Add(character.Submarine);
|
||||
enemyAi.UnattackableSubmarines.Add(Submarine.MainSub);
|
||||
foreach (Submarine sub in Submarine.MainSub.DockedTo)
|
||||
if (Submarine.MainSub != null)
|
||||
{
|
||||
enemyAi.UnattackableSubmarines.Add(sub);
|
||||
enemyAi.UnattackableSubmarines.Add(Submarine.MainSub);
|
||||
foreach (Submarine sub in Submarine.MainSub.DockedTo)
|
||||
{
|
||||
enemyAi.UnattackableSubmarines.Add(sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
namespace Barotrauma
|
||||
using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class CombatMission : Mission
|
||||
{
|
||||
private readonly Dictionary<byte, int> clientKills = new Dictionary<byte, int>();
|
||||
private readonly Dictionary<byte, int> clientDeaths = new Dictionary<byte, int>();
|
||||
|
||||
private readonly Dictionary<ushort, int> botKills = new Dictionary<ushort, int>();
|
||||
private readonly Dictionary<ushort, int> botDeaths = new Dictionary<ushort, int>();
|
||||
|
||||
public override LocalizedString Description
|
||||
{
|
||||
get
|
||||
@@ -21,5 +31,93 @@
|
||||
|
||||
public override bool DisplayAsCompleted => false;
|
||||
public override bool DisplayAsFailed => false;
|
||||
|
||||
public override IEnumerable<(LocalizedString Label, Vector2 Position)> SonarLabels
|
||||
{
|
||||
get
|
||||
{
|
||||
if (targetSubmarine == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return (targetSubmarineSonarLabel is { Loaded: true } ? targetSubmarineSonarLabel : targetSubmarine.Info.DisplayName, targetSubmarine.WorldPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Color GetTeamColor(CharacterTeamType teamID)
|
||||
{
|
||||
if (teamID == CharacterTeamType.Team1)
|
||||
{
|
||||
return GUIStyle.GetComponentStyle("CoalitionIcon")?.Color ?? GUIStyle.Blue;
|
||||
}
|
||||
else if (teamID == CharacterTeamType.Team2)
|
||||
{
|
||||
return GUIStyle.GetComponentStyle("SeparatistIcon")?.Color ?? GUIStyle.Orange;
|
||||
}
|
||||
return Color.White;
|
||||
}
|
||||
|
||||
public int GetClientKillCount(Client client)
|
||||
{
|
||||
if (clientKills.TryGetValue(client.SessionId, out int kills))
|
||||
{
|
||||
return kills;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int GetClientDeathCount(Client client)
|
||||
{
|
||||
if (clientDeaths.TryGetValue(client.SessionId, out int deaths))
|
||||
{
|
||||
return deaths;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int GetBotKillCount(CharacterInfo botInfo)
|
||||
{
|
||||
if (botKills.TryGetValue(botInfo.ID, out int kills))
|
||||
{
|
||||
return kills;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int GetBotDeathCount(CharacterInfo botInfo)
|
||||
{
|
||||
if (botDeaths.TryGetValue(botInfo.ID, out int deaths))
|
||||
{
|
||||
return deaths;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override void ClientRead(IReadMessage msg)
|
||||
{
|
||||
base.ClientRead(msg);
|
||||
Scores[0] = msg.ReadUInt16();
|
||||
Scores[1] = msg.ReadUInt16();
|
||||
|
||||
uint clientCount = msg.ReadVariableUInt32();
|
||||
for (int i = 0; i < clientCount; i++)
|
||||
{
|
||||
byte clientId = msg.ReadByte();
|
||||
clientDeaths[clientId] = (int)msg.ReadVariableUInt32();
|
||||
clientKills[clientId] = (int)msg.ReadVariableUInt32();
|
||||
}
|
||||
|
||||
uint botCount = msg.ReadVariableUInt32();
|
||||
for (int i = 0; i < botCount; i++)
|
||||
{
|
||||
ushort botId = msg.ReadUInt16();
|
||||
botDeaths[botId] = (int)msg.ReadVariableUInt32();
|
||||
botKills[botId] = (int)msg.ReadVariableUInt32();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user