using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LCThirdPerson.Patches;
using Microsoft.CodeAnalysis;
using Steamworks;
using TooManyEmotes.Patches;
using UniVRM10;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LCThirdPerson")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e332d53288328a7c246dac5ccd9641cda1e952db")]
[assembly: AssemblyProduct("LCThirdPerson")]
[assembly: AssemblyTitle("LCThirdPerson")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace LCThirdPerson
{
[BepInPlugin("LCThirdPerson", "LCThirdPerson", "1.0.0")]
public class ThirdPersonPlugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("LCThirdPerson");
private bool tpEnabled;
public bool ShoulderSwapActive;
private bool enablePressed;
private bool shoulderSwapPressed;
private bool TooManyEmotesPatchActive;
public static ThirdPersonPlugin Instance { get; private set; }
public static Transform Camera { get; internal set; }
public static Transform OriginalTransform { get; internal set; }
public static Sprite CrosshairSprite { get; internal set; }
public ConfigEntry<KeyboardShortcut> Enable { get; internal set; }
public ConfigEntry<KeyboardShortcut> ShoulderSwap { get; internal set; }
public ConfigEntry<bool> ShowCursor { get; set; }
public ConfigEntry<bool> StartEnabled { get; set; }
public ConfigEntry<Vector3> Offset { get; set; }
public ConfigEntry<float> CameraMaxHeight { get; set; }
public ConfigEntry<float> CameraLookDownOffset { get; set; }
public ConfigEntry<bool> AlwaysHideVisor { get; set; }
public ConfigEntry<bool> FirstPersonVrm { get; set; }
public ConfigEntry<float> FirstPersonVrmHeadHideDistance { get; set; }
public ConfigEntry<bool> TooManyEmotesSyncFirstPersonSetting { get; set; }
public bool Enabled
{
get
{
return tpEnabled;
}
set
{
SetEnabled(value);
}
}
internal static ManualLogSource Log { get; set; }
internal UnityEvent OnEnable { get; private set; }
internal UnityEvent OnDisable { get; private set; }
private void Awake()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LCThirdPerson is loaded!");
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
Log = Logger.CreateLogSource("LCThirdPerson");
OnEnable = new UnityEvent();
OnDisable = new UnityEvent();
SetConfig();
SetCrosshairSprite();
harmony.PatchAll(typeof(ThirdPersonPlugin));
harmony.PatchAll(typeof(CameraPatch));
harmony.PatchAll(typeof(CursorPatch));
harmony.PatchAll(typeof(HUDPatch));
harmony.PatchAll(typeof(ShovelPatch));
harmony.PatchAll(typeof(EnemyAIPatch));
}
internal void SetConfig()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: 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)
Enable = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keybinds", "Toggle", new KeyboardShortcut((KeyCode)118, Array.Empty<KeyCode>()), (ConfigDescription)null);
ShoulderSwap = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keybinds", "ShoulderSwap", new KeyboardShortcut((KeyCode)301, Array.Empty<KeyCode>()), (ConfigDescription)null);
ShowCursor = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "ShowCursor", true, (ConfigDescription)null);
StartEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "StartEnabled", true, (ConfigDescription)null);
Offset = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Options", "CameraOffset", new Vector3(0.4f, 0f, -2f), (ConfigDescription)null);
CameraMaxHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "CameraMaxHeight", 1f, (ConfigDescription)null);
CameraLookDownOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "CameraLookDownOffset", 0.2f, (ConfigDescription)null);
AlwaysHideVisor = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "AlwaysHideVisor", false, (ConfigDescription)null);
FirstPersonVrm = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "FirstPersonVRM", false, (ConfigDescription)null);
FirstPersonVrmHeadHideDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "VrmHeadHideDistance", 0.8f, (ConfigDescription)null);
Enabled = StartEnabled.Value;
}
internal void SetCrosshairSprite()
{
CrosshairSprite = CursorPatch.CreateCrosshairSprite();
}
internal void CheckEnable()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
IInputSystem current = UnityInput.Current;
KeyboardShortcut value = Enable.Value;
if (current.GetKey(((KeyboardShortcut)(ref value)).MainKey))
{
if (!enablePressed)
{
Enabled = !Enabled;
enablePressed = true;
}
}
else
{
enablePressed = false;
}
}
public void SetEnabled(bool value)
{
tpEnabled = value;
if (tpEnabled)
{
OnEnable.Invoke();
}
else
{
OnDisable.Invoke();
}
}
public void ForceEnabled(bool value)
{
if (value)
{
OnEnable.Invoke();
}
else
{
OnDisable.Invoke();
}
}
internal void CheckShoulderSwap()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
IInputSystem current = UnityInput.Current;
KeyboardShortcut value = ShoulderSwap.Value;
if (current.GetKey(((KeyboardShortcut)(ref value)).MainKey))
{
if (!shoulderSwapPressed)
{
ShoulderSwapActive = !ShoulderSwapActive;
shoulderSwapPressed = true;
}
}
else
{
shoulderSwapPressed = false;
}
}
public void PatchTooManyEmotes()
{
if (!TooManyEmotesPatchActive)
{
harmony.PatchAll(typeof(TooManyEmotesPatch));
TooManyEmotesPatchActive = true;
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "LCThirdPerson";
public const string PLUGIN_NAME = "LCThirdPerson";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace LCThirdPerson.Patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class CameraPatch
{
[CompilerGenerated]
private static class <>O
{
public static UnityAction <0>__OnEnable;
public static UnityAction <1>__OnDisable;
}
private static PlayerControllerB Instance;
private static bool TriggerAwake;
private static float ShoulderSwapCurrentOffset = 1f;
private static MeshRenderer VisorMesh = null;
private static bool VrmAssemblyExists = false;
private static GameObject VrmRootObject = null;
private static Transform VrmHeadTransform = null;
private static List<Renderer> VrmHeadMeshes = new List<Renderer>();
private static bool TooManyEmotesExists = false;
private static bool VrmTriggerAwake = false;
private static bool VrmHeadVisible = true;
private static readonly string[] IgnoreGameObjectPrefixes = new string[1] { "VolumeMain" };
public static void OnEnable()
{
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
ThirdPersonPlugin.Log.LogInfo((object)"Enabled");
Transform localVisor = Instance.localVisor;
SkinnedMeshRenderer thisPlayerModel = Instance.thisPlayerModel;
VisorMesh = ((Component)localVisor).GetComponentInChildren<MeshRenderer>();
if (Object.op_Implicit((Object)(object)VisorMesh))
{
((Renderer)VisorMesh).enabled = false;
}
if (ThirdPersonPlugin.Instance.FirstPersonVrm.Value)
{
SetVrmHeadVisibility(visible: true);
}
((Renderer)thisPlayerModel).shadowCastingMode = (ShadowCastingMode)1;
((Renderer)Instance.thisPlayerModelArms).enabled = false;
Instance.gameplayCamera.cullingMask = Instance.gameplayCamera.cullingMask | 0x800000;
Instance.grabDistance = Math.Max(5f - ThirdPersonPlugin.Instance.Offset.Value.z, 5f);
}
public static void OnDisable()
{
ThirdPersonPlugin.Log.LogInfo((object)"Disabled");
Transform localVisor = Instance.localVisor;
SkinnedMeshRenderer thisPlayerModel = Instance.thisPlayerModel;
VisorMesh = ((Component)localVisor).GetComponentInChildren<MeshRenderer>();
if (Object.op_Implicit((Object)(object)VisorMesh))
{
((Renderer)VisorMesh).enabled = !ThirdPersonPlugin.Instance.AlwaysHideVisor.Value;
}
if (VrmAssemblyExists && ThirdPersonPlugin.Instance.FirstPersonVrm.Value && SetVrmHeadVisibility(visible: false))
{
((Renderer)thisPlayerModel).shadowCastingMode = (ShadowCastingMode)1;
((Renderer)Instance.thisPlayerModelArms).enabled = false;
Instance.gameplayCamera.cullingMask = Instance.gameplayCamera.cullingMask | 0x800000;
}
else
{
((Renderer)thisPlayerModel).shadowCastingMode = (ShadowCastingMode)3;
((Renderer)Instance.thisPlayerModelArms).enabled = true;
Instance.gameplayCamera.cullingMask = Instance.gameplayCamera.cullingMask & -8388609;
}
Instance.grabDistance = 5f;
}
[HarmonyPostfix]
[HarmonyPatch("Awake")]
private static void Awake()
{
TriggerAwake = true;
}
[HarmonyPrefix]
[HarmonyPatch("Update")]
private static void PatchUpdate(ref PlayerControllerB __instance, ref bool ___isCameraDisabled, ref bool ___isPlayerControlled)
{
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Expected O, but got Unknown
//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: 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_0184: Expected O, but got Unknown
//IL_031c: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
if (ThirdPersonPlugin.Instance.FirstPersonVrm.Value && (Object)(object)Instance != (Object)null && VrmAssemblyExists)
{
VrmInit();
if ((Object)(object)ThirdPersonPlugin.Camera != (Object)null && (Object)(object)VrmHeadTransform != (Object)null)
{
bool flag = ((ThirdPersonPlugin.Instance.Enabled || Instance.isPlayerDead || Vector3.Distance(VrmHeadTransform.position, ThirdPersonPlugin.Camera.position) > ThirdPersonPlugin.Instance.FirstPersonVrmHeadHideDistance.Value) ? true : false);
if (VrmHeadVisible != flag || VrmTriggerAwake)
{
SetVrmHeadVisibility(flag);
((Renderer)Instance.thisPlayerModel).shadowCastingMode = (ShadowCastingMode)1;
((Renderer)Instance.thisPlayerModelArms).enabled = false;
Instance.gameplayCamera.cullingMask = Instance.gameplayCamera.cullingMask | 0x800000;
VrmTriggerAwake = false;
}
}
}
if (!___isPlayerControlled | ___isCameraDisabled)
{
return;
}
if (TriggerAwake)
{
Instance = __instance;
((UnityEventBase)ThirdPersonPlugin.Instance.OnEnable).RemoveAllListeners();
((UnityEventBase)ThirdPersonPlugin.Instance.OnDisable).RemoveAllListeners();
UnityEvent onEnable = ThirdPersonPlugin.Instance.OnEnable;
object obj = <>O.<0>__OnEnable;
if (obj == null)
{
UnityAction val = OnEnable;
<>O.<0>__OnEnable = val;
obj = (object)val;
}
onEnable.AddListener((UnityAction)obj);
UnityEvent onDisable = ThirdPersonPlugin.Instance.OnDisable;
object obj2 = <>O.<1>__OnDisable;
if (obj2 == null)
{
UnityAction val2 = OnDisable;
<>O.<1>__OnDisable = val2;
obj2 = (object)val2;
}
onDisable.AddListener((UnityAction)obj2);
if (ThirdPersonPlugin.Instance.Enabled)
{
OnEnable();
}
else
{
OnDisable();
}
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
bool flag2 = false;
bool flag3 = false;
bool flag4 = false;
Assembly[] array = assemblies;
foreach (Assembly assembly in array)
{
if (assembly.FullName.StartsWith("VRM10,"))
{
flag2 = true;
}
else if (assembly.FullName.StartsWith("UniHumanoid,"))
{
flag3 = true;
}
else if (assembly.FullName.StartsWith("TooManyEmotes,"))
{
flag4 = true;
}
}
if (flag2 && flag3)
{
VrmAssemblyExists = true;
ThirdPersonPlugin.Log.LogInfo((object)"VRM Compatibility Enabled");
}
if (flag4)
{
TooManyEmotesExists = true;
ThirdPersonPlugin.Instance.PatchTooManyEmotes();
ThirdPersonPlugin.Log.LogInfo((object)"TooManyEmotes Compatibility Enabled");
}
TriggerAwake = false;
VrmTriggerAwake = true;
}
if ((Object)(object)Instance == (Object)null)
{
return;
}
if ((Object)(object)ThirdPersonPlugin.OriginalTransform == (Object)null)
{
ThirdPersonPlugin.OriginalTransform = CopyTransform(((Component)Instance.gameplayCamera).transform, "LCThirdPerson_Original Camera Position");
ThirdPersonPlugin.Camera = CopyTransform(((Component)Instance.gameplayCamera).transform, "LCThirdPerson_Camera Position");
}
ThirdPersonPlugin.Camera.position = ((Component)Instance.gameplayCamera).transform.position;
ThirdPersonPlugin.Camera.rotation = ((Component)Instance.gameplayCamera).transform.rotation;
if (!Instance.isClimbingLadder && !Instance.inVehicleAnimation)
{
((Component)Instance.gameplayCamera).transform.position = ((Component)ThirdPersonPlugin.OriginalTransform).transform.position;
}
if (!Instance.inTerminalMenu && !Instance.isTypingChat)
{
ThirdPersonPlugin.Instance.CheckEnable();
if (ThirdPersonPlugin.Instance.Enabled)
{
ThirdPersonPlugin.Instance.CheckShoulderSwap();
}
if (TooManyEmotesExists && TooManyEmotesPatch.isPerformingEmote)
{
TooManyEmotesPatch.FixCamera();
}
}
}
[HarmonyPostfix]
[HarmonyPatch("LateUpdate")]
private static void PatchCamera(ref bool ___isCameraDisabled, ref bool ___isPlayerControlled)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: 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_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
Transform originalTransform = ThirdPersonPlugin.OriginalTransform;
if ((!___isPlayerControlled | ___isCameraDisabled) || (Object)(object)originalTransform == (Object)null)
{
return;
}
Camera gameplayCamera = Instance.gameplayCamera;
Vector3 up = ((Component)gameplayCamera).transform.up;
up.y = 0f;
up *= ThirdPersonPlugin.Instance.CameraLookDownOffset.Value;
bool flag = false;
if (!ThirdPersonPlugin.Instance.Enabled || Instance.inTerminalMenu)
{
if (ThirdPersonPlugin.Instance.FirstPersonVrm.Value && (Object)(object)VisorMesh != (Object)null && !((Renderer)VisorMesh).enabled)
{
((Component)gameplayCamera).transform.position = ((Component)originalTransform).transform.position + up;
flag = true;
}
}
else
{
float num = (ThirdPersonPlugin.Instance.ShoulderSwapActive ? (-1f) : 1f);
float num2 = (ShoulderSwapCurrentOffset = Mathf.Lerp(ShoulderSwapCurrentOffset, num, Mathf.Min(1f, 15f * Time.deltaTime)));
Vector3 val = ((Component)originalTransform).transform.right * (ThirdPersonPlugin.Instance.Offset.Value.x * num2) + ((Component)originalTransform).transform.up * ThirdPersonPlugin.Instance.Offset.Value.y;
Vector3 position = ((Component)originalTransform).transform.position;
Vector3 val2 = ((Component)originalTransform).transform.position + up + val + ((Component)gameplayCamera).transform.forward * ThirdPersonPlugin.Instance.Offset.Value.z;
RaycastHit val3 = default(RaycastHit);
val = ((!Physics.Linecast(position, val2, ref val3, StartOfRound.Instance.collidersAndRoomMask) || IgnoreCollision(((Object)((RaycastHit)(ref val3)).transform).name)) ? (val + ((Component)gameplayCamera).transform.forward * ThirdPersonPlugin.Instance.Offset.Value.z) : (val + ((Component)gameplayCamera).transform.forward * (0f - Mathf.Max(((RaycastHit)(ref val3)).distance, 0f))));
val.y = Math.Min(val.y, ThirdPersonPlugin.Instance.CameraMaxHeight.Value);
((Component)gameplayCamera).transform.position = ((Component)originalTransform).transform.position + up + val;
flag = true;
}
if (Instance.isClimbingLadder)
{
flag = false;
}
if (flag)
{
typeof(PlayerControllerB).GetMethod("SetHoverTipAndCurrentInteractTrigger", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(Instance, new object[0]);
}
}
[HarmonyPrefix]
[HarmonyPatch("SetFaceUnderwaterFilters")]
private static void UnderwaterPrepatch()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Instance == (Object)null) && !((Object)(object)ThirdPersonPlugin.Camera == (Object)null))
{
((Component)Instance.gameplayCamera).transform.position = ((Component)ThirdPersonPlugin.Camera).transform.position;
}
}
[HarmonyPostfix]
[HarmonyPatch("SetFaceUnderwaterFilters")]
private static void UnderwaterPostpatch()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Instance == (Object)null) && !((Object)(object)ThirdPersonPlugin.OriginalTransform == (Object)null))
{
((Component)Instance.gameplayCamera).transform.position = ((Component)ThirdPersonPlugin.OriginalTransform).transform.position;
}
}
[HarmonyPostfix]
[HarmonyPatch("SpawnPlayerAnimation")]
private static void SpawnPlayerPostpatch(ref bool ___isPlayerControlled)
{
if (!((Object)(object)Instance == (Object)null) && ___isPlayerControlled)
{
if (ThirdPersonPlugin.Instance.Enabled)
{
OnEnable();
}
else
{
OnDisable();
}
}
}
private static Transform CopyTransform(Transform copyTransform, string gameObjectName)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
Transform transform = new GameObject(gameObjectName).transform;
transform.position = copyTransform.position;
transform.rotation = copyTransform.rotation;
transform.parent = copyTransform.parent;
return transform;
}
private static bool IgnoreCollision(string name)
{
return IgnoreGameObjectPrefixes.Any((string prefix) => name.StartsWith(prefix));
}
private static void VrmInit()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Invalid comparison between Unknown and I4
if ((Object)(object)VrmRootObject != (Object)null)
{
return;
}
VrmHeadVisible = true;
VrmTriggerAwake = true;
SteamId steamId = SteamClient.SteamId;
string name = SteamClient.Name;
if (name == null)
{
return;
}
SteamId val = steamId;
string value = "LethalVRM Character Model " + name + " " + ((object)(SteamId)(ref val)).ToString();
Scene scene = ((Component)Instance.localVisor).gameObject.scene;
GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
foreach (GameObject val2 in rootGameObjects)
{
if (((Object)val2).name.EndsWith(value))
{
VrmRootObject = val2;
break;
}
}
if ((Object)(object)VrmRootObject == (Object)null)
{
return;
}
Vrm10Instance component = VrmRootObject.GetComponent<Vrm10Instance>();
if ((Object)(object)component == (Object)null || (Object)(object)component.Humanoid == (Object)null)
{
VrmHeadTransform = RecursiveFindChild(VrmRootObject.transform, "Neck");
if ((Object)(object)VrmHeadTransform == (Object)null)
{
VrmHeadTransform = RecursiveFindChild(VrmRootObject.transform, "Head");
}
}
else
{
VrmHeadTransform = component.Humanoid.Neck;
}
VrmHeadMeshes.Clear();
if ((Object)(object)component != (Object)null && (Object)(object)component.Vrm != (Object)null && component.Vrm.FirstPerson != null && component.Vrm.FirstPerson.Renderers != null)
{
foreach (RendererFirstPersonFlags renderer2 in component.Vrm.FirstPerson.Renderers)
{
RendererFirstPersonFlags current = renderer2;
if ((int)current.FirstPersonFlag == 2)
{
Renderer renderer = ((RendererFirstPersonFlags)(ref current)).GetRenderer(VrmRootObject.transform);
if ((Object)(object)renderer != (Object)null)
{
VrmHeadMeshes.Add(renderer);
}
}
}
}
ThirdPersonPlugin.Log.LogInfo((object)"Local VRM Model Initialized");
}
private static bool SetVrmHeadVisibility(bool visible)
{
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
if (!VrmAssemblyExists)
{
return false;
}
VrmInit();
if ((Object)(object)VrmRootObject == (Object)null)
{
return false;
}
if (VrmHeadMeshes.Count > 0)
{
ShadowCastingMode shadowCastingMode = (ShadowCastingMode)(visible ? 1 : 3);
foreach (Renderer vrmHeadMesh in VrmHeadMeshes)
{
vrmHeadMesh.shadowCastingMode = shadowCastingMode;
}
}
else
{
Vector3 localScale = (visible ? new Vector3(1f, 1f, 1f) : new Vector3(0f, 0f, 0f));
VrmHeadTransform.localScale = localScale;
}
VrmHeadVisible = visible;
return true;
}
private static Transform RecursiveFindChild(Transform parent, string childName)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
foreach (Transform item in parent)
{
Transform val = item;
if (((Object)val).name.ToLower() == childName.ToLower())
{
return val;
}
Transform val2 = RecursiveFindChild(val, childName);
if ((Object)(object)val2 != (Object)null)
{
return val2;
}
}
return null;
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal class CursorPatch
{
internal static Sprite CreateCrosshairSprite()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
string name = "LCThirdPerson.crosshair.png";
Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name);
Texture2D val = new Texture2D(2, 2);
using (MemoryStream memoryStream = new MemoryStream())
{
manifestResourceStream.CopyTo(memoryStream);
ImageConversion.LoadImage(val, memoryStream.ToArray());
}
((Texture)val).filterMode = (FilterMode)0;
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2((float)(((Texture)val).width / 2), (float)(((Texture)val).height / 2)));
}
[HarmonyPostfix]
[HarmonyPatch("LateUpdate")]
private static void PatchUpdate(ref PlayerControllerB __instance, ref bool ___isCameraDisabled)
{
if (!(!__instance.isPlayerControlled | ___isCameraDisabled) && ThirdPersonPlugin.Instance.Enabled && ThirdPersonPlugin.Instance.ShowCursor.Value && !__instance.inTerminalMenu && !((Behaviour)__instance.cursorIcon).enabled)
{
((Behaviour)__instance.cursorIcon).enabled = true;
__instance.cursorIcon.sprite = ThirdPersonPlugin.CrosshairSprite;
}
}
}
[HarmonyPatch(typeof(EnemyAI))]
internal class EnemyAIPatch
{
[HarmonyPostfix]
[HarmonyPatch("EnableEnemyMesh")]
private static void EnableEnemyMeshPostfix(ref EnemyAI __instance, bool enable, bool overrideDoNotSet)
{
if (!(__instance is DressGirlAI))
{
return;
}
for (int i = 0; i < __instance.skinnedMeshRenderers.Length; i++)
{
if (!((Component)__instance.skinnedMeshRenderers[i]).CompareTag("DoNotSet") || overrideDoNotSet)
{
((Renderer)__instance.skinnedMeshRenderers[i]).forceRenderingOff = !enable;
}
}
for (int j = 0; j < __instance.meshRenderers.Length; j++)
{
if (!((Component)__instance.meshRenderers[j]).CompareTag("DoNotSet") || overrideDoNotSet)
{
((Renderer)__instance.meshRenderers[j]).forceRenderingOff = !enable;
}
}
}
}
[HarmonyPatch(typeof(HUDManager))]
internal class HUDPatch
{
[HarmonyPrefix]
[HarmonyPatch("UpdateScanNodes")]
private static void UnderwaterPrepatch(PlayerControllerB playerScript)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)ThirdPersonPlugin.Camera == (Object)null))
{
((Component)playerScript.gameplayCamera).transform.position = ((Component)ThirdPersonPlugin.Camera).transform.position;
}
}
[HarmonyPostfix]
[HarmonyPatch("UpdateScanNodes")]
private static void UnderwaterPostpatch(PlayerControllerB playerScript)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)ThirdPersonPlugin.OriginalTransform == (Object)null))
{
((Component)playerScript.gameplayCamera).transform.position = ((Component)ThirdPersonPlugin.OriginalTransform).transform.position;
}
}
}
[HarmonyPatch(typeof(Shovel))]
internal class ShovelPatch
{
private static Vector3 originalPosition;
[HarmonyPrefix]
[HarmonyPatch("HitShovel")]
private static void HitShovelPrepatch(Shovel __instance, ref PlayerControllerB ___previousPlayerHeldBy)
{
//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_0053: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)ThirdPersonPlugin.Camera == (Object)null) && !((Object)(object)___previousPlayerHeldBy == (Object)null) && !((Object)(object)___previousPlayerHeldBy.gameplayCamera == (Object)null))
{
originalPosition = ((Component)___previousPlayerHeldBy.gameplayCamera).transform.position;
((Component)___previousPlayerHeldBy.gameplayCamera).transform.position = ((Component)ThirdPersonPlugin.OriginalTransform).transform.position;
}
}
[HarmonyPostfix]
[HarmonyPatch("HitShovel")]
private static void HitShovelPostpatch(Shovel __instance, ref PlayerControllerB ___previousPlayerHeldBy)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)ThirdPersonPlugin.OriginalTransform == (Object)null) && !((Object)(object)___previousPlayerHeldBy == (Object)null) && !((Object)(object)___previousPlayerHeldBy.gameplayCamera == (Object)null))
{
((Component)___previousPlayerHeldBy.gameplayCamera).transform.position = originalPosition;
}
}
}
[HarmonyPatch(typeof(ThirdPersonEmoteController))]
internal class TooManyEmotesPatch
{
public static bool isPerformingEmote;
public static bool firstPersonEmotesEnabled;
[HarmonyPrefix]
[HarmonyPatch("OnStartCustomEmoteLocal")]
private static void OnStartCustomEmoteLocalPrepatch()
{
if (ThirdPersonEmoteController.firstPersonEmotesEnabled)
{
ThirdPersonPlugin.Instance.ForceEnabled(value: false);
}
}
[HarmonyPostfix]
[HarmonyPatch("OnStartCustomEmoteLocal")]
private static void OnStartCustomEmoteLocalPostpatch()
{
isPerformingEmote = true;
firstPersonEmotesEnabled = ThirdPersonEmoteController.firstPersonEmotesEnabled;
}
[HarmonyPostfix]
[HarmonyPatch("OnStopCustomEmoteLocal")]
private static void OnStopCustomEmoteLocalPostpatch()
{
isPerformingEmote = false;
firstPersonEmotesEnabled = ThirdPersonEmoteController.firstPersonEmotesEnabled;
ThirdPersonPlugin.Instance.ForceEnabled(ThirdPersonPlugin.Instance.Enabled);
}
[HarmonyPostfix]
[HarmonyPatch("UpdateFirstPersonEmoteMode")]
private static void UpdateFirstPersonEmoteModePostpatch(bool value)
{
firstPersonEmotesEnabled = ThirdPersonEmoteController.firstPersonEmotesEnabled;
FixCamera();
}
public static void FixCamera()
{
if (isPerformingEmote)
{
if (ThirdPersonPlugin.Instance.Enabled)
{
ThirdPersonPlugin.Instance.ForceEnabled(value: true);
}
else
{
ThirdPersonPlugin.Instance.ForceEnabled(!firstPersonEmotesEnabled);
}
}
}
}
}