using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("OutwardModTemplate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardModTemplate")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace FirstPersonCamera;
[BepInPlugin("Tchernobill.FirstPersonCamera", "FirstPersonCamera", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(CharacterCamera), "LateUpdate")]
public class CharacterCamera_LateUpdate
{
public static void Postfix(ref CharacterCamera __instance)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: 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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: 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_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: 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_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
if (!ActivateFirstPerson.Value || (Object)(object)__instance.m_camera == (Object)null || (Object)(object)__instance.TargetCharacter == (Object)null)
{
if (firstPersonActiveMemo)
{
__instance.BaseOffset = BaseOffsetMemo;
__instance.Offset = BaseOffsetMemo;
__instance.ZoomOffsetSplitScreenH = ArcheryOffsetMemo;
__instance.DialogueAddOffset = DialogueAddOffsetMemo;
__instance.CameraScript.nearClipPlane = ncpMemo;
((LocalCharacterControl)__instance.TargetCharacter.CharacterControl).FaceLikeCamera = (Object)(object)__instance.TargetCharacter.CharacterCamera.LookAtTransform != (Object)null;
firstPersonActiveMemo = false;
}
return;
}
if (!firstPersonActiveMemo)
{
BaseOffsetMemo = __instance.BaseOffset;
ArcheryOffsetMemo = __instance.ZoomOffsetSplitScreenH;
DialogueAddOffsetMemo = __instance.DialogueAddOffset;
ncpMemo = __instance.CameraScript.nearClipPlane;
firstPersonActiveMemo = true;
}
((Vector3)(ref __instance.BaseOffset)).Set(BaseOffsetX.Value, BaseOffsetY.Value, BaseOffsetZ.Value);
__instance.Offset = __instance.BaseOffset;
Vector3 forward = ((Component)__instance).transform.forward;
((Vector3)(ref forward)).Set(0f, 0f, 0f);
((Component)__instance).transform.position = __instance.TargetCharacter.HeadTrans.position;
((LocalCharacterControl)__instance.TargetCharacter.CharacterControl).FaceLikeCamera = true;
if (__instance.m_cameraVertHolder.forward.y > 0f)
{
__instance.CameraScript.nearClipPlane = NCP_LookUp.Value;
}
else
{
__instance.CameraScript.nearClipPlane = NCP_LookDn.Value;
}
((Vector3)(ref __instance.DialogueAddOffset)).Set(0f, 0f, 0f);
((Vector3)(ref __instance.ZoomOffsetSplitScreenH)).Set(ArcheryOffsetX.Value, ArcheryOffsetY.Value, ArcheryOffsetZ.Value);
}
}
[HarmonyPatch(typeof(CharacterCamera), "Update")]
public class CharacterCamera_Update
{
private static void Postfix(ref CharacterCamera __instance)
{
CharacterCamera_LateUpdate.Postfix(ref __instance);
}
}
public const string GUID = "Tchernobill.FirstPersonCamera";
public const string NAME = "FirstPersonCamera";
public const string VERSION = "1.0.2";
public static ConfigEntry<bool> ActivateFirstPerson;
public static ConfigEntry<float> BaseOffsetX;
public static ConfigEntry<float> BaseOffsetY;
public static ConfigEntry<float> BaseOffsetZ;
public static ConfigEntry<float> NCP_LookUp;
public static ConfigEntry<float> NCP_LookDn;
public static ConfigEntry<float> ArcheryOffsetX;
public static ConfigEntry<float> ArcheryOffsetY;
public static ConfigEntry<float> ArcheryOffsetZ;
public static bool firstPersonActiveMemo;
public static Vector3 BaseOffsetMemo;
public static Vector3 ArcheryOffsetMemo;
public static Vector3 DialogueAddOffsetMemo;
public static float ncpMemo;
internal void Awake()
{
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
ActivateFirstPerson = ((BaseUnityPlugin)this).Config.Bind<bool>("FirstPersonCamera", "Activate First Person", true, "Toggle between First Person and Third Person (Vanilla)");
BaseOffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("FirstPersonCamera", "Base Left Offset", 0f, "Relative to theoric head center");
BaseOffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("FirstPersonCamera", "Base Up Offset", 0.05f, "Relative to theoric head center");
BaseOffsetZ = ((BaseUnityPlugin)this).Config.Bind<float>("FirstPersonCamera", "Base Forward Offset", 0.1f, "Relative to theoric head center");
NCP_LookUp = ((BaseUnityPlugin)this).Config.Bind<float>("FirstPersonCamera", "Near Clipping Distance Looking Up", 0.35f, "Bigger value will hide more stuff that is too close to the camera when looking up.");
NCP_LookDn = ((BaseUnityPlugin)this).Config.Bind<float>("FirstPersonCamera", "Near Clipping Distance Looking Down", 0.16f, "Bigger value will hide more stuff that is too close to the camera when looking down.");
ArcheryOffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("FirstPersonCamera", "Archery Zoom Left Offset", 0f, "Relative to theoric head center");
ArcheryOffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("FirstPersonCamera", "Archery Zoom Up Offset", 0f, "Relative to theoric head center");
ArcheryOffsetZ = ((BaseUnityPlugin)this).Config.Bind<float>("FirstPersonCamera", "Archery Zoom Forward Offset", 0.1f, "Relative to theoric head center");
new Harmony("Tchernobill.FirstPersonCamera").PatchAll();
firstPersonActiveMemo = ActivateFirstPerson.Value;
}
}