diff --git a/QSB/ConversationSync/ConversationManager.cs b/QSB/ConversationSync/ConversationManager.cs index 47e5e659..37989021 100644 --- a/QSB/ConversationSync/ConversationManager.cs +++ b/QSB/ConversationSync/ConversationManager.cs @@ -118,7 +118,7 @@ namespace QSB.ConversationSync { var newBox = Instantiate(_boxPrefab); newBox.SetActive(false); - newBox.transform.parent = parent; + newBox.transform.SetParent(parent); newBox.transform.localPosition = new Vector3(0, vertOffset, 0); newBox.transform.rotation = parent.rotation; var lookAt = newBox.AddComponent(); diff --git a/QSB/ConversationSync/ConversationPatches.cs b/QSB/ConversationSync/Patches/ConversationPatches.cs similarity index 99% rename from QSB/ConversationSync/ConversationPatches.cs rename to QSB/ConversationSync/Patches/ConversationPatches.cs index 604f8987..25000aad 100644 --- a/QSB/ConversationSync/ConversationPatches.cs +++ b/QSB/ConversationSync/Patches/ConversationPatches.cs @@ -6,7 +6,7 @@ using QSB.WorldSync; using System.Collections.Generic; using UnityEngine; -namespace QSB.ConversationSync +namespace QSB.ConversationSync.Patches { public class ConversationPatches : QSBPatch { diff --git a/QSB/DeathSync/DeathPatches.cs b/QSB/DeathSync/Patches/DeathPatches.cs similarity index 96% rename from QSB/DeathSync/DeathPatches.cs rename to QSB/DeathSync/Patches/DeathPatches.cs index fdd6a1c9..ee18d7c9 100644 --- a/QSB/DeathSync/DeathPatches.cs +++ b/QSB/DeathSync/Patches/DeathPatches.cs @@ -2,7 +2,7 @@ using QSB.Patches; using System.Linq; -namespace QSB.DeathSync +namespace QSB.DeathSync.Patches { public class DeathPatches : QSBPatch { diff --git a/QSB/ElevatorSync/ElevatorManager.cs b/QSB/ElevatorSync/ElevatorManager.cs index 6227d889..0b0abd52 100644 --- a/QSB/ElevatorSync/ElevatorManager.cs +++ b/QSB/ElevatorSync/ElevatorManager.cs @@ -1,4 +1,5 @@ -using QSB.WorldSync; +using QSB.ElevatorSync.WorldObjects; +using QSB.WorldSync; using System.Collections.Generic; using UnityEngine; diff --git a/QSB/ElevatorSync/Events/ElevatorEvent.cs b/QSB/ElevatorSync/Events/ElevatorEvent.cs index ccb96c0d..f8d83493 100644 --- a/QSB/ElevatorSync/Events/ElevatorEvent.cs +++ b/QSB/ElevatorSync/Events/ElevatorEvent.cs @@ -1,4 +1,5 @@ -using QSB.Events; +using QSB.ElevatorSync.WorldObjects; +using QSB.Events; using QSB.WorldSync; using QSB.WorldSync.Events; diff --git a/QSB/ElevatorSync/ElevatorPatches.cs b/QSB/ElevatorSync/Patches/ElevatorPatches.cs similarity index 94% rename from QSB/ElevatorSync/ElevatorPatches.cs rename to QSB/ElevatorSync/Patches/ElevatorPatches.cs index 2c679672..68282131 100644 --- a/QSB/ElevatorSync/ElevatorPatches.cs +++ b/QSB/ElevatorSync/Patches/ElevatorPatches.cs @@ -2,7 +2,7 @@ using QSB.Events; using QSB.Patches; -namespace QSB.ElevatorSync +namespace QSB.ElevatorSync.Patches { public class ElevatorPatches : QSBPatch { diff --git a/QSB/ElevatorSync/QSBElevator.cs b/QSB/ElevatorSync/WorldObjects/QSBElevator.cs similarity index 97% rename from QSB/ElevatorSync/QSBElevator.cs rename to QSB/ElevatorSync/WorldObjects/QSBElevator.cs index 7d51fd48..ad2ca5a0 100644 --- a/QSB/ElevatorSync/QSBElevator.cs +++ b/QSB/ElevatorSync/WorldObjects/QSBElevator.cs @@ -2,7 +2,7 @@ using QSB.WorldSync; using UnityEngine; -namespace QSB.ElevatorSync +namespace QSB.ElevatorSync.WorldObjects { public class QSBElevator : WorldObject { diff --git a/QSB/Events/EventNames.cs b/QSB/Events/EventNames.cs index fe468dd5..a959d18a 100644 --- a/QSB/Events/EventNames.cs +++ b/QSB/Events/EventNames.cs @@ -2,6 +2,7 @@ { public static class EventNames { + // Built into Outer Wilds -- don't change unless they change in-game! public static string TurnOnFlashlight = "TurnOnFlashlight"; public static string TurnOffFlashlight = "TurnOffFlashlight"; public static string LaunchProbe = "LaunchProbe"; @@ -19,6 +20,8 @@ public static string WakeUp = "WakeUp"; public static string DialogueCondition = "DialogueConditionChanged"; + // Custom event names -- change if you want! These can be anything, as long as both + // sides of the GlobalMessenger (fireevent and setuplistener) reference the same thing. public static string QSBPlayerDeath = "QSBPlayerDeath"; public static string QSBPlayerJoin = "QSBPlayerJoin"; public static string QSBPlayerReady = "QSBPlayerReady"; @@ -39,5 +42,6 @@ public static string QSBMultiStateChange = "QSBMultiStateChange"; public static string QSBIdentifyFrequency = "QSBIdentifyFrequency"; public static string QSBIdentifySignal = "QSBIdentifySignal"; + public static string QSBTextTranslated = "QSBTextTranslated"; } } \ No newline at end of file diff --git a/QSB/Events/EventType.cs b/QSB/Events/EventType.cs index 249ab8eb..e1d8abe7 100644 --- a/QSB/Events/EventType.cs +++ b/QSB/Events/EventType.cs @@ -29,6 +29,7 @@ SocketStateChange, MultiStateChange, IdentifyFrequency, - IdentifySignal + IdentifySignal, + TextTranslated } } \ No newline at end of file diff --git a/QSB/Events/QSBEventManager.cs b/QSB/Events/QSBEventManager.cs index 3d4b2f4b..34e1c788 100644 --- a/QSB/Events/QSBEventManager.cs +++ b/QSB/Events/QSBEventManager.cs @@ -11,6 +11,7 @@ using QSB.Player.Events; using QSB.QuantumSync.Events; using QSB.TimeSync.Events; using QSB.Tools.Events; +using QSB.TranslationSync.Events; using QSB.Utility; using System.Collections.Generic; @@ -49,6 +50,7 @@ namespace QSB.Events new OrbUserEvent(), new SocketStateChangeEvent(), new MultiStateChangeEvent(), + new SetAsTranslatedEvent(), // Conversation/dialogue/exploration new ConversationEvent(), new ConversationStartEndEvent(), diff --git a/QSB/FrequencySync/FrequencyPatches.cs b/QSB/FrequencySync/Patches/FrequencyPatches.cs similarity index 95% rename from QSB/FrequencySync/FrequencyPatches.cs rename to QSB/FrequencySync/Patches/FrequencyPatches.cs index 94375c97..ad18b82b 100644 --- a/QSB/FrequencySync/FrequencyPatches.cs +++ b/QSB/FrequencySync/Patches/FrequencyPatches.cs @@ -1,7 +1,7 @@ using QSB.Events; using QSB.Patches; -namespace QSB.FrequencySync +namespace QSB.FrequencySync.Patches { public class FrequencyPatches : QSBPatch { diff --git a/QSB/GeyserSync/Events/GeyserEvent.cs b/QSB/GeyserSync/Events/GeyserEvent.cs index 5eb10a80..8189b771 100644 --- a/QSB/GeyserSync/Events/GeyserEvent.cs +++ b/QSB/GeyserSync/Events/GeyserEvent.cs @@ -1,4 +1,5 @@ using QSB.Events; +using QSB.GeyserSync.WorldObjects; using QSB.WorldSync; using QSB.WorldSync.Events; diff --git a/QSB/GeyserSync/GeyserManager.cs b/QSB/GeyserSync/GeyserManager.cs index 56830f2a..bf64f54e 100644 --- a/QSB/GeyserSync/GeyserManager.cs +++ b/QSB/GeyserSync/GeyserManager.cs @@ -1,4 +1,5 @@ -using QSB.Patches; +using QSB.GeyserSync.WorldObjects; +using QSB.Patches; using QSB.WorldSync; using UnityEngine; diff --git a/QSB/GeyserSync/QSBGeyser.cs b/QSB/GeyserSync/WorldObjects/QSBGeyser.cs similarity index 95% rename from QSB/GeyserSync/QSBGeyser.cs rename to QSB/GeyserSync/WorldObjects/QSBGeyser.cs index 5c4d02c4..38092393 100644 --- a/QSB/GeyserSync/QSBGeyser.cs +++ b/QSB/GeyserSync/WorldObjects/QSBGeyser.cs @@ -2,7 +2,7 @@ using QSB.WorldSync; using QuantumUNET; -namespace QSB.GeyserSync +namespace QSB.GeyserSync.WorldObjects { public class QSBGeyser : WorldObject { diff --git a/QSB/LogSync/LogPatches.cs b/QSB/LogSync/Patches/LogPatches.cs similarity index 94% rename from QSB/LogSync/LogPatches.cs rename to QSB/LogSync/Patches/LogPatches.cs index 32e4ee59..de402315 100644 --- a/QSB/LogSync/LogPatches.cs +++ b/QSB/LogSync/Patches/LogPatches.cs @@ -1,7 +1,7 @@ using QSB.Events; using QSB.Patches; -namespace QSB.LogSync +namespace QSB.LogSync.Patches { public class LogPatches : QSBPatch { diff --git a/QSB/OrbSync/Events/OrbSlotEvent.cs b/QSB/OrbSync/Events/OrbSlotEvent.cs index d8b0e036..928fd74d 100644 --- a/QSB/OrbSync/Events/OrbSlotEvent.cs +++ b/QSB/OrbSync/Events/OrbSlotEvent.cs @@ -1,4 +1,5 @@ using QSB.Events; +using QSB.OrbSync.WorldObjects; using QSB.WorldSync; namespace QSB.OrbSync.Events diff --git a/QSB/OrbSync/OrbManager.cs b/QSB/OrbSync/OrbManager.cs index c343a7f2..4d92af80 100644 --- a/QSB/OrbSync/OrbManager.cs +++ b/QSB/OrbSync/OrbManager.cs @@ -1,4 +1,5 @@ using OWML.Common; +using QSB.OrbSync.WorldObjects; using QSB.Utility; using QSB.WorldSync; using QuantumUNET; diff --git a/QSB/OrbSync/OrbPatches.cs b/QSB/OrbSync/Patches/OrbPatches.cs similarity index 98% rename from QSB/OrbSync/OrbPatches.cs rename to QSB/OrbSync/Patches/OrbPatches.cs index 64fbe407..967c90dc 100644 --- a/QSB/OrbSync/OrbPatches.cs +++ b/QSB/OrbSync/Patches/OrbPatches.cs @@ -3,7 +3,7 @@ using QSB.Patches; using QSB.WorldSync; using UnityEngine; -namespace QSB.OrbSync +namespace QSB.OrbSync.Patches { public class OrbPatches : QSBPatch { diff --git a/QSB/OrbSync/QSBOrbSlot.cs b/QSB/OrbSync/WorldObjects/QSBOrbSlot.cs similarity index 97% rename from QSB/OrbSync/QSBOrbSlot.cs rename to QSB/OrbSync/WorldObjects/QSBOrbSlot.cs index 33ae1897..78795548 100644 --- a/QSB/OrbSync/QSBOrbSlot.cs +++ b/QSB/OrbSync/WorldObjects/QSBOrbSlot.cs @@ -4,7 +4,7 @@ using QSB.Utility; using QSB.WorldSync; using UnityEngine.UI; -namespace QSB.OrbSync +namespace QSB.OrbSync.WorldObjects { public class QSBOrbSlot : WorldObject { diff --git a/QSB/Patches/QSBPatchManager.cs b/QSB/Patches/QSBPatchManager.cs index 789d2625..50613a00 100644 --- a/QSB/Patches/QSBPatchManager.cs +++ b/QSB/Patches/QSBPatchManager.cs @@ -1,12 +1,13 @@ using OWML.Common; -using QSB.ConversationSync; -using QSB.DeathSync; -using QSB.ElevatorSync; -using QSB.FrequencySync; -using QSB.LogSync; -using QSB.OrbSync; -using QSB.QuantumSync; -using QSB.TimeSync; +using QSB.ConversationSync.Patches; +using QSB.DeathSync.Patches; +using QSB.ElevatorSync.Patches; +using QSB.FrequencySync.Patches; +using QSB.LogSync.Patches; +using QSB.OrbSync.Patches; +using QSB.QuantumSync.Patches; +using QSB.TimeSync.Patches; +using QSB.TranslationSync.Patches; using QSB.Utility; using System; using System.Collections.Generic; @@ -35,7 +36,8 @@ namespace QSB.Patches new QuantumVisibilityPatches(), new ServerQuantumStateChangePatches(), new ClientQuantumStateChangePatches(), - new FrequencyPatches() + new FrequencyPatches(), + new SpiralPatches() }; DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success); diff --git a/QSB/Player/Events/PlayerReadyEvent.cs b/QSB/Player/Events/PlayerReadyEvent.cs index c6f73ae5..5aa7ecfe 100644 --- a/QSB/Player/Events/PlayerReadyEvent.cs +++ b/QSB/Player/Events/PlayerReadyEvent.cs @@ -1,7 +1,7 @@ using OWML.Common; using QSB.Events; using QSB.Messaging; -using QSB.SectorSync; +using QSB.SectorSync.WorldObjects; using QSB.Utility; using System.Linq; diff --git a/QSB/Player/Events/PlayerSectorEvent.cs b/QSB/Player/Events/PlayerSectorEvent.cs index eec4de9e..bfd8e140 100644 --- a/QSB/Player/Events/PlayerSectorEvent.cs +++ b/QSB/Player/Events/PlayerSectorEvent.cs @@ -1,6 +1,6 @@ using OWML.Common; using QSB.Events; -using QSB.SectorSync; +using QSB.SectorSync.WorldObjects; using QSB.Utility; using QSB.WorldSync; using QSB.WorldSync.Events; diff --git a/QSB/Player/Events/PlayerStatesRequestEvent.cs b/QSB/Player/Events/PlayerStatesRequestEvent.cs index a0ec9159..d40d3fa4 100644 --- a/QSB/Player/Events/PlayerStatesRequestEvent.cs +++ b/QSB/Player/Events/PlayerStatesRequestEvent.cs @@ -1,6 +1,9 @@ -using QSB.Events; +using OWML.Utils; +using QSB.Events; using QSB.Messaging; -using QSB.SectorSync; +using QSB.SectorSync.WorldObjects; +using QSB.TranslationSync; +using QSB.TranslationSync.WorldObjects; using QSB.Utility; using QSB.WorldSync; using System.Linq; @@ -46,6 +49,30 @@ namespace QSB.Player.Events { GlobalMessenger.FireEvent(EventNames.QSBRevealFact, fact.Id, fact.SaveGame, false); } + + foreach (var wallText in QSBWorldSync.GetWorldObjects().Where(x => x.AttachedObject.GetValue("_initialized") && x.AttachedObject.GetNumTextBlocks() > 0)) + { + foreach (var id in wallText.GetTranslatedIds()) + { + GlobalMessenger.FireEvent(EventNames.QSBTextTranslated, NomaiTextType.WallText, wallText.ObjectId, id); + } + } + + foreach (var computer in QSBWorldSync.GetWorldObjects().Where(x => x.AttachedObject.GetValue("_initialized") && x.AttachedObject.GetNumTextBlocks() > 0)) + { + foreach (var id in computer.GetTranslatedIds()) + { + GlobalMessenger.FireEvent(EventNames.QSBTextTranslated, NomaiTextType.Computer, computer.ObjectId, id); + } + } + + foreach (var vesselComputer in QSBWorldSync.GetWorldObjects().Where(x => x.AttachedObject.GetValue("_initialized") && x.AttachedObject.GetNumTextBlocks() > 0)) + { + foreach (var id in vesselComputer.GetTranslatedIds()) + { + GlobalMessenger.FireEvent(EventNames.QSBTextTranslated, NomaiTextType.VesselComputer, vesselComputer.ObjectId, id); + } + } } } } \ No newline at end of file diff --git a/QSB/QSB.csproj b/QSB/QSB.csproj index b9ea6929..7bbbcc63 100644 --- a/QSB/QSB.csproj +++ b/QSB/QSB.csproj @@ -149,38 +149,38 @@ - + - - + + - + - + - + - + - + @@ -190,20 +190,28 @@ - + - - - + + + - - + + + + + + + + + + - + @@ -215,14 +223,14 @@ - + - + diff --git a/QSB/QSBCore.cs b/QSB/QSBCore.cs index 178b808c..f6d79e34 100644 --- a/QSB/QSBCore.cs +++ b/QSB/QSBCore.cs @@ -9,6 +9,7 @@ using QSB.Patches; using QSB.QuantumSync; using QSB.SectorSync; using QSB.TimeSync; +using QSB.TranslationSync; using QSB.Utility; using QuantumUNET; using QuantumUNET.Components; @@ -79,6 +80,7 @@ namespace QSB gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); + gameObject.AddComponent(); DebugBoxManager.Init(); diff --git a/QSB/QSBNetworkManager.cs b/QSB/QSBNetworkManager.cs index a2441b06..e1ae72e2 100644 --- a/QSB/QSBNetworkManager.cs +++ b/QSB/QSBNetworkManager.cs @@ -2,14 +2,16 @@ using OWML.Utils; using QSB.Animation; using QSB.DeathSync; -using QSB.ElevatorSync; +using QSB.ElevatorSync.WorldObjects; using QSB.Events; -using QSB.GeyserSync; +using QSB.GeyserSync.WorldObjects; using QSB.Instruments; using QSB.OrbSync; +using QSB.OrbSync.WorldObjects; using QSB.Patches; using QSB.Player; using QSB.SectorSync; +using QSB.SectorSync.WorldObjects; using QSB.TimeSync; using QSB.TransformSync; using QSB.Utility; diff --git a/QSB/QuantumSync/Events/MultiStateChangeEvent.cs b/QSB/QuantumSync/Events/MultiStateChangeEvent.cs index 9129b2dc..adc5118f 100644 --- a/QSB/QuantumSync/Events/MultiStateChangeEvent.cs +++ b/QSB/QuantumSync/Events/MultiStateChangeEvent.cs @@ -1,5 +1,6 @@ using OWML.Utils; using QSB.Events; +using QSB.QuantumSync.WorldObjects; using QSB.WorldSync; namespace QSB.QuantumSync.Events diff --git a/QSB/QuantumSync/Events/SocketStateChangeEvent.cs b/QSB/QuantumSync/Events/SocketStateChangeEvent.cs index b2e8c458..4f734928 100644 --- a/QSB/QuantumSync/Events/SocketStateChangeEvent.cs +++ b/QSB/QuantumSync/Events/SocketStateChangeEvent.cs @@ -1,4 +1,5 @@ using QSB.Events; +using QSB.QuantumSync.WorldObjects; using QSB.WorldSync; using System.Reflection; using UnityEngine; diff --git a/QSB/QuantumSync/ClientQuantumStateChangePatches.cs b/QSB/QuantumSync/Patches/ClientQuantumStateChangePatches.cs similarity index 94% rename from QSB/QuantumSync/ClientQuantumStateChangePatches.cs rename to QSB/QuantumSync/Patches/ClientQuantumStateChangePatches.cs index a74a3e6a..a0ea4742 100644 --- a/QSB/QuantumSync/ClientQuantumStateChangePatches.cs +++ b/QSB/QuantumSync/Patches/ClientQuantumStateChangePatches.cs @@ -1,6 +1,6 @@ using QSB.Patches; -namespace QSB.QuantumSync +namespace QSB.QuantumSync.Patches { public class ClientQuantumStateChangePatches : QSBPatch { diff --git a/QSB/QuantumSync/QuantumVisibilityPatches.cs b/QSB/QuantumSync/Patches/QuantumVisibilityPatches.cs similarity index 98% rename from QSB/QuantumSync/QuantumVisibilityPatches.cs rename to QSB/QuantumSync/Patches/QuantumVisibilityPatches.cs index 946ee21f..d16b9ca5 100644 --- a/QSB/QuantumSync/QuantumVisibilityPatches.cs +++ b/QSB/QuantumSync/Patches/QuantumVisibilityPatches.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Reflection; using UnityEngine; -namespace QSB.QuantumSync +namespace QSB.QuantumSync.Patches { public class QuantumVisibilityPatches : QSBPatch { diff --git a/QSB/QuantumSync/ServerQuantumStateChangePatches.cs b/QSB/QuantumSync/Patches/ServerQuantumStateChangePatches.cs similarity index 95% rename from QSB/QuantumSync/ServerQuantumStateChangePatches.cs rename to QSB/QuantumSync/Patches/ServerQuantumStateChangePatches.cs index 45e9153e..decc9b97 100644 --- a/QSB/QuantumSync/ServerQuantumStateChangePatches.cs +++ b/QSB/QuantumSync/Patches/ServerQuantumStateChangePatches.cs @@ -1,11 +1,12 @@ using QSB.Events; using QSB.Patches; +using QSB.QuantumSync.WorldObjects; using QSB.WorldSync; using System; using System.Linq; using UnityEngine; -namespace QSB.QuantumSync +namespace QSB.QuantumSync.Patches { public class ServerQuantumStateChangePatches : QSBPatch { diff --git a/QSB/QuantumSync/QuantumManager.cs b/QSB/QuantumSync/QuantumManager.cs index 68b747c8..8af4c5db 100644 --- a/QSB/QuantumSync/QuantumManager.cs +++ b/QSB/QuantumSync/QuantumManager.cs @@ -1,4 +1,5 @@ -using QSB.WorldSync; +using QSB.QuantumSync.WorldObjects; +using QSB.WorldSync; using System.Collections.Generic; using UnityEngine; diff --git a/QSB/QuantumSync/QSBMultiStateQuantumObject.cs b/QSB/QuantumSync/WorldObjects/QSBMultiStateQuantumObject.cs similarity index 94% rename from QSB/QuantumSync/QSBMultiStateQuantumObject.cs rename to QSB/QuantumSync/WorldObjects/QSBMultiStateQuantumObject.cs index 638b3d9a..f2135d3d 100644 --- a/QSB/QuantumSync/QSBMultiStateQuantumObject.cs +++ b/QSB/QuantumSync/WorldObjects/QSBMultiStateQuantumObject.cs @@ -3,7 +3,7 @@ using QSB.Utility; using QSB.WorldSync; using UnityEngine.UI; -namespace QSB.QuantumSync +namespace QSB.QuantumSync.WorldObjects { public class QSBMultiStateQuantumObject : WorldObject { diff --git a/QSB/QuantumSync/QSBQuantumSocket.cs b/QSB/QuantumSync/WorldObjects/QSBQuantumSocket.cs similarity index 88% rename from QSB/QuantumSync/QSBQuantumSocket.cs rename to QSB/QuantumSync/WorldObjects/QSBQuantumSocket.cs index febdc7bf..69ef33d9 100644 --- a/QSB/QuantumSync/QSBQuantumSocket.cs +++ b/QSB/QuantumSync/WorldObjects/QSBQuantumSocket.cs @@ -1,7 +1,7 @@ using OWML.Utils; using QSB.WorldSync; -namespace QSB.QuantumSync +namespace QSB.QuantumSync.WorldObjects { internal class QSBQuantumSocket : WorldObject { diff --git a/QSB/QuantumSync/QSBSocketedQuantumObject.cs b/QSB/QuantumSync/WorldObjects/QSBSocketedQuantumObject.cs similarity index 86% rename from QSB/QuantumSync/QSBSocketedQuantumObject.cs rename to QSB/QuantumSync/WorldObjects/QSBSocketedQuantumObject.cs index cc498841..d882d4ae 100644 --- a/QSB/QuantumSync/QSBSocketedQuantumObject.cs +++ b/QSB/QuantumSync/WorldObjects/QSBSocketedQuantumObject.cs @@ -1,6 +1,6 @@ using QSB.WorldSync; -namespace QSB.QuantumSync +namespace QSB.QuantumSync.WorldObjects { internal class QSBSocketedQuantumObject : WorldObject { diff --git a/QSB/SectorSync/QSBSectorManager.cs b/QSB/SectorSync/QSBSectorManager.cs index 6bb0f9d5..902b02b9 100644 --- a/QSB/SectorSync/QSBSectorManager.cs +++ b/QSB/SectorSync/QSBSectorManager.cs @@ -1,4 +1,5 @@ using OWML.Common; +using QSB.SectorSync.WorldObjects; using QSB.Utility; using QSB.WorldSync; using System.Linq; diff --git a/QSB/SectorSync/SectorSync.cs b/QSB/SectorSync/SectorSync.cs index bd0ba16a..5e1eae3a 100644 --- a/QSB/SectorSync/SectorSync.cs +++ b/QSB/SectorSync/SectorSync.cs @@ -1,5 +1,6 @@ using QSB.Events; using QSB.Player; +using QSB.SectorSync.WorldObjects; using System.Linq; using UnityEngine; diff --git a/QSB/SectorSync/QSBSector.cs b/QSB/SectorSync/WorldObjects/QSBSector.cs similarity index 91% rename from QSB/SectorSync/QSBSector.cs rename to QSB/SectorSync/WorldObjects/QSBSector.cs index f0053f38..d9003c6a 100644 --- a/QSB/SectorSync/QSBSector.cs +++ b/QSB/SectorSync/WorldObjects/QSBSector.cs @@ -1,7 +1,7 @@ using QSB.WorldSync; using UnityEngine; -namespace QSB.SectorSync +namespace QSB.SectorSync.WorldObjects { public class QSBSector : WorldObject { diff --git a/QSB/TimeSync/WakeUpPatches.cs b/QSB/TimeSync/Patches/WakeUpPatches.cs similarity index 95% rename from QSB/TimeSync/WakeUpPatches.cs rename to QSB/TimeSync/Patches/WakeUpPatches.cs index fc4fbe74..b73bc4b1 100644 --- a/QSB/TimeSync/WakeUpPatches.cs +++ b/QSB/TimeSync/Patches/WakeUpPatches.cs @@ -1,7 +1,7 @@ using OWML.Utils; using QSB.Patches; -namespace QSB.TimeSync +namespace QSB.TimeSync.Patches { public class WakeUpPatches : QSBPatch { diff --git a/QSB/TimeSync/TimeSyncUI.cs b/QSB/TimeSync/TimeSyncUI.cs index 7ccc40f5..5d8e563b 100644 --- a/QSB/TimeSync/TimeSyncUI.cs +++ b/QSB/TimeSync/TimeSyncUI.cs @@ -37,7 +37,7 @@ namespace QSB.TimeSync public void OnDestroy() { QSBSceneManager.OnUniverseSceneLoaded -= OnUniverseSceneLoad; - if (_canvas.enabled) + if (_canvas != null & _canvas.enabled) { Canvas.willRenderCanvases -= OnWillRenderCanvases; } diff --git a/QSB/TransformSync/TransformSync.cs b/QSB/TransformSync/TransformSync.cs index 060d0f9c..9d607466 100644 --- a/QSB/TransformSync/TransformSync.cs +++ b/QSB/TransformSync/TransformSync.cs @@ -1,6 +1,7 @@ using OWML.Common; using QSB.Player; using QSB.SectorSync; +using QSB.SectorSync.WorldObjects; using QSB.Utility; using System.Linq; using UnityEngine; diff --git a/QSB/TranslationSync/Events/SetAsTranslatedEvent.cs b/QSB/TranslationSync/Events/SetAsTranslatedEvent.cs new file mode 100644 index 00000000..d7bb818b --- /dev/null +++ b/QSB/TranslationSync/Events/SetAsTranslatedEvent.cs @@ -0,0 +1,51 @@ +using QSB.Events; +using QSB.TranslationSync.WorldObjects; +using QSB.WorldSync; + +namespace QSB.TranslationSync.Events +{ + public class SetAsTranslatedEvent : QSBEvent + { + public override EventType Type => EventType.TextTranslated; + + public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBTextTranslated, Handler); + public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBTextTranslated, Handler); + + private void Handler(NomaiTextType type, int objId, int textId) => SendEvent(CreateMessage(type, objId, textId)); + + private SetAsTranslatedMessage CreateMessage(NomaiTextType type, int objId, int textId) => new SetAsTranslatedMessage + { + AboutId = LocalPlayerId, + ObjectId = objId, + TextId = textId, + TextType = type + }; + + public override void OnReceiveRemote(bool server, SetAsTranslatedMessage message) + { + if (!QSBCore.HasWokenUp) + { + return; + } + if (message.TextType == NomaiTextType.WallText) + { + var obj = QSBWorldSync.GetWorldObject(message.ObjectId); + obj.HandleSetAsTranslated(message.TextId); + } + else if (message.TextType == NomaiTextType.Computer) + { + var obj = QSBWorldSync.GetWorldObject(message.ObjectId); + obj.HandleSetAsTranslated(message.TextId); + } + else if (message.TextType == NomaiTextType.VesselComputer) + { + var obj = QSBWorldSync.GetWorldObject(message.ObjectId); + obj.HandleSetAsTranslated(message.TextId); + } + else + { + throw new System.NotImplementedException($"TextType <{message.TextType}> not implemented."); + } + } + } +} \ No newline at end of file diff --git a/QSB/TranslationSync/Events/SetAsTranslatedMessage.cs b/QSB/TranslationSync/Events/SetAsTranslatedMessage.cs new file mode 100644 index 00000000..41176f74 --- /dev/null +++ b/QSB/TranslationSync/Events/SetAsTranslatedMessage.cs @@ -0,0 +1,25 @@ +using QSB.WorldSync.Events; +using QuantumUNET.Transport; + +namespace QSB.TranslationSync.Events +{ + public class SetAsTranslatedMessage : WorldObjectMessage + { + public int TextId { get; set; } + public NomaiTextType TextType { get; set; } + + public override void Deserialize(QNetworkReader reader) + { + base.Deserialize(reader); + TextId = reader.ReadInt32(); + TextType = (NomaiTextType)reader.ReadInt16(); + } + + public override void Serialize(QNetworkWriter writer) + { + base.Serialize(writer); + writer.Write(TextId); + writer.Write((short)TextType); + } + } +} diff --git a/QSB/TranslationSync/NomaiTextType.cs b/QSB/TranslationSync/NomaiTextType.cs new file mode 100644 index 00000000..c5cd6f08 --- /dev/null +++ b/QSB/TranslationSync/NomaiTextType.cs @@ -0,0 +1,9 @@ +namespace QSB.TranslationSync +{ + public enum NomaiTextType + { + Computer = 0, + VesselComputer = 1, + WallText = 2 + } +} diff --git a/QSB/TranslationSync/Patches/SpiralPatches.cs b/QSB/TranslationSync/Patches/SpiralPatches.cs new file mode 100644 index 00000000..98f5ab88 --- /dev/null +++ b/QSB/TranslationSync/Patches/SpiralPatches.cs @@ -0,0 +1,62 @@ +using QSB.Events; +using QSB.Patches; + +namespace QSB.TranslationSync.Patches +{ + internal class SpiralPatches : QSBPatch + { + public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect; + + public override void DoPatches() + { + QSBCore.Helper.HarmonyHelper.AddPrefix("SetAsTranslated", typeof(SpiralPatches), nameof(Wall_SetAsTranslated)); + QSBCore.Helper.HarmonyHelper.AddPrefix("SetAsTranslated", typeof(SpiralPatches), nameof(Computer_SetAsTranslated)); + QSBCore.Helper.HarmonyHelper.AddPrefix("SetAsTranslated", typeof(SpiralPatches), nameof(VesselComputer_SetAsTranslated)); + } + + public static bool Wall_SetAsTranslated(NomaiWallText __instance, int id) + { + if (__instance.IsTranslated(id)) + { + return true; + } + GlobalMessenger + .FireEvent( + EventNames.QSBTextTranslated, + NomaiTextType.WallText, + SpiralManager.Instance.GetId(__instance), + id); + return true; + } + + public static bool Computer_SetAsTranslated(NomaiComputer __instance, int id) + { + if (__instance.IsTranslated(id)) + { + return true; + } + GlobalMessenger + .FireEvent( + EventNames.QSBTextTranslated, + NomaiTextType.Computer, + SpiralManager.Instance.GetId(__instance), + id); + return true; + } + + public static bool VesselComputer_SetAsTranslated(NomaiVesselComputer __instance, int id) + { + if (__instance.IsTranslated(id)) + { + return true; + } + GlobalMessenger + .FireEvent( + EventNames.QSBTextTranslated, + NomaiTextType.VesselComputer, + SpiralManager.Instance.GetId(__instance), + id); + return true; + } + } +} diff --git a/QSB/TranslationSync/SpiralManager.cs b/QSB/TranslationSync/SpiralManager.cs new file mode 100644 index 00000000..8da1777a --- /dev/null +++ b/QSB/TranslationSync/SpiralManager.cs @@ -0,0 +1,35 @@ +using QSB.TranslationSync.WorldObjects; +using QSB.WorldSync; +using System.Collections.Generic; +using UnityEngine; + +namespace QSB.TranslationSync +{ + internal class SpiralManager : MonoBehaviour + { + public static SpiralManager Instance { get; private set; } + + private List _nomaiWallTexts; + private List _nomaiComputers; + private List _nomaiVesselComputers; + + public void Awake() + { + Instance = this; + QSBSceneManager.OnUniverseSceneLoaded += OnSceneLoaded; + } + + public void OnDestroy() => QSBSceneManager.OnUniverseSceneLoaded -= OnSceneLoaded; + + private void OnSceneLoaded(OWScene scene) + { + _nomaiWallTexts = QSBWorldSync.Init(); + _nomaiComputers = QSBWorldSync.Init(); + _nomaiVesselComputers = QSBWorldSync.Init(); + } + + public int GetId(NomaiWallText obj) => _nomaiWallTexts.IndexOf(obj); + public int GetId(NomaiComputer obj) => _nomaiComputers.IndexOf(obj); + public int GetId(NomaiVesselComputer obj) => _nomaiVesselComputers.IndexOf(obj); + } +} diff --git a/QSB/TranslationSync/WorldObjects/QSBComputer.cs b/QSB/TranslationSync/WorldObjects/QSBComputer.cs new file mode 100644 index 00000000..44ae373f --- /dev/null +++ b/QSB/TranslationSync/WorldObjects/QSBComputer.cs @@ -0,0 +1,44 @@ +using OWML.Utils; +using QSB.WorldSync; +using System.Collections.Generic; + +namespace QSB.TranslationSync.WorldObjects +{ + internal class QSBComputer : WorldObject + { + public override void Init(NomaiComputer computer, int id) + { + ObjectId = id; + AttachedObject = computer; + } + + public void HandleSetAsTranslated(int id) + { + if (AttachedObject.IsTranslated(id)) + { + return; + } + AttachedObject.SetAsTranslated(id); + } + + public IEnumerable GetTranslatedIds() + { + var activeList = AttachedObject.GetValue>("_activeRingList"); + foreach (var item in activeList) + { + if (AttachedObject.IsTranslated(item.GetEntryID())) + { + yield return item.GetEntryID(); + } + } + var inactiveList = AttachedObject.GetValue>("_inactiveRingList"); + foreach (var item in inactiveList) + { + if (AttachedObject.IsTranslated(item.GetEntryID())) + { + yield return item.GetEntryID(); + } + } + } + } +} diff --git a/QSB/TranslationSync/WorldObjects/QSBVesselComputer.cs b/QSB/TranslationSync/WorldObjects/QSBVesselComputer.cs new file mode 100644 index 00000000..8771b906 --- /dev/null +++ b/QSB/TranslationSync/WorldObjects/QSBVesselComputer.cs @@ -0,0 +1,33 @@ +using OWML.Utils; +using QSB.WorldSync; +using System.Collections.Generic; +using System.Linq; + +namespace QSB.TranslationSync.WorldObjects +{ + internal class QSBVesselComputer : WorldObject + { + public override void Init(NomaiVesselComputer computer, int id) + { + ObjectId = id; + AttachedObject = computer; + } + + public void HandleSetAsTranslated(int id) + { + if (AttachedObject.IsTranslated(id)) + { + return; + } + AttachedObject.SetAsTranslated(id); + } + + public IEnumerable GetTranslatedIds() + { + var rings = AttachedObject.GetValue("_computerRings"); + return rings + .Where(ring => AttachedObject.IsTranslated(ring.GetEntryID())) + .Select(ring => ring.GetEntryID()); + } + } +} diff --git a/QSB/TranslationSync/WorldObjects/QSBWallText.cs b/QSB/TranslationSync/WorldObjects/QSBWallText.cs new file mode 100644 index 00000000..a1d984de --- /dev/null +++ b/QSB/TranslationSync/WorldObjects/QSBWallText.cs @@ -0,0 +1,31 @@ +using OWML.Utils; +using QSB.WorldSync; +using System.Collections.Generic; +using System.Linq; + +namespace QSB.TranslationSync.WorldObjects +{ + internal class QSBWallText : WorldObject + { + public override void Init(NomaiWallText wallText, int id) + { + ObjectId = id; + AttachedObject = wallText; + } + + public void HandleSetAsTranslated(int id) + { + if (AttachedObject.IsTranslated(id)) + { + return; + } + AttachedObject.SetAsTranslated(id); + } + + public IEnumerable GetTranslatedIds() + { + var dict = AttachedObject.GetValue>>("_idToNodeDict"); + return dict.Keys.Where(key => AttachedObject.IsTranslated(key)); + } + } +} diff --git a/QSB/Utility/DebugBoxManager.cs b/QSB/Utility/DebugBoxManager.cs index 6cfbf86f..0dc42770 100644 --- a/QSB/Utility/DebugBoxManager.cs +++ b/QSB/Utility/DebugBoxManager.cs @@ -25,7 +25,7 @@ namespace QSB.Utility { var newBox = Object.Instantiate(_boxPrefab); newBox.SetActive(false); - newBox.transform.parent = parent; + newBox.transform.SetParent(parent); newBox.transform.localPosition = new Vector3(0, vertOffset, 0); newBox.transform.rotation = parent.rotation; var lookAt = newBox.AddComponent(); diff --git a/QSB/WorldSync/QSBWorldSync.cs b/QSB/WorldSync/QSBWorldSync.cs index 6f693222..78b9aa9b 100644 --- a/QSB/WorldSync/QSBWorldSync.cs +++ b/QSB/WorldSync/QSBWorldSync.cs @@ -1,5 +1,5 @@ using OWML.Common; -using QSB.OrbSync; +using QSB.OrbSync.WorldObjects; using QSB.TransformSync; using QSB.Utility; using System; diff --git a/QuantumUNET/Components/QNetworkIdentity.cs b/QuantumUNET/Components/QNetworkIdentity.cs index d5c2b19c..c60c2a6c 100644 --- a/QuantumUNET/Components/QNetworkIdentity.cs +++ b/QuantumUNET/Components/QNetworkIdentity.cs @@ -61,7 +61,7 @@ namespace QuantumUNET.Components } else { - QLog.LogWarning($"SetDynamicAssetId object already has an assetId <{m_AssetId}>"); + QLog.Warning($"SetDynamicAssetId object already has an assetId <{m_AssetId}>"); } } @@ -69,7 +69,7 @@ namespace QuantumUNET.Components { if (ClientAuthorityOwner != null) { - QLog.LogError("SetClientOwner m_ClientAuthorityOwner already set!"); + QLog.Error("SetClientOwner m_ClientAuthorityOwner already set!"); } ClientAuthorityOwner = conn; ClientAuthorityOwner.AddOwnedObject(this); @@ -198,7 +198,7 @@ namespace QuantumUNET.Components } else if (!allowNonZeroNetId) { - QLog.LogWarning($"Object has non-zero netId {NetId} for {gameObject}"); + QLog.Warning($"Object has non-zero netId {NetId} for {gameObject}"); return; } QNetworkServer.instance.SetLocalObjectOnServer(NetId, gameObject); @@ -210,7 +210,7 @@ namespace QuantumUNET.Components } catch (Exception ex) { - QLog.LogFatalError($"Exception in OnStartServer:{ex.Message} {ex.StackTrace}"); + QLog.FatalError($"Exception in OnStartServer:{ex.Message} {ex.StackTrace}"); } } if (QNetworkClient.active && QNetworkServer.localClientActive) @@ -232,7 +232,7 @@ namespace QuantumUNET.Components IsClient = true; } CacheBehaviours(); - QLog.LogDebug($"OnStartClient {gameObject} GUID:{NetId} localPlayerAuthority:{LocalPlayerAuthority}"); + QLog.Debug($"OnStartClient {gameObject} GUID:{NetId} localPlayerAuthority:{LocalPlayerAuthority}"); foreach (var networkBehaviour in m_NetworkBehaviours) { try @@ -242,7 +242,7 @@ namespace QuantumUNET.Components } catch (Exception ex) { - QLog.LogFatalError($"Exception in OnStartClient:{ex.Message} {ex.StackTrace}"); + QLog.FatalError($"Exception in OnStartClient:{ex.Message} {ex.StackTrace}"); } } } @@ -272,7 +272,7 @@ namespace QuantumUNET.Components } catch (Exception ex) { - QLog.LogFatalError($"Exception in OnStopAuthority:{ex.Message} {ex.StackTrace}"); + QLog.FatalError($"Exception in OnStopAuthority:{ex.Message} {ex.StackTrace}"); } } } @@ -287,7 +287,7 @@ namespace QuantumUNET.Components } catch (Exception ex) { - QLog.LogFatalError($"Exception in OnSetLocalVisibility:{ex.Message} {ex.StackTrace}"); + QLog.FatalError($"Exception in OnSetLocalVisibility:{ex.Message} {ex.StackTrace}"); } } } @@ -305,7 +305,7 @@ namespace QuantumUNET.Components } catch (Exception ex) { - QLog.LogFatalError($"Exception in OnCheckObserver:{ex.Message} {ex.StackTrace}"); + QLog.FatalError($"Exception in OnCheckObserver:{ex.Message} {ex.StackTrace}"); } } @@ -324,7 +324,7 @@ namespace QuantumUNET.Components { if (!LocalPlayerAuthority) { - QLog.LogError($"HandleClientAuthority {gameObject} does not have localPlayerAuthority"); + QLog.Error($"HandleClientAuthority {gameObject} does not have localPlayerAuthority"); } else { @@ -347,7 +347,7 @@ namespace QuantumUNET.Components if (networkBehaviour == null) { var cmdHashHandlerName = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash); - QLog.LogFatalError( + QLog.FatalError( $"Found no behaviour for incoming [{cmdHashHandlerName}] on {gameObject}, the server and client should have the same NetworkBehaviour instances [netId={NetId}]."); invokeComponent = null; result = false; @@ -365,18 +365,18 @@ namespace QuantumUNET.Components if (gameObject == null) { var cmdHashHandlerName = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash); - QLog.LogWarning($"SyncEvent [{cmdHashHandlerName}] received for deleted object [netId={NetId}]"); + QLog.Warning($"SyncEvent [{cmdHashHandlerName}] received for deleted object [netId={NetId}]"); } else if (!QNetworkBehaviour.GetInvokerForHashSyncEvent(cmdHash, out var invokeClass, out var cmdDelegate)) { var cmdHashHandlerName2 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash); - QLog.LogFatalError( + QLog.FatalError( $"Found no receiver for incoming [{cmdHashHandlerName2}] on {gameObject}, the server and client should have the same NetworkBehaviour instances [netId={NetId}]."); } else if (!GetInvokeComponent(cmdHash, invokeClass, out var obj)) { var cmdHashHandlerName3 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash); - QLog.LogWarning($"SyncEvent [{cmdHashHandlerName3}] handler not found [netId={NetId}]"); + QLog.Warning($"SyncEvent [{cmdHashHandlerName3}] handler not found [netId={NetId}]"); } else { @@ -389,18 +389,18 @@ namespace QuantumUNET.Components if (gameObject == null) { var cmdHashHandlerName = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash); - QLog.LogWarning($"SyncList [{cmdHashHandlerName}] received for deleted object [netId={NetId}]"); + QLog.Warning($"SyncList [{cmdHashHandlerName}] received for deleted object [netId={NetId}]"); } else if (!QNetworkBehaviour.GetInvokerForHashSyncList(cmdHash, out var invokeClass, out var cmdDelegate)) { var cmdHashHandlerName2 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash); - QLog.LogFatalError( + QLog.FatalError( $"Found no receiver for incoming [{cmdHashHandlerName2}] on {gameObject}, the server and client should have the same NetworkBehaviour instances [netId={NetId}]."); } else if (!GetInvokeComponent(cmdHash, invokeClass, out var obj)) { var cmdHashHandlerName3 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash); - QLog.LogWarning($"SyncList [{cmdHashHandlerName3}] handler not found [netId={NetId}]"); + QLog.Warning($"SyncList [{cmdHashHandlerName3}] handler not found [netId={NetId}]"); } else { @@ -413,18 +413,18 @@ namespace QuantumUNET.Components if (gameObject == null) { var cmdHashHandlerName = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash); - QLog.LogWarning($"Command [{cmdHashHandlerName}] received for deleted object [netId={NetId}]"); + QLog.Warning($"Command [{cmdHashHandlerName}] received for deleted object [netId={NetId}]"); } else if (!QNetworkBehaviour.GetInvokerForHashCommand(cmdHash, out var invokeClass, out var cmdDelegate)) { var cmdHashHandlerName2 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash); - QLog.LogFatalError( + QLog.FatalError( $"Found no receiver for incoming [{cmdHashHandlerName2}] on {gameObject}, the server and client should have the same NetworkBehaviour instances [netId={NetId}]."); } else if (!GetInvokeComponent(cmdHash, invokeClass, out var obj)) { var cmdHashHandlerName3 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash); - QLog.LogWarning($"Command [{cmdHashHandlerName3}] handler not found [netId={NetId}]"); + QLog.Warning($"Command [{cmdHashHandlerName3}] handler not found [netId={NetId}]"); } else { @@ -437,18 +437,18 @@ namespace QuantumUNET.Components if (gameObject == null) { var cmdHashHandlerName = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash); - QLog.LogWarning($"ClientRpc [{cmdHashHandlerName}] received for deleted object [netId={NetId}]"); + QLog.Warning($"ClientRpc [{cmdHashHandlerName}] received for deleted object [netId={NetId}]"); } else if (!QNetworkBehaviour.GetInvokerForHashClientRpc(cmdHash, out var invokeClass, out var cmdDelegate)) { var cmdHashHandlerName2 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash); - QLog.LogFatalError( + QLog.FatalError( $"Found no receiver for incoming [{cmdHashHandlerName2}] on {gameObject}, the server and client should have the same NetworkBehaviour instances [netId={NetId}]."); } else if (!GetInvokeComponent(cmdHash, invokeClass, out var obj)) { var cmdHashHandlerName3 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash); - QLog.LogWarning($"ClientRpc [{cmdHashHandlerName3}] handler not found [netId={NetId}]"); + QLog.Warning($"ClientRpc [{cmdHashHandlerName3}] handler not found [netId={NetId}]"); } else { @@ -494,7 +494,7 @@ namespace QuantumUNET.Components var maxPacketSize = QNetworkServer.maxPacketSize; if (s_UpdateWriter.Position - position > maxPacketSize) { - QLog.LogWarning( + QLog.Warning( $"Large state update of {s_UpdateWriter.Position - position} bytes for netId:{NetId} from script:{networkBehaviour}"); } } @@ -581,15 +581,15 @@ namespace QuantumUNET.Components { if (m_Observers == null) { - QLog.LogError($"AddObserver for {gameObject} observer list is null"); + QLog.Error($"AddObserver for {gameObject} observer list is null"); } else if (m_ObserverConnections.Contains(conn.connectionId)) { - QLog.LogWarning($"Duplicate observer {conn.address} added for {gameObject}"); + QLog.Warning($"Duplicate observer {conn.address} added for {gameObject}"); } else { - QLog.LogDebug($"Added observer {conn.address} added for {gameObject}"); + QLog.Debug($"Added observer {conn.address} added for {gameObject}"); m_Observers.Add(conn); m_ObserverConnections.Add(conn.connectionId); conn.AddToVisList(this); @@ -653,7 +653,7 @@ namespace QuantumUNET.Components { if (!networkConnection3.isReady) { - QLog.LogWarning($"Observer is not ready for {gameObject} {networkConnection3}"); + QLog.Warning($"Observer is not ready for {gameObject} {networkConnection3}"); } else if (initialize || !hashSet2.Contains(networkConnection3)) { @@ -699,22 +699,22 @@ namespace QuantumUNET.Components { if (!IsServer) { - QLog.LogWarning($"Cannot remove authority on client-side. (NetId:{NetId}, Gameobject:{gameObject.name})"); + QLog.Warning($"Cannot remove authority on client-side. (NetId:{NetId}, Gameobject:{gameObject.name})"); return false; } else if (ConnectionToClient != null) { - QLog.LogWarning("RemoveClientAuthority cannot remove authority for a player object"); + QLog.Warning("RemoveClientAuthority cannot remove authority for a player object"); return false; } else if (ClientAuthorityOwner == null) { - QLog.LogWarning($"RemoveClientAuthority for {gameObject} has no clientAuthority owner."); + QLog.Warning($"RemoveClientAuthority for {gameObject} has no clientAuthority owner."); return false; } else if (ClientAuthorityOwner != conn) { - QLog.LogWarning($"RemoveClientAuthority for {gameObject} has different owner."); + QLog.Warning($"RemoveClientAuthority for {gameObject} has different owner."); return false; } ClientAuthorityOwner.RemoveOwnedObject(this); @@ -733,22 +733,22 @@ namespace QuantumUNET.Components { if (!IsServer) { - QLog.LogWarning($"Cannot assign authority on client-side. (NetId:{NetId}, Gameobject:{gameObject.name})"); + QLog.Warning($"Cannot assign authority on client-side. (NetId:{NetId}, Gameobject:{gameObject.name})"); return false; } else if (!LocalPlayerAuthority) { - QLog.LogWarning($"Cannot assign authority on object without LocalPlayerAuthority. (NetId:{NetId}, Gameobject:{gameObject.name})"); + QLog.Warning($"Cannot assign authority on object without LocalPlayerAuthority. (NetId:{NetId}, Gameobject:{gameObject.name})"); return false; } else if (ClientAuthorityOwner != null && conn != ClientAuthorityOwner) { - QLog.LogWarning($"AssignClientAuthority for {gameObject} already has an owner. Use RemoveClientAuthority() first."); + QLog.Warning($"AssignClientAuthority for {gameObject} already has an owner. Use RemoveClientAuthority() first."); return false; } else if (conn == null) { - QLog.LogWarning($"AssignClientAuthority for {gameObject} owner cannot be null. Use RemoveClientAuthority() instead."); + QLog.Warning($"AssignClientAuthority for {gameObject} owner cannot be null. Use RemoveClientAuthority() instead."); return false; } ClientAuthorityOwner = conn; diff --git a/QuantumUNET/Components/QNetworkManager.cs b/QuantumUNET/Components/QNetworkManager.cs index d8c0cd48..a56b8db9 100644 --- a/QuantumUNET/Components/QNetworkManager.cs +++ b/QuantumUNET/Components/QNetworkManager.cs @@ -105,7 +105,7 @@ namespace QuantumUNET.Components { if (singleton != null) { - QLog.LogWarning("Multiple NetworkManagers detected in the scene. Only one NetworkManager can exist at a time. The duplicate NetworkManager will not be used."); + QLog.Warning("Multiple NetworkManagers detected in the scene. Only one NetworkManager can exist at a time. The duplicate NetworkManager will not be used."); Destroy(gameObject); return; } @@ -175,13 +175,13 @@ namespace QuantumUNET.Components { if (!QNetworkServer.Listen(serverBindAddress, networkPort)) { - QLog.LogFatalError($"StartServer listen on {serverBindAddress} failed."); + QLog.FatalError($"StartServer listen on {serverBindAddress} failed."); return false; } } else if (!QNetworkServer.Listen(networkPort)) { - QLog.LogFatalError("StartServer listen failed."); + QLog.FatalError("StartServer listen failed."); return false; } RegisterServerMessages(); @@ -286,7 +286,7 @@ namespace QuantumUNET.Components RegisterClientMessages(client); if (string.IsNullOrEmpty(networkAddress)) { - QLog.LogError("Must set the Network Address field in the manager"); + QLog.Error("Must set the Network Address field in the manager"); return null; } if (useSimulator) @@ -396,7 +396,7 @@ namespace QuantumUNET.Components { if (string.IsNullOrEmpty(newSceneName)) { - QLog.LogError("ServerChangeScene empty scene name"); + QLog.Error("ServerChangeScene empty scene name"); } else { @@ -421,7 +421,7 @@ namespace QuantumUNET.Components { if (string.IsNullOrEmpty(newSceneName)) { - QLog.LogError("ClientChangeScene empty scene name"); + QLog.Error("ClientChangeScene empty scene name"); } else { @@ -452,7 +452,7 @@ namespace QuantumUNET.Components } else { - QLog.LogError("FinishLoadScene client is null"); + QLog.Error("FinishLoadScene client is null"); } if (QNetworkServer.active) { @@ -623,7 +623,7 @@ namespace QuantumUNET.Components QNetworkServer.DestroyPlayersForConnection(conn); if (conn.LastError != NetworkError.Ok) { - QLog.LogError($"ServerDisconnected due to error: {conn.LastError}"); + QLog.Error($"ServerDisconnected due to error: {conn.LastError}"); } } @@ -631,7 +631,7 @@ namespace QuantumUNET.Components { if (conn.PlayerControllers.Count == 0) { - QLog.LogWarning("Ready with no player object"); + QLog.Warning("Ready with no player object"); } QNetworkServer.SetClientReady(conn); } @@ -644,15 +644,15 @@ namespace QuantumUNET.Components { if (playerPrefab == null) { - QLog.LogFatalError("The PlayerPrefab is empty on the QSBNetworkManager. Please setup a PlayerPrefab object."); + QLog.FatalError("The PlayerPrefab is empty on the QSBNetworkManager. Please setup a PlayerPrefab object."); } else if (playerPrefab.GetComponent() == null) { - QLog.LogFatalError("The PlayerPrefab does not have a QSBNetworkIdentity. Please add a QSBNetworkIdentity to the player prefab."); + QLog.FatalError("The PlayerPrefab does not have a QSBNetworkIdentity. Please add a QSBNetworkIdentity to the player prefab."); } else if (playerControllerId < conn.PlayerControllers.Count && conn.PlayerControllers[playerControllerId].IsValid && conn.PlayerControllers[playerControllerId].Gameobject != null) { - QLog.LogWarning("There is already a player at that playerControllerId for this connections."); + QLog.Warning("There is already a player at that playerControllerId for this connections."); } else { @@ -694,7 +694,7 @@ namespace QuantumUNET.Components StopClient(); if (conn.LastError != NetworkError.Ok) { - QLog.LogError($"ClientDisconnected due to error: {conn.LastError}"); + QLog.Error($"ClientDisconnected due to error: {conn.LastError}"); } } diff --git a/QuantumUNET/Components/QNetworkTransform.cs b/QuantumUNET/Components/QNetworkTransform.cs index 5db20658..ecf8d697 100644 --- a/QuantumUNET/Components/QNetworkTransform.cs +++ b/QuantumUNET/Components/QNetworkTransform.cs @@ -196,22 +196,22 @@ namespace QuantumUNET.Components var gameObject = QNetworkServer.FindLocalObject(networkInstanceId); if (gameObject == null) { - QLog.LogWarning("Received NetworkTransform data for GameObject that doesn't exist"); + QLog.Warning("Received NetworkTransform data for GameObject that doesn't exist"); } else { var component = gameObject.GetComponent(); if (component == null) { - QLog.LogWarning("HandleTransform null target"); + QLog.Warning("HandleTransform null target"); } else if (!component.LocalPlayerAuthority) { - QLog.LogWarning("HandleTransform no localPlayerAuthority"); + QLog.Warning("HandleTransform no localPlayerAuthority"); } else if (netMsg.Connection.ClientOwnedObjects == null) { - QLog.LogWarning("HandleTransform object not owned by connection"); + QLog.Warning("HandleTransform object not owned by connection"); } else if (netMsg.Connection.ClientOwnedObjects.Contains(networkInstanceId)) { @@ -220,7 +220,7 @@ namespace QuantumUNET.Components } else { - QLog.LogWarning( + QLog.Warning( $"HandleTransform netId:{networkInstanceId} is not for a valid player"); } } diff --git a/QuantumUNET/Logging/FlagsHelper.cs b/QuantumUNET/Logging/FlagsHelper.cs deleted file mode 100644 index 18d49b0e..00000000 --- a/QuantumUNET/Logging/FlagsHelper.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace QuantumUNET.Logging -{ - // Stolen from here : https://stackoverflow.com/questions/3261451/using-a-bitmask-in-c-sharp - - public static class FlagsHelper - { - public static bool IsSet(T flags, T flag) where T : struct - { - var flagsValue = (int)(object)flags; - var flagValue = (int)(object)flag; - - return (flagsValue & flagValue) != 0; - } - - public static void Set(ref T flags, T flag) where T : struct - { - var flagsValue = (int)(object)flags; - var flagValue = (int)(object)flag; - - flags = (T)(object)(flagsValue | flagValue); - } - - public static void Unset(ref T flags, T flag) where T : struct - { - var flagsValue = (int)(object)flags; - var flagValue = (int)(object)flag; - - flags = (T)(object)(flagsValue & ~flagValue); - } - } -} \ No newline at end of file diff --git a/QuantumUNET/Logging/QLog.cs b/QuantumUNET/Logging/QLog.cs index 9e33b1f6..e712cff5 100644 --- a/QuantumUNET/Logging/QLog.cs +++ b/QuantumUNET/Logging/QLog.cs @@ -1,67 +1,66 @@ -using UnityEngine; - -namespace QuantumUNET.Logging +namespace QuantumUNET.Logging { public static class QLog { - private static QLogType LogType = QLogType.Warning | QLogType.Error | QLogType.FatalError; + public const int DebugType = 0; + public const int LogType = 1; + public const int WarningType = 2; + public const int ErrorType = 3; + public const int FatalErrorType = 4; - public static void SetLogType(QLogType flags) - => LogType = flags; + private static int _currentLog; + private static bool _logDebug => _currentLog <= 0; + private static bool _logLog => _currentLog <= 1; + private static bool _logWarning => _currentLog <= 2; + private static bool _logError => _currentLog <= 3; + private static bool _logFatal => _currentLog <= 4; - public static void SetSpecifcLogType(QLogType flag, bool state) + public static void SetLogType(int level) + => _currentLog = level; + + public static void Debug(string message) { - if (state) - { - FlagsHelper.Set(ref LogType, flag); - return; - } - FlagsHelper.Unset(ref LogType, flag); - } - - public static void LogDebug(string message) - { - if (!FlagsHelper.IsSet(LogType, QLogType.Debug)) + if (_logDebug) { return; } - Debug.Log($"DEBUG : {message}"); + UnityEngine.Debug.Log($"DEBUG : {message}"); } public static void Log(string message) { - if (!FlagsHelper.IsSet(LogType, QLogType.Log)) + if (_logLog) { return; } - Debug.Log($"LOG : {message}"); + UnityEngine.Debug.Log($"LOG : {message}"); } - public static void LogWarning(string message) + public static void Warning(string message) { - if (!FlagsHelper.IsSet(LogType, QLogType.Warning)) + if (_logWarning) { return; } - Debug.LogWarning($"WARN : {message}"); + UnityEngine.Debug.LogWarning($"WARN : {message}"); } - public static void LogError(string message) + public static void Error(string message) { - if (!FlagsHelper.IsSet(LogType, QLogType.Error)) + if (_logError) { return; } - Debug.LogError($"ERROR : {message}"); + UnityEngine.Debug.LogError($"ERROR : {message}"); } - public static void LogFatalError(string message) + public static void FatalError(string message) { - if (!FlagsHelper.IsSet(LogType, QLogType.FatalError)) + if (_logFatal) { return; } - Debug.LogError($"FATAL : {message}"); + UnityEngine.Debug.LogError($"FATAL : {message}"); } } } diff --git a/QuantumUNET/Logging/QLogType.cs b/QuantumUNET/Logging/QLogType.cs deleted file mode 100644 index 9267e0a8..00000000 --- a/QuantumUNET/Logging/QLogType.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace QuantumUNET.Logging -{ - [Flags] - public enum QLogType - { - Debug, - Log, - Warning, - Error, - FatalError - } -} diff --git a/QuantumUNET/QNetworkBehaviour.cs b/QuantumUNET/QNetworkBehaviour.cs index 7c511742..04c08603 100644 --- a/QuantumUNET/QNetworkBehaviour.cs +++ b/QuantumUNET/QNetworkBehaviour.cs @@ -36,7 +36,7 @@ namespace QuantumUNET m_MyView = GetComponent(); if (m_MyView == null) { - QLog.LogFatalError($"There is no QNetworkIdentity on this object (name={name}). Please add one."); + QLog.FatalError($"There is no QNetworkIdentity on this object (name={name}). Please add one."); } myView = m_MyView; } @@ -52,11 +52,11 @@ namespace QuantumUNET { if (!IsLocalPlayer && !HasAuthority) { - QLog.LogWarning("Trying to send command for object without authority."); + QLog.Warning("Trying to send command for object without authority."); } else if (QClientScene.readyConnection == null) { - QLog.LogError($"Send command attempted with no client running [client={ConnectionToServer}]."); + QLog.Error($"Send command attempted with no client running [client={ConnectionToServer}]."); } else { @@ -71,7 +71,7 @@ namespace QuantumUNET { if (!IsServer) { - QLog.LogWarning("ClientRpc call on un-spawned object"); + QLog.Warning("ClientRpc call on un-spawned object"); return; } writer.FinishMessage(); @@ -82,7 +82,7 @@ namespace QuantumUNET { if (!IsServer) { - QLog.LogWarning("TargetRpc call on un-spawned object"); + QLog.Warning("TargetRpc call on un-spawned object"); return; } writer.FinishMessage(); @@ -95,7 +95,7 @@ namespace QuantumUNET { if (!QNetworkServer.active) { - QLog.LogError($"Tried to send event {eventName} on channel {channelId} but QSBNetworkServer isn't active."); + QLog.Error($"Tried to send event {eventName} on channel {channelId} but QSBNetworkServer isn't active."); return; } writer.FinishMessage(); @@ -194,21 +194,21 @@ namespace QuantumUNET bool result; if (!s_CmdHandlerDelegates.TryGetValue(cmdHash, out var invoker)) { - QLog.LogError($"GetInvokerForHash hash:{cmdHash} not found"); + QLog.Error($"GetInvokerForHash hash:{cmdHash} not found"); invokeClass = null; invokeFunction = null; result = false; } else if (invoker == null) { - QLog.LogError($"GetInvokerForHash hash:{cmdHash} invoker null"); + QLog.Error($"GetInvokerForHash hash:{cmdHash} invoker null"); invokeClass = null; invokeFunction = null; result = false; } else if (invoker.invokeType != invokeType) { - QLog.LogError($"GetInvokerForHash hash:{cmdHash} mismatched invokeType"); + QLog.Error($"GetInvokerForHash hash:{cmdHash} mismatched invokeType"); invokeClass = null; invokeFunction = null; result = false; @@ -405,7 +405,7 @@ namespace QuantumUNET networkInstanceId = component.NetId; if (networkInstanceId.IsEmpty()) { - QLog.LogWarning( + QLog.Warning( $"SetSyncVarGameObject GameObject {newGameObject} has a zero netId. Maybe it is not spawned yet?"); } } diff --git a/QuantumUNET/QNetworkClient.cs b/QuantumUNET/QNetworkClient.cs index e600b637..33752c43 100644 --- a/QuantumUNET/QNetworkClient.cs +++ b/QuantumUNET/QNetworkClient.cs @@ -92,12 +92,12 @@ namespace QuantumUNET bool result; if (!active) { - QLog.LogError("Reconnect - NetworkClient must be active"); + QLog.Error("Reconnect - NetworkClient must be active"); result = false; } else if (m_Connection == null) { - QLog.LogError("Reconnect - no old connection exists"); + QLog.Error("Reconnect - no old connection exists"); result = false; } else @@ -135,12 +135,12 @@ namespace QuantumUNET bool result; if (!active) { - QLog.LogError("Reconnect - NetworkClient must be active"); + QLog.Error("Reconnect - NetworkClient must be active"); result = false; } else if (m_Connection == null) { - QLog.LogError("Reconnect - no old connection exists"); + QLog.Error("Reconnect - no old connection exists"); result = false; } else @@ -153,13 +153,13 @@ namespace QuantumUNET hostId = NetworkTransport.AddHost(hostTopology, m_HostPort); if (secureTunnelEndPoint == null) { - QLog.LogError("Reconnect failed: null endpoint passed in"); + QLog.Error("Reconnect failed: null endpoint passed in"); m_AsyncConnect = ConnectState.Failed; result = false; } else if (secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetwork && secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetworkV6) { - QLog.LogError("Reconnect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6"); + QLog.Error("Reconnect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6"); m_AsyncConnect = ConnectState.Failed; result = false; } @@ -174,7 +174,7 @@ namespace QuantumUNET } else if (fullName != "UnityEngine.XboxOne.XboxOneEndPoint" && fullName != "UnityEngine.PS4.SceEndPoint") { - QLog.LogError("Reconnect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint or SceEndPoint)"); + QLog.Error("Reconnect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint or SceEndPoint)"); m_AsyncConnect = ConnectState.Failed; result = false; } @@ -189,13 +189,13 @@ namespace QuantumUNET } catch (Exception arg) { - QLog.LogError($"Reconnect failed: Exception when trying to connect to EndPoint: {arg}"); + QLog.Error($"Reconnect failed: Exception when trying to connect to EndPoint: {arg}"); m_AsyncConnect = ConnectState.Failed; return false; } if (m_ClientConnectionId == 0) { - QLog.LogError($"Reconnect failed: Unable to connect to EndPoint ({b})"); + QLog.Error($"Reconnect failed: Unable to connect to EndPoint ({b})"); m_AsyncConnect = ConnectState.Failed; result = false; } @@ -257,12 +257,12 @@ namespace QuantumUNET QLog.Log("Client Connect to remoteSockAddr"); if (secureTunnelEndPoint == null) { - QLog.LogError("Connect failed: null endpoint passed in"); + QLog.Error("Connect failed: null endpoint passed in"); m_AsyncConnect = ConnectState.Failed; } else if (secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetwork && secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetworkV6) { - QLog.LogError("Connect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6"); + QLog.Error("Connect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6"); m_AsyncConnect = ConnectState.Failed; } else @@ -275,7 +275,7 @@ namespace QuantumUNET } else if (fullName != "UnityEngine.XboxOne.XboxOneEndPoint" && fullName != "UnityEngine.PS4.SceEndPoint" && fullName != "UnityEngine.PSVita.SceEndPoint") { - QLog.LogError("Connect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint or SceEndPoint)"); + QLog.Error("Connect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint or SceEndPoint)"); m_AsyncConnect = ConnectState.Failed; } else @@ -289,13 +289,13 @@ namespace QuantumUNET } catch (Exception arg) { - QLog.LogError($"Connect failed: Exception when trying to connect to EndPoint: {arg}"); + QLog.Error($"Connect failed: Exception when trying to connect to EndPoint: {arg}"); m_AsyncConnect = ConnectState.Failed; return; } if (m_ClientConnectionId == 0) { - QLog.LogError($"Connect failed: Unable to connect to EndPoint ({b})"); + QLog.Error($"Connect failed: Unable to connect to EndPoint ({b})"); m_AsyncConnect = ConnectState.Failed; } else @@ -345,7 +345,7 @@ namespace QuantumUNET var networkClient = (QNetworkClient)ar.AsyncState; if (array.Length == 0) { - QLog.LogError($"DNS lookup failed for:{networkClient.m_RequestedServerHost}"); + QLog.Error($"DNS lookup failed for:{networkClient.m_RequestedServerHost}"); networkClient.m_AsyncConnect = ConnectState.Failed; } else @@ -359,8 +359,8 @@ namespace QuantumUNET catch (SocketException ex) { var networkClient2 = (QNetworkClient)ar.AsyncState; - QLog.LogError($"DNS resolution failed: {ex.GetErrorCode()}"); - QLog.LogError($"Exception:{ex}"); + QLog.Error($"DNS resolution failed: {ex.GetErrorCode()}"); + QLog.Error($"Exception:{ex}"); networkClient2.m_AsyncConnect = ConnectState.Failed; } } @@ -412,7 +412,7 @@ namespace QuantumUNET { if (m_AsyncConnect != ConnectState.Connected) { - QLog.LogError("NetworkClient Send when not connected to a server"); + QLog.Error("NetworkClient Send when not connected to a server"); result = false; } else @@ -422,7 +422,7 @@ namespace QuantumUNET } else { - QLog.LogError("NetworkClient Send with no connection"); + QLog.Error("NetworkClient Send with no connection"); result = false; } return result; @@ -435,7 +435,7 @@ namespace QuantumUNET { if (m_AsyncConnect != ConnectState.Connected) { - QLog.LogError("NetworkClient SendWriter when not connected to a server"); + QLog.Error("NetworkClient SendWriter when not connected to a server"); result = false; } else @@ -445,7 +445,7 @@ namespace QuantumUNET } else { - QLog.LogError("NetworkClient SendWriter with no connection"); + QLog.Error("NetworkClient SendWriter with no connection"); result = false; } return result; @@ -458,7 +458,7 @@ namespace QuantumUNET { if (m_AsyncConnect != ConnectState.Connected) { - QLog.LogError("NetworkClient SendBytes when not connected to a server"); + QLog.Error("NetworkClient SendBytes when not connected to a server"); result = false; } else @@ -468,7 +468,7 @@ namespace QuantumUNET } else { - QLog.LogError("NetworkClient SendBytes with no connection"); + QLog.Error("NetworkClient SendBytes with no connection"); result = false; } return result; @@ -481,7 +481,7 @@ namespace QuantumUNET { if (m_AsyncConnect != ConnectState.Connected) { - QLog.LogError("NetworkClient SendUnreliable when not connected to a server"); + QLog.Error("NetworkClient SendUnreliable when not connected to a server"); result = false; } else @@ -491,7 +491,7 @@ namespace QuantumUNET } else { - QLog.LogError("NetworkClient SendUnreliable with no connection"); + QLog.Error("NetworkClient SendUnreliable with no connection"); result = false; } return result; @@ -504,7 +504,7 @@ namespace QuantumUNET { if (m_AsyncConnect != ConnectState.Connected) { - QLog.LogError("NetworkClient SendByChannel when not connected to a server"); + QLog.Error("NetworkClient SendByChannel when not connected to a server"); result = false; } else @@ -514,7 +514,7 @@ namespace QuantumUNET } else { - QLog.LogError("NetworkClient SendByChannel with no connection"); + QLog.Error("NetworkClient SendByChannel with no connection"); result = false; } return result; @@ -524,7 +524,7 @@ namespace QuantumUNET { if (m_Connection == null) { - QLog.LogWarning("SetMaxDelay failed, not connected."); + QLog.Warning("SetMaxDelay failed, not connected."); } else { @@ -622,7 +622,7 @@ namespace QuantumUNET break; default: - QLog.LogError($"Unknown network message type received: {networkEventType}"); + QLog.Error($"Unknown network message type received: {networkEventType}"); break; } if (++num >= 500) @@ -657,19 +657,19 @@ namespace QuantumUNET private void GenerateConnectError(int error) { - QLog.LogError($"UNet Client Error Connect Error: {error}"); + QLog.Error($"UNet Client Error Connect Error: {error}"); GenerateError(error); } private void GenerateDataError(int error) { - QLog.LogError($"UNet Client Data Error: {(NetworkError)error}"); + QLog.Error($"UNet Client Data Error: {(NetworkError)error}"); GenerateError(error); } private void GenerateDisconnectError(int error) { - QLog.LogError($"UNet Client Disconnect Error: {(NetworkError)error}"); + QLog.Error($"UNet Client Disconnect Error: {(NetworkError)error}"); GenerateError(error); } diff --git a/QuantumUNET/QNetworkConnection.cs b/QuantumUNET/QNetworkConnection.cs index e337db6f..9eafb43a 100644 --- a/QuantumUNET/QNetworkConnection.cs +++ b/QuantumUNET/QNetworkConnection.cs @@ -196,7 +196,7 @@ namespace QuantumUNET return; } } - QLog.LogError($"RemovePlayer player at playerControllerId {playerControllerId} not found"); + QLog.Error($"RemovePlayer player at playerControllerId {playerControllerId} not found"); } internal bool GetPlayerController(short playerControllerId, out QPlayerController playerController) @@ -284,12 +284,12 @@ namespace QuantumUNET bool result; if (m_Channels == null) { - QLog.LogWarning($"Channels not initialized sending on id '{channelId}"); + QLog.Warning($"Channels not initialized sending on id '{channelId}"); result = false; } else if (channelId < 0 || channelId >= m_Channels.Length) { - QLog.LogError( + QLog.Error( $"Invalid channel when sending buffered data, '{channelId}'. Current channel count is {m_Channels.Length}"); result = false; } @@ -325,7 +325,7 @@ namespace QuantumUNET } if (networkMessageDelegate == null) { - QLog.LogError($"Unknown message ID {num2} connId:{connectionId}"); + QLog.Error($"Unknown message ID {num2} connId:{connectionId}"); break; } m_NetMsg.MsgType = num2; diff --git a/QuantumUNET/QNetworkMessageHandlers.cs b/QuantumUNET/QNetworkMessageHandlers.cs index 49b9a3c2..d341f326 100644 --- a/QuantumUNET/QNetworkMessageHandlers.cs +++ b/QuantumUNET/QNetworkMessageHandlers.cs @@ -12,11 +12,11 @@ namespace QuantumUNET { if (handler == null) { - QLog.LogError($"RegisterHandlerSafe id:{msgType} handler is null"); + QLog.Error($"RegisterHandlerSafe id:{msgType} handler is null"); } else { - QLog.LogDebug($"RegisterHandlerSafe id:{msgType} handler:{handler.GetMethodName()}"); + QLog.Debug($"RegisterHandlerSafe id:{msgType} handler:{handler.GetMethodName()}"); if (!_msgHandlers.ContainsKey(msgType)) { _msgHandlers.Add(msgType, handler); @@ -28,11 +28,11 @@ namespace QuantumUNET { if (handler == null) { - QLog.LogError($"RegisterHandler id:{msgType} handler is null"); + QLog.Error($"RegisterHandler id:{msgType} handler is null"); } else if (msgType <= 31) { - QLog.LogError($"RegisterHandler: Cannot replace system message handler {msgType}"); + QLog.Error($"RegisterHandler: Cannot replace system message handler {msgType}"); } else { @@ -41,7 +41,7 @@ namespace QuantumUNET QLog.Log($"RegisterHandler replacing {msgType}"); _msgHandlers.Remove(msgType); } - QLog.LogDebug($"RegisterHandler id:{msgType} handler:{handler.GetMethodName()}"); + QLog.Debug($"RegisterHandler id:{msgType} handler:{handler.GetMethodName()}"); _msgHandlers.Add(msgType, handler); } } diff --git a/QuantumUNET/QNetworkServer.cs b/QuantumUNET/QNetworkServer.cs index 391074aa..7160db5c 100644 --- a/QuantumUNET/QNetworkServer.cs +++ b/QuantumUNET/QNetworkServer.cs @@ -164,7 +164,7 @@ namespace QuantumUNET int result; if (m_LocalConnectionsFakeList.Count != 0) { - QLog.LogError("Local Connection already exists"); + QLog.Error("Local Connection already exists"); result = -1; } else @@ -203,7 +203,7 @@ namespace QuantumUNET internal void SetLocalObjectOnServer(NetworkInstanceId netId, GameObject obj) { - QLog.LogDebug($"SetLocalObjectOnServer {netId} {obj}"); + QLog.Debug($"SetLocalObjectOnServer {netId} {obj}"); m_NetworkScene.SetLocalObject(netId, obj, false, true); } @@ -226,7 +226,7 @@ namespace QuantumUNET public static bool SendToAll(short msgType, QMessageBase msg) { - QLog.LogDebug($"Server.SendToAll msgType:{msgType}"); + QLog.Debug($"Server.SendToAll msgType:{msgType}"); var flag = true; foreach (var networkConnection in connections) { @@ -240,7 +240,7 @@ namespace QuantumUNET private static bool SendToObservers(GameObject contextObj, short msgType, QMessageBase msg) { - QLog.LogDebug($"Server.SendToObservers id:{msgType}"); + QLog.Debug($"Server.SendToObservers id:{msgType}"); var flag = true; var component = contextObj.GetComponent(); bool result; @@ -263,7 +263,7 @@ namespace QuantumUNET public static bool SendToReady(GameObject contextObj, short msgType, QMessageBase msg) { - QLog.LogDebug($"Server.SendToReady id:{msgType}"); + QLog.Debug($"Server.SendToReady id:{msgType}"); bool result; if (contextObj == null) { @@ -329,7 +329,7 @@ namespace QuantumUNET } if (!flag) { - QLog.LogError("SendBytesToReady failed"); + QLog.Error("SendBytesToReady failed"); } } else @@ -352,12 +352,12 @@ namespace QuantumUNET } if (!flag2) { - QLog.LogError($"SendBytesToReady failed for {contextObj}"); + QLog.Error($"SendBytesToReady failed for {contextObj}"); } } catch (NullReferenceException) { - QLog.LogError($"SendBytesToReady object {contextObj} has not been spawned"); + QLog.Error($"SendBytesToReady object {contextObj} has not been spawned"); } } } @@ -558,7 +558,7 @@ namespace QuantumUNET { if (controller.Gameobject != null) { - QLog.LogWarning("Player not destroyed when connection disconnected."); + QLog.Warning("Player not destroyed when connection disconnected."); } } QLog.Log($"Server lost client:{conn.connectionId}"); @@ -570,19 +570,19 @@ namespace QuantumUNET private void GenerateConnectError(int error) { - QLog.LogError($"UNet Server Connect Error: {error}"); + QLog.Error($"UNet Server Connect Error: {error}"); GenerateError(null, error); } private void GenerateDataError(QNetworkConnection conn, int error) { - QLog.LogError($"UNet Server Data Error: {(NetworkError)error}"); + QLog.Error($"UNet Server Data Error: {(NetworkError)error}"); GenerateError(conn, error); } private void GenerateDisconnectError(QNetworkConnection conn, int error) { - QLog.LogError($"UNet Server Disconnect Error: {(NetworkError)error} conn:[{conn}]:{conn.connectionId}"); + QLog.Error($"UNet Server Disconnect Error: {(NetworkError)error} conn:[{conn}]:{conn.connectionId}"); GenerateError(conn, error); } @@ -659,7 +659,7 @@ namespace QuantumUNET } } } - QLog.LogError($"Failed to send message to player object '{player.name}, not found in connection list"); + QLog.Error($"Failed to send message to player object '{player.name}, not found in connection list"); } public static void SendToClient(int connectionId, short msgType, QMessageBase msg) @@ -673,7 +673,7 @@ namespace QuantumUNET return; } } - QLog.LogError($"Failed to send message to connection ID '{connectionId}, not found in connection list"); + QLog.Error($"Failed to send message to connection ID '{connectionId}, not found in connection list"); } public static bool AddPlayerForConnection(QNetworkConnection conn, GameObject player, short playerControllerId) => instance.InternalAddPlayerForConnection(conn, player, playerControllerId); @@ -739,7 +739,7 @@ namespace QuantumUNET bool result; if (playerControllerId < 0) { - QLog.LogError($"AddPlayer: playerControllerId of {playerControllerId} is negative"); + QLog.Error($"AddPlayer: playerControllerId of {playerControllerId} is negative"); result = false; } else if (playerControllerId > 32) @@ -751,7 +751,7 @@ namespace QuantumUNET { if (playerControllerId > 16) { - QLog.LogWarning($"AddPlayer: playerControllerId of {playerControllerId} is unusually high"); + QLog.Warning($"AddPlayer: playerControllerId of {playerControllerId} is unusually high"); } result = true; } @@ -802,7 +802,7 @@ namespace QuantumUNET bool result; if (!GetNetworkIdentity(playerGameObject, out var networkIdentity)) { - QLog.LogError($"ReplacePlayer: playerGameObject has no NetworkIdentity. Please add a NetworkIdentity to {playerGameObject}"); + QLog.Error($"ReplacePlayer: playerGameObject has no NetworkIdentity. Please add a NetworkIdentity to {playerGameObject}"); result = false; } else if (!CheckPlayerControllerIdForConnection(conn, playerControllerId)) @@ -846,7 +846,7 @@ namespace QuantumUNET bool result; if (view == null) { - QLog.LogError("UNET failure. GameObject doesn't have NetworkIdentity."); + QLog.Error("UNET failure. GameObject doesn't have NetworkIdentity."); result = false; } else @@ -869,7 +869,7 @@ namespace QuantumUNET { if (conn.PlayerControllers.Count == 0) { - QLog.LogWarning("Ready with no player object"); + QLog.Warning("Ready with no player object"); } conn.isReady = true; if (conn is QULocalConnectionToClient) @@ -904,11 +904,11 @@ namespace QuantumUNET { if (networkIdentity2 == null) { - QLog.LogWarning("Invalid object found in server local object list (null NetworkIdentity)."); + QLog.Warning("Invalid object found in server local object list (null NetworkIdentity)."); } else if (networkIdentity2.gameObject.activeSelf) { - QLog.LogDebug( + QLog.Debug( $"Sending spawn message for current server objects name='{networkIdentity2.gameObject.name}' netId={networkIdentity2.NetId}"); var flag2 = networkIdentity2.OnCheckObserver(conn); if (flag2) @@ -981,7 +981,7 @@ namespace QuantumUNET } else { - QLog.LogError( + QLog.Error( $"Received remove player message but could not find the player ID: {s_RemovePlayerMessage.PlayerControllerId}"); } } @@ -993,14 +993,14 @@ namespace QuantumUNET var gameObject = FindLocalObject(networkInstanceId); if (gameObject == null) { - QLog.LogWarning($"Instance not found when handling Command message [netId={networkInstanceId}]"); + QLog.Warning($"Instance not found when handling Command message [netId={networkInstanceId}]"); } else { var component = gameObject.GetComponent(); if (component == null) { - QLog.LogWarning( + QLog.Warning( $"NetworkIdentity deleted when handling Command message [netId={networkInstanceId}]"); } else @@ -1018,7 +1018,7 @@ namespace QuantumUNET { if (component.ClientAuthorityOwner != netMsg.Connection) { - QLog.LogWarning($"Command for object without authority [netId={networkInstanceId}]"); + QLog.Warning($"Command for object without authority [netId={networkInstanceId}]"); return; } } @@ -1032,12 +1032,12 @@ namespace QuantumUNET { if (!active) { - QLog.LogError( + QLog.Error( $"SpawnObject for {obj}, NetworkServer is not active. Cannot spawn objects without an active server."); } else if (!GetNetworkIdentity(obj, out var networkIdentity)) { - QLog.LogError($"SpawnObject {obj} has no QSBNetworkIdentity. Please add a NetworkIdentity to {obj}"); + QLog.Error($"SpawnObject {obj} has no QSBNetworkIdentity. Please add a NetworkIdentity to {obj}"); } else { @@ -1105,7 +1105,7 @@ namespace QuantumUNET { if (conn.PlayerControllers.Count == 0) { - QLog.LogWarning("Empty player list given to NetworkServer.Destroy(), nothing to do."); + QLog.Warning("Empty player list given to NetworkServer.Destroy(), nothing to do."); } else { @@ -1202,7 +1202,7 @@ namespace QuantumUNET bool result; if (CheckForPrefab(obj)) { - QLog.LogError($"GameObject {obj.name} is a prefab, it can't be spawned. This will cause errors in builds."); + QLog.Error($"GameObject {obj.name} is a prefab, it can't be spawned. This will cause errors in builds."); result = false; } else @@ -1218,12 +1218,12 @@ namespace QuantumUNET bool result; if (component == null) { - QLog.LogError("SpawnWithClientAuthority player object has no NetworkIdentity"); + QLog.Error("SpawnWithClientAuthority player object has no NetworkIdentity"); result = false; } else if (component.ConnectionToClient == null) { - QLog.LogError("SpawnWithClientAuthority player object is not a player."); + QLog.Error("SpawnWithClientAuthority player object is not a player."); result = false; } else @@ -1238,7 +1238,7 @@ namespace QuantumUNET bool result; if (!conn.isReady) { - QLog.LogError("SpawnWithClientAuthority NetworkConnection is not ready!"); + QLog.Error("SpawnWithClientAuthority NetworkConnection is not ready!"); result = false; } else @@ -1304,7 +1304,7 @@ namespace QuantumUNET } else { - QLog.LogError($"Local invoke: Failed to find local connection to invoke handler on [connectionId={conn.connectionId}] for MsgId:{msgType}"); + QLog.Error($"Local invoke: Failed to find local connection to invoke handler on [connectionId={conn.connectionId}] for MsgId:{msgType}"); result = false; } return result; diff --git a/QuantumUNET/QuantumUNET.csproj b/QuantumUNET/QuantumUNET.csproj index 0f9ab2c1..971dbe6d 100644 --- a/QuantumUNET/QuantumUNET.csproj +++ b/QuantumUNET/QuantumUNET.csproj @@ -64,7 +64,6 @@ - @@ -72,7 +71,6 @@ - diff --git a/README.md b/README.md index ddbabb7c..89f850b1 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ along with this program. If not, see . - [FAQs](#frequently-asked-questions) + - [Requirements](#requirements) - [What is synced?](#what-is-currently-synced) - [Why can't I connect?](#why-cant-i-connect-to-a-server) - [Installation](#installation) @@ -37,6 +38,14 @@ along with this program. If not, see . ## Frequently Asked Questions +### Requirements +- Latest version of OWML. +- Latest version of Mod Manager. (If using) +- Latest version of Outer Wilds. (Epic version preferred, as Steam version is untestable.) +- Fast and stable internet connection, upload and download. +- Should be able to run on minimum Outer Wilds system requirements. +- Ability to port forward. + ### What is currently synced? QSB does not operate on a strict server-client relationship. Each player's game is left as a completely seperate game, and individual elemets are synced or patched so they can be controlled though network messages. Right now, the list of synced objects are : - Geysers @@ -47,6 +56,14 @@ QSB does not operate on a strict server-client relationship. Each player's game - Player ships - Player probes - NPC heads in conversations +- Ship log +- Discovering frequencies / signals +- Nomai text (Spirals + Computers) + +QSB also changes some mechanics of the base game, to better fit a multiplayer experience. These include : +- Adding dialogue boxes above NPC and player heads, so other players can "listen in" on conversations. +- Quantum objects check observations from all players and all player probes. +- When dying from any cause other than the supernova, the ATP black hole, or the end of the game, the player respawns instantly at Timber Hearth. ### Why can't I connect to a server? #### For the host :