Unstable 1.8.4.0
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Barotrauma.Networking;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Barotrauma.Networking;
|
||||
using FarseerPhysics;
|
||||
|
||||
namespace Barotrauma
|
||||
@@ -7,26 +9,51 @@ namespace Barotrauma
|
||||
{
|
||||
public override bool DisplayAsCompleted => false;
|
||||
public override bool DisplayAsFailed => false;
|
||||
|
||||
private void TryShowPickedUpMessage() => HandleMessage(ref pickedUpMessage);
|
||||
|
||||
private void TryShowRetrievedMessage()
|
||||
{
|
||||
if (DetermineCompleted())
|
||||
{
|
||||
if (!allRetrievedMessage.IsNullOrEmpty()) { CreateMessageBox(string.Empty, allRetrievedMessage); }
|
||||
//no need to show this again, clear it
|
||||
allRetrievedMessage = string.Empty;
|
||||
HandleMessage(ref allRetrievedMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!partiallyRetrievedMessage.IsNullOrEmpty()) { CreateMessageBox(string.Empty, partiallyRetrievedMessage); }
|
||||
//no need to show this again, clear it
|
||||
partiallyRetrievedMessage = string.Empty;
|
||||
HandleMessage(ref partiallyRetrievedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleMessage(ref LocalizedString message)
|
||||
{
|
||||
if (!message.IsNullOrEmpty()) { CreateMessageBox(string.Empty, message); }
|
||||
//no need to show this again, clear it
|
||||
message = string.Empty;
|
||||
}
|
||||
|
||||
public override void ClientReadInitial(IReadMessage msg)
|
||||
{
|
||||
base.ClientReadInitial(msg);
|
||||
|
||||
byte characterCount = msg.ReadByte();
|
||||
for (int i = 0; i < characterCount; i++)
|
||||
{
|
||||
Character character = Character.ReadSpawnData(msg);
|
||||
characters.Add(character);
|
||||
ushort itemCount = msg.ReadUInt16();
|
||||
for (int j = 0; j < itemCount; j++)
|
||||
{
|
||||
Item.ReadSpawnData(msg);
|
||||
}
|
||||
}
|
||||
if (characters.Contains(null))
|
||||
{
|
||||
throw new System.Exception("Error in SalvageMission.ClientReadInitial: character list contains null (mission: " + Prefab.Identifier + ")");
|
||||
}
|
||||
if (characters.Count != characterCount)
|
||||
{
|
||||
throw new System.Exception("Error in SalvageMission.ClientReadInitial: character count does not match the server count (" + characters + " != " + characters.Count + "mission: " + Prefab.Identifier + ")");
|
||||
}
|
||||
|
||||
foreach (var target in targets)
|
||||
{
|
||||
@@ -81,24 +108,37 @@ namespace Barotrauma
|
||||
{
|
||||
base.ClientRead(msg);
|
||||
bool atLeastOneTargetWasRetrieved = false;
|
||||
bool showPickedUpMsg = false;
|
||||
int targetCount = msg.ReadByte();
|
||||
for (int i = 0; i < targetCount; i++)
|
||||
{
|
||||
var state = (Target.RetrievalState)msg.ReadByte();
|
||||
if (i < targets.Count)
|
||||
{
|
||||
bool wasRetrieved = targets[i].Retrieved;
|
||||
Target target = targets[i];
|
||||
bool wasRetrieved = target.Retrieved;
|
||||
bool wasPickedUp = target.State == Target.RetrievalState.PickedUp;
|
||||
targets[i].State = state;
|
||||
if (!wasRetrieved && targets[i].Retrieved)
|
||||
if (!wasRetrieved && target.Retrieved)
|
||||
{
|
||||
atLeastOneTargetWasRetrieved = true;
|
||||
}
|
||||
else if (!wasPickedUp && target.State == Target.RetrievalState.PickedUp)
|
||||
{
|
||||
showPickedUpMsg = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (atLeastOneTargetWasRetrieved)
|
||||
{
|
||||
TryShowRetrievedMessage();
|
||||
}
|
||||
if (showPickedUpMsg)
|
||||
{
|
||||
TryShowPickedUpMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<Entity> HudIconTargets => targets.Where(static t => !t.Retrieved && t.Item.GetRootInventoryOwner() is not Character { IsLocalPlayer: true }).Select(static t => t.Item);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user