mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-20 15:41:01 +00:00
add tomb patches + messages
This commit is contained in:
parent
6e2dba8e9c
commit
92ed2ea3cc
16
QSB/EyeOfTheUniverse/Tomb/Messages/EnterExitStageMessage.cs
Normal file
16
QSB/EyeOfTheUniverse/Tomb/Messages/EnterExitStageMessage.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using QSB.Messaging;
|
||||
using QSB.WorldSync;
|
||||
using System.Linq;
|
||||
|
||||
namespace QSB.EyeOfTheUniverse.Tomb.Messages;
|
||||
|
||||
internal class EnterExitStageMessage : QSBMessage<bool>
|
||||
{
|
||||
public EnterExitStageMessage(bool enter) : base(enter) { }
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
var tomb = QSBWorldSync.GetUnityObjects<EyeTombController>().First();
|
||||
tomb._candleController.FadeTo(Data ? 1f : 0f, 1f);
|
||||
}
|
||||
}
|
43
QSB/EyeOfTheUniverse/Tomb/Messages/ToggleLitStateMessage.cs
Normal file
43
QSB/EyeOfTheUniverse/Tomb/Messages/ToggleLitStateMessage.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using QSB.Messaging;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
|
||||
namespace QSB.EyeOfTheUniverse.Tomb.Messages;
|
||||
|
||||
internal class ToggleLitStateMessage : QSBMessage<(int stateIndex, int direction, bool wasLit)>
|
||||
{
|
||||
public ToggleLitStateMessage(int currentStateIndex, int direction, bool wasLit) : base((currentStateIndex, direction, wasLit)) { }
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
var tomb = QSBWorldSync.GetUnityObject<EyeTombController>();
|
||||
|
||||
if (tomb._stateIndex != Data.stateIndex)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Received ToggleLitStateMessage with stateIndex of {Data.stateIndex}, but is currently {tomb._stateIndex}. Correcting...");
|
||||
tomb._states[tomb._stateIndex].SetActive(false);
|
||||
tomb._stateIndex = Data.stateIndex;
|
||||
}
|
||||
|
||||
if (tomb._lit != Data.wasLit)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Received ToggleLitStateMessage, and the value of lit did not match. Correcting...");
|
||||
tomb._lit = Data.wasLit;
|
||||
}
|
||||
|
||||
tomb._lit = !tomb._lit;
|
||||
tomb._planetLightController.SetIntensity(tomb._lit ? 1f : 0f);
|
||||
tomb._planetObject.SetActive(tomb._lit);
|
||||
tomb._lightBeamController.SetFade(tomb._lit ? 1f : 0f);
|
||||
|
||||
if (!tomb._lit)
|
||||
{
|
||||
tomb._states[tomb._stateIndex].SetActive(false);
|
||||
tomb._stateIndex += Data.direction;
|
||||
tomb._states[tomb._stateIndex].SetActive(true);
|
||||
}
|
||||
|
||||
tomb._gearEffects.AddRotation(Data.direction * 45f, 0f);
|
||||
tomb._oneShotSource.PlayOneShot((Data.direction > 0f) ? AudioType.Projector_Next : AudioType.Projector_Prev, 1f);
|
||||
}
|
||||
}
|
25
QSB/EyeOfTheUniverse/Tomb/Messages/UseTombMessage.cs
Normal file
25
QSB/EyeOfTheUniverse/Tomb/Messages/UseTombMessage.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using QSB.Messaging;
|
||||
using QSB.WorldSync;
|
||||
|
||||
namespace QSB.EyeOfTheUniverse.Tomb.Messages;
|
||||
|
||||
internal class UseTombMessage : QSBMessage<bool>
|
||||
{
|
||||
public UseTombMessage(bool use) : base(use) { }
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
var tomb = QSBWorldSync.GetUnityObject<EyeTombController>();
|
||||
|
||||
if (Data)
|
||||
{
|
||||
if (!tomb._hasMovedSignalDeeper)
|
||||
{
|
||||
tomb._hasMovedSignalDeeper = true;
|
||||
tomb._buriedSignal.transform.position = tomb._signalDeepSocket.position;
|
||||
}
|
||||
}
|
||||
|
||||
tomb._interactReceiver.SetInteractionEnabled(!Data);
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
using HarmonyLib;
|
||||
using QSB.EyeOfTheUniverse.Tomb.Messages;
|
||||
using QSB.Messaging;
|
||||
using QSB.Patches;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.EyeOfTheUniverse.Tomb.Patches;
|
||||
|
||||
[HarmonyPatch(typeof(EyeTombController))]
|
||||
internal class EyeTombControllerPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(nameof(EyeTombController.OnPressInteract))]
|
||||
public static void OnPressInteract() => new UseTombMessage(true).Send();
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(nameof(EyeTombController.CancelInteraction))]
|
||||
public static void CancelInteract() => new UseTombMessage(false).Send();
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(EyeTombController.OnEnterStage))]
|
||||
public static bool OnEnterStage(EyeTombController __instance, GameObject hitObj)
|
||||
{
|
||||
if (hitObj.CompareTag("PlayerDetector"))
|
||||
{
|
||||
__instance._candleController.FadeTo(1, 1);
|
||||
new EnterExitStageMessage(true).Send();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(EyeTombController.OnExitStage))]
|
||||
public static bool OnExitStage(EyeTombController __instance, GameObject hitObj)
|
||||
{
|
||||
if (hitObj.CompareTag("PlayerDetector"))
|
||||
{
|
||||
__instance._candleController.FadeTo(0, 1);
|
||||
new EnterExitStageMessage(false).Send();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(EyeTombController.ToggleLitState))]
|
||||
public static bool ToggleLitState(EyeTombController __instance, int direction)
|
||||
{
|
||||
var newStateIndex = __instance._stateIndex + direction;
|
||||
if (__instance._lit && (newStateIndex < 0 || newStateIndex > __instance._states.Length - 1))
|
||||
{
|
||||
__instance._gearEffects.PlayFailure(direction > 0, 1f);
|
||||
return false;
|
||||
}
|
||||
|
||||
new ToggleLitStateMessage(__instance._stateIndex, direction, __instance._lit).Send();
|
||||
|
||||
__instance._lit = !__instance._lit;
|
||||
__instance._planetLightController.SetIntensity(__instance._lit ? 1f : 0f);
|
||||
__instance._planetObject.SetActive(__instance._lit);
|
||||
__instance._lightBeamController.SetFade(__instance._lit ? 1f : 0f);
|
||||
if (!__instance._lit)
|
||||
{
|
||||
__instance._states[__instance._stateIndex].SetActive(false);
|
||||
__instance._stateIndex += direction;
|
||||
__instance._states[__instance._stateIndex].SetActive(true);
|
||||
}
|
||||
|
||||
__instance._gearEffects.AddRotation(direction * 45f, 0f);
|
||||
__instance._oneShotSource.PlayOneShot((direction > 0f) ? AudioType.Projector_Next : AudioType.Projector_Prev, 1f);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user