Build 1.1.4.0
This commit is contained in:
@@ -41,7 +41,7 @@ namespace Barotrauma
|
||||
clientsToRemove.Add(k);
|
||||
}
|
||||
}
|
||||
if (!(clientsToRemove is null))
|
||||
if (clientsToRemove is not null)
|
||||
{
|
||||
foreach (var k in clientsToRemove)
|
||||
{
|
||||
@@ -62,7 +62,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (Entity e in targets)
|
||||
{
|
||||
if (!(e is Character character) || !character.IsRemotePlayer) { continue; }
|
||||
if (e is not Character character || !character.IsRemotePlayer) { continue; }
|
||||
Client targetClient = GameMain.Server.ConnectedClients.Find(c => c.Character == character);
|
||||
if (targetClient != null)
|
||||
{
|
||||
@@ -85,7 +85,7 @@ namespace Barotrauma
|
||||
IEnumerable<Entity> entities = ParentEvent.GetTargets(TargetTag);
|
||||
foreach (Entity e in entities)
|
||||
{
|
||||
if (!(e is Character character) || !character.IsRemotePlayer) { continue; }
|
||||
if (e is not Character character || !character.IsRemotePlayer) { continue; }
|
||||
Client targetClient = GameMain.Server.ConnectedClients.Find(c => c.Character == character);
|
||||
if (targetClient != null)
|
||||
{
|
||||
@@ -149,5 +149,15 @@ namespace Barotrauma
|
||||
}
|
||||
GameMain.Server?.ServerPeer?.Send(outmsg, client.Connection, DeliveryMethod.Reliable);
|
||||
}
|
||||
|
||||
public void ServerWriteSelectedOption(Client client)
|
||||
{
|
||||
IWriteMessage outmsg = new WriteOnlyMessage();
|
||||
outmsg.WriteByte((byte)ServerPacketHeader.EVENTACTION);
|
||||
outmsg.WriteByte((byte)EventManager.NetworkEventType.CONVERSATION_SELECTED_OPTION);
|
||||
outmsg.WriteUInt16(Identifier);
|
||||
outmsg.WriteByte((byte)(selectedOption + 1));
|
||||
GameMain.Server?.ServerPeer?.Send(outmsg, client.Connection, DeliveryMethod.Reliable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using Barotrauma.Networking;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class MissionAction : EventAction
|
||||
{
|
||||
private static readonly HashSet<Mission> missionsUnlockedThisRound = new HashSet<Mission>();
|
||||
|
||||
public static void ResetMissionsUnlockedThisRound()
|
||||
{
|
||||
missionsUnlockedThisRound.Clear();
|
||||
}
|
||||
|
||||
public static void NotifyMissionsUnlockedThisRound(Client client)
|
||||
{
|
||||
foreach (Mission mission in missionsUnlockedThisRound)
|
||||
{
|
||||
NotifyMissionUnlock(mission, client);
|
||||
}
|
||||
}
|
||||
|
||||
private static void NotifyMissionUnlock(Mission mission)
|
||||
{
|
||||
foreach (Client client in GameMain.Server.ConnectedClients)
|
||||
{
|
||||
NotifyMissionUnlock(mission, client);
|
||||
}
|
||||
}
|
||||
|
||||
private static void NotifyMissionUnlock(Mission mission, Client client)
|
||||
{
|
||||
IWriteMessage outmsg = new WriteOnlyMessage();
|
||||
outmsg.WriteByte((byte)ServerPacketHeader.EVENTACTION);
|
||||
outmsg.WriteByte((byte)EventManager.NetworkEventType.MISSION);
|
||||
outmsg.WriteIdentifier(mission.Prefab.Identifier);
|
||||
outmsg.WriteInt32(GameMain.GameSession?.Map?.Locations.IndexOf(mission.Locations[0]) ?? -1);
|
||||
outmsg.WriteInt32(GameMain.GameSession?.Map?.Locations.IndexOf(mission.Locations[1]) ?? -1);
|
||||
outmsg.WriteString(mission.Name.Value);
|
||||
GameMain.Server.ServerPeer.Send(outmsg, client.Connection, DeliveryMethod.Reliable);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,12 @@ namespace Barotrauma
|
||||
|
||||
foreach (Event ev in activeEvents)
|
||||
{
|
||||
if (!(ev is ScriptedEvent scriptedEvent)) { continue; }
|
||||
if (ev is not ScriptedEvent scriptedEvent) { continue; }
|
||||
|
||||
var actions = FindActions(scriptedEvent);
|
||||
foreach (EventAction action in actions.Select(a => a.Item2))
|
||||
{
|
||||
if (!(action is ConversationAction convAction) || convAction.Identifier != actionId) { continue; }
|
||||
if (action is not ConversationAction convAction || convAction.Identifier != actionId) { continue; }
|
||||
if (!convAction.TargetClients.Contains(sender))
|
||||
{
|
||||
#if DEBUG || UNSTABLE
|
||||
@@ -42,6 +42,14 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
convAction.SelectedOption = selectedOption;
|
||||
if (convAction.Options.Any() && !convAction.GetEndingOptions().Contains(selectedOption))
|
||||
{
|
||||
foreach (Client c in convAction.TargetClients)
|
||||
{
|
||||
if (c == sender) { continue; }
|
||||
convAction.ServerWriteSelectedOption(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using Barotrauma.Networking;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class EndMission : Mission
|
||||
{
|
||||
public override void ServerWriteInitial(IWriteMessage msg, Client c)
|
||||
{
|
||||
base.ServerWriteInitial(msg, c);
|
||||
|
||||
boss.WriteSpawnData(msg, boss.ID, restrictMessageSize: false);
|
||||
msg.WriteByte((byte)minions.Length);
|
||||
foreach (Character minion in minions)
|
||||
{
|
||||
minion.WriteSpawnData(msg, minion.ID, restrictMessageSize: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Barotrauma.Networking;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -16,11 +17,10 @@ namespace Barotrauma
|
||||
foreach (var kvp in spawnedResources)
|
||||
{
|
||||
msg.WriteByte((byte)kvp.Value.Count);
|
||||
var rotation = resourceClusters[kvp.Key].Rotation;
|
||||
msg.WriteSingle(rotation);
|
||||
foreach (var r in kvp.Value)
|
||||
msg.WriteSingle(kvp.Value.FirstOrDefault()?.Rotation ?? 0.0f);
|
||||
foreach (var item in kvp.Value)
|
||||
{
|
||||
r.WriteSpawnData(msg, r.ID, Entity.NullEntityID, 0, -1);
|
||||
item.WriteSpawnData(msg, item.ID, Entity.NullEntityID, 0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ namespace Barotrauma
|
||||
{
|
||||
msg.WriteIdentifier(kvp.Key);
|
||||
msg.WriteByte((byte)kvp.Value.Length);
|
||||
foreach (var i in kvp.Value)
|
||||
foreach (var item in kvp.Value)
|
||||
{
|
||||
msg.WriteUInt16(i.ID);
|
||||
msg.WriteUInt16(item.ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,33 +6,66 @@ namespace Barotrauma
|
||||
{
|
||||
partial class SalvageMission : Mission
|
||||
{
|
||||
private bool usedExistingItem;
|
||||
struct SpawnInfo
|
||||
{
|
||||
public readonly bool UsedExistingItem;
|
||||
public readonly UInt16 OriginalInventoryID;
|
||||
public readonly byte OriginalItemContainerIndex;
|
||||
public readonly int OriginalSlotIndex;
|
||||
public readonly List<(int listIndex, int effectIndex)> ExecutedEffectIndices;
|
||||
|
||||
private UInt16 originalInventoryID;
|
||||
private byte originalItemContainerIndex;
|
||||
private int originalSlotIndex;
|
||||
public SpawnInfo(bool usedExistingItem, UInt16 originalInventoryID, byte originalItemContainerIndex, int originalSlotIndex, List<(int listIndex, int effectIndex)> executedEffectIndices)
|
||||
{
|
||||
UsedExistingItem = usedExistingItem;
|
||||
OriginalInventoryID = originalInventoryID;
|
||||
OriginalItemContainerIndex = originalItemContainerIndex;
|
||||
OriginalSlotIndex = originalSlotIndex;
|
||||
ExecutedEffectIndices = executedEffectIndices;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly List<Pair<int, int>> executedEffectIndices = new List<Pair<int, int>>();
|
||||
private readonly Dictionary<Target, SpawnInfo> spawnInfo = new Dictionary<Target, SpawnInfo>();
|
||||
|
||||
public override void ServerWriteInitial(IWriteMessage msg, Client c)
|
||||
{
|
||||
base.ServerWriteInitial(msg, c);
|
||||
|
||||
msg.WriteBoolean(usedExistingItem);
|
||||
if (usedExistingItem)
|
||||
foreach (var target in targets)
|
||||
{
|
||||
msg.WriteUInt16(item.ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.WriteSpawnData(msg, item.ID, originalInventoryID, originalItemContainerIndex, originalSlotIndex);
|
||||
}
|
||||
bool targetFound = spawnInfo.ContainsKey(target) && target.Item != null;
|
||||
msg.WriteBoolean(targetFound);
|
||||
if (!targetFound) { continue; }
|
||||
|
||||
msg.WriteByte((byte)executedEffectIndices.Count);
|
||||
foreach (Pair<int, int> effectIndex in executedEffectIndices)
|
||||
msg.WriteBoolean(spawnInfo[target].UsedExistingItem);
|
||||
if (spawnInfo[target].UsedExistingItem)
|
||||
{
|
||||
msg.WriteUInt16(target.Item.ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
target.Item.WriteSpawnData(msg,
|
||||
target.Item.ID,
|
||||
spawnInfo[target].OriginalInventoryID,
|
||||
spawnInfo[target].OriginalItemContainerIndex,
|
||||
spawnInfo[target].OriginalSlotIndex);
|
||||
}
|
||||
|
||||
msg.WriteByte((byte)spawnInfo[target].ExecutedEffectIndices.Count);
|
||||
foreach ((int listIndex, int effectIndex) in spawnInfo[target].ExecutedEffectIndices)
|
||||
{
|
||||
msg.WriteByte((byte)listIndex);
|
||||
msg.WriteByte((byte)effectIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void ServerWrite(IWriteMessage msg)
|
||||
{
|
||||
base.ServerWrite(msg);
|
||||
msg.WriteByte((byte)targets.Count);
|
||||
for (int i = 0; i < targets.Count; i++)
|
||||
{
|
||||
msg.WriteByte((byte)effectIndex.First);
|
||||
msg.WriteByte((byte)effectIndex.Second);
|
||||
msg.WriteByte((byte)targets[i].State);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user