using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Rendering;
using Valheim.SettingsGui;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("CameraMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CameraMod")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ab4a6382-432a-4d10-8c83-18b4c2eea643")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CameraMod;
[BepInPlugin("CameraMod.Kailen_", "CameraMod", "0.0.93.0")]
[BepInProcess("valheim.exe")]
public class CameraMod : BaseUnityPlugin
{
[HarmonyPatch(typeof(GameCamera))]
[HarmonyPatch("GetCameraPosition")]
private static class UpdateCamera_PatchGetCameraPosition
{
private static void Postfix(GameCamera __instance, float dt, ref Vector3 __1, ref Quaternion __2, ref float ___m_distance, Camera ___m_camera)
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
Player localPlayer = Player.m_localPlayer;
if (!Object.op_Implicit((Object)(object)localPlayer))
{
return;
}
if (___m_distance <= 0f)
{
fpv = true;
if (__instance.m_fov != (float)fpfov)
{
__instance.m_fov = fpfov;
}
if (bowzoomON && (aimingTime > 0f || lerptime > 0f))
{
__instance.m_fov = getFov();
}
headPos = ((Character)localPlayer).GetHeadPoint() + head.rotation * new Vector3(faceoffset, 0.152f, 0f);
__2 = ((Component)((Character)localPlayer).m_eye).transform.rotation;
if (smoothCam && aimingTime <= 0f && !((Character)localPlayer).IsSwimming())
{
__1 = new Vector3(headPos.x, __1.y, headPos.z);
}
else
{
__1 = headPos;
}
}
else
{
__instance.m_fov = thirdPfov;
fpv = false;
forcedrotation = false;
lerptime = 0f;
aimingTime = 0f;
}
}
}
[HarmonyPatch(typeof(GameCamera))]
[HarmonyPatch("UpdateCamera")]
private static class UpdateCamera_PatchUpdateUpdateCamera
{
[HarmonyPriority(0)]
private static void Prefix(GameCamera __instance)
{
if (__instance.m_maxDistance != __instance.m_minDistance)
{
__instance.m_minDistance = 0f;
__instance.m_nearClipPlaneMin = nearClipMin;
__instance.m_nearClipPlaneMax = nearClipMax;
}
}
private static void Postfix(GameCamera __instance, Camera ___m_camera)
{
}
}
[HarmonyPatch(typeof(Game))]
[HarmonyPatch("Awake")]
private static class UpdateGame_PatchAwake
{
private static void Postfix(Game __instance)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
Object[] array = Resources.FindObjectsOfTypeAll(typeof(Material));
for (int i = 0; i < array.Length; i++)
{
Material val = (Material)array[i];
try
{
val.SetFloat("_CamCull", 0f);
}
catch
{
}
}
}
}
[HarmonyPatch(typeof(Player))]
[HarmonyPatch("SetControls")]
private static class UpdatePlayer_PatchSetControls
{
private static void Prefix(Player __instance, Vector3 movedir, ref bool ___m_attack, ref bool __2)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Player.m_localPlayer != (Object)(object)__instance))
{
notmoving = movedir == Vector3.zero;
attackingHold = __2;
}
}
}
[HarmonyPatch(typeof(Player))]
[HarmonyPatch("Update")]
private static class UpdatePlayer_PatchLateUpdate
{
private static void Postfix(Player __instance, Transform ___m_head, ref Rigidbody ___m_body, ref VisEquipment ___m_visEquipment, ItemData ___m_rightItem, ItemData ___m_leftItem, ItemData ___m_helmetItem, string ___m_hairItem)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
Player localPlayer = Player.m_localPlayer;
if ((Object)(object)localPlayer != (Object)(object)__instance)
{
return;
}
helmetItem = ___m_helmetItem;
Quaternion rotation = ((Character)__instance).m_eye.rotation;
Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
rotation = ___m_visEquipment.m_leftHand.rotation;
_ = ((Quaternion)(ref rotation)).eulerAngles;
if (FPVmouseSensitivityON)
{
if (fpv)
{
PlayerController.m_mouseSens = FPVmouseSensitivity;
}
else
{
PlayerController.m_mouseSens = PlayerPrefs.GetFloat("MouseSensitivity", PlayerController.m_mouseSens);
}
}
if (fpv && (Object)(object)localPlayer == (Object)(object)__instance && Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)___m_body) && (Object)(object)__instance.GetControlledShip() == (Object)null && !((Character)__instance).InDodge())
{
chin.localScale = new Vector3(0.1f, 0.1f, 0.1f);
float y = eulerAngles.y;
rotation = ___m_body.rotation;
necktwist = 0f - AngleDifference(y, ((Quaternion)(ref rotation)).eulerAngles.y);
if (necktwist > (float)rightTurnLimit)
{
rotation = ___m_body.rotation;
float num = ((Quaternion)(ref rotation)).eulerAngles.y * 1f;
num += (Math.Abs(necktwist) - (float)rightTurnLimit) * (float)Math.Sign(necktwist);
rotation = ___m_body.rotation;
float x = ((Quaternion)(ref rotation)).eulerAngles.x;
float num2 = num;
rotation = ___m_body.rotation;
rotPlay = Quaternion.Euler(x, num2, ((Quaternion)(ref rotation)).eulerAngles.z);
mybod = ___m_body;
if (notmoving)
{
mybod.rotation = rotPlay;
}
forcedrotation = true;
}
else if (necktwist < (float)leftTurnLimit)
{
rotation = ___m_body.rotation;
float num3 = ((Quaternion)(ref rotation)).eulerAngles.y * 1f;
num3 += (Math.Abs(necktwist) - (float)Math.Abs(leftTurnLimit)) * (float)Math.Sign(necktwist);
rotation = ___m_body.rotation;
float x2 = ((Quaternion)(ref rotation)).eulerAngles.x;
float num4 = num3;
rotation = ___m_body.rotation;
rotPlay = Quaternion.Euler(x2, num4, ((Quaternion)(ref rotation)).eulerAngles.z);
mybod = ___m_body;
if (notmoving)
{
mybod.rotation = rotPlay;
}
forcedrotation = true;
}
else
{
forcedrotation = false;
}
}
else
{
chin.localScale = new Vector3(1f, 1f, 1f);
}
}
}
[HarmonyPatch(typeof(Player))]
[HarmonyPatch("FixedUpdate")]
private static class UpdatePlayer_SetVisible
{
private static void Postfix(Player __instance, bool ___m_lodVisible, ref LODGroup ___m_lodGroup, Vector3 ___m_originalLocalRef, ItemData ___m_leftItem, ref Rigidbody ___m_body)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Player.m_localPlayer != (Object)(object)__instance)
{
return;
}
if (fpv)
{
___m_lodGroup.localReferencePoint = ___m_originalLocalRef;
if (slightlyTaller)
{
((Component)__instance).transform.localScale = new Vector3(1f, 1.06f, 1f);
}
}
else if (slightlyTaller)
{
((Component)__instance).transform.localScale = new Vector3(oldscale.x, oldscale.y, oldscale.z);
}
}
}
[HarmonyPatch(typeof(Character))]
[HarmonyPatch("UpdateRotation")]
private static class UpdateRotation_patchrotation
{
private static bool Prefix(Character __instance, float turnSpeed, float dt)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.IsPlayer())
{
return true;
}
if (forcedrotation && fpv)
{
((Component)__instance).transform.rotation = rotPlay;
}
return true;
}
}
[HarmonyPatch(typeof(Player))]
[HarmonyPatch("LateUpdate")]
private static class UpdatePlayer_PatchLateLateUpdate
{
private static void Postfix(Player __instance, Transform ___m_head, ref Rigidbody ___m_body, ref VisEquipment ___m_visEquipment, ItemData ___m_rightItem, ItemData ___m_leftItem)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Player.m_localPlayer != (Object)(object)__instance) && ((___m_leftItem != null && (int)___m_leftItem.m_shared.m_itemType == 4 && attackingHold && fpv && Object.op_Implicit((Object)(object)___m_body)) || aimingTime > 0f))
{
Quaternion rotation = ((Component)((Character)__instance).m_eye).transform.rotation;
CameraMod.aimingnewy = ((Quaternion)(ref rotation)).eulerAngles.y + 90f;
Transform spine = CameraMod.spine;
rotation = CameraMod.spine.rotation;
float x = ((Quaternion)(ref rotation)).eulerAngles.x;
float aimingnewy = CameraMod.aimingnewy;
rotation = ((Component)((Character)__instance).m_eye).transform.rotation;
spine.rotation = Quaternion.Euler(x, aimingnewy, ((Quaternion)(ref rotation)).eulerAngles.x);
if (attackingHold)
{
aimingTime = 0.75f;
}
else
{
aimingTime -= Time.deltaTime;
}
}
}
}
[HarmonyPatch(typeof(VisEquipment))]
[HarmonyPatch("CustomUpdate")]
private static class UpdateVisEquipment_Update
{
private static void Prefix(VisEquipment __instance, bool ___m_isPlayer, ref int ___m_currentHelmetItemHash, ref int ___m_currentBeardItemHash, ref int ___m_currentHairItemHash)
{
if ((Object)(object)playerVisEquipment != (Object)(object)__instance || !__instance.m_isPlayer || !Object.op_Implicit((Object)(object)Player.m_localPlayer))
{
return;
}
if (oldhelm != ___m_currentHelmetItemHash)
{
faceStuffRemoved = false;
}
oldhelm = ___m_currentHelmetItemHash;
if (!faceStuffRemoved && fpv)
{
GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(___m_currentHairItemHash);
GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab(___m_currentBeardItemHash);
GameObject itemPrefab3 = ObjectDB.instance.GetItemPrefab(___m_currentHelmetItemHash);
if (Object.op_Implicit((Object)(object)itemPrefab))
{
ShadowOnly(itemPrefab);
___m_currentHairItemHash = -1;
Debug.Log((object)(((Object)itemPrefab).name + " set to shadows only"));
}
if (Object.op_Implicit((Object)(object)itemPrefab2))
{
ShadowOnly(itemPrefab2);
___m_currentBeardItemHash = -1;
Debug.Log((object)(((Object)itemPrefab2).name + " set to shadows only"));
}
if (Object.op_Implicit((Object)(object)itemPrefab3))
{
ShadowOnly(itemPrefab3);
___m_currentHelmetItemHash = -1;
Debug.Log((object)(((Object)itemPrefab3).name + " set to shadows only"));
}
}
if (faceStuffRemoved && !fpv)
{
___m_currentHelmetItemHash = -1;
___m_currentBeardItemHash = -1;
___m_currentHairItemHash = -1;
}
}
private static void Postfix(VisEquipment __instance, bool ___m_isPlayer, ref int ___m_currentHelmetItemHash, ref int ___m_currentBeardItemHash, ref int ___m_currentHairItemHash)
{
if ((Object)(object)playerVisEquipment != (Object)(object)__instance || !__instance.m_isPlayer || !Object.op_Implicit((Object)(object)Player.m_localPlayer))
{
return;
}
if (!faceStuffRemoved && fpv)
{
Debug.Log((object)"Stuff equipped");
GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(___m_currentHairItemHash);
GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab(___m_currentBeardItemHash);
GameObject itemPrefab3 = ObjectDB.instance.GetItemPrefab(___m_currentHelmetItemHash);
if (Object.op_Implicit((Object)(object)itemPrefab))
{
Back2Normal(itemPrefab);
Debug.Log((object)(((Object)itemPrefab).name + " set to back to normal"));
}
if (Object.op_Implicit((Object)(object)itemPrefab2))
{
Back2Normal(itemPrefab2);
Debug.Log((object)(((Object)itemPrefab2).name + " set to back to normal"));
}
if (Object.op_Implicit((Object)(object)itemPrefab3))
{
Back2Normal(itemPrefab3);
Debug.Log((object)(((Object)itemPrefab3).name + " set to back to normal"));
}
faceStuffRemoved = true;
}
else if (faceStuffRemoved && !fpv)
{
faceStuffRemoved = false;
}
}
}
[HarmonyPatch(typeof(Hud))]
[HarmonyPatch("UpdateShipHud")]
private static class UpdateHud_fixshiphud
{
private static void Postfix(Hud __instance)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
if (fpv)
{
Camera mainCamera = Utils.GetMainCamera();
if (!((Object)(object)mainCamera == (Object)null))
{
__instance.m_shipControlsRoot.transform.position = new Vector3((float)mainCamera.pixelWidth * 0.5f, (float)mainCamera.pixelHeight * 0.2f, 0f);
}
}
}
}
[HarmonyPatch(typeof(DamageText))]
[HarmonyPatch("Awake")]
private static class changefloattextDistance
{
private static void Prefix(DamageText __instance)
{
__instance.m_maxTextDistance = 100f;
__instance.m_smallFontDistance = 35f;
}
}
[HarmonyPatch(typeof(DamageText))]
[HarmonyPatch("AddInworldText")]
private static class changefloattextSize
{
private static void Prefix(DamageText __instance, TextType type, ref Vector3 pos, bool mySelf)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Invalid comparison between Unknown and I4
if ((Object)(object)Utils.GetMainCamera() == (Object)null)
{
return;
}
if (!fpv)
{
__instance.m_largeFontSize = 16;
__instance.m_smallFontSize = 8;
return;
}
__instance.m_largeFontSize = DT_fontsize;
__instance.m_smallFontSize = DT_fontsize / 2;
if (mySelf || (int)type == 6)
{
pos += head.rotation * new Vector3(2f, 0f, 0f);
}
}
}
[HarmonyPatch(typeof(DamageText))]
[HarmonyPatch("UpdateWorldTexts")]
private static class UpdateWorldTexts_patch
{
private static void Prefix(DamageText __instance, ref float dt)
{
if (fpv)
{
dt *= damagetext_delayMult;
}
}
}
[HarmonyPatch(typeof(GameplaySettings))]
[HarmonyPatch("SaveSettings")]
private static class SaveSettings_patch
{
private static void Postfix()
{
updatefromConfig();
}
}
[HarmonyPatch(typeof(Player))]
[HarmonyPatch("Awake")]
private static class UpdatePlayer_PatchAwake
{
private static void Postfix(Player __instance, VisEquipment ___m_visEquipment)
{
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
{
Debug.Log((object)("$$ " + ((Object)Player.m_localPlayer).name));
}
Debug.Log((object)("islocal " + ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)));
Debug.Log((object)("id " + __instance.GetPlayerID()));
Debug.Log((object)("name " + __instance.GetPlayerName()));
if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
{
Debug.Log((object)("local " + ((Object)Player.m_localPlayer).name));
Debug.Log((object)("playerID " + Player.m_localPlayer.GetPlayerID()));
}
else
{
Debug.Log((object)"no local ");
}
spine = findBone(___m_visEquipment.m_bodyModel.bones, "Spine");
chin = findBone(___m_visEquipment.m_bodyModel.bones, "Jaw");
head = findBone(___m_visEquipment.m_bodyModel.bones, "Head");
playerVisEquipment = ___m_visEquipment;
Debug.Log((object)((Humanoid)__instance).GetHair());
Debug.Log((object)((Humanoid)__instance).GetBeard());
forcedrot = new Vector3(0f, 0f, 0f);
notmoving = false;
forcedrotation = false;
fpvold = false;
fpv = false;
oldscale = ((Component)__instance).transform.localScale;
}
}
private static ConfigEntry<bool> BowZoomOnConfig;
private static ConfigEntry<int> BowZoomFOVConfig;
private static ConfigEntry<float> BowZoomSpeedConfig;
private static float bowzoomSpeed;
private static bool bowzoomON;
private static int bowzoomFOV;
private static bool smoothCam;
private static bool LvlUpMove;
private static ConfigEntry<int> nexusID;
private static ConfigEntry<int> fov;
private static ConfigEntry<int> fov2;
private static ConfigEntry<float> DamageText_delay;
private static ConfigEntry<int> DamageText_size;
private static ConfigEntry<float> nearClipPlaneMin;
private static ConfigEntry<float> FPVmouseSensitivityConfig;
private static ConfigEntry<float> nearClipPlaneMax;
private static ConfigEntry<float> faceoff;
private static ConfigEntry<bool> slightlyTallerConfig;
private static ConfigEntry<bool> FPVmouseSensitivityONConfig;
private static bool FPVmouseSensitivityON;
private static bool slightlyTaller;
private static ConfigEntry<bool> LvlUpconfig;
private static ConfigEntry<bool> smoothCamConfig;
private static int fpfov;
private static int thirdPfov;
private static float damagetext_delayMult;
private static float FPVmouseSensitivity;
private static float nearClipMin;
private static float nearClipMax;
private static float faceoffset;
private static int DT_fontsize;
private static ConfigFile config;
private static float necktwist = 0f;
private static float turnrange = 62f;
private static bool fpv = false;
private static bool fpvHeadResized = true;
private static Quaternion rotPlay;
private static Rigidbody mybod;
private static Vector3 forcedrot = new Vector3(0f, 0f, 0f);
private static Transform spine;
private static Transform chin;
private static Transform head;
private static bool notmoving;
private static bool forcedrotation;
private static bool fpvold;
private static float aimingTime;
private static float aimingnewy;
private static bool attackingHold;
private static Vector3 headPos;
public static int interpolationFramesCount = 0;
public static int elapsedFrames = 0;
private static Quaternion relaxedback;
public static float lerptime;
public static float lerp;
private static Vector3 oldscale;
private static int localPlayerID;
private static Player thisplayer;
private static bool removedHair = false;
private static int leftTurnLimit = -30;
private static int rightTurnLimit = 60;
private static ItemData helmetItem;
private static int helmhash;
private static bool faceStuffRemoved = false;
private static int oldhelm = 0;
private static VisEquipment playerVisEquipment;
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
new ConfigFile(Path.Combine(Paths.ConfigPath, "CameraMod.Kailen_.cfg"), true);
fov = ((BaseUnityPlugin)this).Config.Bind<int>("Camera Options", "First Person FOV:", 85, "First person field of view, game's default is 65");
fov2 = ((BaseUnityPlugin)this).Config.Bind<int>("Camera Options", "Third Person FOV:", 65, "Third person field of view, game's default is 65");
BowZoomOnConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera Options", "Bow Zoom :", false, "(true/false) Change FOV when aiming with the bow, make it lower than the 1st person FOV for a zoom effect.");
BowZoomFOVConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Camera Options", "Bow Zoom FOV:", 65, "make it lower than the 1st person FOV for a zoom effect");
BowZoomSpeedConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Camera Options", "Bow Zoom Speed:", 2f, "time in seconds for zoom in/out effect");
smoothCamConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera Options", "Smooth camera", false, "(true/false) Smooth camera, Smoother vertical motion, removes most natural head bobbing ");
nearClipPlaneMax = ((BaseUnityPlugin)this).Config.Bind<float>("Camera Options", "nearClipPlaneMax", 0.07f, "Increase if you have issues with sun rays flickering. game's default is .5");
faceoff = ((BaseUnityPlugin)this).Config.Bind<float>("Camera Options", "faceoffset", 0f, "");
DamageText_delay = ((BaseUnityPlugin)this).Config.Bind<float>("GUI Options", "DamageText delay", 1f, "A multiplier to make the damage text display longer in first person. (.5 will make the text display twice as long, .25 would be 4x as long. etc.)");
DamageText_size = ((BaseUnityPlugin)this).Config.Bind<int>("GUI Options", "DamageText font size", 28, "Font size of damagetext in first person mode. game's defualt is 16. anything bigger than 32 seems to have issues appearing sometimes");
slightlyTallerConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Other Options", "Slightly Taller", false, "(true/false) Slightly Taller: Experimental, Makes you slightly taller in first person ( its +6%, anymore and you start to get stuck on stuff.), expect to clip into the top of smaller doors, you are physically taller including your hit box.");
nexusID = ((BaseUnityPlugin)this).Config.Bind<int>("General", "NexusID", 44, "Nexus mod ID for updates from update mod mod");
nearClipPlaneMin = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "nearClipPlaneMin", 0.1f, " .1 game default, should not need to be modified.");
FPVmouseSensitivityONConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera Options", "Change FPV mouse sensitivity", false, " ");
FPVmouseSensitivityConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Camera Options", "FPV mouse sensitivity", 1f, "Default 1, for reference the ingame slider in the settings ranges from 0.5 to 3 ");
LvlUpconfig = ((BaseUnityPlugin)this).Config.Bind<bool>("GUI Options", "Move level up notification:", false, "(true/false) attempts to move the halo effect around your head to the top of the screen, so you can see it.");
config = ((BaseUnityPlugin)this).Config;
updatefromConfig();
DoPatching();
}
public static void DoPatching()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("MyCameraMod.Kailen").PatchAll();
}
public static float AngleDifference(float angle1, float angle2)
{
float num = (angle2 - angle1 + 180f) % 360f - 180f;
if (num >= -180f)
{
return num;
}
return num + 360f;
}
public static void updatefromConfig()
{
config.Reload();
fpfov = fov.Value;
thirdPfov = fov2.Value;
damagetext_delayMult = DamageText_delay.Value;
DT_fontsize = DamageText_size.Value;
nearClipMin = nearClipPlaneMin.Value;
nearClipMax = nearClipPlaneMax.Value;
faceoffset = faceoff.Value;
smoothCam = smoothCamConfig.Value;
slightlyTaller = slightlyTallerConfig.Value;
LvlUpMove = LvlUpconfig.Value;
bowzoomON = BowZoomOnConfig.Value;
bowzoomFOV = BowZoomFOVConfig.Value;
bowzoomSpeed = BowZoomSpeedConfig.Value;
FPVmouseSensitivity = FPVmouseSensitivityConfig.Value;
FPVmouseSensitivityON = FPVmouseSensitivityONConfig.Value;
Debug.Log((object)("1ST FOV:" + fpfov));
Debug.Log((object)("3RD FOV:" + thirdPfov));
Debug.Log((object)("bowzoomON:" + bowzoomON));
Debug.Log((object)("bowzoomFOV:" + bowzoomFOV));
Debug.Log((object)("bowzoomSpeed:" + bowzoomSpeed));
Debug.Log((object)("smoothCam: " + smoothCam));
Debug.Log((object)("FPVmouseSensitivityON: " + FPVmouseSensitivityON));
Debug.Log((object)("FPVmouseSensitivity: " + FPVmouseSensitivity));
Debug.Log((object)("LvlUpMove: " + LvlUpMove));
Debug.Log((object)("slightlyTaller: " + slightlyTaller));
Debug.Log((object)("DamageText_delay: " + damagetext_delayMult));
Debug.Log((object)("DamageText_size: " + DT_fontsize));
Debug.Log((object)("nearClipMin: " + nearClipMin));
}
private static Transform findBone(Transform[] bones, string bone2find)
{
foreach (Transform val in bones)
{
if (((Object)val).name.ToUpper() == bone2find.ToUpper())
{
return val;
}
}
return null;
}
public static float getFov()
{
if (aimingTime > 0f && attackingHold)
{
if (lerptime == 0f)
{
lerptime = Time.deltaTime;
}
else
{
lerptime += Time.deltaTime;
}
lerp = lerptime / bowzoomSpeed;
if (lerptime > bowzoomSpeed)
{
lerptime = bowzoomSpeed;
}
}
else if (lerptime > 0f)
{
if (lerptime > bowzoomSpeed)
{
lerptime = bowzoomSpeed;
}
lerp = lerptime / bowzoomSpeed;
lerptime -= Time.deltaTime;
if (lerptime < 0f)
{
lerptime = 0f;
}
}
lerp = Mathf.SmoothStep(0f, 1f, lerp);
return Mathf.Lerp((float)fpfov, (float)bowzoomFOV, lerp);
}
protected static void ShadowOnly(GameObject obj)
{
int childCount = obj.transform.childCount;
for (int i = 0; i < childCount; i++)
{
Transform child = obj.transform.GetChild(i);
if (((Object)((Component)child).gameObject).name == "attach" || ((Object)((Component)child).gameObject).name == "attach_skin")
{
Renderer[] componentsInChildren = ((Component)child).gameObject.GetComponentsInChildren<Renderer>();
for (int j = 0; j < componentsInChildren.Length; j++)
{
componentsInChildren[j].shadowCastingMode = (ShadowCastingMode)3;
}
}
}
}
protected static void Back2Normal(GameObject obj)
{
int childCount = obj.transform.childCount;
for (int i = 0; i < childCount; i++)
{
Transform child = obj.transform.GetChild(i);
if (((Object)((Component)child).gameObject).name == "attach" || ((Object)((Component)child).gameObject).name == "attach_skin")
{
Renderer[] componentsInChildren = ((Component)child).gameObject.GetComponentsInChildren<Renderer>();
for (int j = 0; j < componentsInChildren.Length; j++)
{
componentsInChildren[j].shadowCastingMode = (ShadowCastingMode)1;
}
}
}
}
}