mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
fix gathering instruments
This commit is contained in:
parent
96fd427bfb
commit
41972f232e
@ -3,6 +3,7 @@ using QSB.Events;
|
||||
using QSB.EyeOfTheUniverse.InstrumentSync.WorldObjects;
|
||||
using QSB.Patches;
|
||||
using QSB.WorldSync;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.EyeOfTheUniverse.InstrumentSync.Patches
|
||||
{
|
||||
@ -11,8 +12,36 @@ namespace QSB.EyeOfTheUniverse.InstrumentSync.Patches
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(QuantumInstrument), nameof(QuantumInstrument.Gather))]
|
||||
public static void Gather(QuantumInstrument __instance)
|
||||
[HarmonyPatch(typeof(QuantumInstrument), nameof(QuantumInstrument.OnPressInteract))]
|
||||
public static void OnPressInteract(QuantumInstrument __instance)
|
||||
=> QSBEventManager.FireEvent(EventNames.QSBGatherInstrument, QSBWorldSync.GetWorldFromUnity<QSBQuantumInstrument>(__instance));
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(QuantumInstrument), nameof(QuantumInstrument.Update))]
|
||||
public static bool Update(QuantumInstrument __instance)
|
||||
{
|
||||
if (__instance._gatherWithScope && !__instance._waitToFlickerOut)
|
||||
{
|
||||
__instance._scopeGatherPrompt.SetVisibility(false);
|
||||
if (Locator.GetToolModeSwapper().GetSignalScope().InZoomMode()
|
||||
&& Vector3.Angle(__instance.transform.position - Locator.GetPlayerCamera().transform.position, Locator.GetPlayerCamera().transform.forward) < 1f)
|
||||
{
|
||||
__instance._scopeGatherPrompt.SetVisibility(true);
|
||||
if (OWInput.IsNewlyPressed(InputLibrary.interact, InputMode.All))
|
||||
{
|
||||
__instance.Gather();
|
||||
QSBEventManager.FireEvent(EventNames.QSBGatherInstrument, QSBWorldSync.GetWorldFromUnity<QSBQuantumInstrument>(__instance));
|
||||
Locator.GetPromptManager().RemoveScreenPrompt(__instance._scopeGatherPrompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance._waitToFlickerOut && Time.time > __instance._flickerOutTime)
|
||||
{
|
||||
__instance.FinishGather();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user