quantum-space-buddies/QSB/Player/Patches/VolumePatches.cs

65 lines
2.1 KiB
C#
Raw Normal View History

2022-05-31 14:31:12 +00:00
using HarmonyLib;
using QSB.Patches;
2022-10-05 06:45:20 +00:00
using QSB.Utility;
2022-05-31 14:31:12 +00:00
using UnityEngine;
namespace QSB.Player.Patches;
2023-07-28 18:30:57 +00:00
public class VolumePatches : QSBPatch
2022-05-31 14:31:12 +00:00
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
[HarmonyPostfix]
[HarmonyPatch(typeof(FluidVolume), nameof(FluidVolume.OnEffectVolumeEnter))]
public static void OnEffectVolumeEnter(FluidVolume __instance, GameObject hitObj)
{
var comp = hitObj.GetComponent<RemotePlayerFluidDetector>();
if (comp != null)
{
comp.AddVolume(__instance);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(FluidVolume), nameof(FluidVolume.OnEffectVolumeExit))]
public static void OnEffectVolumeExit(FluidVolume __instance, GameObject hitObj)
{
var comp = hitObj.GetComponent<RemotePlayerFluidDetector>();
if (comp != null)
{
comp.RemoveVolume(__instance);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(RingRiverFluidVolume), nameof(RingRiverFluidVolume.OnEffectVolumeEnter))]
public static void OnEffectVolumeEnter(RingRiverFluidVolume __instance, GameObject hitObj)
{
var comp = hitObj.GetComponent<RemotePlayerFluidDetector>();
if (comp != null)
{
comp.AddVolume(__instance);
}
}
2022-08-09 22:50:27 +00:00
[HarmonyPrefix]
[HarmonyPatch(typeof(ElectricityVolume), nameof(ElectricityVolume.OnEffectVolumeEnter))]
[HarmonyPatch(typeof(DreamWarpVolume), nameof(DreamWarpVolume.OnEnterTriggerVolume))]
[HarmonyPatch(typeof(NomaiWarpPlatform), nameof(NomaiWarpPlatform.OnEntry))]
2022-10-05 06:45:20 +00:00
public static bool PreventRemotePlayerEnter(object __instance, GameObject hitObj)
{
DebugLog.DebugWrite($"{__instance} funny prevent enter {hitObj}");
// TODO: also do this with remote probes
2022-10-06 23:05:36 +00:00
return hitObj.name is not ("REMOTE_PlayerDetector" or "REMOTE_CameraDetector");
2022-10-05 06:45:20 +00:00
}
[HarmonyPrefix]
[HarmonyPatch(typeof(VanishVolume), nameof(VanishVolume.OnTriggerEnter))]
public static bool PreventRemotePlayerEnter(object __instance, Collider hitCollider)
{
DebugLog.DebugWrite($"{__instance} funny prevent enter {hitCollider}");
// TODO: also do this with remote probes
return hitCollider.name is not ("REMOTE_PlayerDetector" or "REMOTE_CameraDetector");
}
2022-05-31 14:31:12 +00:00
}