From e557cadba0fe98dd1d92e38f137dcc093e21b1a7 Mon Sep 17 00:00:00 2001 From: _nebula <41904486+misternebula@users.noreply.github.com> Date: Sat, 5 Aug 2023 12:50:21 +0100 Subject: [PATCH 01/24] dont send message for non serializable stuff --- QSB/Player/Messages/RequestStateResyncMessage.cs | 5 +++++ QSB/Player/PlayerInfo.cs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/QSB/Player/Messages/RequestStateResyncMessage.cs b/QSB/Player/Messages/RequestStateResyncMessage.cs index 347e5317..7b40cf26 100644 --- a/QSB/Player/Messages/RequestStateResyncMessage.cs +++ b/QSB/Player/Messages/RequestStateResyncMessage.cs @@ -55,6 +55,11 @@ public class RequestStateResyncMessage : QSBMessage // Initial sync of all custom data from APIs foreach (var kvp in QSBPlayerManager.LocalPlayer._customData) { + if (!kvp.Value.GetType().IsSerializable) + { + continue; + } + new AddonCustomDataSyncMessage(QSBPlayerManager.LocalPlayerId, kvp.Key, kvp.Value) { To = From }.Send(); } } diff --git a/QSB/Player/PlayerInfo.cs b/QSB/Player/PlayerInfo.cs index 81b1bcac..202491c0 100644 --- a/QSB/Player/PlayerInfo.cs +++ b/QSB/Player/PlayerInfo.cs @@ -188,7 +188,7 @@ public partial class PlayerInfo { _customData[key] = data; - if (!QSBPatch.Remote) + if (!QSBPatch.Remote && typeof(T).IsSerializable) { new AddonCustomDataSyncMessage(PlayerId, key, data).Send(); } From 52f698ea5c7e85ac1ed78b15f2ae05e8a7ec7e81 Mon Sep 17 00:00:00 2001 From: _nebula <41904486+misternebula@users.noreply.github.com> Date: Tue, 8 Aug 2023 11:21:02 +0100 Subject: [PATCH 02/24] add config.json --- QSB/QSB.csproj | 3 +++ QSB/config.json | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 QSB/config.json diff --git a/QSB/QSB.csproj b/QSB/QSB.csproj index 4065ce97..363c2803 100644 --- a/QSB/QSB.csproj +++ b/QSB/QSB.csproj @@ -45,6 +45,9 @@ True \ + + PreserveNewest + PreserveNewest diff --git a/QSB/config.json b/QSB/config.json new file mode 100644 index 00000000..aac83985 --- /dev/null +++ b/QSB/config.json @@ -0,0 +1,48 @@ +{ + "$schema": "https://raw.githubusercontent.com/ow-mods/owml/master/schemas/config_schema.json", + "enabled": true, + "settings": { + "useKcpTransport": { + "title": "Use KCP Transport", + "type": "toggle", + "value": true, + "tooltip": "Use alternative transport that requires port forwarding but seems to be more reliable. The port to forward is 7777 as TCP/UDP. Use this if you are having trouble connecting. ALL PLAYERS MUST HAVE THIS AS THE SAME VALUE." + }, + "defaultServerIP": { + "title": "Last Entered IP/ID", + "type": "text", + "value": "localhost", + "tooltip": "Used if you leave the connect prompt blank." + }, + "incompatibleModsAllowed": { + "title": "Incompatible Mods Allowed", + "type": "toggle", + "value": false, + "tooltip": "Kicks players if they have certain mods." + }, + "showPlayerNames": { + "title": "Show Player Names", + "type": "toggle", + "value": true, + "tooltip": "Shows player names in the HUD and the map view." + }, + "shipDamage": { + "title": "Ship Damage", + "type": "toggle", + "value": true, + "tooltip": "Take impact damage when inside the ship." + }, + "showExtraHud": { + "title": "Show Extra HUD Elements", + "type": "toggle", + "value": true, + "tooltip": "Show extra HUD elements, like player status and minimap icons." + }, + "textChatInput": { + "title": "Text Chat Input", + "type": "toggle", + "value": true, + "tooltip": "Disable this if using NomaiVR, or any other mod with conflicting inputs." + } + } +} \ No newline at end of file From 2d25316637c1f8ad1288686061d83d8e4808e1b9 Mon Sep 17 00:00:00 2001 From: _nebula <41904486+misternebula@users.noreply.github.com> Date: Tue, 8 Aug 2023 11:45:10 +0100 Subject: [PATCH 03/24] add latency simulation --- QSB/QSBNetworkManager.cs | 25 +++++++++++++++++++++++-- QSB/Utility/DebugSettings.cs | 3 +++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/QSB/QSBNetworkManager.cs b/QSB/QSBNetworkManager.cs index 2cf83cbe..6250eea9 100644 --- a/QSB/QSBNetworkManager.cs +++ b/QSB/QSBNetworkManager.cs @@ -68,6 +68,7 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart private (TransportError error, string reason) _lastTransportError = (TransportError.Unexpected, "transport did not give an error. uh oh"); + private static LatencySimulation _latencyTransport; private static kcp2k.KcpTransport _kcpTransport; private static EosTransport _eosTransport; @@ -78,6 +79,7 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart { _kcpTransport = gameObject.AddComponent(); } + { // https://dev.epicgames.com/portal/en-US/qsb/sdk/credentials/qsb var eosApiKey = ScriptableObject.CreateInstance(); @@ -95,7 +97,16 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart _eosTransport = gameObject.AddComponent(); } - transport = QSBCore.UseKcpTransport ? _kcpTransport : _eosTransport; + + { + _latencyTransport = gameObject.AddComponent(); + _latencyTransport.reliableLatency = QSBCore.DebugSettings.LatencySimulation; + _latencyTransport.wrap = QSBCore.UseKcpTransport ? _kcpTransport : _eosTransport; + } + + transport = QSBCore.DebugSettings.LatencySimulation > 0 + ? _latencyTransport + : QSBCore.UseKcpTransport ? _kcpTransport : _eosTransport; gameObject.SetActive(true); @@ -164,10 +175,20 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart { return; } + if (singleton != null) { - singleton.transport = Transport.active = QSBCore.UseKcpTransport ? _kcpTransport : _eosTransport; + if (QSBCore.DebugSettings.LatencySimulation > 0) + { + _latencyTransport.wrap = QSBCore.UseKcpTransport ? _kcpTransport : _eosTransport; + singleton.transport = Transport.active = _latencyTransport; + } + else + { + singleton.transport = Transport.active = QSBCore.UseKcpTransport ? _kcpTransport : _eosTransport; + } } + if (MenuManager.Instance != null) { MenuManager.Instance.OnLanguageChanged(); // hack to update text diff --git a/QSB/Utility/DebugSettings.cs b/QSB/Utility/DebugSettings.cs index c1da6cca..f2e16f58 100644 --- a/QSB/Utility/DebugSettings.cs +++ b/QSB/Utility/DebugSettings.cs @@ -26,6 +26,9 @@ public class DebugSettings [JsonProperty("disableLoopDeath")] public bool DisableLoopDeath; + [JsonProperty("latencySimulation")] + public int LatencySimulation; + [JsonProperty("debugMode")] public bool DebugMode; From 8a6d774ead243edab16ad4220938eeb0c002bdce Mon Sep 17 00:00:00 2001 From: _nebula <41904486+misternebula@users.noreply.github.com> Date: Tue, 8 Aug 2023 16:15:02 +0100 Subject: [PATCH 04/24] im dumb --- QSB/QSBNetworkManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QSB/QSBNetworkManager.cs b/QSB/QSBNetworkManager.cs index 6250eea9..f11bbbe7 100644 --- a/QSB/QSBNetworkManager.cs +++ b/QSB/QSBNetworkManager.cs @@ -100,7 +100,7 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart { _latencyTransport = gameObject.AddComponent(); - _latencyTransport.reliableLatency = QSBCore.DebugSettings.LatencySimulation; + _latencyTransport.reliableLatency = _latencyTransport.unreliableLatency = QSBCore.DebugSettings.LatencySimulation; _latencyTransport.wrap = QSBCore.UseKcpTransport ? _kcpTransport : _eosTransport; } From c378ecc7b60df96d30e1eba2453b71aaa2526578 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 8 Aug 2023 16:19:53 -0700 Subject: [PATCH 05/24] Revert "add config.json" This reverts commit 52f698ea5c7e85ac1ed78b15f2ae05e8a7ec7e81. --- QSB/QSB.csproj | 3 --- QSB/config.json | 48 ------------------------------------------------ 2 files changed, 51 deletions(-) delete mode 100644 QSB/config.json diff --git a/QSB/QSB.csproj b/QSB/QSB.csproj index 363c2803..4065ce97 100644 --- a/QSB/QSB.csproj +++ b/QSB/QSB.csproj @@ -45,9 +45,6 @@ True \ - - PreserveNewest - PreserveNewest diff --git a/QSB/config.json b/QSB/config.json deleted file mode 100644 index aac83985..00000000 --- a/QSB/config.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/ow-mods/owml/master/schemas/config_schema.json", - "enabled": true, - "settings": { - "useKcpTransport": { - "title": "Use KCP Transport", - "type": "toggle", - "value": true, - "tooltip": "Use alternative transport that requires port forwarding but seems to be more reliable. The port to forward is 7777 as TCP/UDP. Use this if you are having trouble connecting. ALL PLAYERS MUST HAVE THIS AS THE SAME VALUE." - }, - "defaultServerIP": { - "title": "Last Entered IP/ID", - "type": "text", - "value": "localhost", - "tooltip": "Used if you leave the connect prompt blank." - }, - "incompatibleModsAllowed": { - "title": "Incompatible Mods Allowed", - "type": "toggle", - "value": false, - "tooltip": "Kicks players if they have certain mods." - }, - "showPlayerNames": { - "title": "Show Player Names", - "type": "toggle", - "value": true, - "tooltip": "Shows player names in the HUD and the map view." - }, - "shipDamage": { - "title": "Ship Damage", - "type": "toggle", - "value": true, - "tooltip": "Take impact damage when inside the ship." - }, - "showExtraHud": { - "title": "Show Extra HUD Elements", - "type": "toggle", - "value": true, - "tooltip": "Show extra HUD elements, like player status and minimap icons." - }, - "textChatInput": { - "title": "Text Chat Input", - "type": "toggle", - "value": true, - "tooltip": "Disable this if using NomaiVR, or any other mod with conflicting inputs." - } - } -} \ No newline at end of file From 5f11c487a648925820f690a777d0f5639a32d76f Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 8 Aug 2023 16:29:24 -0700 Subject: [PATCH 06/24] null check in OnClientReceive --- QSB/Messaging/QSBMessageManager.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/QSB/Messaging/QSBMessageManager.cs b/QSB/Messaging/QSBMessageManager.cs index 6bc4964d..94c86a51 100644 --- a/QSB/Messaging/QSBMessageManager.cs +++ b/QSB/Messaging/QSBMessageManager.cs @@ -69,6 +69,11 @@ public static class QSBMessageManager private static void OnClientReceive(QSBMessage msg) { + if (msg == null) + { + return; + } + if (PlayerTransformSync.LocalInstance == null) { DebugLog.ToConsole($"Warning - Tried to handle message {msg} before local player was established.", MessageType.Warning); From 2b2eddd462da8a0f5c0f12adbc894d9ff9d59dca Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 8 Aug 2023 20:16:18 -0700 Subject: [PATCH 07/24] doc --- APITestMod/IQSBAPI.cs | 2 +- QSB/API/IQSBAPI.cs | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/APITestMod/IQSBAPI.cs b/APITestMod/IQSBAPI.cs index 7fe3b560..8f795e0e 100644 --- a/APITestMod/IQSBAPI.cs +++ b/APITestMod/IQSBAPI.cs @@ -56,7 +56,7 @@ public interface IQSBAPI /// /// Sets some arbitrary data for a given player. /// - /// The type of the data. + /// The type of the data. If not serializable, data will not be synced. /// The ID of the player. /// The unique key to access this data by. /// The data to set. diff --git a/QSB/API/IQSBAPI.cs b/QSB/API/IQSBAPI.cs index 3cb193a5..8f795e0e 100644 --- a/QSB/API/IQSBAPI.cs +++ b/QSB/API/IQSBAPI.cs @@ -55,10 +55,8 @@ public interface IQSBAPI /// /// Sets some arbitrary data for a given player. - /// - /// Not synced. /// - /// The type of the data. + /// The type of the data. If not serializable, data will not be synced. /// The ID of the player. /// The unique key to access this data by. /// The data to set. @@ -66,8 +64,6 @@ public interface IQSBAPI /// /// Returns some arbitrary data from a given player. - /// - /// Not synced. /// /// The type of the data. /// The ID of the player. From 42a033249ac30100cc7e4311ba4e90d00cdf567f Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 8 Aug 2023 20:26:46 -0700 Subject: [PATCH 08/24] RegisterNotRequiredForAllPlayers: check NetworkBehaviour too --- QSB/QSBCore.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/QSB/QSBCore.cs b/QSB/QSBCore.cs index 8b22b71c..ed263a6a 100644 --- a/QSB/QSBCore.cs +++ b/QSB/QSBCore.cs @@ -242,7 +242,9 @@ public class QSBCore : ModBehaviour foreach (var type in addonAssembly.GetTypes()) { - if (typeof(WorldObjectManager).IsAssignableFrom(type) || typeof(IWorldObject).IsAssignableFrom(type)) + if (typeof(WorldObjectManager).IsAssignableFrom(type) || + typeof(IWorldObject).IsAssignableFrom(type) || + typeof(NetworkBehaviour).IsAssignableFrom(type)) { DebugLog.ToConsole($"Addon \"{uniqueName}\" cannot be cosmetic, as it creates networking objects.", MessageType.Error); return; From 4b62d53b172d3783e30898a9b8cdf53a84eeb443 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 9 Aug 2023 13:05:32 -0400 Subject: [PATCH 09/24] Fix my name and also credit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c6c82af..c49525e0 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ See [DEVELOPMENT.md](DEVELOPMENT.md) - [Chris Yeninas](https://github.com/PhantomGamers) - Help with project files and GitHub workflows. - [Tlya](https://github.com/Tllya) - Russian translation. -- [Xen](https://github.com/xen-42) - French translation, and help with particle effects and sounds. +- [xen](https://github.com/xen-42) - French translation, and help with syncing particle/sound effects, fixing lantern item bugs, and syncing addon data. - [ShoosGun](https://github.com/ShoosGun) - Portuguese translation. - [DertolleDude](https://github.com/DertolleDude) - German translation. - [SakuradaYuki](https://github.com/SakuradaYuki) - Chinese translation. From 901a736db59a377f55006b1aefc979cb1d8310ec Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 9 Aug 2023 13:31:40 -0400 Subject: [PATCH 10/24] Shouldn't build when changing these files --- .github/workflows/build.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 535998df..1fa379e1 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,11 @@ name: Build -on: push +on: + push: + paths-ignore: + - "*.md" + - "LICENSE" + - ".gitignore" jobs: build: From 8cef0f9a6d05cec2c8ff19324dc62ba9b4505674 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Wed, 9 Aug 2023 13:29:46 -0700 Subject: [PATCH 11/24] remove debug message for addon data, addons dev should just do this themselves --- QSB/API/AddonDataManager.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/QSB/API/AddonDataManager.cs b/QSB/API/AddonDataManager.cs index 8de5e1a9..1652b156 100644 --- a/QSB/API/AddonDataManager.cs +++ b/QSB/API/AddonDataManager.cs @@ -11,7 +11,6 @@ public static class AddonDataManager public static void OnReceiveDataMessage(int hash, object data, uint from) { - DebugLog.DebugWrite($"Received addon message of with hash {hash} from {from}!"); if (!_handlers.TryGetValue(hash, out var handler)) { DebugLog.DebugWrite($"unknown addon message type with hash {hash}", MessageType.Error); @@ -22,7 +21,6 @@ public static class AddonDataManager public static void RegisterHandler(int hash, Action handler) { - DebugLog.DebugWrite($"Registering addon message handler for hash {hash} with type {typeof(T).Name}"); _handlers.Add(hash, (from, data) => handler(from, (T)data)); } } From 8cb47041e8616d1fdb90ccfd5a16e83adc9a06fd Mon Sep 17 00:00:00 2001 From: _nebula <41904486+misternebula@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:46:47 +0100 Subject: [PATCH 12/24] remove old taunts stuff --- QSB/Inputs/QSBInputManager.cs | 44 ----------------------------------- 1 file changed, 44 deletions(-) diff --git a/QSB/Inputs/QSBInputManager.cs b/QSB/Inputs/QSBInputManager.cs index 05150c7a..62aa90ec 100644 --- a/QSB/Inputs/QSBInputManager.cs +++ b/QSB/Inputs/QSBInputManager.cs @@ -5,50 +5,6 @@ namespace QSB.Inputs; public class QSBInputManager : MonoBehaviour, IAddComponentOnStart { - // TODO : finish instruments - disabled for 0.7.0 release - /* - public static event Action ChertTaunt; - public static event Action EskerTaunt; - public static event Action RiebeckTaunt; - public static event Action GabbroTaunt; - public static event Action FeldsparTaunt; - public static event Action ExitTaunt; - - public void Update() - { - if (Input.GetKey(KeyCode.T)) - { - // Listed order is from sun to dark bramble - if (Input.GetKeyDown(KeyCode.Alpha1)) - { - ChertTaunt?.Invoke(); - } - else if (Input.GetKeyDown(KeyCode.Alpha2)) - { - EskerTaunt?.Invoke(); - } - else if (Input.GetKeyDown(KeyCode.Alpha5)) - { - RiebeckTaunt?.Invoke(); - } - else if (Input.GetKeyDown(KeyCode.Alpha4)) - { - GabbroTaunt?.Invoke(); - } - else if (Input.GetKeyDown(KeyCode.Alpha3)) - { - FeldsparTaunt?.Invoke(); - } - } - - if (OWInput.GetValue(InputLibrary.moveXZ, InputMode.None) != Vector2.zero - || OWInput.GetValue(InputLibrary.jump, InputMode.None) != 0f) - { - ExitTaunt?.Invoke(); - } - } - */ - public static QSBInputManager Instance { get; private set; } public void Start() From 0fc0715048e982917a9fa2cf2a1599169ea45e7e Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Wed, 23 Aug 2023 14:51:56 -0700 Subject: [PATCH 13/24] test --- QSB/API/AddonDataManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QSB/API/AddonDataManager.cs b/QSB/API/AddonDataManager.cs index 1652b156..ce25078d 100644 --- a/QSB/API/AddonDataManager.cs +++ b/QSB/API/AddonDataManager.cs @@ -14,7 +14,7 @@ public static class AddonDataManager if (!_handlers.TryGetValue(hash, out var handler)) { DebugLog.DebugWrite($"unknown addon message type with hash {hash}", MessageType.Error); - return; + return; // test } handler(from, data); } From 63a5a13342f92a3936aeb975c1d4823103c464e5 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Wed, 23 Aug 2023 16:03:51 -0700 Subject: [PATCH 14/24] Revert "test" This reverts commit 0fc0715048e982917a9fa2cf2a1599169ea45e7e. --- QSB/API/AddonDataManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QSB/API/AddonDataManager.cs b/QSB/API/AddonDataManager.cs index ce25078d..1652b156 100644 --- a/QSB/API/AddonDataManager.cs +++ b/QSB/API/AddonDataManager.cs @@ -14,7 +14,7 @@ public static class AddonDataManager if (!_handlers.TryGetValue(hash, out var handler)) { DebugLog.DebugWrite($"unknown addon message type with hash {hash}", MessageType.Error); - return; // test + return; } handler(from, data); } From 55a9c533ab76ed4442ee1f450f5b569990b47840 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Fri, 1 Sep 2023 12:17:27 -0700 Subject: [PATCH 15/24] RegisterNotRequiredForAllPlayers: update doc, i meant to do this earlier --- QSB/QSBCore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QSB/QSBCore.cs b/QSB/QSBCore.cs index ed263a6a..5a4ab2c4 100644 --- a/QSB/QSBCore.cs +++ b/QSB/QSBCore.cs @@ -232,7 +232,7 @@ public class QSBCore : ModBehaviour /// /// Registers an addon that shouldn't be considered for hash checks when joining. - /// This addon MUST NOT send any network messages, or create any worldobjects. + /// This addon MUST NOT create any WorldObjects or NetworkBehaviours. /// /// The behaviour of the addon. public static void RegisterNotRequiredForAllPlayers(IModBehaviour addon) From 2c02873e78a883443a0a2be36190ac46b24e0400 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 2 Sep 2023 23:04:46 -0700 Subject: [PATCH 16/24] update debug actions --- DEVELOPMENT.md | 14 ++++++++------ QSB/Utility/DebugActions.cs | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 2277524a..564bfea5 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -19,12 +19,12 @@ We recommend using the Outer Wilds Mod Manager, but you can use OWML on its own - New Manager : Press the "..." button at the top, and select "Show OWML Folder". - `QSB.sln` should now be ready to open. ***This solution needs to be opened with Visual Studio 2022 or higher!*** -## Steam +## Multiple instances on Steam If using the Steam version of Outer Wilds, you will need to create a file to allow you to run multiple instances of the game. - Navigate to your game install folder. You can find this by right-clicking on the game in Steam, and going `Manage > Browse local files`. - Create a file named `steam_appid.txt`. -- In this file, write `753640` and save. -This file will override some Steam DRM features and allow the game to be ran multiple times at once. +- In this file, write `753640` and save. This file will override some Steam DRM features and allow the game to be ran multiple times at once. +- Either turn on "Force Exe" in the mod manager, or run OuterWilds.exe directly. ## Building Simply build the solution normally. (`Build > Build Solution` or CTRL-SHIFT-B) @@ -48,16 +48,18 @@ Use the API by copying [the API definition](https://github.com/misternebula/quan ## Debugging ### Debug Actions : +Press Q + Numpad Enter to toggle debug mode in game (corresponds with the debug setting "debugMode" in the section below). + Hold Q and press : - Numpad 1 - Teleport to nearest player. -- Numpad 2 - If holding LeftShift, warp to the dreamworld Vault fire. If not, warp to the Endless Canyon. +- Numpad 2 - If holding LeftShift, warp to the dreamworld Vault fire. If not, warp to the Endless Canyon. If already in dreamworld, pick up lantern. - Numpad 3 - Unlock the Sealed Vault. - Numpad 4 - Damage the ship's electrical system. - Numpad 5 - Trigger the supernova. - Numpad 6 - Set the flags for having met Solanum and the Prisoner. -- Numpad 7 - Warp to the Vessel. -- Numpad 8 - Insert the Advanced Warp Core into the Vessel. +- Numpad 7 - Warp to the Vessel and insert the warp core. +- Numpad 8 - Spawn a fake player. For Ghostbuster testing. - Numpad 9 - If holding LeftShift, load the SolarSystem scene. If not, load the EyeOfTheUniverse scene. - Numpad 0 - Revive a random dead player. diff --git a/QSB/Utility/DebugActions.cs b/QSB/Utility/DebugActions.cs index 4749c8cc..8ea9721a 100644 --- a/QSB/Utility/DebugActions.cs +++ b/QSB/Utility/DebugActions.cs @@ -170,7 +170,7 @@ public class DebugActions : MonoBehaviour, IAddComponentOnStart var dreamLanternItem = QSBWorldSync.GetWorldObjects().First(x => x.AttachedObject._lanternType == DreamLanternType.Functioning && QSBPlayerManager.PlayerList.All(y => y.HeldItem != x) && - !x.AttachedObject.GetLanternController().IsLit() + !x.AttachedObject.GetLanternController().IsLit() // lit = someone else is holding. backup in case held item isnt initial state synced ).AttachedObject; Locator.GetToolModeSwapper().GetItemCarryTool().PickUpItemInstantly(dreamLanternItem); } From 89ab73af81eecf5fc881a4efe6922bb938e13b73 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 2 Sep 2023 23:05:26 -0700 Subject: [PATCH 17/24] make this more clear --- DEVELOPMENT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 564bfea5..978a09cc 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -65,7 +65,7 @@ Hold Q and press : ### Debug Settings : -Create a file called `debugsettings.json` in the mod folder. +Create a file called `debugsettings.json` in the qsb folder. The template for this file is this : ```json From 9a30458ed1ddddf33c32e0da8aef6129f78c03fd Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 2 Sep 2023 23:06:42 -0700 Subject: [PATCH 18/24] capitalize QSB oops --- DEVELOPMENT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 978a09cc..0bb5f48c 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -65,7 +65,7 @@ Hold Q and press : ### Debug Settings : -Create a file called `debugsettings.json` in the qsb folder. +Create a file called `debugsettings.json` in the QSB folder. The template for this file is this : ```json From aa0143ec7b7b60c70ed9637d8eb8e7bfc2dad9b0 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 2 Sep 2023 23:14:47 -0700 Subject: [PATCH 19/24] bump owml --- APITestMod/APITestMod.csproj | 2 +- APITestMod/manifest.json | 2 +- EpicRerouter/EpicRerouter.csproj | 2 +- MirrorWeaver/MirrorWeaver.csproj | 2 +- QSB/QSB.csproj | 2 +- QSB/manifest.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/APITestMod/APITestMod.csproj b/APITestMod/APITestMod.csproj index e74118fb..c00112a8 100644 --- a/APITestMod/APITestMod.csproj +++ b/APITestMod/APITestMod.csproj @@ -10,7 +10,7 @@ - + diff --git a/APITestMod/manifest.json b/APITestMod/manifest.json index 60efa966..0c2a22a9 100644 --- a/APITestMod/manifest.json +++ b/APITestMod/manifest.json @@ -4,6 +4,6 @@ "name": "QSB API Test Mod", "uniqueName": "_nebula.QSBAPITest", "version": "1.0.0", - "owmlVersion": "2.9.5", + "owmlVersion": "2.9.7", "dependencies": [ "Raicuparta.QuantumSpaceBuddies", "_nebula.MenuFramework" ] } diff --git a/EpicRerouter/EpicRerouter.csproj b/EpicRerouter/EpicRerouter.csproj index a49e2189..7c5d6582 100644 --- a/EpicRerouter/EpicRerouter.csproj +++ b/EpicRerouter/EpicRerouter.csproj @@ -15,6 +15,6 @@ - + diff --git a/MirrorWeaver/MirrorWeaver.csproj b/MirrorWeaver/MirrorWeaver.csproj index 27fa86ea..45f161d3 100644 --- a/MirrorWeaver/MirrorWeaver.csproj +++ b/MirrorWeaver/MirrorWeaver.csproj @@ -9,7 +9,7 @@ - + diff --git a/QSB/QSB.csproj b/QSB/QSB.csproj index 4065ce97..a194c8a0 100644 --- a/QSB/QSB.csproj +++ b/QSB/QSB.csproj @@ -69,7 +69,7 @@ - + diff --git a/QSB/manifest.json b/QSB/manifest.json index e4d62b67..a9812b9c 100644 --- a/QSB/manifest.json +++ b/QSB/manifest.json @@ -8,7 +8,7 @@ }, "uniqueName": "Raicuparta.QuantumSpaceBuddies", "version": "0.30.2", - "owmlVersion": "2.9.5", + "owmlVersion": "2.9.7", "dependencies": [ "_nebula.MenuFramework", "JohnCorby.VanillaFix" ], "pathsToPreserve": [ "debugsettings.json" ], "requireLatestVersion": true From 81f9360a81b9df9f9c84f454e624864cacc075cc Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sun, 3 Sep 2023 12:36:46 -0700 Subject: [PATCH 20/24] update version for etherpod --- QSB/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QSB/manifest.json b/QSB/manifest.json index a9812b9c..22f7b19a 100644 --- a/QSB/manifest.json +++ b/QSB/manifest.json @@ -7,7 +7,7 @@ "body": "- Disable *all* other mods. (Can heavily affect performance)\n- Make sure you are not running any other network-intensive applications." }, "uniqueName": "Raicuparta.QuantumSpaceBuddies", - "version": "0.30.2", + "version": "0.30.3", "owmlVersion": "2.9.7", "dependencies": [ "_nebula.MenuFramework", "JohnCorby.VanillaFix" ], "pathsToPreserve": [ "debugsettings.json" ], From 93b8c00240c7ac3074c56b078e90ad3aff8826a6 Mon Sep 17 00:00:00 2001 From: _nebula <41904486+misternebula@users.noreply.github.com> Date: Fri, 8 Sep 2023 11:21:50 +0100 Subject: [PATCH 21/24] fix resharper??? --- QSB/QSB.csproj.DotSettings | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 QSB/QSB.csproj.DotSettings diff --git a/QSB/QSB.csproj.DotSettings b/QSB/QSB.csproj.DotSettings new file mode 100644 index 00000000..b5b235a9 --- /dev/null +++ b/QSB/QSB.csproj.DotSettings @@ -0,0 +1,2 @@ + + Default \ No newline at end of file From 7a1a7deb2e21d0f5f84b251fb882e0840c9473da Mon Sep 17 00:00:00 2001 From: _nebula <41904486+misternebula@users.noreply.github.com> Date: Fri, 8 Sep 2023 11:23:01 +0100 Subject: [PATCH 22/24] add chat method + event to api --- APITestMod/APITestMod.cs | 4 ++++ APITestMod/IQSBAPI.cs | 20 ++++++++++++++++++++ QSB/API/IQSBAPI.cs | 20 ++++++++++++++++++++ QSB/API/QSBAPI.cs | 14 ++++++++++++++ QSB/HUD/Messages/ChatMessage.cs | 23 +++++++++++++++++++++++ QSB/HUD/MultiplayerHUDManager.cs | 7 ++++++- 6 files changed, 87 insertions(+), 1 deletion(-) diff --git a/APITestMod/APITestMod.cs b/APITestMod/APITestMod.cs index 50c26fc2..1d3fb575 100644 --- a/APITestMod/APITestMod.cs +++ b/APITestMod/APITestMod.cs @@ -23,6 +23,7 @@ public class APITestMod : ModBehaviour qsbAPI.OnPlayerJoin().AddListener((uint playerId) => ModHelper.Console.WriteLine($"{playerId} joined the game!", MessageType.Success)); qsbAPI.OnPlayerLeave().AddListener((uint playerId) => ModHelper.Console.WriteLine($"{playerId} left the game!", MessageType.Success)); + qsbAPI.OnChatMessage().AddListener((string message, uint from) => ModHelper.Console.WriteLine($"Chat message \"{message}\" from {from} ({(from == uint.MaxValue ? "QSB" : qsbAPI.GetPlayerName(from))})")); button.onClick.AddListener(() => { @@ -52,6 +53,9 @@ public class APITestMod : ModBehaviour ModHelper.Console.WriteLine("Sending float message test..."); qsbAPI.RegisterHandler("apitest-float", MessageHandler); qsbAPI.SendMessage("apitest-float", 3.14f, receiveLocally: true); + + qsbAPI.SendChatMessage("Non-system chat message", false, Color.white); + qsbAPI.SendChatMessage("System chat message", true, Color.cyan); }); }; } diff --git a/APITestMod/IQSBAPI.cs b/APITestMod/IQSBAPI.cs index 8f795e0e..eadb98ce 100644 --- a/APITestMod/IQSBAPI.cs +++ b/APITestMod/IQSBAPI.cs @@ -1,5 +1,6 @@ using System; using OWML.Common; +using UnityEngine; using UnityEngine.Events; public interface IQSBAPI @@ -96,4 +97,23 @@ public interface IQSBAPI void RegisterHandler(string messageType, Action handler); #endregion + + #region Chat + + /// + /// Invoked when a chat message is received. + /// The string is the message body. + /// The uint is the player who sent the message. If it's a system message, this is uint.MaxValue. + /// + UnityEvent OnChatMessage(); + + /// + /// Sends a message in chat. + /// + /// The text of the message. + /// If false, the message is sent as if the local player wrote it manually. If true, the message has no player attached to it, like the player join messages. + /// The color of the message. + void SendChatMessage(string message, bool systemMessage, Color color); + + #endregion } diff --git a/QSB/API/IQSBAPI.cs b/QSB/API/IQSBAPI.cs index 8f795e0e..eadb98ce 100644 --- a/QSB/API/IQSBAPI.cs +++ b/QSB/API/IQSBAPI.cs @@ -1,5 +1,6 @@ using System; using OWML.Common; +using UnityEngine; using UnityEngine.Events; public interface IQSBAPI @@ -96,4 +97,23 @@ public interface IQSBAPI void RegisterHandler(string messageType, Action handler); #endregion + + #region Chat + + /// + /// Invoked when a chat message is received. + /// The string is the message body. + /// The uint is the player who sent the message. If it's a system message, this is uint.MaxValue. + /// + UnityEvent OnChatMessage(); + + /// + /// Sends a message in chat. + /// + /// The text of the message. + /// If false, the message is sent as if the local player wrote it manually. If true, the message has no player attached to it, like the player join messages. + /// The color of the message. + void SendChatMessage(string message, bool systemMessage, Color color); + + #endregion } diff --git a/QSB/API/QSBAPI.cs b/QSB/API/QSBAPI.cs index 9fe0969c..1430e142 100644 --- a/QSB/API/QSBAPI.cs +++ b/QSB/API/QSBAPI.cs @@ -5,7 +5,10 @@ using QSB.Messaging; using QSB.Player; using System; using System.Linq; +using QSB.HUD; +using QSB.HUD.Messages; using UnityEngine.Events; +using UnityEngine; namespace QSB.API; @@ -35,6 +38,17 @@ public class QSBAPI : IQSBAPI public void RegisterHandler(string messageType, Action handler) => AddonDataManager.RegisterHandler(messageType.GetStableHashCode(), handler); + + public UnityEvent OnChatMessage() => MultiplayerHUDManager.OnChatMessageEvent; + + public void SendChatMessage(string message, bool systemMessage, Color color) + { + var fromName = systemMessage + ? "QSB" + : QSBPlayerManager.LocalPlayer.Name; + + new ChatMessage($"{fromName}: {message}", color).Send(); + } } internal static class QSBAPIEvents diff --git a/QSB/HUD/Messages/ChatMessage.cs b/QSB/HUD/Messages/ChatMessage.cs index b8333299..b21e1e24 100644 --- a/QSB/HUD/Messages/ChatMessage.cs +++ b/QSB/HUD/Messages/ChatMessage.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using QSB.Player; using UnityEngine; namespace QSB.HUD.Messages; @@ -17,5 +18,27 @@ public class ChatMessage : QSBMessage<(string message, Color color)> public override void OnReceiveRemote() { MultiplayerHUDManager.Instance.WriteMessage(Data.message, Data.color); + + var fromPlayer = QSBPlayerManager.GetPlayer(From); + var qsb = false; + string name; + if (Data.message.StartsWith("QSB: ")) + { + name = "QSB: "; + qsb = true; + } + else if (Data.message.StartsWith($"{fromPlayer.Name}: ")) + { + name = $"{fromPlayer.Name}: "; + } + else + { + // uhhh idk what happened + MultiplayerHUDManager.OnChatMessageEvent.Invoke(Data.message, From); + return; + } + + var messageWithoutName = Data.message.Remove(Data.message.IndexOf(name), name.Length); + MultiplayerHUDManager.OnChatMessageEvent.Invoke(messageWithoutName, qsb ? uint.MaxValue : From); } } \ No newline at end of file diff --git a/QSB/HUD/MultiplayerHUDManager.cs b/QSB/HUD/MultiplayerHUDManager.cs index 36a77183..ec719592 100644 --- a/QSB/HUD/MultiplayerHUDManager.cs +++ b/QSB/HUD/MultiplayerHUDManager.cs @@ -9,6 +9,7 @@ using QSB.WorldSync; using System; using System.Linq; using UnityEngine; +using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.SceneManagement; using UnityEngine.UI; @@ -42,6 +43,9 @@ public class MultiplayerHUDManager : MonoBehaviour, IAddComponentOnStart public static readonly ListStack HUDIconStack = new(true); + public class ChatEvent : UnityEvent { } + public static readonly ChatEvent OnChatMessageEvent = new(); + private void Start() { Instance = this; @@ -87,7 +91,8 @@ public class MultiplayerHUDManager : MonoBehaviour, IAddComponentOnStart // perks of being a qsb dev :-) public void WriteSystemMessage(string message, Color color) { - WriteMessage(message, color); + WriteMessage($"QSB: {message}", color); + OnChatMessageEvent.Invoke(message, uint.MaxValue); } public void WriteMessage(string message, Color color) From 8e52797aef7baf5af4fdcfaa76c98d43e79d5e0f Mon Sep 17 00:00:00 2001 From: _nebula <41904486+misternebula@users.noreply.github.com> Date: Fri, 8 Sep 2023 11:23:19 +0100 Subject: [PATCH 23/24] fix api test mod trying to re-register handlers --- APITestMod/APITestMod.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/APITestMod/APITestMod.cs b/APITestMod/APITestMod.cs index 1d3fb575..e3e7ad7f 100644 --- a/APITestMod/APITestMod.cs +++ b/APITestMod/APITestMod.cs @@ -25,6 +25,10 @@ public class APITestMod : ModBehaviour qsbAPI.OnPlayerLeave().AddListener((uint playerId) => ModHelper.Console.WriteLine($"{playerId} left the game!", MessageType.Success)); qsbAPI.OnChatMessage().AddListener((string message, uint from) => ModHelper.Console.WriteLine($"Chat message \"{message}\" from {from} ({(from == uint.MaxValue ? "QSB" : qsbAPI.GetPlayerName(from))})")); + qsbAPI.RegisterHandler("apitest-string", MessageHandler); + qsbAPI.RegisterHandler("apitest-int", MessageHandler); + qsbAPI.RegisterHandler("apitest-float", MessageHandler); + button.onClick.AddListener(() => { ModHelper.Console.WriteLine("TESTING QSB API!"); @@ -43,15 +47,12 @@ public class APITestMod : ModBehaviour ModHelper.Console.WriteLine($"Retreiving custom data : {qsbAPI.GetCustomData(qsbAPI.GetLocalPlayerID(), "APITEST.TESTSTRING")}"); ModHelper.Console.WriteLine("Sending string message test..."); - qsbAPI.RegisterHandler("apitest-string", MessageHandler); qsbAPI.SendMessage("apitest-string", "STRING MESSAGE", receiveLocally: true); ModHelper.Console.WriteLine("Sending int message test..."); - qsbAPI.RegisterHandler("apitest-int", MessageHandler); qsbAPI.SendMessage("apitest-int", 123, receiveLocally: true); ModHelper.Console.WriteLine("Sending float message test..."); - qsbAPI.RegisterHandler("apitest-float", MessageHandler); qsbAPI.SendMessage("apitest-float", 3.14f, receiveLocally: true); qsbAPI.SendChatMessage("Non-system chat message", false, Color.white); From 9ff0b729786a4242775a407613e8e9fc4e2a8593 Mon Sep 17 00:00:00 2001 From: _nebula <41904486+misternebula@users.noreply.github.com> Date: Fri, 8 Sep 2023 12:47:31 +0100 Subject: [PATCH 24/24] add copy-id command --- QSB/Utility/CommandInterpreter.cs | 37 ++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/QSB/Utility/CommandInterpreter.cs b/QSB/Utility/CommandInterpreter.cs index f402d559..f8ebe042 100644 --- a/QSB/Utility/CommandInterpreter.cs +++ b/QSB/Utility/CommandInterpreter.cs @@ -1,6 +1,6 @@ -using QSB.HUD; +using EpicTransport; +using QSB.HUD; using QSB.Messaging; -using QSB.ShipSync; using QSB.ShipSync.Messages; using QSB.WorldSync; using System.Linq; @@ -25,14 +25,39 @@ public class CommandInterpreter : MonoBehaviour, IAddComponentOnStart case "ship": ShipCommand(commandParts.Skip(1).ToArray()); break; + case "copy-id": + CopyProductUserID(); + break; default: - MultiplayerHUDManager.Instance.WriteMessage($"Unknown command \"{command}\".", Color.red); + WriteToChat($"Unknown command \"{command}\".", Color.red); break; } return true; } + private static void WriteToChat(string message, Color color) + { + // TODO : make italics work in chat so we can use them here + MultiplayerHUDManager.Instance.WriteMessage(message, color); + } + + public static void CopyProductUserID() + { + if (QSBCore.UseKcpTransport) + { + WriteToChat($"Cannot get Product User ID for KCP-hosted server.", Color.red); + return; + } + + var productUserID = QSBCore.IsHost + ? EOSSDKComponent.LocalUserProductIdString + : QSBNetworkManager.singleton.networkAddress; + + GUIUtility.systemCopyBuffer = productUserID; + WriteToChat($"Copied {productUserID} to the clipboard.", Color.green); + } + public static void ShipCommand(string[] arguments) { var command = arguments[0]; @@ -40,7 +65,7 @@ public class CommandInterpreter : MonoBehaviour, IAddComponentOnStart switch (command) { case "explode": - MultiplayerHUDManager.Instance.WriteMessage($"Blowing up the ship.", Color.green); + WriteToChat($"Blowing up the ship.", Color.green); var shipDamageController = Locator.GetShipTransform().GetComponentInChildren(); shipDamageController.Explode(); break; @@ -56,7 +81,7 @@ public class CommandInterpreter : MonoBehaviour, IAddComponentOnStart default: break; } - MultiplayerHUDManager.Instance.WriteMessage($"{(damage ? "Damaging" : "Repairing")} the {arguments[1]}.", Color.green); + WriteToChat($"{(damage ? "Damaging" : "Repairing")} the {arguments[1]}.", Color.green); break; case "open-hatch": QSBWorldSync.GetUnityObject().OpenHatch(); @@ -67,7 +92,7 @@ public class CommandInterpreter : MonoBehaviour, IAddComponentOnStart new HatchMessage(false).Send(); break; default: - MultiplayerHUDManager.Instance.WriteMessage($"Unknown ship command \"{command}\".", Color.red); + WriteToChat($"Unknown ship command \"{command}\".", Color.red); break; } }