-
Notifications
You must be signed in to change notification settings - Fork 2
/
Plugin.cs
60 lines (45 loc) · 1.63 KB
/
Plugin.cs
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
using BepInEx;
using CrashUtils.WeaponManager.WeaponSetup;
using HarmonyLib;
using System.IO;
using System.Reflection;
using UnityEngine;
namespace CoolCamUtils
{
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
public class CamGunLoader : BaseUnityPlugin
{
public static CamGunLoader CG;
public static CameraGun CamGn;
public static AssetBundle Assets;
public static Harmony Harmony = new Harmony(PluginInfo.PLUGIN_GUID);
private void Awake()
{
CG = this;
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
Harmony.PatchAll(typeof(CamGunLoader));
Assets = AssetBundle.LoadFromFile(Path.Combine(ModPath(), "camgun"));
CamGun.LoadAssets();
GunAdditives.Register(new CamGun());
}
private void Update()
{
if (CamGn != null)
{
if (CamGn.LookAt)
{
CamGn.Cam.transform.LookAt(CamGn.PlayerCam.transform);
CamGn.Cam.fieldOfView = 100 - Vector3.Distance(CamGn.PlayerCam.transform.position, CamGn.Cam.transform.position);
if (CamGn.Cam.fieldOfView <= 5)
{
CamGn.Cam.fieldOfView = 5;
}
}
}
}
public static string ModPath()
{
return Assembly.GetExecutingAssembly().Location.Substring(0, Assembly.GetExecutingAssembly().Location.LastIndexOf(Path.DirectorySeparatorChar));
}
}
}