From b99dfaa510e0b781f980815f4de66da9b850d67b Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Wed, 2 Mar 2022 19:41:33 -0800 Subject: [PATCH] fix the messages that were using the old variants --- QSB/AuthoritySync/AuthQueueMessage.cs | 10 +++---- .../Messages/ConversationMessage.cs | 27 +++++++++---------- .../Messages/ConversationStartEndMessage.cs | 19 +++++++------ .../Messages/DialogueConditionMessage.cs | 25 +++++++++-------- .../Messages/PersistentConditionMessage.cs | 25 +++++++++-------- .../Messages/DreamLanternStateMessage.cs | 16 +++++------ QSB/ItemSync/Messages/SocketItemMessage.cs | 23 ++++++++-------- 7 files changed, 70 insertions(+), 75 deletions(-) diff --git a/QSB/AuthoritySync/AuthQueueMessage.cs b/QSB/AuthoritySync/AuthQueueMessage.cs index bb60918c..4db46bee 100644 --- a/QSB/AuthoritySync/AuthQueueMessage.cs +++ b/QSB/AuthoritySync/AuthQueueMessage.cs @@ -7,18 +7,18 @@ namespace QSB.AuthoritySync /// /// always sent to host /// - public class AuthQueueMessage : QSBMessage + 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 /// Force } -} \ No newline at end of file +} diff --git a/QSB/ConversationSync/Messages/ConversationMessage.cs b/QSB/ConversationSync/Messages/ConversationMessage.cs index a2d91b63..2bb14937 100644 --- a/QSB/ConversationSync/Messages/ConversationMessage.cs +++ b/QSB/ConversationSync/Messages/ConversationMessage.cs @@ -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 + 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; } } } -} \ No newline at end of file +} diff --git a/QSB/ConversationSync/Messages/ConversationStartEndMessage.cs b/QSB/ConversationSync/Messages/ConversationStartEndMessage.cs index 007dbd9e..7d82b164 100644 --- a/QSB/ConversationSync/Messages/ConversationStartEndMessage.cs +++ b/QSB/ConversationSync/Messages/ConversationStartEndMessage.cs @@ -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 + 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(); } } -} \ No newline at end of file +} diff --git a/QSB/ConversationSync/Messages/DialogueConditionMessage.cs b/QSB/ConversationSync/Messages/DialogueConditionMessage.cs index 4314cb68..b74832db 100644 --- a/QSB/ConversationSync/Messages/DialogueConditionMessage.cs +++ b/QSB/ConversationSync/Messages/DialogueConditionMessage.cs @@ -1,47 +1,46 @@ -using Mirror; using QSB.Messaging; using QSB.WorldSync; namespace QSB.ConversationSync.Messages { - public class DialogueConditionMessage : QSBMessage + 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.FireEvent("DialogueConditionChanged", Value1, Value2); + GlobalMessenger.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); } } } -} \ No newline at end of file +} diff --git a/QSB/ConversationSync/Messages/PersistentConditionMessage.cs b/QSB/ConversationSync/Messages/PersistentConditionMessage.cs index fdd19cb5..2bc92d40 100644 --- a/QSB/ConversationSync/Messages/PersistentConditionMessage.cs +++ b/QSB/ConversationSync/Messages/PersistentConditionMessage.cs @@ -1,36 +1,35 @@ -using Mirror; -using QSB.Messaging; +using QSB.Messaging; using QSB.WorldSync; namespace QSB.ConversationSync.Messages { - internal class PersistentConditionMessage : QSBMessage + 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); } } } -} \ No newline at end of file +} diff --git a/QSB/EchoesOfTheEye/DreamLantern/Messages/DreamLanternStateMessage.cs b/QSB/EchoesOfTheEye/DreamLantern/Messages/DreamLanternStateMessage.cs index 5c579510..10a8a5dd 100644 --- a/QSB/EchoesOfTheEye/DreamLantern/Messages/DreamLanternStateMessage.cs +++ b/QSB/EchoesOfTheEye/DreamLantern/Messages/DreamLanternStateMessage.cs @@ -5,18 +5,18 @@ using QSB.Utility; namespace QSB.EchoesOfTheEye.DreamLantern.Messages; -internal class DreamLanternStateMessage : QSBMessage +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 + 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(); - itemWorldObject = Value3.GetWorldObject(); + socketWorldObject = Data.SocketId.GetWorldObject(); + itemWorldObject = Data.ItemId.GetWorldObject(); socketWorldObject.PlaceIntoSocket(itemWorldObject); return; case SocketMessageType.StartUnsocket: - socketWorldObject = Value2.GetWorldObject(); + socketWorldObject = Data.SocketId.GetWorldObject(); if (!socketWorldObject.IsSocketOccupied()) { @@ -49,11 +48,11 @@ namespace QSB.ItemSync.Messages socketWorldObject.RemoveFromSocket(); return; case SocketMessageType.CompleteUnsocket: - itemWorldObject = Value3.GetWorldObject(); + itemWorldObject = Data.ItemId.GetWorldObject(); itemWorldObject.OnCompleteUnsocket(); return; } } } -} \ No newline at end of file +}