-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.cs
More file actions
107 lines (89 loc) · 4.09 KB
/
Plugin.cs
File metadata and controls
107 lines (89 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System.Collections.Generic;
using System.Reflection;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
namespace FovUpdate
{
[BepInAutoPlugin]
public partial class Plugin : BaseUnityPlugin
{
public static Plugin instance = null!;
internal static ManualLogSource Log = null!;
public static List<Camera> playerCams = [];
private void Awake()
{
instance = this;
Log = base.Logger;
Log.LogInfo($"{Name} is loading with version {Version}!");
FovConfig.Init();
instance.Config.SettingChanged += OnSettingChanged;
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly());
Log.LogInfo($"{Name} load complete!");
Log.LogInfo($"This version of the mod has been compiled for REPO version 0.2.1 :)");
}
private void OnSettingChanged(object sender, SettingChangedEventArgs settingChangedArg)
{
Spam("CONFIG SETTING CHANGE EVENT");
if (settingChangedArg.ChangedSetting == null || CameraZoom.Instance == null)
return;
if (settingChangedArg.ChangedSetting == FovConfig.DeveloperLogging || settingChangedArg.ChangedSetting == FovConfig.AspectRatioFix)
Log.LogDebug($"{settingChangedArg.ChangedSetting.Definition.Key} is enabled [ {(bool)settingChangedArg.ChangedSetting.BoxedValue} ]");
if (settingChangedArg.ChangedSetting == FovConfig.UserSprintFov && !FovConfig.ChangingSprintFov)
{
CameraZoom.Instance.SprintZoom = FovConfig.UpdateSprintConfigItem();
Spam($"SprintFov updated to {CameraZoom.Instance.SprintZoom}");
}
if (settingChangedArg.ChangedSetting == FovConfig.ResMultiplier)
ResolutionOverride.SetResolutionFix();
if (settingChangedArg.ChangedSetting == FovConfig.UserDefinedFov)
{
if(!CameraZoom.Instance.OverrideActive && CameraNoPlayerTarget.instance == null)
PlayerAvatar.instance.StartCoroutine(ChatCommandHandler.ForceFovZoomCurve((float)settingChangedArg.ChangedSetting.BoxedValue, PlayerAvatar.instance.gameObject));
else
{
CameraZoom.Instance.playerZoomDefault = FovConfig.UserDefinedFov.Value;
}
CameraZoom.Instance.SprintZoom = FovConfig.UpdateSprintConfigItem();
Spam($"Fov updated to {(float)settingChangedArg.ChangedSetting.BoxedValue}");
}
if (settingChangedArg.ChangedSetting == FovConfig.UserCrouchFov)
{
if (PlayerAvatar.instance == null)
return;
if (PlayerAvatar.instance.tumble == null)
return;
if(CameraZoom.Instance.OverrideActive && PlayerAvatar.instance.tumble.isTumbling)
PlayerAvatar.instance.StartCoroutine(ChatCommandHandler.ForceFovZoomCurve((float)settingChangedArg.ChangedSetting.BoxedValue, PlayerAvatar.instance.tumble.gameObject, false));
Spam($"CrouchFov updated to {(float)settingChangedArg.ChangedSetting.BoxedValue}");
}
//refresh rects to adjust to new ui change
if (settingChangedArg.ChangedSetting == FovConfig.DontStretchUI)
UltraWideSupport.Rects = [];
}
internal static void UpdateCams()
{
if (CameraZoom.Instance == null)
return;
playerCams.RemoveAll(c => c == null);
CameraZoom.Instance.cams.DoIf(c => !playerCams.Contains(c), c => playerCams.Add(c));
}
internal static void Spam(string message)
{
if (FovConfig.DeveloperLogging.Value)
Log.LogDebug(message);
else
return;
}
internal static void ERROR(string message)
{
Log.LogError(message);
}
internal static void WARNING(string message)
{
Log.LogWarning(message);
}
}
}