fix the messages that were using the old variants

This commit is contained in:
JohnCorby 2022-03-02 19:41:33 -08:00
parent 20eaa8adfc
commit b99dfaa510
7 changed files with 70 additions and 75 deletions

View File

@ -7,18 +7,18 @@ namespace QSB.AuthoritySync
/// <summary>
/// always sent to host
/// </summary>
public class AuthQueueMessage : QSBMessage<AuthQueueAction, uint>
public class AuthQueueMessage : QSBMessage<(uint NetId, AuthQueueAction Action)>
{
public AuthQueueMessage(uint netId, AuthQueueAction action)
{
To = 0;
Value1 = action;
Value2 = netId;
Data.NetId = netId;
Data.Action = action;
}
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
public override void OnReceiveLocal() => OnReceiveRemote();
public override void OnReceiveRemote() => NetworkServer.spawned[Value2].ServerUpdateAuthQueue(From, Value1);
public override void OnReceiveRemote() => NetworkServer.spawned[Data.NetId].ServerUpdateAuthQueue(From, Data.Action);
}
public enum AuthQueueAction
@ -36,4 +36,4 @@ namespace QSB.AuthoritySync
/// </summary>
Force
}
}
}

View File

@ -1,5 +1,4 @@
using Mirror;
using QSB.Messaging;
using QSB.Messaging;
using QSB.Player;
using QSB.WorldSync;
using System.Text.RegularExpressions;
@ -7,45 +6,45 @@ using UnityEngine;
namespace QSB.ConversationSync.Messages
{
public class ConversationMessage : QSBMessage<ConversationType, int, string>
public class ConversationMessage : QSBMessage<(ConversationType Type, int Id, string Message)>
{
public ConversationMessage(ConversationType type, int id, string message = "")
{
Value1 = type;
Value2 = id;
Value3 = message;
Data.Type = type;
Data.Id = id;
Data.Message = message;
}
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
public override void OnReceiveRemote()
{
switch (Value1)
switch (Data.Type)
{
case ConversationType.Character:
var translated = TextTranslation.Translate(Value3).Trim();
var translated = TextTranslation.Translate(Data.Message).Trim();
translated = Regex.Replace(translated, @"<[Pp]ause=?\d*\.?\d*\s?\/?>", "");
ConversationManager.Instance.DisplayCharacterConversationBox(Value2, translated);
ConversationManager.Instance.DisplayCharacterConversationBox(Data.Id, translated);
break;
case ConversationType.Player:
ConversationManager.Instance.DisplayPlayerConversationBox((uint)Value2, Value3);
ConversationManager.Instance.DisplayPlayerConversationBox((uint)Data.Id, Data.Message);
break;
case ConversationType.CloseCharacter:
if (Value2 == -1)
if (Data.Id == -1)
{
break;
}
var tree = QSBWorldSync.OldDialogueTrees[Value2];
var tree = QSBWorldSync.OldDialogueTrees[Data.Id];
Object.Destroy(ConversationManager.Instance.BoxMappings[tree]);
break;
case ConversationType.ClosePlayer:
Object.Destroy(QSBPlayerManager.GetPlayer((uint)Value2).CurrentDialogueBox);
Object.Destroy(QSBPlayerManager.GetPlayer((uint)Data.Id).CurrentDialogueBox);
break;
}
}
}
}
}

View File

@ -1,5 +1,4 @@
using Mirror;
using OWML.Common;
using OWML.Common;
using QSB.Messaging;
using QSB.Player;
using QSB.Utility;
@ -7,29 +6,29 @@ using QSB.WorldSync;
namespace QSB.ConversationSync.Messages
{
public class ConversationStartEndMessage : QSBMessage<bool, int>
public class ConversationStartEndMessage : QSBMessage<(int TreeId, bool Start)>
{
public ConversationStartEndMessage(int treeId, bool start)
{
Value2 = treeId;
Value1 = start;
Data.TreeId = treeId;
Data.Start = start;
}
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
public override void OnReceiveRemote()
{
if (Value2 == -1)
if (Data.TreeId == -1)
{
DebugLog.ToConsole("Warning - Received conv. start/end event with char id -1.", MessageType.Warning);
return;
}
var dialogueTree = QSBWorldSync.OldDialogueTrees[Value2];
var dialogueTree = QSBWorldSync.OldDialogueTrees[Data.TreeId];
if (Value1)
if (Data.Start)
{
StartConversation(From, Value2, dialogueTree);
StartConversation(From, Data.TreeId, dialogueTree);
}
else
{
@ -54,4 +53,4 @@ namespace QSB.ConversationSync.Messages
tree.GetInteractVolume().EnableInteraction();
}
}
}
}

