From 2baeba1ede130cfbfeb57a5a553c5f53e01fff3e Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Sun, 14 Feb 2021 20:39:40 +0000 Subject: [PATCH] fix clouds appearing in eye state --- .../Events/MoonStateChangeEvent.cs | 20 +++++++++++++++++-- .../Patches/ServerQuantumPatches.cs | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/QSB/QuantumSync/Events/MoonStateChangeEvent.cs b/QSB/QuantumSync/Events/MoonStateChangeEvent.cs index a222d9f1..be3ab92a 100644 --- a/QSB/QuantumSync/Events/MoonStateChangeEvent.cs +++ b/QSB/QuantumSync/Events/MoonStateChangeEvent.cs @@ -1,5 +1,6 @@ using OWML.Utils; using QSB.Events; +using QSB.Utility; using System.Linq; using System.Reflection; using UnityEngine; @@ -29,7 +30,7 @@ namespace QSB.QuantumSync.Events { return; } - + DebugLog.DebugWrite($"Moon to state {message.StateIndex}"); var moon = Locator.GetQuantumMoon(); var wasPlayerEntangled = moon.IsPlayerEntangled(); var location = new RelativeLocationData(Locator.GetPlayerTransform().GetComponent(), moon.transform); @@ -49,7 +50,22 @@ namespace QSB.QuantumSync.Events moonBody.SetVelocity(OWPhysics.CalculateOrbitVelocity(owRigidbody, moonBody, message.OrbitAngle) + owRigidbody.GetVelocity()); moon.SetValue("_stateIndex", message.StateIndex); - moon.GetType().GetMethod("SetSurfaceState", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(moon, new object[] { message.StateIndex }); + if (moon.IsPlayerInside()) + { + moon.GetType().GetMethod("SetSurfaceState", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(moon, new object[] { message.StateIndex }); + } + else + { + moon.GetType().GetMethod("SetSurfaceState", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(moon, new object[] { -1 }); + moon.GetValue("_quantumSignal").SetSignalActivation(message.StateIndex != 5, 2f); + } + moon.GetValue("_referenceFrameVolume").gameObject.SetActive(message.StateIndex != 5); + moonBody.SetIsTargetable(message.StateIndex != 5); + foreach (var obj in moon.GetValue("_deactivateAtEye")) + { + obj.SetActive(message.StateIndex != 5); + } + GlobalMessenger.FireEvent("QuantumMoonChangeState", moonBody); if (wasPlayerEntangled) { diff --git a/QSB/QuantumSync/Patches/ServerQuantumPatches.cs b/QSB/QuantumSync/Patches/ServerQuantumPatches.cs index ae6b5b46..877ea6cb 100644 --- a/QSB/QuantumSync/Patches/ServerQuantumPatches.cs +++ b/QSB/QuantumSync/Patches/ServerQuantumPatches.cs @@ -157,7 +157,7 @@ namespace QSB.QuantumSync.Patches { ____deactivateAtEye[l].SetActive(____stateIndex != 5); } - QSBEventManager.FireEvent("QuantumMoonChangeState", ____moonBody); + GlobalMessenger.FireEvent("QuantumMoonChangeState", ____moonBody); __result = true; return false; }