ClearVision/ClientMod/ClearVisionPatches.cs

108 lines
4.6 KiB
C#
Raw Normal View History

using UnityEngine;
using BSG.CameraEffects;
using Aki.Reflection.Patching;
using System.Reflection;
namespace ClearVision {
public class GogglesPatches : ModulePatch {
2023-09-12 22:49:37 -04:00
protected override MethodBase GetTargetMethod() {
var result = typeof(NightVision).GetMethod("method_1", BindingFlags.Instance | BindingFlags.NonPublic);
return result;
}
2023-09-12 22:49:37 -04:00
[PatchPostfix]
static void Postfix() {
2023-09-13 22:13:13 -04:00
if(Plugin.GlobalEnabled.Value) { // sanity check
// Get Camera
GameObject maincam = GameObject.Find("FPS Camera");
NightVision nv = maincam.GetComponent<NightVision>();
CC_Vintage vintage = maincam.GetComponent<CC_Vintage>();
if(nv != null && (nv.On || nv.InProcessSwitching)) {
2023-09-15 21:55:38 -04:00
nv.Intensity = Plugin.NVGIntensity.Value;
nv.NoiseIntensity = Plugin.NVGNoiseIntensity.Value;
nv.NoiseScale = Plugin.NVGNoiseScale.Value;
if (Plugin.NVGMaskEnabled.Value) {
2023-09-13 22:13:13 -04:00
nv.TextureMask.enabled = true;
2023-09-15 21:55:38 -04:00
nv.TextureMask.Size = Plugin.NVGMaskSize.Value;
2023-09-13 22:13:13 -04:00
}
2023-09-15 21:55:38 -04:00
else {
nv.TextureMask.enabled = false;
}
nv.Color = Plugin.NVGColor.Value;
2023-09-13 22:13:13 -04:00
vintage.enabled = false;
return;
}
else {
vintage.enabled = true;
return;
}
2023-09-12 22:49:37 -04:00
}
}
}
public class ScopePatches : ModulePatch {
2023-09-12 22:49:37 -04:00
protected override MethodBase GetTargetMethod() {
Debug.LogError("ScopePatches GTM()");
var result = typeof(ThermalVision).GetMethod("method_1", BindingFlags.Instance | BindingFlags.NonPublic);
return result;
}
2023-09-12 22:49:37 -04:00
[PatchPostfix]
static void Postfix() {
2023-09-13 22:13:13 -04:00
Debug.LogError("ScopePatches Postfix()");
if(Plugin.GlobalEnabled.Value) { // sanity check
// Get Camera
GameObject maincam = GameObject.Find("FPS Camera");
ThermalVision t7 = maincam.GetComponent<ThermalVision>();
CC_Vintage vintage = maincam.GetComponent<CC_Vintage>();
// Get BaseOpticScope(Clone) obj, but need to check if it actually exists
2023-09-13 22:13:13 -04:00
GameObject scope = GameObject.FindGameObjectWithTag("OpticCamera");
ThermalVision thermal = scope.GetComponent<ThermalVision>();
if(t7 != null && (t7.On || t7.InProcessSwitching)) {
2023-09-13 22:13:13 -04:00
t7.IsGlitch = Plugin.T7Glitch.Value;
t7.IsPixelated = Plugin.T7Pixel.Value;
t7.IsNoisy = Plugin.T7Glitch.Value;
t7.IsFpsStuck = Plugin.T7Glitch.Value;
if (Plugin.T7Fps.Value) {
2023-09-13 22:13:13 -04:00
t7.StuckFpsUtilities.MaxFramerate = Plugin.T7FpsMax.Value;
t7.StuckFpsUtilities.MinFramerate = Plugin.T7FpsMax.Value;
}
if(Plugin.T7MaskEnabled.Value) {
t7.TextureMask.enabled = true;
t7.TextureMask.Size = Plugin.T7MaskSize.Value;
}
else{
t7.TextureMask.enabled = false;
}
2023-09-13 22:13:13 -04:00
vintage.enabled = false;
// Far/near clip plane distance is done on the optic_camera for each "mode" acording to UABEA,
// just need to see where it is in the data structure
return;
2023-09-13 22:13:13 -04:00
}
else if (scope != null && thermal != null && (thermal.On || t7.InProcessSwitching)) {
//scope.
2023-09-15 21:55:38 -04:00
thermal.IsGlitch = Plugin.ThermalGlitch.Value;
thermal.IsPixelated = Plugin.ThermalPixel.Value;
thermal.IsNoisy = Plugin.ThermalGlitch.Value;
thermal.IsFpsStuck = Plugin.ThermalGlitch.Value;
if (Plugin.ThermalGlitch.Value) {
thermal.StuckFpsUtilities.MaxFramerate = Plugin.ThermalFpsMax.Value;
thermal.StuckFpsUtilities.MinFramerate = Plugin.ThermalFpsMax.Value;
}
2023-09-13 22:13:13 -04:00
vintage.enabled = false;
return;
2023-09-13 22:13:13 -04:00
}
else {
vintage.enabled = true;
return;
}
}
else
return;
2023-09-12 22:49:37 -04:00
}
}
}