Unstable 1.8.4.0

This commit is contained in:
Markus Isberg
2025-03-12 12:56:27 +00:00
parent a4c3e868e4
commit a4a3427e4e
627 changed files with 29860 additions and 10018 deletions
@@ -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);
}
}