(965c31410a) Unstable v0.10.4.0
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
using Barotrauma.Networking;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class ConversationAction : EventAction
|
||||
{
|
||||
public int SelectedOption
|
||||
{
|
||||
get { return selectedOption; }
|
||||
set { selectedOption = value; }
|
||||
}
|
||||
|
||||
|
||||
private static readonly Dictionary<Client, ConversationAction> lastActiveAction = new Dictionary<Client, ConversationAction>();
|
||||
|
||||
private readonly HashSet<Client> targetClients = new HashSet<Client>();
|
||||
public IEnumerable<Client> TargetClients
|
||||
{
|
||||
get { return targetClients; }
|
||||
}
|
||||
|
||||
private bool IsBlockedByAnotherConversation(IEnumerable<Entity> targets)
|
||||
{
|
||||
foreach (Entity e in targets)
|
||||
{
|
||||
if (!(e is Character character) || !character.IsRemotePlayer) { continue; }
|
||||
Client targetClient = GameMain.Server.ConnectedClients.Find(c => c.Character == character);
|
||||
if (targetClient != null)
|
||||
{
|
||||
if (lastActiveAction.ContainsKey(targetClient) &&
|
||||
lastActiveAction[targetClient].ParentEvent != ParentEvent &&
|
||||
Timing.TotalTime < lastActiveAction[targetClient].lastActiveTime + BlockOtherConversationsDuration)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
partial void ShowDialog(Character speaker, Character targetCharacter)
|
||||
{
|
||||
targetClients.Clear();
|
||||
if (!string.IsNullOrEmpty(TargetTag))
|
||||
{
|
||||
IEnumerable<Entity> entities = ParentEvent.GetTargets(TargetTag);
|
||||
foreach (Entity e in entities)
|
||||
{
|
||||
if (!(e is Character character) || !character.IsRemotePlayer) { continue; }
|
||||
Client targetClient = GameMain.Server.ConnectedClients.Find(c => c.Character == character);
|
||||
if (targetClient != null)
|
||||
{
|
||||
targetClients.Add(targetClient);
|
||||
lastActiveAction[targetClient] = this;
|
||||
ServerWrite(speaker, targetClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Client c in GameMain.Server.ConnectedClients)
|
||||
{
|
||||
if (c.InGame && c.Character != null)
|
||||
{
|
||||
if (targetCharacter == null || targetCharacter == c.Character)
|
||||
{
|
||||
targetClients.Add(c);
|
||||
lastActiveAction[c] = this;
|
||||
ServerWrite(speaker, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ServerWrite(Character speaker, Client client)
|
||||
{
|
||||
IWriteMessage outmsg = new WriteOnlyMessage();
|
||||
outmsg.Write((byte)ServerPacketHeader.EVENTACTION);
|
||||
outmsg.Write((byte)EventManager.NetworkEventType.CONVERSATION);
|
||||
outmsg.Write(Identifier);
|
||||
outmsg.Write(EventSprite);
|
||||
outmsg.Write((byte)DialogType);
|
||||
outmsg.Write(ContinueConversation);
|
||||
if (interrupt)
|
||||
{
|
||||
outmsg.Write(speaker?.ID ?? Entity.NullEntityID);
|
||||
outmsg.Write(string.Empty);
|
||||
outmsg.Write(false);
|
||||
outmsg.Write((byte)0);
|
||||
outmsg.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
outmsg.Write(speaker?.ID ?? Entity.NullEntityID);
|
||||
outmsg.Write(Text ?? string.Empty);
|
||||
outmsg.Write(FadeToBlack);
|
||||
outmsg.Write((byte)Options.Count);
|
||||
for (int i = 0; i < Options.Count; i++)
|
||||
{
|
||||
outmsg.Write(Options[i].Text);
|
||||
}
|
||||
|
||||
int[] endings = GetEndingOptions();
|
||||
outmsg.Write((byte)endings.Length);
|
||||
foreach (var end in endings)
|
||||
{
|
||||
outmsg.Write((byte)end);
|
||||
}
|
||||
}
|
||||
GameMain.Server?.ServerPeer?.Send(outmsg, client.Connection, DeliveryMethod.Reliable);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Barotrauma.Networking;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class StatusEffectAction : EventAction
|
||||
{
|
||||
private void ServerWrite(IEnumerable<Entity> targets)
|
||||
{
|
||||
IWriteMessage outmsg = new WriteOnlyMessage();
|
||||
outmsg.Write((byte)ServerPacketHeader.EVENTACTION);
|
||||
outmsg.Write((byte)EventManager.NetworkEventType.STATUSEFFECT);
|
||||
outmsg.Write(ParentEvent.Prefab.Identifier);
|
||||
outmsg.Write((UInt16)actionIndex);
|
||||
outmsg.Write((UInt16)targets.Count());
|
||||
foreach (Entity target in targets)
|
||||
{
|
||||
outmsg.Write(target.ID);
|
||||
}
|
||||
foreach (Client c in GameMain.Server.ConnectedClients)
|
||||
{
|
||||
GameMain.Server.ServerPeer?.Send(outmsg, c.Connection, DeliveryMethod.Reliable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Barotrauma.Networking;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class EventManager
|
||||
{
|
||||
public void ServerRead(IReadMessage inc, Client sender)
|
||||
{
|
||||
UInt16 actionId = inc.ReadUInt16();
|
||||
byte selectedOption = inc.ReadByte();
|
||||
|
||||
foreach (Event ev in activeEvents)
|
||||
{
|
||||
if (!(ev is 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 (!convAction.TargetClients.Contains(sender))
|
||||
{
|
||||
#if DEBUG || UNSTABLE
|
||||
DebugConsole.ThrowError($"Client \"{sender.Name}\" tried to respond to a ConversationAction that was not targeted to them.");
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
convAction.SelectedOption = selectedOption;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,9 @@ namespace Barotrauma
|
||||
foreach (Item item in items)
|
||||
{
|
||||
item.WriteSpawnData(msg,
|
||||
itemIDs[item],
|
||||
parentInventoryIDs.ContainsKey(item) ? parentInventoryIDs[item] : Entity.NullEntityID);
|
||||
item.OriginalID,
|
||||
parentInventoryIDs.ContainsKey(item) ? parentInventoryIDs[item] : Entity.NullEntityID,
|
||||
parentItemContainerIndices.ContainsKey(item) ? parentItemContainerIndices[item] : (byte)0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Barotrauma
|
||||
{
|
||||
public override void ServerWriteInitial(IWriteMessage msg, Client c)
|
||||
{
|
||||
if (monsters.Count == 0 && monsterFiles.Count > 0)
|
||||
if (monsters.Count == 0 && monsterPrefabs.Count > 0)
|
||||
{
|
||||
throw new InvalidOperationException("Server attempted to write monster mission data when no monsters had been spawned.");
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace Barotrauma
|
||||
{
|
||||
private bool usedExistingItem;
|
||||
|
||||
private UInt16 originalItemID;
|
||||
private UInt16 originalInventoryID;
|
||||
private byte originalItemContainerIndex;
|
||||
|
||||
private readonly List<Pair<int, int>> executedEffectIndices = new List<Pair<int, int>>();
|
||||
|
||||
@@ -18,11 +18,11 @@ namespace Barotrauma
|
||||
msg.Write(usedExistingItem);
|
||||
if (usedExistingItem)
|
||||
{
|
||||
msg.Write(originalItemID);
|
||||
msg.Write(item.OriginalID);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.WriteSpawnData(msg, originalItemID, originalInventoryID);
|
||||
item.WriteSpawnData(msg, item.OriginalID, originalInventoryID, originalItemContainerIndex);
|
||||
}
|
||||
|
||||
msg.Write((byte)executedEffectIndices.Count);
|
||||
|
||||
Reference in New Issue
Block a user