View File

@ -1,47 +1,46 @@
using Mirror;
using QSB.Messaging;
using QSB.WorldSync;
namespace QSB.ConversationSync.Messages
{
public class DialogueConditionMessage : QSBMessage<string, bool>
public class DialogueConditionMessage : QSBMessage<(string Name, bool State)>
{
public DialogueConditionMessage(string name, bool state)
{
Value1 = name;
Value2 = state;
Data.Name = name;
Data.State = state;
}
public override void OnReceiveRemote()
{
if (QSBCore.IsHost)
{
QSBWorldSync.SetDialogueCondition(Value1, Value2);
QSBWorldSync.SetDialogueCondition(Data.Name, Data.State);
}
var sharedInstance = DialogueConditionManager.SharedInstance;
var flag = true;
if (sharedInstance.ConditionExists(Value1))
if (sharedInstance.ConditionExists(Data.Name))
{
if (sharedInstance._dictConditions[Value1] == Value2)
if (sharedInstance._dictConditions[Data.Name] == Data.State)
{
flag = false;
}
sharedInstance._dictConditions[Value1] = Value2;
sharedInstance._dictConditions[Data.Name] = Data.State;
}
else
{
sharedInstance.AddCondition(Value1, Value2);
sharedInstance.AddCondition(Data.Name, Data.State);
}
if (flag)
{
GlobalMessenger<string, bool>.FireEvent("DialogueConditionChanged", Value1, Value2);
GlobalMessenger<string, bool>.FireEvent("DialogueConditionChanged", Data.Name, Data.State);
}
if (Value1 == "LAUNCH_CODES_GIVEN")
if (Data.Name == "LAUNCH_CODES_GIVEN")
{
PlayerData.LearnLaunchCodes();
}
@ -51,8 +50,8 @@ namespace QSB.ConversationSync.Messages
{
if (QSBCore.IsHost)
{
QSBWorldSync.SetDialogueCondition(Value1, Value2);
QSBWorldSync.SetDialogueCondition(Data.Name, Data.State);
}
}
}
}
}

View File

