From 875d269781e78de485e67cb816bad22a22b5f54e Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 26 Aug 2022 18:21:13 -0400 Subject: [PATCH 01/29] Sync probe launcher rotation, allow one person to use at a time --- .../RotatingElementsVariableSyncer.cs | 2 +- QSB/QSBNetworkManager.cs | 5 + .../StationaryProbeLauncherMessage.cs | 11 ++ .../Patches/StationaryProbeLauncherPatches.cs | 27 +++++ .../StationaryProbeLauncherManager.cs | 15 +++ .../StationaryProbeLauncherTransformSync.cs | 35 ++++++ .../QSBStationaryProbeLauncher.cs | 108 ++++++++++++++++++ .../ProbeLauncherTool/ProbeLauncherManager.cs | 2 +- 8 files changed, 203 insertions(+), 2 deletions(-) create mode 100644 QSB/StationaryProbeLauncherSync/Messages/StationaryProbeLauncherMessage.cs create mode 100644 QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs create mode 100644 QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs create mode 100644 QSB/StationaryProbeLauncherSync/TransformSync/StationaryProbeLauncherTransformSync.cs create mode 100644 QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs diff --git a/QSB/EchoesOfTheEye/RotatingElementsVariableSyncer.cs b/QSB/EchoesOfTheEye/RotatingElementsVariableSyncer.cs index c510a730..271bf807 100644 --- a/QSB/EchoesOfTheEye/RotatingElementsVariableSyncer.cs +++ b/QSB/EchoesOfTheEye/RotatingElementsVariableSyncer.cs @@ -8,7 +8,7 @@ using UnityEngine; namespace QSB.EchoesOfTheEye; -internal abstract class RotatingElementsVariableSyncer : BaseVariableSyncer, ILinkedNetworkBehaviour +public abstract class RotatingElementsVariableSyncer : BaseVariableSyncer, ILinkedNetworkBehaviour where TWorldObject : IWorldObject { public override void OnStartClient() diff --git a/QSB/QSBNetworkManager.cs b/QSB/QSBNetworkManager.cs index 78fb5359..e32a6cf9 100644 --- a/QSB/QSBNetworkManager.cs +++ b/QSB/QSBNetworkManager.cs @@ -24,6 +24,7 @@ using QSB.Player.TransformSync; using QSB.SaveSync; using QSB.ShipSync; using QSB.ShipSync.TransformSync; +using QSB.StationaryProbeLauncherSync.TransformSync; using QSB.Syncs.Occasional; using QSB.TimeSync; using QSB.Tools.ProbeTool.TransformSync; @@ -56,6 +57,7 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart public GameObject ShipModulePrefab { get; private set; } public GameObject ShipLegPrefab { get; private set; } public GameObject ModelShipPrefab { get; private set; } + public GameObject StationaryProbeLauncherPrefab { get; private set; } private string PlayerName { get; set; } private GameObject _probePrefab; @@ -149,6 +151,9 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart ModelShipPrefab = MakeNewNetworkObject(14, "NetworkModelShip", typeof(ModelShipTransformSync)); spawnPrefabs.Add(ModelShipPrefab); + StationaryProbeLauncherPrefab = MakeNewNetworkObject(15, "NetworkStationaryProbeLauncher", typeof(StationaryProbeLauncherTransformSync)); + spawnPrefabs.Add(StationaryProbeLauncherPrefab); + ConfigureNetworkManager(); } diff --git a/QSB/StationaryProbeLauncherSync/Messages/StationaryProbeLauncherMessage.cs b/QSB/StationaryProbeLauncherSync/Messages/StationaryProbeLauncherMessage.cs new file mode 100644 index 00000000..641e1f4d --- /dev/null +++ b/QSB/StationaryProbeLauncherSync/Messages/StationaryProbeLauncherMessage.cs @@ -0,0 +1,11 @@ +using QSB.Messaging; +using QSB.StationaryProbeLauncherSync.WorldObjects; + +namespace QSB.StationaryProbeLauncherSync.Messages; + +public class StationaryProbeLauncherMessage : QSBWorldObjectMessage +{ + public StationaryProbeLauncherMessage(bool inUse) : base(inUse) { } + + public override void OnReceiveRemote() => WorldObject.OnUseStateChanged(Data, From); +} diff --git a/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs b/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs new file mode 100644 index 00000000..51dec4c5 --- /dev/null +++ b/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs @@ -0,0 +1,27 @@ +using HarmonyLib; +using QSB.Messaging; +using QSB.Patches; +using QSB.StationaryProbeLauncherSync.Messages; +using QSB.StationaryProbeLauncherSync.WorldObjects; +using QSB.WorldSync; + +namespace QSB.StationaryProbeLauncherSync.Patches; + +[HarmonyPatch] +public class StationaryProbeLauncherPatches : QSBPatch +{ + public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect; + + [HarmonyPostfix] + [HarmonyPatch(typeof(StationaryProbeLauncher), nameof(StationaryProbeLauncher.FinishExitSequence))] + public static void StationaryProbeLauncher_FinishExitSequence(Elevator __instance) + { + if (Remote) + { + return; + } + + var qsbStationaryProbe = __instance.GetWorldObject(); + qsbStationaryProbe.SendMessage(new StationaryProbeLauncherMessage(false)); + } +} diff --git a/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs b/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs new file mode 100644 index 00000000..515709ad --- /dev/null +++ b/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs @@ -0,0 +1,15 @@ +using Cysharp.Threading.Tasks; +using QSB.StationaryProbeLauncherSync.WorldObjects; +using QSB.Utility; +using QSB.WorldSync; +using System.Threading; + +namespace QSB.StationaryProbeLauncherSync; + +public class StationaryProbeLauncherManager : WorldObjectManager +{ + public override WorldObjectScene WorldObjectScene => WorldObjectScene.SolarSystem; + + public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct) => + QSBWorldSync.Init(QSBWorldSync.GetUnityObjects().SortDeterministic()); +} diff --git a/QSB/StationaryProbeLauncherSync/TransformSync/StationaryProbeLauncherTransformSync.cs b/QSB/StationaryProbeLauncherSync/TransformSync/StationaryProbeLauncherTransformSync.cs new file mode 100644 index 00000000..f9095e2c --- /dev/null +++ b/QSB/StationaryProbeLauncherSync/TransformSync/StationaryProbeLauncherTransformSync.cs @@ -0,0 +1,35 @@ +using Mirror; +using QSB.EchoesOfTheEye; +using QSB.StationaryProbeLauncherSync.WorldObjects; +using UnityEngine; + +namespace QSB.StationaryProbeLauncherSync.TransformSync; + +public class StationaryProbeLauncherTransformSync : RotatingElementsVariableSyncer +{ + protected override Transform[] RotatingElements => new Transform[] { WorldObject.AttachedObject.transform }; + + protected override void Serialize(NetworkWriter writer) + { + base.Serialize(writer); + + var launcher = (WorldObject.AttachedObject as StationaryProbeLauncher); + + writer.Write(launcher.transform.localRotation); + writer.Write(launcher._degreesX); + writer.Write(launcher._degreesY); + writer.Write(launcher._audioSource.GetLocalVolume()); + } + + protected override void Deserialize(NetworkReader reader) + { + base.Deserialize(reader); + + var launcher = (WorldObject.AttachedObject as StationaryProbeLauncher); + + launcher.transform.localRotation = reader.Read(); + launcher._degreesX = reader.Read(); + launcher._degreesY = reader.Read(); + launcher._audioSource.SetLocalVolume(reader.Read()); + } +} diff --git a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs new file mode 100644 index 00000000..8823a5d7 --- /dev/null +++ b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs @@ -0,0 +1,108 @@ +using Cysharp.Threading.Tasks; +using Mirror; +using QSB.AuthoritySync; +using QSB.Messaging; +using QSB.Player; +using QSB.StationaryProbeLauncherSync.Messages; +using QSB.StationaryProbeLauncherSync.TransformSync; +using QSB.Tools.ProbeLauncherTool.WorldObjects; +using QSB.Utility.LinkedWorldObject; +using System.Threading; + +namespace QSB.StationaryProbeLauncherSync.WorldObjects; + +public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject +{ + public StationaryProbeLauncherTransformSync NetworkBehaviour { get; private set; } + public void SetNetworkBehaviour(NetworkBehaviour networkBehaviour) => NetworkBehaviour = (StationaryProbeLauncherTransformSync)networkBehaviour; + + private bool _isInit; + private bool _isInUse; + private Shape _shape; + private StationaryProbeLauncher _stationaryProbeLauncher; + + public override async UniTask Init(CancellationToken ct) + { + _isInit = true; + + // This is implemented by inheriting LinkedWorldObject normally, however I want to inherit from QSBProbeLauncher + // Else we'd have to redo the sync for the effects + if (QSBCore.IsHost) + { + this.SpawnLinked(QSBNetworkManager.singleton.StationaryProbeLauncherPrefab, false); + } + else + { + await this.WaitForLink(ct); + } + + await base.Init(ct); + + _stationaryProbeLauncher = AttachedObject as StationaryProbeLauncher; + _shape = ((InteractZone)_stationaryProbeLauncher._interactVolume)._trigger._shape; + + _stationaryProbeLauncher._interactVolume.OnPressInteract += OnPressInteract; + + UpdateUse(); + } + + public override void OnRemoval() + { + _isInit = false; + + if (QSBCore.IsHost) + { + NetworkServer.Destroy(NetworkBehaviour.gameObject); + } + + base.OnRemoval(); + + _stationaryProbeLauncher._interactVolume.OnPressInteract -= OnPressInteract; + } + + private void OnPressInteract() + { + // Whoever is using it needs authority to be able to rotate it + // If this is a client they'll get authority from the host when the message is received otherwise give now + if (QSBCore.IsHost) NetworkBehaviour.netIdentity.SetAuthority(QSBPlayerManager.LocalPlayerId); + + _isInUse = true; + this.SendMessage(new StationaryProbeLauncherMessage(_isInUse)); + } + + public override void SendInitialState(uint to) + { + base.SendInitialState(to); + + this.SendMessage(new StationaryProbeLauncherMessage(_isInUse) { To = to }); + } + + private void UpdateUse() + { + // Stuff can be null when its sending the initial state info + if (!_isInit) return; + + // If somebody is using this we disable the interaction shape + _shape.enabled = !_isInUse; + + if (_isInUse) + { + _stationaryProbeLauncher._audioSource.SetLocalVolume(0f); + _stationaryProbeLauncher._audioSource.Start(); + } + else + { + _stationaryProbeLauncher._audioSource.Stop(); + } + } + + public void OnUseStateChanged(bool isInUse, uint from) + { + // Whoever is using it needs authority to be able to rotate it + if (QSBCore.IsHost) NetworkBehaviour.netIdentity.SetAuthority(from); + + _isInUse = isInUse; + + UpdateUse(); + } +} diff --git a/QSB/Tools/ProbeLauncherTool/ProbeLauncherManager.cs b/QSB/Tools/ProbeLauncherTool/ProbeLauncherManager.cs index cff58709..60ca8d8e 100644 --- a/QSB/Tools/ProbeLauncherTool/ProbeLauncherManager.cs +++ b/QSB/Tools/ProbeLauncherTool/ProbeLauncherManager.cs @@ -12,7 +12,7 @@ internal class ProbeLauncherManager : WorldObjectManager public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct) { - QSBWorldSync.Init(typeof(PlayerProbeLauncher)); + QSBWorldSync.Init(typeof(PlayerProbeLauncher), typeof(StationaryProbeLauncher)); if (scene == OWScene.SolarSystem) { QSBWorldSync.Init(new[] From 991e3bfc5d807680e73f83daf2cf2cb6e832b650 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 26 Aug 2022 18:29:42 -0400 Subject: [PATCH 02/29] Was setting rotation twice --- .../TransformSync/StationaryProbeLauncherTransformSync.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/QSB/StationaryProbeLauncherSync/TransformSync/StationaryProbeLauncherTransformSync.cs b/QSB/StationaryProbeLauncherSync/TransformSync/StationaryProbeLauncherTransformSync.cs index f9095e2c..44851746 100644 --- a/QSB/StationaryProbeLauncherSync/TransformSync/StationaryProbeLauncherTransformSync.cs +++ b/QSB/StationaryProbeLauncherSync/TransformSync/StationaryProbeLauncherTransformSync.cs @@ -15,7 +15,6 @@ public class StationaryProbeLauncherTransformSync : RotatingElementsVariableSync var launcher = (WorldObject.AttachedObject as StationaryProbeLauncher); - writer.Write(launcher.transform.localRotation); writer.Write(launcher._degreesX); writer.Write(launcher._degreesY); writer.Write(launcher._audioSource.GetLocalVolume()); @@ -27,7 +26,6 @@ public class StationaryProbeLauncherTransformSync : RotatingElementsVariableSync var launcher = (WorldObject.AttachedObject as StationaryProbeLauncher); - launcher.transform.localRotation = reader.Read(); launcher._degreesX = reader.Read(); launcher._degreesY = reader.Read(); launcher._audioSource.SetLocalVolume(reader.Read()); From 5ceca388c3c931b8dfb90bc77913be192e0c62f5 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 26 Aug 2022 18:33:42 -0400 Subject: [PATCH 03/29] Rename from TransformSync to VariableSync --- .../StationaryProbeLauncherTransformSync.cs | 33 ------------------- .../StationaryProbeLauncherVariableSync.cs | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 33 deletions(-) delete mode 100644 QSB/StationaryProbeLauncherSync/TransformSync/StationaryProbeLauncherTransformSync.cs create mode 100644 QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs diff --git a/QSB/StationaryProbeLauncherSync/TransformSync/StationaryProbeLauncherTransformSync.cs b/QSB/StationaryProbeLauncherSync/TransformSync/StationaryProbeLauncherTransformSync.cs deleted file mode 100644 index 44851746..00000000 --- a/QSB/StationaryProbeLauncherSync/TransformSync/StationaryProbeLauncherTransformSync.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Mirror; -using QSB.EchoesOfTheEye; -using QSB.StationaryProbeLauncherSync.WorldObjects; -using UnityEngine; - -namespace QSB.StationaryProbeLauncherSync.TransformSync; - -public class StationaryProbeLauncherTransformSync : RotatingElementsVariableSyncer -{ - protected override Transform[] RotatingElements => new Transform[] { WorldObject.AttachedObject.transform }; - - protected override void Serialize(NetworkWriter writer) - { - base.Serialize(writer); - - var launcher = (WorldObject.AttachedObject as StationaryProbeLauncher); - - writer.Write(launcher._degreesX); - writer.Write(launcher._degreesY); - writer.Write(launcher._audioSource.GetLocalVolume()); - } - - protected override void Deserialize(NetworkReader reader) - { - base.Deserialize(reader); - - var launcher = (WorldObject.AttachedObject as StationaryProbeLauncher); - - launcher._degreesX = reader.Read(); - launcher._degreesY = reader.Read(); - launcher._audioSource.SetLocalVolume(reader.Read()); - } -} diff --git a/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs b/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs new file mode 100644 index 00000000..314d12ce --- /dev/null +++ b/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs @@ -0,0 +1,33 @@ +using Mirror; +using QSB.EchoesOfTheEye; +using QSB.StationaryProbeLauncherSync.WorldObjects; +using UnityEngine; + +namespace QSB.StationaryProbeLauncherSync.VariableSync; + +public class StationaryProbeLauncherVariableSync : RotatingElementsVariableSyncer +{ + protected override Transform[] RotatingElements => new Transform[] { WorldObject.AttachedObject.transform }; + + protected override void Serialize(NetworkWriter writer) + { + base.Serialize(writer); + + var launcher = WorldObject.AttachedObject as StationaryProbeLauncher; + + writer.Write(launcher._degreesX); + writer.Write(launcher._degreesY); + writer.Write(launcher._audioSource.GetLocalVolume()); + } + + protected override void Deserialize(NetworkReader reader) + { + base.Deserialize(reader); + + var launcher = WorldObject.AttachedObject as StationaryProbeLauncher; + + launcher._degreesX = reader.Read(); + launcher._degreesY = reader.Read(); + launcher._audioSource.SetLocalVolume(reader.Read()); + } +} From a328a99a0cf6b153827d81ad946e0074f2f5bccd Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 26 Aug 2022 18:35:35 -0400 Subject: [PATCH 04/29] Forgot to update uses of the name --- QSB/QSBNetworkManager.cs | 4 ++-- .../WorldObjects/QSBStationaryProbeLauncher.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/QSB/QSBNetworkManager.cs b/QSB/QSBNetworkManager.cs index e32a6cf9..79146a1f 100644 --- a/QSB/QSBNetworkManager.cs +++ b/QSB/QSBNetworkManager.cs @@ -24,7 +24,7 @@ using QSB.Player.TransformSync; using QSB.SaveSync; using QSB.ShipSync; using QSB.ShipSync.TransformSync; -using QSB.StationaryProbeLauncherSync.TransformSync; +using QSB.StationaryProbeLauncherSync.VariableSync; using QSB.Syncs.Occasional; using QSB.TimeSync; using QSB.Tools.ProbeTool.TransformSync; @@ -151,7 +151,7 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart ModelShipPrefab = MakeNewNetworkObject(14, "NetworkModelShip", typeof(ModelShipTransformSync)); spawnPrefabs.Add(ModelShipPrefab); - StationaryProbeLauncherPrefab = MakeNewNetworkObject(15, "NetworkStationaryProbeLauncher", typeof(StationaryProbeLauncherTransformSync)); + StationaryProbeLauncherPrefab = MakeNewNetworkObject(15, "NetworkStationaryProbeLauncher", typeof(StationaryProbeLauncherVariableSync)); spawnPrefabs.Add(StationaryProbeLauncherPrefab); ConfigureNetworkManager(); diff --git a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs index 8823a5d7..39c4917f 100644 --- a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs +++ b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs @@ -4,17 +4,17 @@ using QSB.AuthoritySync; using QSB.Messaging; using QSB.Player; using QSB.StationaryProbeLauncherSync.Messages; -using QSB.StationaryProbeLauncherSync.TransformSync; +using QSB.StationaryProbeLauncherSync.VariableSync; using QSB.Tools.ProbeLauncherTool.WorldObjects; using QSB.Utility.LinkedWorldObject; using System.Threading; namespace QSB.StationaryProbeLauncherSync.WorldObjects; -public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject +public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject { - public StationaryProbeLauncherTransformSync NetworkBehaviour { get; private set; } - public void SetNetworkBehaviour(NetworkBehaviour networkBehaviour) => NetworkBehaviour = (StationaryProbeLauncherTransformSync)networkBehaviour; + public StationaryProbeLauncherVariableSync NetworkBehaviour { get; private set; } + public void SetNetworkBehaviour(NetworkBehaviour networkBehaviour) => NetworkBehaviour = (StationaryProbeLauncherVariableSync)networkBehaviour; private bool _isInit; private bool _isInUse; From ea9c651114733009cbbc018172b43880b91339af Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Fri, 26 Aug 2022 15:35:44 -0700 Subject: [PATCH 05/29] dont have to do GetWorldObjects here i win --- .../StationaryProbeLauncherManager.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs b/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs index 515709ad..39ead8c3 100644 --- a/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs +++ b/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs @@ -1,6 +1,5 @@ using Cysharp.Threading.Tasks; using QSB.StationaryProbeLauncherSync.WorldObjects; -using QSB.Utility; using QSB.WorldSync; using System.Threading; @@ -11,5 +10,5 @@ public class StationaryProbeLauncherManager : WorldObjectManager public override WorldObjectScene WorldObjectScene => WorldObjectScene.SolarSystem; public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct) => - QSBWorldSync.Init(QSBWorldSync.GetUnityObjects().SortDeterministic()); + QSBWorldSync.Init(); } From 593388b1108acb5e9fceb624f2f5fda4871af0bc Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 26 Aug 2022 18:52:20 -0400 Subject: [PATCH 06/29] Reorganize + use right method to play audio --- .../StationaryProbeLauncherMessage.cs | 2 +- .../StationaryProbeLauncherVariableSync.cs | 2 +- .../QSBStationaryProbeLauncher.cs | 40 +++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/QSB/StationaryProbeLauncherSync/Messages/StationaryProbeLauncherMessage.cs b/QSB/StationaryProbeLauncherSync/Messages/StationaryProbeLauncherMessage.cs index 641e1f4d..a4ac5e49 100644 --- a/QSB/StationaryProbeLauncherSync/Messages/StationaryProbeLauncherMessage.cs +++ b/QSB/StationaryProbeLauncherSync/Messages/StationaryProbeLauncherMessage.cs @@ -7,5 +7,5 @@ public class StationaryProbeLauncherMessage : QSBWorldObjectMessage WorldObject.OnUseStateChanged(Data, From); + public override void OnReceiveRemote() => WorldObject.OnRemoteUseStateChanged(Data, From); } diff --git a/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs b/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs index 314d12ce..c9ddcc01 100644 --- a/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs +++ b/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs @@ -29,5 +29,5 @@ public class StationaryProbeLauncherVariableSync : RotatingElementsVariableSynce launcher._degreesX = reader.Read(); launcher._degreesY = reader.Read(); launcher._audioSource.SetLocalVolume(reader.Read()); - } + } } diff --git a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs index 39c4917f..b809469c 100644 --- a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs +++ b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs @@ -77,26 +77,7 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject Date: Fri, 26 Aug 2022 18:56:22 -0400 Subject: [PATCH 07/29] Revert "dont have to do GetWorldObjects here i win" This reverts commit ea9c651114733009cbbc018172b43880b91339af. --- .../StationaryProbeLauncherManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs b/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs index 39ead8c3..515709ad 100644 --- a/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs +++ b/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs @@ -1,5 +1,6 @@ using Cysharp.Threading.Tasks; using QSB.StationaryProbeLauncherSync.WorldObjects; +using QSB.Utility; using QSB.WorldSync; using System.Threading; @@ -10,5 +11,5 @@ public class StationaryProbeLauncherManager : WorldObjectManager public override WorldObjectScene WorldObjectScene => WorldObjectScene.SolarSystem; public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct) => - QSBWorldSync.Init(); + QSBWorldSync.Init(QSBWorldSync.GetUnityObjects().SortDeterministic()); } From d927a6521d6bc7b64e97c106bfbe6e301018ed73 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 26 Aug 2022 19:00:27 -0400 Subject: [PATCH 08/29] Add a comment so John doesn't try to delete this again --- .../StationaryProbeLauncherManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs b/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs index 515709ad..ee1df3f7 100644 --- a/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs +++ b/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs @@ -11,5 +11,6 @@ public class StationaryProbeLauncherManager : WorldObjectManager public override WorldObjectScene WorldObjectScene => WorldObjectScene.SolarSystem; public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct) => + // Using ProbeLaunchers here so we can do inheritance, put only applying it to found StationaryProbeLauncher QSBWorldSync.Init(QSBWorldSync.GetUnityObjects().SortDeterministic()); } From a2d34c22bc55fdd7b54b895d51243fdd098c4b2f Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Fri, 26 Aug 2022 16:10:35 -0700 Subject: [PATCH 09/29] dont change shape, just use SetInteractionEnabled --- .../WorldObjects/QSBStationaryProbeLauncher.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs index b809469c..b77dbf66 100644 --- a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs +++ b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs @@ -18,7 +18,6 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject Date: Fri, 26 Aug 2022 16:11:29 -0700 Subject: [PATCH 10/29] format --- .../StationaryProbeLauncherVariableSync.cs | 33 ++++++++++--------- .../QSBStationaryProbeLauncher.cs | 15 +++++++-- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs b/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs index c9ddcc01..6c592c37 100644 --- a/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs +++ b/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs @@ -5,29 +5,30 @@ using UnityEngine; namespace QSB.StationaryProbeLauncherSync.VariableSync; +// TODO: use base variable sync instead of doing transform, uses less network bandwidth lol public class StationaryProbeLauncherVariableSync : RotatingElementsVariableSyncer { - protected override Transform[] RotatingElements => new Transform[] { WorldObject.AttachedObject.transform }; + protected override Transform[] RotatingElements => new[] { WorldObject.AttachedObject.transform }; - protected override void Serialize(NetworkWriter writer) - { - base.Serialize(writer); + protected override void Serialize(NetworkWriter writer) + { + base.Serialize(writer); - var launcher = WorldObject.AttachedObject as StationaryProbeLauncher; + var launcher = (StationaryProbeLauncher)WorldObject.AttachedObject; - writer.Write(launcher._degreesX); - writer.Write(launcher._degreesY); - writer.Write(launcher._audioSource.GetLocalVolume()); - } + writer.Write(launcher._degreesX); + writer.Write(launcher._degreesY); + writer.Write(launcher._audioSource.GetLocalVolume()); + } - protected override void Deserialize(NetworkReader reader) - { - base.Deserialize(reader); + protected override void Deserialize(NetworkReader reader) + { + base.Deserialize(reader); - var launcher = WorldObject.AttachedObject as StationaryProbeLauncher; + var launcher = (StationaryProbeLauncher)WorldObject.AttachedObject; - launcher._degreesX = reader.Read(); - launcher._degreesY = reader.Read(); - launcher._audioSource.SetLocalVolume(reader.Read()); + launcher._degreesX = reader.Read(); + launcher._degreesY = reader.Read(); + launcher._audioSource.SetLocalVolume(reader.Read()); } } diff --git a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs index b77dbf66..e10bbb8f 100644 --- a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs +++ b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs @@ -61,7 +61,10 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject Date: Fri, 26 Aug 2022 16:15:50 -0700 Subject: [PATCH 11/29] funny bug --- .../WorldObjects/QSBStationaryProbeLauncher.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs index e10bbb8f..3516f67b 100644 --- a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs +++ b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs @@ -74,15 +74,16 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject Date: Fri, 26 Aug 2022 16:17:19 -0700 Subject: [PATCH 12/29] lol --- .../WorldObjects/QSBStationaryProbeLauncher.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs index 3516f67b..a6d85fb3 100644 --- a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs +++ b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs @@ -74,7 +74,7 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject Date: Fri, 26 Aug 2022 20:15:53 -0700 Subject: [PATCH 13/29] i was wrong --- .../WorldObjects/QSBStationaryProbeLauncher.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs index a6d85fb3..5adb418a 100644 --- a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs +++ b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs @@ -74,7 +74,8 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject Date: Sat, 27 Aug 2022 00:14:34 -0400 Subject: [PATCH 14/29] Use base variable sync instead of transform --- .../StationaryProbeLauncherVariableSync.cs | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs b/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs index 6c592c37..81842d91 100644 --- a/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs +++ b/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs @@ -1,14 +1,22 @@ using Mirror; -using QSB.EchoesOfTheEye; using QSB.StationaryProbeLauncherSync.WorldObjects; +using QSB.Utility.LinkedWorldObject; +using QSB.Utility.VariableSync; +using QSB.WorldSync; using UnityEngine; namespace QSB.StationaryProbeLauncherSync.VariableSync; -// TODO: use base variable sync instead of doing transform, uses less network bandwidth lol -public class StationaryProbeLauncherVariableSync : RotatingElementsVariableSyncer +public class StationaryProbeLauncherVariableSync : BaseVariableSyncer<(float, float, float)>, ILinkedNetworkBehaviour { - protected override Transform[] RotatingElements => new[] { WorldObject.AttachedObject.transform }; + protected override bool HasChanged() + { + var launcher = (StationaryProbeLauncher)WorldObject.AttachedObject; + + Value = (launcher._degreesX, launcher._degreesY, launcher._audioSource._localVolume); + + return Value != PrevValue; + } protected override void Serialize(NetworkWriter writer) { @@ -30,5 +38,14 @@ public class StationaryProbeLauncherVariableSync : RotatingElementsVariableSynce launcher._degreesX = reader.Read(); launcher._degreesY = reader.Read(); launcher._audioSource.SetLocalVolume(reader.Read()); + + // Update rotation based on x and y degrees + launcher.transform.localRotation = Quaternion.AngleAxis(launcher._degreesX, launcher._localUpAxis) * launcher._initRotX; + launcher._verticalPivot.localRotation = Quaternion.AngleAxis(launcher._degreesY, -Vector3.right) * launcher._initRotY; + + Value = (launcher._degreesX, launcher._degreesY, launcher._audioSource._localVolume); } + + protected QSBStationaryProbeLauncher WorldObject { get; private set; } + public void SetWorldObject(IWorldObject worldObject) => WorldObject = (QSBStationaryProbeLauncher)worldObject; } From 3434999c1351c16d204c8493851fee6e2742f397 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 27 Aug 2022 01:27:36 -0400 Subject: [PATCH 15/29] What --- .../Patches/StationaryProbeLauncherPatches.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs b/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs index 51dec4c5..757ae5ca 100644 --- a/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs +++ b/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs @@ -14,7 +14,7 @@ public class StationaryProbeLauncherPatches : QSBPatch [HarmonyPostfix] [HarmonyPatch(typeof(StationaryProbeLauncher), nameof(StationaryProbeLauncher.FinishExitSequence))] - public static void StationaryProbeLauncher_FinishExitSequence(Elevator __instance) + public static void StationaryProbeLauncher_FinishExitSequence(StationaryProbeLauncher __instance) { if (Remote) { From 3d1df048a09a85dd58386913039da915bf261bf7 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 27 Aug 2022 02:03:48 -0400 Subject: [PATCH 16/29] Remove unneeded remote guard --- .../Patches/StationaryProbeLauncherPatches.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs b/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs index 757ae5ca..dd0665f1 100644 --- a/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs +++ b/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs @@ -16,11 +16,6 @@ public class StationaryProbeLauncherPatches : QSBPatch [HarmonyPatch(typeof(StationaryProbeLauncher), nameof(StationaryProbeLauncher.FinishExitSequence))] public static void StationaryProbeLauncher_FinishExitSequence(StationaryProbeLauncher __instance) { - if (Remote) - { - return; - } - var qsbStationaryProbe = __instance.GetWorldObject(); qsbStationaryProbe.SendMessage(new StationaryProbeLauncherMessage(false)); } From 6f6c2f212daf324231b7f8e7b369b2d17ed3ec37 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 27 Aug 2022 02:04:19 -0400 Subject: [PATCH 17/29] Remove isInit, I must have been doing something wrong before --- .../WorldObjects/QSBStationaryProbeLauncher.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs index 5adb418a..d4e2de74 100644 --- a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs +++ b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs @@ -16,14 +16,11 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject NetworkBehaviour = (StationaryProbeLauncherVariableSync)networkBehaviour; - private bool _isInit; private bool _isInUse; private StationaryProbeLauncher _stationaryProbeLauncher; public override async UniTask Init(CancellationToken ct) { - _isInit = true; - // This is implemented by inheriting LinkedWorldObject normally, however I want to inherit from QSBProbeLauncher // Else we'd have to redo the sync for the effects if (QSBCore.IsHost) @@ -45,8 +42,6 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject Date: Sat, 27 Aug 2022 02:05:15 -0400 Subject: [PATCH 18/29] Sync snapshot and change mode audio for probe launchers --- .../Messages/ChangeModeMessage.cs | 16 ++++++++++ .../PlayerLauncherChangeModeMessage.cs | 16 ++++++++++ .../PlayerLauncherTakeSnapshotMessage.cs | 16 ++++++++++ .../Messages/TakeSnapshotMessage.cs | 16 ++++++++++ .../Patches/LauncherPatches.cs | 30 +++++++++++++++++++ .../ProbeLauncherTool/QSBProbeLauncherTool.cs | 27 +++++++++++++---- .../WorldObjects/QSBProbeLauncher.cs | 11 +++++++ 7 files changed, 127 insertions(+), 5 deletions(-) create mode 100644 QSB/Tools/ProbeLauncherTool/Messages/ChangeModeMessage.cs create mode 100644 QSB/Tools/ProbeLauncherTool/Messages/PlayerLauncherChangeModeMessage.cs create mode 100644 QSB/Tools/ProbeLauncherTool/Messages/PlayerLauncherTakeSnapshotMessage.cs create mode 100644 QSB/Tools/ProbeLauncherTool/Messages/TakeSnapshotMessage.cs diff --git a/QSB/Tools/ProbeLauncherTool/Messages/ChangeModeMessage.cs b/QSB/Tools/ProbeLauncherTool/Messages/ChangeModeMessage.cs new file mode 100644 index 00000000..f2224915 --- /dev/null +++ b/QSB/Tools/ProbeLauncherTool/Messages/ChangeModeMessage.cs @@ -0,0 +1,16 @@ +using QSB.Messaging; +using QSB.Tools.ProbeLauncherTool.WorldObjects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace QSB.Tools.ProbeLauncherTool.Messages; + +internal class ChangeModeMessage : QSBWorldObjectMessage +{ + public ChangeModeMessage() : base() { } + + public override void OnReceiveRemote() => WorldObject.ChangeMode(); +} diff --git a/QSB/Tools/ProbeLauncherTool/Messages/PlayerLauncherChangeModeMessage.cs b/QSB/Tools/ProbeLauncherTool/Messages/PlayerLauncherChangeModeMessage.cs new file mode 100644 index 00000000..14fd7da7 --- /dev/null +++ b/QSB/Tools/ProbeLauncherTool/Messages/PlayerLauncherChangeModeMessage.cs @@ -0,0 +1,16 @@ +using QSB.Messaging; +using QSB.Player; +using QSB.WorldSync; + +namespace QSB.Tools.ProbeLauncherTool.Messages; + +internal class PlayerLauncherChangeModeMessage : QSBMessage +{ + public override bool ShouldReceive => QSBWorldSync.AllObjectsReady; + + public override void OnReceiveRemote() + { + var player = QSBPlayerManager.GetPlayer(From); + player.ProbeLauncherTool.ChangeMode(); + } +} diff --git a/QSB/Tools/ProbeLauncherTool/Messages/PlayerLauncherTakeSnapshotMessage.cs b/QSB/Tools/ProbeLauncherTool/Messages/PlayerLauncherTakeSnapshotMessage.cs new file mode 100644 index 00000000..2ff0dfda --- /dev/null +++ b/QSB/Tools/ProbeLauncherTool/Messages/PlayerLauncherTakeSnapshotMessage.cs @@ -0,0 +1,16 @@ +using QSB.Messaging; +using QSB.Player; +using QSB.WorldSync; + +namespace QSB.Tools.ProbeLauncherTool.Messages; + +internal class PlayerLauncherTakeSnapshotMessage : QSBMessage +{ + public override bool ShouldReceive => QSBWorldSync.AllObjectsReady; + + public override void OnReceiveRemote() + { + var player = QSBPlayerManager.GetPlayer(From); + player.ProbeLauncherTool.TakeSnapshot(); + } +} diff --git a/QSB/Tools/ProbeLauncherTool/Messages/TakeSnapshotMessage.cs b/QSB/Tools/ProbeLauncherTool/Messages/TakeSnapshotMessage.cs new file mode 100644 index 00000000..a92b5b7e --- /dev/null +++ b/QSB/Tools/ProbeLauncherTool/Messages/TakeSnapshotMessage.cs @@ -0,0 +1,16 @@ +using QSB.Messaging; +using QSB.Tools.ProbeLauncherTool.WorldObjects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace QSB.Tools.ProbeLauncherTool.Messages; + +internal class TakeSnapshotMessage : QSBWorldObjectMessage +{ + public TakeSnapshotMessage() : base() { } + + public override void OnReceiveRemote() => WorldObject.TakeSnapshot(); +} diff --git a/QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs b/QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs index 66e16537..f1c1645e 100644 --- a/QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs +++ b/QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs @@ -89,4 +89,34 @@ internal class LauncherPatches : QSBPatch __instance._owAudioSource.GetAudioSource().spatialBlend = 1f; return true; } + + [HarmonyPostfix] + [HarmonyPatch(typeof(ProbeLauncherEffects), nameof(ProbeLauncherEffects.PlayChangeModeClip))] + public static void ProbeLauncherEffects_PlayChangeModeClip(ProbeLauncherEffects __instance) + { + if (__instance != QSBPlayerManager.LocalPlayer.LocalProbeLauncher._effects) + { + __instance.gameObject.GetComponent().GetWorldObject() + .SendMessage(new ChangeModeMessage()); + } + else + { + new PlayerLauncherChangeModeMessage().Send(); + } + } + + [HarmonyPostfix] + [HarmonyPatch(typeof(ProbeLauncherEffects), nameof(ProbeLauncherEffects.PlaySnapshotClip))] + public static void ProbeLauncherEffects_PlaySnapshotClip(ProbeLauncherEffects __instance) + { + if (__instance != QSBPlayerManager.LocalPlayer.LocalProbeLauncher._effects) + { + __instance.gameObject.GetComponent().GetWorldObject() + .SendMessage(new TakeSnapshotMessage()); + } + else + { + new PlayerLauncherTakeSnapshotMessage().Send(); + } + } } \ No newline at end of file diff --git a/QSB/Tools/ProbeLauncherTool/QSBProbeLauncherTool.cs b/QSB/Tools/ProbeLauncherTool/QSBProbeLauncherTool.cs index 244b6b0d..68434f17 100644 --- a/QSB/Tools/ProbeLauncherTool/QSBProbeLauncherTool.cs +++ b/QSB/Tools/ProbeLauncherTool/QSBProbeLauncherTool.cs @@ -8,12 +8,17 @@ public class QSBProbeLauncherTool : QSBTool public ProbeLauncherEffects Effects; public SingularityWarpEffect ProbeRetrievalEffect; - public void RetrieveProbe(bool playEffects) + private void VerifyAudioSource() { if (Effects._owAudioSource == null) { Effects._owAudioSource = Player.AudioController._repairToolSource; } + } + + public void RetrieveProbe(bool playEffects) + { + VerifyAudioSource(); PreLaunchProbeProxy.SetActive(true); if (playEffects) @@ -27,13 +32,25 @@ public class QSBProbeLauncherTool : QSBTool { PreLaunchProbeProxy.SetActive(false); - if (Effects._owAudioSource == null) - { - Effects._owAudioSource = Player.AudioController._repairToolSource; - } + VerifyAudioSource(); // TODO : make this do underwater stuff correctly Effects.PlayLaunchClip(false); Effects.PlayLaunchParticles(false); } + + public void ChangeMode() + { + VerifyAudioSource(); + + Effects.PlayChangeModeClip(); + } + + public void TakeSnapshot() + { + VerifyAudioSource(); + + // Vanilla method uses the global player audio controller -> bad + Effects._owAudioSource.PlayOneShot(global::AudioType.ToolProbeTakePhoto, 1f); + } } \ No newline at end of file diff --git a/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs b/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs index 80742aca..8315228c 100644 --- a/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs +++ b/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs @@ -60,4 +60,15 @@ public class QSBProbeLauncher : WorldObject AttachedObject._effects.PlayLaunchParticles(false); } } + + public void ChangeMode() + { + AttachedObject._effects.PlayChangeModeClip(); + } + + public void TakeSnapshot() + { + // Not using PlaySnapshotClip because that uses Locator.GetPlayerAudioController() instead of owAudioSource for some reason + AttachedObject._effects._owAudioSource.PlayOneShot(global::AudioType.ToolProbeTakePhoto, 1f); + } } \ No newline at end of file From 3f636494c4525eca554a5e4806ef07bba82b4a75 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 27 Aug 2022 02:27:49 -0400 Subject: [PATCH 19/29] Fix NRE --- QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs b/QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs index f1c1645e..b14acb6a 100644 --- a/QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs +++ b/QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs @@ -96,8 +96,8 @@ internal class LauncherPatches : QSBPatch { if (__instance != QSBPlayerManager.LocalPlayer.LocalProbeLauncher._effects) { - __instance.gameObject.GetComponent().GetWorldObject() - .SendMessage(new ChangeModeMessage()); + __instance.gameObject.GetComponent()?.GetWorldObject() + ?.SendMessage(new ChangeModeMessage()); } else { @@ -111,8 +111,8 @@ internal class LauncherPatches : QSBPatch { if (__instance != QSBPlayerManager.LocalPlayer.LocalProbeLauncher._effects) { - __instance.gameObject.GetComponent().GetWorldObject() - .SendMessage(new TakeSnapshotMessage()); + __instance.gameObject.GetComponent()?.GetWorldObject() + ?.SendMessage(new TakeSnapshotMessage()); } else { From 399073c675175c62c2f6ddee91d1bea5a66cfbef Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 27 Aug 2022 02:28:10 -0400 Subject: [PATCH 20/29] Fix syncing state, current user of probe launcher --- .../StationaryProbeLauncherMessage.cs | 6 +-- .../Patches/StationaryProbeLauncherPatches.cs | 8 ++-- .../QSBStationaryProbeLauncher.cs | 44 +++++++++++-------- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/QSB/StationaryProbeLauncherSync/Messages/StationaryProbeLauncherMessage.cs b/QSB/StationaryProbeLauncherSync/Messages/StationaryProbeLauncherMessage.cs index a4ac5e49..a4e9eb19 100644 --- a/QSB/StationaryProbeLauncherSync/Messages/StationaryProbeLauncherMessage.cs +++ b/QSB/StationaryProbeLauncherSync/Messages/StationaryProbeLauncherMessage.cs @@ -3,9 +3,9 @@ using QSB.StationaryProbeLauncherSync.WorldObjects; namespace QSB.StationaryProbeLauncherSync.Messages; -public class StationaryProbeLauncherMessage : QSBWorldObjectMessage +public class StationaryProbeLauncherMessage : QSBWorldObjectMessage { - public StationaryProbeLauncherMessage(bool inUse) : base(inUse) { } + public StationaryProbeLauncherMessage(bool inUse, uint userID) : base((inUse, userID)) { } - public override void OnReceiveRemote() => WorldObject.OnRemoteUseStateChanged(Data, From); + public override void OnReceiveRemote() => WorldObject.OnRemoteUseStateChanged(Data.Item1, Data.Item2); } diff --git a/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs b/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs index dd0665f1..3e0b8bbb 100644 --- a/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs +++ b/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs @@ -1,6 +1,7 @@ using HarmonyLib; using QSB.Messaging; using QSB.Patches; +using QSB.Player; using QSB.StationaryProbeLauncherSync.Messages; using QSB.StationaryProbeLauncherSync.WorldObjects; using QSB.WorldSync; @@ -14,9 +15,6 @@ public class StationaryProbeLauncherPatches : QSBPatch [HarmonyPostfix] [HarmonyPatch(typeof(StationaryProbeLauncher), nameof(StationaryProbeLauncher.FinishExitSequence))] - public static void StationaryProbeLauncher_FinishExitSequence(StationaryProbeLauncher __instance) - { - var qsbStationaryProbe = __instance.GetWorldObject(); - qsbStationaryProbe.SendMessage(new StationaryProbeLauncherMessage(false)); - } + public static void StationaryProbeLauncher_FinishExitSequence(StationaryProbeLauncher __instance) => + __instance.GetWorldObject().OnLocalUseStateChanged(false); } diff --git a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs index d4e2de74..e1aca33e 100644 --- a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs +++ b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs @@ -13,6 +13,8 @@ namespace QSB.StationaryProbeLauncherSync.WorldObjects; public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject { + private uint _currentUser = uint.MaxValue; + public StationaryProbeLauncherVariableSync NetworkBehaviour { get; private set; } public void SetNetworkBehaviour(NetworkBehaviour networkBehaviour) => NetworkBehaviour = (StationaryProbeLauncherVariableSync)networkBehaviour; @@ -21,8 +23,8 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject OnLocalUseStateChanged(true); public override void SendInitialState(uint to) { base.SendInitialState(to); - // even tho from is always host here, it's okay because it won't set authority - // (since OnRemoteUseStateChanged is only called from OnReceiveRemote) - this.SendMessage(new StationaryProbeLauncherMessage(_isInUse) { To = to }); + this.SendMessage(new StationaryProbeLauncherMessage(_isInUse, _currentUser) { To = to }); } public void OnRemoteUseStateChanged(bool isInUse, uint user) { + _isInUse = isInUse; + + _currentUser = isInUse ? user : uint.MaxValue; + // Whoever is using it needs authority to be able to rotate it if (QSBCore.IsHost) { - NetworkBehaviour.netIdentity.SetAuthority(isInUse ? user : uint.MaxValue); + NetworkBehaviour.netIdentity.SetAuthority(_currentUser); } + UpdateUse(); + } + + public void OnLocalUseStateChanged(bool isInUse) + { _isInUse = isInUse; - UpdateUse(); + _currentUser = isInUse ? QSBPlayerManager.LocalPlayerId : uint.MaxValue; + + // Whoever is using it needs authority to be able to rotate it + if (QSBCore.IsHost) + { + NetworkBehaviour.netIdentity.SetAuthority(_currentUser); + } + + this.SendMessage(new StationaryProbeLauncherMessage(isInUse, _currentUser)); } private void UpdateUse() From aa7c58d6c398191221331fd8693c2b9fde6d3198 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 27 Aug 2022 02:34:05 -0400 Subject: [PATCH 21/29] Switch RotatingElementsVariableSyncer back to internal --- QSB/EchoesOfTheEye/RotatingElementsVariableSyncer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QSB/EchoesOfTheEye/RotatingElementsVariableSyncer.cs b/QSB/EchoesOfTheEye/RotatingElementsVariableSyncer.cs index 271bf807..c510a730 100644 --- a/QSB/EchoesOfTheEye/RotatingElementsVariableSyncer.cs +++ b/QSB/EchoesOfTheEye/RotatingElementsVariableSyncer.cs @@ -8,7 +8,7 @@ using UnityEngine; namespace QSB.EchoesOfTheEye; -public abstract class RotatingElementsVariableSyncer : BaseVariableSyncer, ILinkedNetworkBehaviour +internal abstract class RotatingElementsVariableSyncer : BaseVariableSyncer, ILinkedNetworkBehaviour where TWorldObject : IWorldObject { public override void OnStartClient() From c0a23082ca2e05ffdf12d8a5029736e83d2fd245 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Sat, 27 Aug 2022 10:18:13 +0100 Subject: [PATCH 22/29] StationaryProbeLauncherVariableSync -> StationaryProbeLauncherVariableSyncer --- QSB/QSBNetworkManager.cs | 2 +- ...ableSync.cs => StationaryProbeLauncherVariableSyncer.cs} | 2 +- .../WorldObjects/QSBStationaryProbeLauncher.cs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) rename QSB/StationaryProbeLauncherSync/VariableSync/{StationaryProbeLauncherVariableSync.cs => StationaryProbeLauncherVariableSyncer.cs} (93%) diff --git a/QSB/QSBNetworkManager.cs b/QSB/QSBNetworkManager.cs index 79146a1f..386a284a 100644 --- a/QSB/QSBNetworkManager.cs +++ b/QSB/QSBNetworkManager.cs @@ -151,7 +151,7 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart ModelShipPrefab = MakeNewNetworkObject(14, "NetworkModelShip", typeof(ModelShipTransformSync)); spawnPrefabs.Add(ModelShipPrefab); - StationaryProbeLauncherPrefab = MakeNewNetworkObject(15, "NetworkStationaryProbeLauncher", typeof(StationaryProbeLauncherVariableSync)); + StationaryProbeLauncherPrefab = MakeNewNetworkObject(15, "NetworkStationaryProbeLauncher", typeof(StationaryProbeLauncherVariableSyncer)); spawnPrefabs.Add(StationaryProbeLauncherPrefab); ConfigureNetworkManager(); diff --git a/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs b/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSyncer.cs similarity index 93% rename from QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs rename to QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSyncer.cs index 81842d91..3c464b98 100644 --- a/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSync.cs +++ b/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSyncer.cs @@ -7,7 +7,7 @@ using UnityEngine; namespace QSB.StationaryProbeLauncherSync.VariableSync; -public class StationaryProbeLauncherVariableSync : BaseVariableSyncer<(float, float, float)>, ILinkedNetworkBehaviour +public class StationaryProbeLauncherVariableSyncer : BaseVariableSyncer<(float, float, float)>, ILinkedNetworkBehaviour { protected override bool HasChanged() { diff --git a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs index e1aca33e..54e56569 100644 --- a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs +++ b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs @@ -11,12 +11,12 @@ using System.Threading; namespace QSB.StationaryProbeLauncherSync.WorldObjects; -public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject +public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject { private uint _currentUser = uint.MaxValue; - public StationaryProbeLauncherVariableSync NetworkBehaviour { get; private set; } - public void SetNetworkBehaviour(NetworkBehaviour networkBehaviour) => NetworkBehaviour = (StationaryProbeLauncherVariableSync)networkBehaviour; + public StationaryProbeLauncherVariableSyncer NetworkBehaviour { get; private set; } + public void SetNetworkBehaviour(NetworkBehaviour networkBehaviour) => NetworkBehaviour = (StationaryProbeLauncherVariableSyncer)networkBehaviour; private bool _isInUse; private StationaryProbeLauncher _stationaryProbeLauncher; From 6c9bd967fb31a7e465f3919fe13fcae0577c1a5d Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Sat, 27 Aug 2022 10:32:24 +0100 Subject: [PATCH 23/29] split across lines --- QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs b/QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs index b14acb6a..40cbeac3 100644 --- a/QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs +++ b/QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs @@ -96,7 +96,9 @@ internal class LauncherPatches : QSBPatch { if (__instance != QSBPlayerManager.LocalPlayer.LocalProbeLauncher._effects) { - __instance.gameObject.GetComponent()?.GetWorldObject() + __instance.gameObject + .GetComponent() + ?.GetWorldObject() ?.SendMessage(new ChangeModeMessage()); } else @@ -111,7 +113,9 @@ internal class LauncherPatches : QSBPatch { if (__instance != QSBPlayerManager.LocalPlayer.LocalProbeLauncher._effects) { - __instance.gameObject.GetComponent()?.GetWorldObject() + __instance.gameObject + .GetComponent() + ?.GetWorldObject() ?.SendMessage(new TakeSnapshotMessage()); } else From baacfb010a15418112c5ab3ab879233aed39cd2f Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 27 Aug 2022 14:06:28 -0400 Subject: [PATCH 24/29] Make probe itself play the snapshot sound, fix spatial blend for stationary --- .../QSBStationaryProbeLauncher.cs | 4 +++ .../Messages/ChangeModeMessage.cs | 5 ---- .../Messages/LaunchProbeMessage.cs | 6 ++-- .../Messages/RetrieveProbeMessage.cs | 2 +- .../ProbeLauncherTool/QSBProbeLauncherTool.cs | 5 +++- .../WorldObjects/QSBProbeLauncher.cs | 28 ++++++++++++++++--- QSB/Tools/ProbeTool/QSBProbe.cs | 3 ++ QSB/Tools/ProbeTool/QSBProbeEffects.cs | 5 ++++ 8 files changed, 44 insertions(+), 14 deletions(-) diff --git a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs index 54e56569..9d5a6cfc 100644 --- a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs +++ b/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs @@ -39,6 +39,10 @@ public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject +internal class LaunchProbeMessage : QSBWorldObjectMessage { - public LaunchProbeMessage(bool playEffects) : base(playEffects) { } + public LaunchProbeMessage(bool playEffects, uint probeOwnerID) : base((playEffects, probeOwnerID)) { } - public override void OnReceiveRemote() => WorldObject.LaunchProbe(Data); + public override void OnReceiveRemote() => WorldObject.LaunchProbe(Data.Item1, Data.Item2); } \ No newline at end of file diff --git a/QSB/Tools/ProbeLauncherTool/Messages/RetrieveProbeMessage.cs b/QSB/Tools/ProbeLauncherTool/Messages/RetrieveProbeMessage.cs index 4a29f84c..df87f681 100644 --- a/QSB/Tools/ProbeLauncherTool/Messages/RetrieveProbeMessage.cs +++ b/QSB/Tools/ProbeLauncherTool/Messages/RetrieveProbeMessage.cs @@ -5,7 +5,7 @@ namespace QSB.Tools.ProbeLauncherTool.Messages; internal class RetrieveProbeMessage : QSBWorldObjectMessage { - public RetrieveProbeMessage(bool playEffects) : base(playEffects) { } + public RetrieveProbeMessage(bool playEffects) : base((playEffects)) { } public override void OnReceiveRemote() => WorldObject.RetrieveProbe(Data); } \ No newline at end of file diff --git a/QSB/Tools/ProbeLauncherTool/QSBProbeLauncherTool.cs b/QSB/Tools/ProbeLauncherTool/QSBProbeLauncherTool.cs index 68434f17..7d70acd7 100644 --- a/QSB/Tools/ProbeLauncherTool/QSBProbeLauncherTool.cs +++ b/QSB/Tools/ProbeLauncherTool/QSBProbeLauncherTool.cs @@ -51,6 +51,9 @@ public class QSBProbeLauncherTool : QSBTool VerifyAudioSource(); // Vanilla method uses the global player audio controller -> bad - Effects._owAudioSource.PlayOneShot(global::AudioType.ToolProbeTakePhoto, 1f); + Effects._owAudioSource.PlayOneShot(AudioType.ToolProbeTakePhoto, 1f); + + // Also make the probe itself play the sound effect + if (Player.Probe.IsLaunched()) Player.Probe.TakeSnapshot(); } } \ No newline at end of file diff --git a/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs b/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs index 8315228c..72c800aa 100644 --- a/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs +++ b/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs @@ -1,13 +1,19 @@ using Cysharp.Threading.Tasks; using QSB.Messaging; +using QSB.Player; using QSB.Tools.ProbeLauncherTool.Messages; +using QSB.Tools.ProbeTool; using QSB.WorldSync; using System.Threading; +using UnityEngine; namespace QSB.Tools.ProbeLauncherTool.WorldObjects; public class QSBProbeLauncher : WorldObject { + private uint _probeOwnerID = uint.MaxValue; + protected QSBProbe LaunchedProbe { get; private set; } + public override async UniTask Init(CancellationToken ct) => AttachedObject.OnLaunchProbe += OnLaunchProbe; @@ -16,21 +22,27 @@ public class QSBProbeLauncher : WorldObject public override void SendInitialState(uint to) { + // Retrieval resets the probe owner ID + var probeOwnerID = _probeOwnerID; + if (AttachedObject._preLaunchProbeProxy.activeSelf) { this.SendMessage(new RetrieveProbeMessage(false)); } else { - this.SendMessage(new LaunchProbeMessage(false)); + this.SendMessage(new LaunchProbeMessage(false, probeOwnerID)); } } private void OnLaunchProbe(SurveyorProbe probe) => - this.SendMessage(new LaunchProbeMessage(true)); + this.SendMessage(new LaunchProbeMessage(true, QSBPlayerManager.LocalPlayerId)); public void RetrieveProbe(bool playEffects) { + _probeOwnerID = uint.MaxValue; + LaunchedProbe = null; + if (AttachedObject._preLaunchProbeProxy.activeSelf) { return; @@ -44,8 +56,13 @@ public class QSBProbeLauncher : WorldObject } } - public void LaunchProbe(bool playEffects) + public void LaunchProbe(bool playEffects, uint probeOwnerID) { + _probeOwnerID = probeOwnerID; + LaunchedProbe = QSBPlayerManager.GetPlayer(_probeOwnerID)?.Probe; + + if (LaunchedProbe == null) Debug.LogError($"Could not find probe owner with ID {_probeOwnerID}"); + if (!AttachedObject._preLaunchProbeProxy.activeSelf) { return; @@ -69,6 +86,9 @@ public class QSBProbeLauncher : WorldObject public void TakeSnapshot() { // Not using PlaySnapshotClip because that uses Locator.GetPlayerAudioController() instead of owAudioSource for some reason - AttachedObject._effects._owAudioSource.PlayOneShot(global::AudioType.ToolProbeTakePhoto, 1f); + AttachedObject._effects._owAudioSource.PlayOneShot(AudioType.ToolProbeTakePhoto, 1f); + + // If their probe is launched also play a snapshot from it + if (LaunchedProbe && LaunchedProbe.IsLaunched()) LaunchedProbe.TakeSnapshot(); } } \ No newline at end of file diff --git a/QSB/Tools/ProbeTool/QSBProbe.cs b/QSB/Tools/ProbeTool/QSBProbe.cs index 45881b8c..577be66b 100644 --- a/QSB/Tools/ProbeTool/QSBProbe.cs +++ b/QSB/Tools/ProbeTool/QSBProbe.cs @@ -17,6 +17,7 @@ public class QSBProbe : MonoBehaviour, ILightSource public event SurveyorProbeEvent OnUnanchorProbe; public event SurveyorProbeEvent OnRetrieveProbe; public event SurveyorProbeEvent OnProbeDestroyed; + public event SurveyorProbeEvent OnTakeSnapshot; public event RetrieveEvent OnStartRetrieveProbe; private GameObject _detectorObj; @@ -204,4 +205,6 @@ public class QSBProbe : MonoBehaviour, ILightSource public LightSourceType GetLightSourceType() => LightSourceType.PROBE; public OWLight2[] GetLights() => _illuminationCheckLights; public Vector3 GetLightSourcePosition() => _lightSourceVol.transform.position; + + public void TakeSnapshot() => OnTakeSnapshot?.Invoke(); } \ No newline at end of file diff --git a/QSB/Tools/ProbeTool/QSBProbeEffects.cs b/QSB/Tools/ProbeTool/QSBProbeEffects.cs index bc0f5bad..3db0412e 100644 --- a/QSB/Tools/ProbeTool/QSBProbeEffects.cs +++ b/QSB/Tools/ProbeTool/QSBProbeEffects.cs @@ -25,6 +25,7 @@ internal class QSBProbeEffects : MonoBehaviour _probe.OnAnchorProbe += OnAnchor; _probe.OnUnanchorProbe += OnUnanchor; _probe.OnStartRetrieveProbe += OnStartRetrieve; + _probe.OnTakeSnapshot += OnTakeSnapshot; } private void OnDestroy() @@ -33,6 +34,7 @@ internal class QSBProbeEffects : MonoBehaviour _probe.OnAnchorProbe -= OnAnchor; _probe.OnUnanchorProbe -= OnUnanchor; _probe.OnStartRetrieveProbe -= OnStartRetrieve; + _probe.OnTakeSnapshot -= OnTakeSnapshot; } private void OnLaunch() => _flightLoopAudio.FadeIn(0.1f, true, true); @@ -58,4 +60,7 @@ internal class QSBProbeEffects : MonoBehaviour private void OnStartRetrieve(float retrieveLength) => _flightLoopAudio.FadeOut(retrieveLength); + + private void OnTakeSnapshot() + => _anchorAudio.PlayOneShot(AudioType.ToolProbeTakePhoto); } \ No newline at end of file From 87931f82d6fd5e8f631910d762678087f4f44ea6 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 27 Aug 2022 11:09:19 -0700 Subject: [PATCH 25/29] do cool --- QSB/Tools/ProbeLauncherTool/Messages/LaunchProbeMessage.cs | 4 ++-- QSB/Tools/ProbeLauncherTool/Messages/RetrieveProbeMessage.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/QSB/Tools/ProbeLauncherTool/Messages/LaunchProbeMessage.cs b/QSB/Tools/ProbeLauncherTool/Messages/LaunchProbeMessage.cs index cb4b2afc..535c1a2f 100644 --- a/QSB/Tools/ProbeLauncherTool/Messages/LaunchProbeMessage.cs +++ b/QSB/Tools/ProbeLauncherTool/Messages/LaunchProbeMessage.cs @@ -3,9 +3,9 @@ using QSB.Tools.ProbeLauncherTool.WorldObjects; namespace QSB.Tools.ProbeLauncherTool.Messages; -internal class LaunchProbeMessage : QSBWorldObjectMessage +internal class LaunchProbeMessage : QSBWorldObjectMessage { public LaunchProbeMessage(bool playEffects, uint probeOwnerID) : base((playEffects, probeOwnerID)) { } - public override void OnReceiveRemote() => WorldObject.LaunchProbe(Data.Item1, Data.Item2); + public override void OnReceiveRemote() => WorldObject.LaunchProbe(Data.playEffects, Data.probeOwnerID); } \ No newline at end of file diff --git a/QSB/Tools/ProbeLauncherTool/Messages/RetrieveProbeMessage.cs b/QSB/Tools/ProbeLauncherTool/Messages/RetrieveProbeMessage.cs index df87f681..4a29f84c 100644 --- a/QSB/Tools/ProbeLauncherTool/Messages/RetrieveProbeMessage.cs +++ b/QSB/Tools/ProbeLauncherTool/Messages/RetrieveProbeMessage.cs @@ -5,7 +5,7 @@ namespace QSB.Tools.ProbeLauncherTool.Messages; internal class RetrieveProbeMessage : QSBWorldObjectMessage { - public RetrieveProbeMessage(bool playEffects) : base((playEffects)) { } + public RetrieveProbeMessage(bool playEffects) : base(playEffects) { } public override void OnReceiveRemote() => WorldObject.RetrieveProbe(Data); } \ No newline at end of file From 21680ffad8b9ab0703b7e659ce5f81d779643fbd Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 27 Aug 2022 11:11:49 -0700 Subject: [PATCH 26/29] move stationary probe stuff to probe folder + rename QSBProbe to match probe-camera branch --- .../Patches/LightSensorPatches.cs | 4 ++-- QSB/Player/PlayerInfoParts/Tools.cs | 2 +- QSB/Player/QSBPlayerManager.cs | 2 +- QSB/QSBNetworkManager.cs | 4 ++-- .../StationaryProbeLauncherManager.cs | 16 ---------------- .../Messages/StationaryProbeLauncherMessage.cs | 4 ++-- .../Patches/StationaryProbeLauncherPatches.cs | 7 ++----- .../ProbeLauncherTool/ProbeLauncherManager.cs | 3 +++ .../StationaryProbeLauncherVariableSync.cs} | 6 +++--- .../WorldObjects/QSBProbeLauncher.cs | 2 +- .../WorldObjects/QSBStationaryProbeLauncher.cs | 13 ++++++------- QSB/Tools/ProbeTool/ProbeCreator.cs | 2 +- QSB/Tools/ProbeTool/QSBProbeEffects.cs | 4 ++-- QSB/Tools/ProbeTool/QSBProbeLantern.cs | 4 ++-- QSB/Tools/ProbeTool/QSBProbeSpotlight.cs | 4 ++-- .../{QSBProbe.cs => QSBSurveyorProbe.cs} | 2 +- 16 files changed, 31 insertions(+), 48 deletions(-) delete mode 100644 QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs rename QSB/{StationaryProbeLauncherSync => Tools/ProbeLauncherTool}/Messages/StationaryProbeLauncherMessage.cs (76%) rename QSB/{StationaryProbeLauncherSync => Tools/ProbeLauncherTool}/Patches/StationaryProbeLauncherPatches.cs (73%) rename QSB/{StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSyncer.cs => Tools/ProbeLauncherTool/VariableSync/StationaryProbeLauncherVariableSync.cs} (87%) rename QSB/{StationaryProbeLauncherSync => Tools/ProbeLauncherTool}/WorldObjects/QSBStationaryProbeLauncher.cs (86%) rename QSB/Tools/ProbeTool/{QSBProbe.cs => QSBSurveyorProbe.cs} (98%) diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs index d060a2f7..dd0a4247 100644 --- a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs +++ b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs @@ -247,7 +247,7 @@ internal class LightSensorPatches : QSBPatch } case LightSourceType.PROBE: { - if (lightSource is QSBProbe qsbProbe) + if (lightSource is QSBSurveyorProbe qsbProbe) { var probe = qsbProbe; if (probe != null && @@ -350,7 +350,7 @@ internal class LightSensorPatches : QSBPatch } case LightSourceType.PROBE: { - if (lightSource is not QSBProbe) + if (lightSource is not QSBSurveyorProbe) { var probe = Locator.GetProbe(); if (probe != null && diff --git a/QSB/Player/PlayerInfoParts/Tools.cs b/QSB/Player/PlayerInfoParts/Tools.cs index 65788e41..04141b5c 100644 --- a/QSB/Player/PlayerInfoParts/Tools.cs +++ b/QSB/Player/PlayerInfoParts/Tools.cs @@ -15,7 +15,7 @@ namespace QSB.Player; public partial class PlayerInfo { public GameObject ProbeBody { get; set; } - public QSBProbe Probe { get; set; } + public QSBSurveyorProbe Probe { get; set; } public QSBFlashlight FlashLight => CameraBody == null ? null : CameraBody.GetComponentInChildren(); public QSBTool Signalscope => GetToolByType(ToolType.Signalscope); public QSBTool Translator => GetToolByType(ToolType.Translator); diff --git a/QSB/Player/QSBPlayerManager.cs b/QSB/Player/QSBPlayerManager.cs index 20fcf91d..a7216c8e 100644 --- a/QSB/Player/QSBPlayerManager.cs +++ b/QSB/Player/QSBPlayerManager.cs @@ -88,7 +88,7 @@ public static class QSBPlayerManager public static (Flashlight LocalFlashlight, IEnumerable RemoteFlashlights) GetPlayerFlashlights() => (Locator.GetFlashlight(), PlayerList.Where(x => x.FlashLight != null).Select(x => x.FlashLight)); - public static (SurveyorProbe LocalProbe, IEnumerable RemoteProbes) GetPlayerProbes() + public static (SurveyorProbe LocalProbe, IEnumerable RemoteProbes) GetPlayerProbes() => (Locator.GetProbe(), PlayerList.Where(x => x.Probe != null).Select(x => x.Probe)); public static IEnumerable GetThrusterLightTrackers() diff --git a/QSB/QSBNetworkManager.cs b/QSB/QSBNetworkManager.cs index 386a284a..3ee53eed 100644 --- a/QSB/QSBNetworkManager.cs +++ b/QSB/QSBNetworkManager.cs @@ -24,9 +24,9 @@ using QSB.Player.TransformSync; using QSB.SaveSync; using QSB.ShipSync; using QSB.ShipSync.TransformSync; -using QSB.StationaryProbeLauncherSync.VariableSync; using QSB.Syncs.Occasional; using QSB.TimeSync; +using QSB.Tools.ProbeLauncherTool.VariableSync; using QSB.Tools.ProbeTool.TransformSync; using QSB.Utility; using QSB.Utility.VariableSync; @@ -151,7 +151,7 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart ModelShipPrefab = MakeNewNetworkObject(14, "NetworkModelShip", typeof(ModelShipTransformSync)); spawnPrefabs.Add(ModelShipPrefab); - StationaryProbeLauncherPrefab = MakeNewNetworkObject(15, "NetworkStationaryProbeLauncher", typeof(StationaryProbeLauncherVariableSyncer)); + StationaryProbeLauncherPrefab = MakeNewNetworkObject(15, "NetworkStationaryProbeLauncher", typeof(StationaryProbeLauncherVariableSync)); spawnPrefabs.Add(StationaryProbeLauncherPrefab); ConfigureNetworkManager(); diff --git a/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs b/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs deleted file mode 100644 index ee1df3f7..00000000 --- a/QSB/StationaryProbeLauncherSync/StationaryProbeLauncherManager.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Cysharp.Threading.Tasks; -using QSB.StationaryProbeLauncherSync.WorldObjects; -using QSB.Utility; -using QSB.WorldSync; -using System.Threading; - -namespace QSB.StationaryProbeLauncherSync; - -public class StationaryProbeLauncherManager : WorldObjectManager -{ - public override WorldObjectScene WorldObjectScene => WorldObjectScene.SolarSystem; - - public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct) => - // Using ProbeLaunchers here so we can do inheritance, put only applying it to found StationaryProbeLauncher - QSBWorldSync.Init(QSBWorldSync.GetUnityObjects().SortDeterministic()); -} diff --git a/QSB/StationaryProbeLauncherSync/Messages/StationaryProbeLauncherMessage.cs b/QSB/Tools/ProbeLauncherTool/Messages/StationaryProbeLauncherMessage.cs similarity index 76% rename from QSB/StationaryProbeLauncherSync/Messages/StationaryProbeLauncherMessage.cs rename to QSB/Tools/ProbeLauncherTool/Messages/StationaryProbeLauncherMessage.cs index a4e9eb19..dcb5fe07 100644 --- a/QSB/StationaryProbeLauncherSync/Messages/StationaryProbeLauncherMessage.cs +++ b/QSB/Tools/ProbeLauncherTool/Messages/StationaryProbeLauncherMessage.cs @@ -1,7 +1,7 @@ using QSB.Messaging; -using QSB.StationaryProbeLauncherSync.WorldObjects; +using QSB.Tools.ProbeLauncherTool.WorldObjects; -namespace QSB.StationaryProbeLauncherSync.Messages; +namespace QSB.Tools.ProbeLauncherTool.Messages; public class StationaryProbeLauncherMessage : QSBWorldObjectMessage { diff --git a/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs b/QSB/Tools/ProbeLauncherTool/Patches/StationaryProbeLauncherPatches.cs similarity index 73% rename from QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs rename to QSB/Tools/ProbeLauncherTool/Patches/StationaryProbeLauncherPatches.cs index 3e0b8bbb..cb07642a 100644 --- a/QSB/StationaryProbeLauncherSync/Patches/StationaryProbeLauncherPatches.cs +++ b/QSB/Tools/ProbeLauncherTool/Patches/StationaryProbeLauncherPatches.cs @@ -1,12 +1,9 @@ using HarmonyLib; -using QSB.Messaging; using QSB.Patches; -using QSB.Player; -using QSB.StationaryProbeLauncherSync.Messages; -using QSB.StationaryProbeLauncherSync.WorldObjects; +using QSB.Tools.ProbeLauncherTool.WorldObjects; using QSB.WorldSync; -namespace QSB.StationaryProbeLauncherSync.Patches; +namespace QSB.Tools.ProbeLauncherTool.Patches; [HarmonyPatch] public class StationaryProbeLauncherPatches : QSBPatch diff --git a/QSB/Tools/ProbeLauncherTool/ProbeLauncherManager.cs b/QSB/Tools/ProbeLauncherTool/ProbeLauncherManager.cs index 60ca8d8e..76123255 100644 --- a/QSB/Tools/ProbeLauncherTool/ProbeLauncherManager.cs +++ b/QSB/Tools/ProbeLauncherTool/ProbeLauncherManager.cs @@ -1,5 +1,6 @@ using Cysharp.Threading.Tasks; using QSB.Tools.ProbeLauncherTool.WorldObjects; +using QSB.Utility; using QSB.WorldSync; using System.Linq; using System.Threading; @@ -13,6 +14,8 @@ internal class ProbeLauncherManager : WorldObjectManager public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct) { QSBWorldSync.Init(typeof(PlayerProbeLauncher), typeof(StationaryProbeLauncher)); + // Using ProbeLaunchers here so we can do inheritance, put only applying it to found StationaryProbeLauncher + QSBWorldSync.Init(QSBWorldSync.GetUnityObjects().SortDeterministic()); if (scene == OWScene.SolarSystem) { QSBWorldSync.Init(new[] diff --git a/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSyncer.cs b/QSB/Tools/ProbeLauncherTool/VariableSync/StationaryProbeLauncherVariableSync.cs similarity index 87% rename from QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSyncer.cs rename to QSB/Tools/ProbeLauncherTool/VariableSync/StationaryProbeLauncherVariableSync.cs index 3c464b98..182ab993 100644 --- a/QSB/StationaryProbeLauncherSync/VariableSync/StationaryProbeLauncherVariableSyncer.cs +++ b/QSB/Tools/ProbeLauncherTool/VariableSync/StationaryProbeLauncherVariableSync.cs @@ -1,13 +1,13 @@ using Mirror; -using QSB.StationaryProbeLauncherSync.WorldObjects; +using QSB.Tools.ProbeLauncherTool.WorldObjects; using QSB.Utility.LinkedWorldObject; using QSB.Utility.VariableSync; using QSB.WorldSync; using UnityEngine; -namespace QSB.StationaryProbeLauncherSync.VariableSync; +namespace QSB.Tools.ProbeLauncherTool.VariableSync; -public class StationaryProbeLauncherVariableSyncer : BaseVariableSyncer<(float, float, float)>, ILinkedNetworkBehaviour +public class StationaryProbeLauncherVariableSync : BaseVariableSyncer<(float, float, float)>, ILinkedNetworkBehaviour { protected override bool HasChanged() { diff --git a/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs b/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs index 72c800aa..0a9df25a 100644 --- a/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs +++ b/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs @@ -12,7 +12,7 @@ namespace QSB.Tools.ProbeLauncherTool.WorldObjects; public class QSBProbeLauncher : WorldObject { private uint _probeOwnerID = uint.MaxValue; - protected QSBProbe LaunchedProbe { get; private set; } + protected QSBSurveyorProbe LaunchedProbe { get; private set; } public override async UniTask Init(CancellationToken ct) => AttachedObject.OnLaunchProbe += OnLaunchProbe; diff --git a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs b/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBStationaryProbeLauncher.cs similarity index 86% rename from QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs rename to QSB/Tools/ProbeLauncherTool/WorldObjects/QSBStationaryProbeLauncher.cs index 9d5a6cfc..0d176585 100644 --- a/QSB/StationaryProbeLauncherSync/WorldObjects/QSBStationaryProbeLauncher.cs +++ b/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBStationaryProbeLauncher.cs @@ -3,20 +3,19 @@ using Mirror; using QSB.AuthoritySync; using QSB.Messaging; using QSB.Player; -using QSB.StationaryProbeLauncherSync.Messages; -using QSB.StationaryProbeLauncherSync.VariableSync; -using QSB.Tools.ProbeLauncherTool.WorldObjects; +using QSB.Tools.ProbeLauncherTool.Messages; +using QSB.Tools.ProbeLauncherTool.VariableSync; using QSB.Utility.LinkedWorldObject; using System.Threading; -namespace QSB.StationaryProbeLauncherSync.WorldObjects; +namespace QSB.Tools.ProbeLauncherTool.WorldObjects; -public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject +public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject { private uint _currentUser = uint.MaxValue; - public StationaryProbeLauncherVariableSyncer NetworkBehaviour { get; private set; } - public void SetNetworkBehaviour(NetworkBehaviour networkBehaviour) => NetworkBehaviour = (StationaryProbeLauncherVariableSyncer)networkBehaviour; + public StationaryProbeLauncherVariableSync NetworkBehaviour { get; private set; } + public void SetNetworkBehaviour(NetworkBehaviour networkBehaviour) => NetworkBehaviour = (StationaryProbeLauncherVariableSync)networkBehaviour; private bool _isInUse; private StationaryProbeLauncher _stationaryProbeLauncher; diff --git a/QSB/Tools/ProbeTool/ProbeCreator.cs b/QSB/Tools/ProbeTool/ProbeCreator.cs index 4a82e84b..8742ac34 100644 --- a/QSB/Tools/ProbeTool/ProbeCreator.cs +++ b/QSB/Tools/ProbeTool/ProbeCreator.cs @@ -26,7 +26,7 @@ internal static class ProbeCreator { var REMOTE_Probe_Body = Object.Instantiate(GetPrefab()); - var qsbProbe = REMOTE_Probe_Body.GetComponent(); + var qsbProbe = REMOTE_Probe_Body.GetComponent(); player.Probe = qsbProbe; qsbProbe.SetOwner(player); diff --git a/QSB/Tools/ProbeTool/QSBProbeEffects.cs b/QSB/Tools/ProbeTool/QSBProbeEffects.cs index 3db0412e..358dcbc7 100644 --- a/QSB/Tools/ProbeTool/QSBProbeEffects.cs +++ b/QSB/Tools/ProbeTool/QSBProbeEffects.cs @@ -11,11 +11,11 @@ internal class QSBProbeEffects : MonoBehaviour public OWAudioSource _anchorAudio; public ParticleSystem _anchorParticles; - private QSBProbe _probe; + private QSBSurveyorProbe _probe; private void Awake() { - _probe = QSBWorldSync.GetUnityObjects().First(x => gameObject.transform.IsChildOf(x.transform)); + _probe = QSBWorldSync.GetUnityObjects().First(x => gameObject.transform.IsChildOf(x.transform)); if (_probe == null) { DebugLog.ToConsole($"Error - Couldn't find QSBProbe!", OWML.Common.MessageType.Error); diff --git a/QSB/Tools/ProbeTool/QSBProbeLantern.cs b/QSB/Tools/ProbeTool/QSBProbeLantern.cs index 74365302..c01a9f1b 100644 --- a/QSB/Tools/ProbeTool/QSBProbeLantern.cs +++ b/QSB/Tools/ProbeTool/QSBProbeLantern.cs @@ -13,7 +13,7 @@ internal class QSBProbeLantern : MonoBehaviour public OWEmissiveRenderer _emissiveRenderer; public float _originalRange; - private QSBProbe _probe; + private QSBSurveyorProbe _probe; private OWLight2 _light; private float _fadeFraction; private float _targetFade; @@ -23,7 +23,7 @@ internal class QSBProbeLantern : MonoBehaviour private void Awake() { - _probe = QSBWorldSync.GetUnityObjects().First(x => gameObject.transform.IsChildOf(x.transform)); + _probe = QSBWorldSync.GetUnityObjects().First(x => gameObject.transform.IsChildOf(x.transform)); if (_probe == null) { DebugLog.ToConsole($"Error - Couldn't find QSBProbe!", OWML.Common.MessageType.Error); diff --git a/QSB/Tools/ProbeTool/QSBProbeSpotlight.cs b/QSB/Tools/ProbeTool/QSBProbeSpotlight.cs index 2e235cd2..a8e07a3a 100644 --- a/QSB/Tools/ProbeTool/QSBProbeSpotlight.cs +++ b/QSB/Tools/ProbeTool/QSBProbeSpotlight.cs @@ -11,13 +11,13 @@ internal class QSBProbeSpotlight : MonoBehaviour public float _fadeInLength = 1f; public float _intensity; - private QSBProbe _probe; + private QSBSurveyorProbe _probe; private OWLight2 _light; private float _timer; private void Awake() { - _probe = QSBWorldSync.GetUnityObjects().First(x => gameObject.transform.IsChildOf(x.transform)); + _probe = QSBWorldSync.GetUnityObjects().First(x => gameObject.transform.IsChildOf(x.transform)); if (_probe == null) { DebugLog.ToConsole($"Error - Couldn't find QSBProbe!", OWML.Common.MessageType.Error); diff --git a/QSB/Tools/ProbeTool/QSBProbe.cs b/QSB/Tools/ProbeTool/QSBSurveyorProbe.cs similarity index 98% rename from QSB/Tools/ProbeTool/QSBProbe.cs rename to QSB/Tools/ProbeTool/QSBSurveyorProbe.cs index 577be66b..737cf296 100644 --- a/QSB/Tools/ProbeTool/QSBProbe.cs +++ b/QSB/Tools/ProbeTool/QSBSurveyorProbe.cs @@ -4,7 +4,7 @@ using UnityEngine; namespace QSB.Tools.ProbeTool; -public class QSBProbe : MonoBehaviour, ILightSource +public class QSBSurveyorProbe : MonoBehaviour, ILightSource { public delegate void SurveyorProbeEvent(); public delegate void RetrieveEvent(float retrieveLength); From 423c3803caba115e6c10bd384d097593fcaf9842 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 27 Aug 2022 11:21:09 -0700 Subject: [PATCH 27/29] im a dumbass --- QSB/QSBNetworkManager.cs | 2 +- ...ableSync.cs => StationaryProbeLauncherVariableSyncer.cs} | 2 +- .../WorldObjects/QSBStationaryProbeLauncher.cs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) rename QSB/Tools/ProbeLauncherTool/VariableSync/{StationaryProbeLauncherVariableSync.cs => StationaryProbeLauncherVariableSyncer.cs} (93%) diff --git a/QSB/QSBNetworkManager.cs b/QSB/QSBNetworkManager.cs index 3ee53eed..7f076104 100644 --- a/QSB/QSBNetworkManager.cs +++ b/QSB/QSBNetworkManager.cs @@ -151,7 +151,7 @@ public class QSBNetworkManager : NetworkManager, IAddComponentOnStart ModelShipPrefab = MakeNewNetworkObject(14, "NetworkModelShip", typeof(ModelShipTransformSync)); spawnPrefabs.Add(ModelShipPrefab); - StationaryProbeLauncherPrefab = MakeNewNetworkObject(15, "NetworkStationaryProbeLauncher", typeof(StationaryProbeLauncherVariableSync)); + StationaryProbeLauncherPrefab = MakeNewNetworkObject(15, "NetworkStationaryProbeLauncher", typeof(StationaryProbeLauncherVariableSyncer)); spawnPrefabs.Add(StationaryProbeLauncherPrefab); ConfigureNetworkManager(); diff --git a/QSB/Tools/ProbeLauncherTool/VariableSync/StationaryProbeLauncherVariableSync.cs b/QSB/Tools/ProbeLauncherTool/VariableSync/StationaryProbeLauncherVariableSyncer.cs similarity index 93% rename from QSB/Tools/ProbeLauncherTool/VariableSync/StationaryProbeLauncherVariableSync.cs rename to QSB/Tools/ProbeLauncherTool/VariableSync/StationaryProbeLauncherVariableSyncer.cs index 182ab993..b857afec 100644 --- a/QSB/Tools/ProbeLauncherTool/VariableSync/StationaryProbeLauncherVariableSync.cs +++ b/QSB/Tools/ProbeLauncherTool/VariableSync/StationaryProbeLauncherVariableSyncer.cs @@ -7,7 +7,7 @@ using UnityEngine; namespace QSB.Tools.ProbeLauncherTool.VariableSync; -public class StationaryProbeLauncherVariableSync : BaseVariableSyncer<(float, float, float)>, ILinkedNetworkBehaviour +public class StationaryProbeLauncherVariableSyncer : BaseVariableSyncer<(float, float, float)>, ILinkedNetworkBehaviour { protected override bool HasChanged() { diff --git a/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBStationaryProbeLauncher.cs b/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBStationaryProbeLauncher.cs index 0d176585..23c89afe 100644 --- a/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBStationaryProbeLauncher.cs +++ b/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBStationaryProbeLauncher.cs @@ -10,12 +10,12 @@ using System.Threading; namespace QSB.Tools.ProbeLauncherTool.WorldObjects; -public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject +public class QSBStationaryProbeLauncher : QSBProbeLauncher, ILinkedWorldObject { private uint _currentUser = uint.MaxValue; - public StationaryProbeLauncherVariableSync NetworkBehaviour { get; private set; } - public void SetNetworkBehaviour(NetworkBehaviour networkBehaviour) => NetworkBehaviour = (StationaryProbeLauncherVariableSync)networkBehaviour; + public StationaryProbeLauncherVariableSyncer NetworkBehaviour { get; private set; } + public void SetNetworkBehaviour(NetworkBehaviour networkBehaviour) => NetworkBehaviour = (StationaryProbeLauncherVariableSyncer)networkBehaviour; private bool _isInUse; private StationaryProbeLauncher _stationaryProbeLauncher; From ba40bd9c5057c7cc8ebc73346c770a19685b2557 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 27 Aug 2022 11:27:16 -0700 Subject: [PATCH 28/29] ok dont renamed probe yet cuz unity project --- .../LightSensorSync/Patches/LightSensorPatches.cs | 4 ++-- QSB/Player/PlayerInfoParts/Tools.cs | 2 +- QSB/Player/QSBPlayerManager.cs | 2 +- QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs | 2 +- QSB/Tools/ProbeTool/ProbeCreator.cs | 2 +- QSB/Tools/ProbeTool/{QSBSurveyorProbe.cs => QSBProbe.cs} | 2 +- QSB/Tools/ProbeTool/QSBProbeEffects.cs | 4 ++-- QSB/Tools/ProbeTool/QSBProbeLantern.cs | 4 ++-- QSB/Tools/ProbeTool/QSBProbeSpotlight.cs | 4 ++-- 9 files changed, 13 insertions(+), 13 deletions(-) rename QSB/Tools/ProbeTool/{QSBSurveyorProbe.cs => QSBProbe.cs} (98%) diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs index dd0a4247..d060a2f7 100644 --- a/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs +++ b/QSB/EchoesOfTheEye/LightSensorSync/Patches/LightSensorPatches.cs @@ -247,7 +247,7 @@ internal class LightSensorPatches : QSBPatch } case LightSourceType.PROBE: { - if (lightSource is QSBSurveyorProbe qsbProbe) + if (lightSource is QSBProbe qsbProbe) { var probe = qsbProbe; if (probe != null && @@ -350,7 +350,7 @@ internal class LightSensorPatches : QSBPatch } case LightSourceType.PROBE: { - if (lightSource is not QSBSurveyorProbe) + if (lightSource is not QSBProbe) { var probe = Locator.GetProbe(); if (probe != null && diff --git a/QSB/Player/PlayerInfoParts/Tools.cs b/QSB/Player/PlayerInfoParts/Tools.cs index 04141b5c..65788e41 100644 --- a/QSB/Player/PlayerInfoParts/Tools.cs +++ b/QSB/Player/PlayerInfoParts/Tools.cs @@ -15,7 +15,7 @@ namespace QSB.Player; public partial class PlayerInfo { public GameObject ProbeBody { get; set; } - public QSBSurveyorProbe Probe { get; set; } + public QSBProbe Probe { get; set; } public QSBFlashlight FlashLight => CameraBody == null ? null : CameraBody.GetComponentInChildren(); public QSBTool Signalscope => GetToolByType(ToolType.Signalscope); public QSBTool Translator => GetToolByType(ToolType.Translator); diff --git a/QSB/Player/QSBPlayerManager.cs b/QSB/Player/QSBPlayerManager.cs index a7216c8e..20fcf91d 100644 --- a/QSB/Player/QSBPlayerManager.cs +++ b/QSB/Player/QSBPlayerManager.cs @@ -88,7 +88,7 @@ public static class QSBPlayerManager public static (Flashlight LocalFlashlight, IEnumerable RemoteFlashlights) GetPlayerFlashlights() => (Locator.GetFlashlight(), PlayerList.Where(x => x.FlashLight != null).Select(x => x.FlashLight)); - public static (SurveyorProbe LocalProbe, IEnumerable RemoteProbes) GetPlayerProbes() + public static (SurveyorProbe LocalProbe, IEnumerable RemoteProbes) GetPlayerProbes() => (Locator.GetProbe(), PlayerList.Where(x => x.Probe != null).Select(x => x.Probe)); public static IEnumerable GetThrusterLightTrackers() diff --git a/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs b/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs index 0a9df25a..72c800aa 100644 --- a/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs +++ b/QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs @@ -12,7 +12,7 @@ namespace QSB.Tools.ProbeLauncherTool.WorldObjects; public class QSBProbeLauncher : WorldObject { private uint _probeOwnerID = uint.MaxValue; - protected QSBSurveyorProbe LaunchedProbe { get; private set; } + protected QSBProbe LaunchedProbe { get; private set; } public override async UniTask Init(CancellationToken ct) => AttachedObject.OnLaunchProbe += OnLaunchProbe; diff --git a/QSB/Tools/ProbeTool/ProbeCreator.cs b/QSB/Tools/ProbeTool/ProbeCreator.cs index 8742ac34..4a82e84b 100644 --- a/QSB/Tools/ProbeTool/ProbeCreator.cs +++ b/QSB/Tools/ProbeTool/ProbeCreator.cs @@ -26,7 +26,7 @@ internal static class ProbeCreator { var REMOTE_Probe_Body = Object.Instantiate(GetPrefab()); - var qsbProbe = REMOTE_Probe_Body.GetComponent(); + var qsbProbe = REMOTE_Probe_Body.GetComponent(); player.Probe = qsbProbe; qsbProbe.SetOwner(player); diff --git a/QSB/Tools/ProbeTool/QSBSurveyorProbe.cs b/QSB/Tools/ProbeTool/QSBProbe.cs similarity index 98% rename from QSB/Tools/ProbeTool/QSBSurveyorProbe.cs rename to QSB/Tools/ProbeTool/QSBProbe.cs index 737cf296..577be66b 100644 --- a/QSB/Tools/ProbeTool/QSBSurveyorProbe.cs +++ b/QSB/Tools/ProbeTool/QSBProbe.cs @@ -4,7 +4,7 @@ using UnityEngine; namespace QSB.Tools.ProbeTool; -public class QSBSurveyorProbe : MonoBehaviour, ILightSource +public class QSBProbe : MonoBehaviour, ILightSource { public delegate void SurveyorProbeEvent(); public delegate void RetrieveEvent(float retrieveLength); diff --git a/QSB/Tools/ProbeTool/QSBProbeEffects.cs b/QSB/Tools/ProbeTool/QSBProbeEffects.cs index 358dcbc7..3db0412e 100644 --- a/QSB/Tools/ProbeTool/QSBProbeEffects.cs +++ b/QSB/Tools/ProbeTool/QSBProbeEffects.cs @@ -11,11 +11,11 @@ internal class QSBProbeEffects : MonoBehaviour public OWAudioSource _anchorAudio; public ParticleSystem _anchorParticles; - private QSBSurveyorProbe _probe; + private QSBProbe _probe; private void Awake() { - _probe = QSBWorldSync.GetUnityObjects().First(x => gameObject.transform.IsChildOf(x.transform)); + _probe = QSBWorldSync.GetUnityObjects().First(x => gameObject.transform.IsChildOf(x.transform)); if (_probe == null) { DebugLog.ToConsole($"Error - Couldn't find QSBProbe!", OWML.Common.MessageType.Error); diff --git a/QSB/Tools/ProbeTool/QSBProbeLantern.cs b/QSB/Tools/ProbeTool/QSBProbeLantern.cs index c01a9f1b..74365302 100644 --- a/QSB/Tools/ProbeTool/QSBProbeLantern.cs +++ b/QSB/Tools/ProbeTool/QSBProbeLantern.cs @@ -13,7 +13,7 @@ internal class QSBProbeLantern : MonoBehaviour public OWEmissiveRenderer _emissiveRenderer; public float _originalRange; - private QSBSurveyorProbe _probe; + private QSBProbe _probe; private OWLight2 _light; private float _fadeFraction; private float _targetFade; @@ -23,7 +23,7 @@ internal class QSBProbeLantern : MonoBehaviour private void Awake() { - _probe = QSBWorldSync.GetUnityObjects().First(x => gameObject.transform.IsChildOf(x.transform)); + _probe = QSBWorldSync.GetUnityObjects().First(x => gameObject.transform.IsChildOf(x.transform)); if (_probe == null) { DebugLog.ToConsole($"Error - Couldn't find QSBProbe!", OWML.Common.MessageType.Error); diff --git a/QSB/Tools/ProbeTool/QSBProbeSpotlight.cs b/QSB/Tools/ProbeTool/QSBProbeSpotlight.cs index a8e07a3a..2e235cd2 100644 --- a/QSB/Tools/ProbeTool/QSBProbeSpotlight.cs +++ b/QSB/Tools/ProbeTool/QSBProbeSpotlight.cs @@ -11,13 +11,13 @@ internal class QSBProbeSpotlight : MonoBehaviour public float _fadeInLength = 1f; public float _intensity; - private QSBSurveyorProbe _probe; + private QSBProbe _probe; private OWLight2 _light; private float _timer; private void Awake() { - _probe = QSBWorldSync.GetUnityObjects().First(x => gameObject.transform.IsChildOf(x.transform)); + _probe = QSBWorldSync.GetUnityObjects().First(x => gameObject.transform.IsChildOf(x.transform)); if (_probe == null) { DebugLog.ToConsole($"Error - Couldn't find QSBProbe!", OWML.Common.MessageType.Error); From 7378eeda988120725349a348c30ae3c3cb327045 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 27 Aug 2022 14:41:44 -0400 Subject: [PATCH 29/29] Make probe play warp effect when retrieved Previously only played directly on the launcher --- QSB/Tools/ProbeTool/QSBProbeEffects.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/QSB/Tools/ProbeTool/QSBProbeEffects.cs b/QSB/Tools/ProbeTool/QSBProbeEffects.cs index 3db0412e..37c8bd20 100644 --- a/QSB/Tools/ProbeTool/QSBProbeEffects.cs +++ b/QSB/Tools/ProbeTool/QSBProbeEffects.cs @@ -59,7 +59,10 @@ internal class QSBProbeEffects : MonoBehaviour => _flightLoopAudio.FadeIn(0.5f); private void OnStartRetrieve(float retrieveLength) - => _flightLoopAudio.FadeOut(retrieveLength); + { + _flightLoopAudio.FadeOut(retrieveLength); + _anchorAudio.PlayOneShot(AudioType.ToolProbeRetrieve); + } private void OnTakeSnapshot() => _anchorAudio.PlayOneShot(AudioType.ToolProbeTakePhoto);