using System;
using System.Collections;
using System.Diagnostics;
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 IL.GameNetcodeStuff;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On;
using On.GameNetcodeStuff;
using UnityEngine;
using View360.Patches;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("View360")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Allows you to look around while using the terminal or ladder")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyInformationalVersion("1.0.5+43206f0475d7dae18e393eaa115cfd192399712f")]
[assembly: AssemblyProduct("View360")]
[assembly: AssemblyTitle("View360")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.5.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 View360
{
[BepInPlugin("Gulag.360View", "360View", "1.0.5")]
public class Plugin : BaseUnityPlugin
{
public const string ModGUID = "Gulag.360View";
public const string ModName = "360View";
public const string ModVersion = "1.0.5";
internal static ManualLogSource Logger;
internal static ConfigEntry<bool> AllowLadder360;
internal static ConfigEntry<bool> LockTerminalView;
internal static ConfigEntry<bool> LockLadderView;
internal static int TerminalTicks;
internal static int LadderTicks;
public void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"360View loaded!");
AllowLadder360 = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Allow360Ladder", true, "Allow 360 view on ladders as well");
LockTerminalView = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "LockTerminalView", false, "Lock the view for the terminal to 0 degrees instead of 360, useful if using terminal mods that play games (e.g. DOOM)");
LockLadderView = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "LockLadderView", false, "Lock the view for the ladder to 0 degrees instead of 360");
InteractTriggerPatch.Init();
PlayerControllerBPatch.Init();
TerminalPatch.Init();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "View360";
public const string PLUGIN_NAME = "View360";
public const string PLUGIN_VERSION = "1.0.5";
}
}
namespace View360.Patches
{
public static class InteractTriggerPatch
{
[CompilerGenerated]
private static class <>O
{
public static hook_LateUpdate <0>__LateUpdate;
public static hook_CancelLadderAnimation <1>__CancelLadderAnimation;
public static hook_specialInteractAnimation <2>__SpecialInteractAnimation;
}
public static void Init()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_0030: 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_003b: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
object obj = <>O.<0>__LateUpdate;
if (obj == null)
{
hook_LateUpdate val = LateUpdate;
<>O.<0>__LateUpdate = val;
obj = (object)val;
}
InteractTrigger.LateUpdate += (hook_LateUpdate)obj;
object obj2 = <>O.<1>__CancelLadderAnimation;
if (obj2 == null)
{
hook_CancelLadderAnimation val2 = CancelLadderAnimation;
<>O.<1>__CancelLadderAnimation = val2;
obj2 = (object)val2;
}
InteractTrigger.CancelLadderAnimation += (hook_CancelLadderAnimation)obj2;
object obj3 = <>O.<2>__SpecialInteractAnimation;
if (obj3 == null)
{
hook_specialInteractAnimation val3 = SpecialInteractAnimation;
<>O.<2>__SpecialInteractAnimation = val3;
obj3 = (object)val3;
}
InteractTrigger.specialInteractAnimation += (hook_specialInteractAnimation)obj3;
}
private static void LateUpdate(orig_LateUpdate orig, InteractTrigger self)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
if (self.isPlayingSpecialAnimation && (Object)(object)self.lockedPlayer != (Object)null && !self.playerScriptInSpecialAnimation.isPlayerDead && self.lockPlayerPosition)
{
self.lockedPlayer.position = Vector3.Lerp(self.lockedPlayer.position, self.playerPositionNode.position, Time.deltaTime * 20f);
if ((self.playerScriptInSpecialAnimation.inTerminalMenu && (double)((float)Plugin.TerminalTicks / (float)Application.targetFrameRate) < 0.5) || (!self.playerScriptInSpecialAnimation.inTerminalMenu && !self.playerScriptInSpecialAnimation.isClimbingLadder))
{
self.lockedPlayer.rotation = Quaternion.Lerp(self.lockedPlayer.rotation, self.playerPositionNode.rotation, Time.deltaTime * 20f);
}
}
}
private static void CancelLadderAnimation(orig_CancelLadderAnimation orig, InteractTrigger self)
{
orig.Invoke(self);
Plugin.LadderTicks = 0;
}
private static IEnumerator SpecialInteractAnimation(orig_specialInteractAnimation orig, InteractTrigger self, PlayerControllerB playerController)
{
IEnumerator origEnum = orig.Invoke(self, playerController);
while (origEnum.MoveNext())
{
playerController.inSpecialInteractAnimation = false;
yield return origEnum.Current;
}
}
}
internal class PlayerControllerBPatch
{
[CompilerGenerated]
private static class <>O
{
public static Manipulator <0>__ILUpdate;
public static hook_Update <1>__Update;
public static hook_PlayerLookInput <2>__PlayerLookInput;
public static hook_LookWhileClimbingLadder <3>__LookWhileClimbingLadder;
public static hook_UpdatePlayerRotationServerRpc <4>__UpdatePlayerRotationServerRpc;
}
public static void Init()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_0030: 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_003b: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
object obj = <>O.<0>__ILUpdate;
if (obj == null)
{
Manipulator val = ILUpdate;
<>O.<0>__ILUpdate = val;
obj = (object)val;
}
PlayerControllerB.Update += (Manipulator)obj;
object obj2 = <>O.<1>__Update;
if (obj2 == null)
{
hook_Update val2 = Update;
<>O.<1>__Update = val2;
obj2 = (object)val2;
}
PlayerControllerB.Update += (hook_Update)obj2;
object obj3 = <>O.<2>__PlayerLookInput;
if (obj3 == null)
{
hook_PlayerLookInput val3 = PlayerLookInput;
<>O.<2>__PlayerLookInput = val3;
obj3 = (object)val3;
}
PlayerControllerB.PlayerLookInput += (hook_PlayerLookInput)obj3;
object obj4 = <>O.<3>__LookWhileClimbingLadder;
if (obj4 == null)
{
hook_LookWhileClimbingLadder val4 = LookWhileClimbingLadder;
<>O.<3>__LookWhileClimbingLadder = val4;
obj4 = (object)val4;
}
PlayerControllerB.LookWhileClimbingLadder += (hook_LookWhileClimbingLadder)obj4;
object obj5 = <>O.<4>__UpdatePlayerRotationServerRpc;
if (obj5 == null)
{
hook_UpdatePlayerRotationServerRpc val5 = UpdatePlayerRotationServerRpc;
<>O.<4>__UpdatePlayerRotationServerRpc = val5;
obj5 = (object)val5;
}
PlayerControllerB.UpdatePlayerRotationServerRpc += (hook_UpdatePlayerRotationServerRpc)obj5;
}
private static void ILUpdate(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext(new Func<Instruction, bool>[26]
{
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<PlayerControllerB>(x, "cameraUp"),
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0f),
(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 5f),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Time>(x, "get_deltaTime"),
(Instruction x) => ILPatternMatchingExt.MatchMul(x),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Mathf>(x, "Lerp"),
(Instruction x) => ILPatternMatchingExt.MatchStfld<PlayerControllerB>(x, "cameraUp"),
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<PlayerControllerB>(x, "gameplayCamera"),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Component>(x, "get_transform"),
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<PlayerControllerB>(x, "cameraUp"),
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<PlayerControllerB>(x, "gameplayCamera"),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Component>(x, "get_transform"),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Transform>(x, "get_localEulerAngles"),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<Vector3>(x, "y"),
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<PlayerControllerB>(x, "gameplayCamera"),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Component>(x, "get_transform"),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Transform>(x, "get_localEulerAngles"),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<Vector3>(x, "z"),
(Instruction x) => ILPatternMatchingExt.MatchNewobj<Vector3>(x),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Transform>(x, "set_localEulerAngles")
}))
{
val.RemoveRange(26);
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Action<PlayerControllerB>>((Action<PlayerControllerB>)delegate(PlayerControllerB self)
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: 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)
if (self.inTerminalMenu && (double)((float)Plugin.TerminalTicks / (float)Application.targetFrameRate) < 0.5 && !Plugin.LockTerminalView.Value)
{
self.cameraUp = Mathf.Lerp(self.cameraUp, 0f, 5f * Time.deltaTime);
((Component)self.gameplayCamera).transform.localEulerAngles = new Vector3(self.cameraUp, ((Component)self.gameplayCamera).transform.localEulerAngles.y, ((Component)self.gameplayCamera).transform.localEulerAngles.z);
}
});
}
else
{
Plugin.Logger.LogError((object)"Failed to patch PlayerControllerB.Update, contact `thegulagisalie` on Discord!");
}
}
private static void Update(orig_Update orig, PlayerControllerB self)
{
orig.Invoke(self);
if (self.isClimbingLadder)
{
Plugin.LadderTicks++;
}
}
private static void PlayerLookInput(orig_PlayerLookInput orig, PlayerControllerB self)
{
if ((!self.inTerminalMenu || !Plugin.LockTerminalView.Value) && (!self.isClimbingLadder || !Plugin.LockLadderView.Value))
{
orig.Invoke(self);
}
}
private static void LookWhileClimbingLadder(orig_LookWhileClimbingLadder orig, PlayerControllerB self, Vector2 lookInput)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.LockLadderView.Value)
{
if (!Plugin.AllowLadder360.Value)
{
orig.Invoke(self, lookInput);
}
else
{
self.CalculateNormalLookingInput(lookInput);
}
}
}
private static void UpdatePlayerRotationServerRpc(orig_UpdatePlayerRotationServerRpc orig, PlayerControllerB self, short newRot, short newYRot)
{
if (self.playerClientId != GameNetworkManager.Instance.localPlayerController.playerClientId)
{
orig.Invoke(self, newRot, newYRot);
}
else if (self.inTerminalMenu && (double)((float)Plugin.TerminalTicks / (float)Application.targetFrameRate) < 0.5 && !Plugin.LockTerminalView.Value)
{
orig.Invoke(self, newRot, newYRot);
}
else if (!self.inTerminalMenu && !self.isClimbingLadder)
{
orig.Invoke(self, newRot, newYRot);
}
}
}
public static class TerminalPatch
{
[CompilerGenerated]
private static class <>O
{
public static hook_Update <0>__Update;
public static hook_BeginUsingTerminal <1>__BeginUsingTerminal;
public static hook_QuitTerminal <2>__QuitTerminal;
}
private static bool inTerminalMenu;
public static void Init()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_0030: 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_003b: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
object obj = <>O.<0>__Update;
if (obj == null)
{
hook_Update val = Update;
<>O.<0>__Update = val;
obj = (object)val;
}
Terminal.Update += (hook_Update)obj;
object obj2 = <>O.<1>__BeginUsingTerminal;
if (obj2 == null)
{
hook_BeginUsingTerminal val2 = BeginUsingTerminal;
<>O.<1>__BeginUsingTerminal = val2;
obj2 = (object)val2;
}
Terminal.BeginUsingTerminal += (hook_BeginUsingTerminal)obj2;
object obj3 = <>O.<2>__QuitTerminal;
if (obj3 == null)
{
hook_QuitTerminal val3 = QuitTerminal;
<>O.<2>__QuitTerminal = val3;
obj3 = (object)val3;
}
Terminal.QuitTerminal += (hook_QuitTerminal)obj3;
}
private static void BeginUsingTerminal(orig_BeginUsingTerminal orig, Terminal self)
{
orig.Invoke(self);
inTerminalMenu = true;
}
private static void Update(orig_Update orig, Terminal self)
{
orig.Invoke(self);
if (inTerminalMenu)
{
Plugin.TerminalTicks++;
}
}
private static void QuitTerminal(orig_QuitTerminal orig, Terminal self)
{
orig.Invoke(self);
inTerminalMenu = false;
Plugin.TerminalTicks = 0;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}