@ -1,36 +1,35 @@
using Mirror;
using QSB.Messaging;
using QSB.Messaging;
using QSB.WorldSync;
namespace QSB.ConversationSync.Messages
{
internal class PersistentConditionMessage : QSBMessage<string, bool>
internal class PersistentConditionMessage : QSBMessage<(string Condition, bool State)>
{
public PersistentConditionMessage(string condition, bool state)
{
Value1 = condition;
Value2 = state;
Data.Condition = condition;
Data.State = state;
}
public override void OnReceiveRemote()
{
if (QSBCore.IsHost)
{
QSBWorldSync.SetPersistentCondition(Value1, Value2);
QSBWorldSync.SetPersistentCondition(Data.Condition, Data.State);
}
var gameSave = PlayerData._currentGameSave;
if (gameSave.dictConditions.ContainsKey(Value1))
if (gameSave.dictConditions.ContainsKey(Data.Condition))
{
gameSave.dictConditions[Value1] = Value2;
gameSave.dictConditions[Data.Condition] = Data.State;
}
else
{
gameSave.dictConditions.Add(Value1, Value2);
gameSave.dictConditions.Add(Data.Condition, Data.State);
}
if (Value1
is not "LAUNCH_CODES_GIVEN"
if (Data.Condition
is not "LAUNCH_CODES_GIVEN"
and not "PLAYER_ENTERED_TIMELOOPCORE"
and not "PROBE_ENTERED_TIMELOOPCORE"
and not "PLAYER_ENTERED_TIMELOOPCORE_MULTIPLE")
@ -43,8 +42,8 @@ namespace QSB.ConversationSync.Messages
{
if (QSBCore.IsHost)
{
QSBWorldSync.SetPersistentCondition(Value1, Value2);
QSBWorldSync.SetPersistentCondition(Data.Condition, Data.State);
}
}
}
}
}

View File

@ -5,18 +5,18 @@ using QSB.Utility;
namespace QSB.EchoesOfTheEye.DreamLantern.Messages;
internal class DreamLanternStateMessage : QSBMessage<DreamLanternActionType, bool, float>
internal class DreamLanternStateMessage : QSBMessage<(DreamLanternActionType Type, bool BoolValue, float FloatValue)>
{
public DreamLanternStateMessage(DreamLanternActionType actionType, bool state = false, float floatValue = 0f)
{
Value1 = actionType;
Value2 = state;
Value3 = floatValue;
Data.Type = actionType;
Data.BoolValue = state;
Data.FloatValue = floatValue;
}
public override void OnReceiveRemote()
{
DebugLog.DebugWrite($"{From} Action:{Value1} Value:{Value2} FloatValue:{Value3}");
DebugLog.DebugWrite($"{From} Action:{Data.Type} BoolValue:{Data.BoolValue} FloatValue:{Data.FloatValue}");
var heldItem = QSBPlayerManager.GetPlayer(From).HeldItem;
@ -28,13 +28,13 @@ internal class DreamLanternStateMessage : QSBMessage<DreamLanternActionType, boo
var controller = lantern.AttachedObject._lanternController;
switch (Value1)
switch (Data.Type)
{
case DreamLanternActionType.CONCEAL:
controller.SetConcealed(Value2);
controller.SetConcealed(Data.BoolValue);
break;
case DreamLanternActionType.FOCUS:
controller.SetFocus(Value3);
controller.SetFocus(Data.FloatValue);
break;
}
}

View File

@ -1,5 +1,4 @@
using Mirror;
using QSB.ItemSync.WorldObjects.Items;
using QSB.ItemSync.WorldObjects.Items;
using QSB.ItemSync.WorldObjects.Sockets;
using QSB.Messaging;
using QSB.Player;
@ -8,13 +7,13 @@ using QSB.WorldSync;
namespace QSB.ItemSync.Messages
{
internal class SocketItemMessage : QSBMessage<SocketMessageType, int, int>
internal class SocketItemMessage : QSBMessage<(SocketMessageType Type, int SocketId, int ItemId)>
{
public SocketItemMessage(SocketMessageType type, int socketId = -1, int itemId = -1)
{
Value1 = type;
Value2 = socketId;
Value3 = itemId;
Data.Type = type;
Data.SocketId = socketId;
Data.ItemId = itemId;
}
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
@ -29,16 +28,16 @@ namespace QSB.ItemSync.Messages
DebugLog.DebugWrite("DROP HELD ITEM");
player.AnimationSync.VisibleAnimator.SetTrigger("DropHeldItem");
switch (Value1)
switch (Data.Type)
{
case SocketMessageType.Socket:
socketWorldObject = Value2.GetWorldObject<QSBItemSocket>();
itemWorldObject = Value3.GetWorldObject<IQSBItem>();
socketWorldObject = Data.SocketId.GetWorldObject<QSBItemSocket>();
itemWorldObject = Data.ItemId.GetWorldObject<IQSBItem>();
socketWorldObject.PlaceIntoSocket(itemWorldObject);
return;
case SocketMessageType.StartUnsocket:
socketWorldObject = Value2.GetWorldObject<QSBItemSocket>();
socketWorldObject = Data.SocketId.GetWorldObject<QSBItemSocket>();
if (!socketWorldObject.IsSocketOccupied())
{
@ -49,11 +48,11 @@ namespace QSB.ItemSync.Messages
socketWorldObject.RemoveFromSocket();
return;
case SocketMessageType.CompleteUnsocket:
itemWorldObject = Value3.GetWorldObject<IQSBItem>();
itemWorldObject = Data.ItemId.GetWorldObject<IQSBItem>();
itemWorldObject.OnCompleteUnsocket();
return;
}
}
}
}
}