fix clouds appearing in eye state

This commit is contained in:
Mister_Nebula 2021-02-14 20:39:40 +00:00
parent 98c275085a
commit 2baeba1ede
2 changed files with 19 additions and 3 deletions

View File

@ -1,5 +1,6 @@
using OWML.Utils; using OWML.Utils;
using QSB.Events; using QSB.Events;
using QSB.Utility;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
@ -29,7 +30,7 @@ namespace QSB.QuantumSync.Events
{ {
return; return;
} }
DebugLog.DebugWrite($"Moon to state {message.StateIndex}");
var moon = Locator.GetQuantumMoon(); var moon = Locator.GetQuantumMoon();
var wasPlayerEntangled = moon.IsPlayerEntangled(); var wasPlayerEntangled = moon.IsPlayerEntangled();
var location = new RelativeLocationData(Locator.GetPlayerTransform().GetComponent<OWRigidbody>(), moon.transform); var location = new RelativeLocationData(Locator.GetPlayerTransform().GetComponent<OWRigidbody>(), moon.transform);
@ -49,7 +50,22 @@ namespace QSB.QuantumSync.Events
moonBody.SetVelocity(OWPhysics.CalculateOrbitVelocity(owRigidbody, moonBody, message.OrbitAngle) + owRigidbody.GetVelocity()); moonBody.SetVelocity(OWPhysics.CalculateOrbitVelocity(owRigidbody, moonBody, message.OrbitAngle) + owRigidbody.GetVelocity());
moon.SetValue("_stateIndex", message.StateIndex); 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<AudioSignal>("_quantumSignal").SetSignalActivation(message.StateIndex != 5, 2f);
}
moon.GetValue<ReferenceFrameVolume>("_referenceFrameVolume").gameObject.SetActive(message.StateIndex != 5);
moonBody.SetIsTargetable(message.StateIndex != 5);
foreach (var obj in moon.GetValue<GameObject[]>("_deactivateAtEye"))
{
obj.SetActive(message.StateIndex != 5);
}
GlobalMessenger<OWRigidbody>.FireEvent("QuantumMoonChangeState", moonBody);
if (wasPlayerEntangled) if (wasPlayerEntangled)
{ {

View File

@ -157,7 +157,7 @@ namespace QSB.QuantumSync.Patches
{ {
____deactivateAtEye[l].SetActive(____stateIndex != 5); ____deactivateAtEye[l].SetActive(____stateIndex != 5);
} }
QSBEventManager.FireEvent("QuantumMoonChangeState", ____moonBody); GlobalMessenger<OWRigidbody>.FireEvent("QuantumMoonChangeState", ____moonBody);
__result = true; __result = true;
return false; return false;
} }