using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mod")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d6d7a494-722e-4763-959b-c2d6b6a42b01")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[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 CameraModPorted
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("triceraquach.etg.cameramodported", "CameraModPorted", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string GUID = "triceraquach.etg.cameramodported";
public const string NAME = "CameraModPorted";
public const string VERSION = "1.0.0";
public const string TEXT_COLOR = "#00FFFF";
public static float currentRotPitch;
public static float currentRotYaw;
public static float currentRotRoll;
public static float spinPitchDegreesPersecond;
public static float spinYawDegreesPersecond;
public static float spinRollDegreesPersecond;
public static ConfigEntry<float> configZoom;
public static ConfigEntry<float> configPitch;
public static ConfigEntry<float> configYaw;
public static ConfigEntry<float> configRoll;
public static ConfigEntry<float> configSpinPitch;
public static ConfigEntry<float> configSpinYaw;
public static ConfigEntry<float> configSpinRoll;
public static ConfigEntry<bool> configOrthographic;
public static ConfigEntry<float> configFov;
public static CameraController camControl;
public void Start()
{
ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
}
public void Awake()
{
configZoom = ((BaseUnityPlugin)this).Config.Bind<float>("_Recommended", "Zoom", 1f, "Default zoom level (> 0 recommended), try it with mouseAimLook: false in SlotA.options");
configPitch = ((BaseUnityPlugin)this).Config.Bind<float>("Misc", "Pitch", 0f, "Default pitch (degrees)");
configYaw = ((BaseUnityPlugin)this).Config.Bind<float>("Misc", "Yaw", 0f, "Default yaw (degrees)");
configRoll = ((BaseUnityPlugin)this).Config.Bind<float>("Misc", "Roll", 0f, "Default roll (degrees)");
configSpinPitch = ((BaseUnityPlugin)this).Config.Bind<float>("Misc", "SpinPitch", 0f, "Default pitch spin (degrees / second)");
configSpinYaw = ((BaseUnityPlugin)this).Config.Bind<float>("Misc", "SpinYaw", 0f, "Default yaw spin (degrees / second)");
configSpinRoll = ((BaseUnityPlugin)this).Config.Bind<float>("Misc", "SpinRoll", 0f, "Default roll spin (degrees / second)");
configOrthographic = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "Orthographic", true, "Default camera type");
configFov = ((BaseUnityPlugin)this).Config.Bind<float>("Misc", "FOV", 60f, "Default fov, used with non-orthographic camera (> 0 recommended)");
}
public static void InitDefaultCamera()
{
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
camControl.OverrideZoomScale = configZoom.Value;
camControl.Camera.fieldOfView = configFov.Value;
camControl.Camera.orthographic = configOrthographic.Value;
spinPitchDegreesPersecond = configSpinPitch.Value;
spinYawDegreesPersecond = configSpinYaw.Value;
spinRollDegreesPersecond = configSpinRoll.Value;
((Component)camControl.Camera).transform.rotation = Quaternion.Euler(configPitch.Value, configYaw.Value, configSpinRoll.Value);
currentRotPitch = configPitch.Value;
currentRotYaw = configYaw.Value;
currentRotRoll = configSpinRoll.Value;
if (AllCameraValuesZero() || spinPitchDegreesPersecond == 0f || spinYawDegreesPersecond == 0f || spinRollDegreesPersecond == 0f)
{
Pixelator.Instance.DoOcclusionLayer = true;
}
else
{
Pixelator.Instance.DoOcclusionLayer = false;
}
}
public static bool AllCameraValuesZero()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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)
bool result = true;
if (((Component)camControl.Camera).transform.rotation.x != 0f)
{
result = false;
}
if (((Component)camControl.Camera).transform.rotation.y != 0f)
{
result = false;
}
if (((Component)camControl.Camera).transform.rotation.z != 0f)
{
result = false;
}
return result;
}
public void GMStart(GameManager g)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
((Component)ETGModMainBehaviour.Instance).gameObject.AddComponent<CameraFuckeryComp>();
camControl = g.MainCameraController;
new Harmony("triceraquach.etg.cameramodported").PatchAll();
ETGModConsole.Commands.AddGroup("camera", (Action<string[]>)delegate
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
Log("All camera commands: save, load, reset, zoom #, pitch #, yaw #, roll #, spin_pitch #, spin_yaw #, spin_roll #, orthographic_toggle, fov #", "#00FFFF");
Log($"Current camera: {((Component)g.MainCameraController.Camera).transform.rotation}", "#00FFFF");
});
ETGModConsole.Commands.GetGroup("camera").AddUnit("zoom", (Action<string[]>)delegate(string[] args)
{
if (args != null && args.Length != 0)
{
if (args.Length == 1)
{
float.TryParse(args[0], out var result8);
g.MainCameraController.OverrideZoomScale = result8;
Log($"Setting zoom to: {result8}", "#00FFFF");
}
else
{
Log("Error: Too many arguments!", "#FF1500");
}
}
else
{
Log($"Current zoom: {g.MainCameraController.OverrideZoomScale}", "#00FFFF");
}
});
ETGModConsole.Commands.GetGroup("camera").AddUnit("reset", (Action<string[]>)delegate
{
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
g.MainCameraController.OverrideZoomScale = 1f;
g.MainCameraController.Camera.fieldOfView = 60f;
g.MainCameraController.Camera.orthographic = true;
Pixelator.Instance.DoOcclusionLayer = true;
spinPitchDegreesPersecond = 0f;
spinYawDegreesPersecond = 0f;
spinRollDegreesPersecond = 0f;
((Component)g.MainCameraController.Camera).transform.rotation = Quaternion.Euler(0f, 0f, 0f);
currentRotPitch = 0f;
currentRotYaw = 0f;
currentRotRoll = 0f;
Log("Camera reset!", "#00FFFF");
});
ETGModConsole.Commands.GetGroup("camera").AddUnit("load", (Action<string[]>)delegate
{
InitDefaultCamera();
Log("Camera config loaded!", "#00FFFF");
});
ETGModConsole.Commands.GetGroup("camera").AddUnit("save", (Action<string[]>)delegate
{
configZoom.Value = g.MainCameraController.OverrideZoomScale;
configFov.Value = g.MainCameraController.Camera.fieldOfView;
configOrthographic.Value = g.MainCameraController.Camera.orthographic;
configSpinPitch.Value = spinPitchDegreesPersecond;
configSpinYaw.Value = spinYawDegreesPersecond;
configSpinRoll.Value = spinRollDegreesPersecond;
configPitch.Value = currentRotPitch;
configYaw.Value = currentRotYaw;
configSpinRoll.Value = currentRotRoll;
((BaseUnityPlugin)this).Config.Save();
Log("Camera config saved!", "#00FFFF");
});
ETGModConsole.Commands.GetGroup("camera").AddUnit("orthographic_toggle", (Action<string[]>)delegate
{
if (g.MainCameraController.Camera.orthographic)
{
g.MainCameraController.Camera.orthographic = false;
Log("Camera mode is now set to non-orthographic.", "#00FFFF");
}
else
{
g.MainCameraController.Camera.orthographic = true;
Log("Camera mode is now set to orthographic.", "#00FFFF");
}
});
ETGModConsole.Commands.GetGroup("camera").AddUnit("fov", (Action<string[]>)delegate(string[] args)
{
if (args != null && args.Length != 0)
{
if (args.Length == 1)
{
float.TryParse(args[0], out var result7);
g.MainCameraController.Camera.fieldOfView = result7;
Log($"Setting zoom to: {result7}", "#00FFFF");
}
else
{
Log("Error: Too many arguments!", "#FF1500");
}
}
else
{
Log($"Current fov: {g.MainCameraController.Camera.fieldOfView}", "#00FFFF");
}
});
ETGModConsole.Commands.GetGroup("camera").AddUnit("spin_pitch", (Action<string[]>)delegate(string[] args)
{
if (args != null && args.Length != 0)
{
if (args.Length == 1)
{
float.TryParse(args[0], out var result6);
spinPitchDegreesPersecond = result6;
if (AllCameraValuesZero(g) || spinPitchDegreesPersecond == 0f)
{
Pixelator.Instance.DoOcclusionLayer = true;
}
else
{
Pixelator.Instance.DoOcclusionLayer = false;
}
Log($"Setting pitch spin to: {result6}", "#00FFFF");
}
else
{
Log("Error: Too many arguments!", "#FF1500");
}
}
else
{
Log($"Current pitch spin: {spinPitchDegreesPersecond}", "#00FFFF");
}
});
ETGModConsole.Commands.GetGroup("camera").AddUnit("spin_yaw", (Action<string[]>)delegate(string[] args)
{
if (args != null && args.Length != 0)
{
if (args.Length == 1)
{
float.TryParse(args[0], out var result5);
spinYawDegreesPersecond = result5;
if (AllCameraValuesZero(g) || spinYawDegreesPersecond == 0f)
{
Pixelator.Instance.DoOcclusionLayer = true;
}
else
{
Pixelator.Instance.DoOcclusionLayer = false;
}
Log($"Setting yaw spin to: {result5}", "#00FFFF");
}
else
{
Log("Error: Too many arguments!", "#FF1500");
}
}
else
{
Log($"Current yaw spin: {spinYawDegreesPersecond}", "#00FFFF");
}
});
ETGModConsole.Commands.GetGroup("camera").AddUnit("spin_roll", (Action<string[]>)delegate(string[] args)
{
if (args != null && args.Length != 0)
{
if (args.Length == 1)
{
float.TryParse(args[0], out var result4);
spinRollDegreesPersecond = result4;
if (AllCameraValuesZero(g) || spinRollDegreesPersecond == 0f)
{
Pixelator.Instance.DoOcclusionLayer = true;
}
else
{
Pixelator.Instance.DoOcclusionLayer = false;
}
Log($"Setting roll spin to: {result4}", "#00FFFF");
}
else
{
Log("Error: Too many arguments!", "#FF1500");
}
}
else
{
Log($"Current roll spin: {spinRollDegreesPersecond}", "#00FFFF");
}
});
ETGModConsole.Commands.GetGroup("camera").AddUnit("pitch", (Action<string[]>)delegate(string[] args)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
if (args != null && args.Length != 0)
{
if (args.Length == 1)
{
float.TryParse(args[0], out var result3);
currentRotPitch = result3;
((Component)g.MainCameraController.Camera).transform.rotation = Quaternion.Euler(currentRotPitch, currentRotYaw, currentRotRoll);
if (AllCameraValuesZero(g))
{
Pixelator.Instance.DoOcclusionLayer = true;
}
else
{
Pixelator.Instance.DoOcclusionLayer = false;
}
Log($"Setting pitch to: {result3}", "#00FFFF");
}
else
{
Log("Error: Too many arguments!", "#FF1500");
}
}
else
{
Log($"Current pitch: {currentRotPitch}", "#00FFFF");
}
});
ETGModConsole.Commands.GetGroup("camera").AddUnit("yaw", (Action<string[]>)delegate(string[] args)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
if (args != null && args.Length != 0)
{
if (args.Length == 1)
{
float.TryParse(args[0], out var result2);
currentRotYaw = result2;
((Component)g.MainCameraController.Camera).transform.rotation = Quaternion.Euler(currentRotPitch, currentRotYaw, currentRotRoll);
if (AllCameraValuesZero(g))
{
Pixelator.Instance.DoOcclusionLayer = true;
}
else
{
Pixelator.Instance.DoOcclusionLayer = false;
}
Log($"Setting yaw to: {result2}", "#00FFFF");
}
else
{
Log("Error: Too many arguments!", "#FF1500");
}
}
else
{
Log($"Current yaw: {currentRotYaw}", "#00FFFF");
}
});
ETGModConsole.Commands.GetGroup("camera").AddUnit("roll", (Action<string[]>)delegate(string[] args)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
if (args != null && args.Length != 0)
{
if (args.Length == 1)
{
float.TryParse(args[0], out var result);
currentRotRoll = result;
((Component)g.MainCameraController.Camera).transform.rotation = Quaternion.Euler(currentRotPitch, currentRotYaw, currentRotRoll);
if (AllCameraValuesZero(g))
{
Pixelator.Instance.DoOcclusionLayer = true;
}
else
{
Pixelator.Instance.DoOcclusionLayer = false;
}
Log($"Setting roll to: {result}", "#00FFFF");
}
else
{
Log("Error: Too many arguments!", "#FF1500");
}
}
else
{
Log($"Current roll: {currentRotRoll}", "#00FFFF");
}
});
Log("CameraModPorted v1.0.0 started successfully.", "#00FFFF");
}
public static void Log(string text, string color = "#FFFFFF")
{
ETGModConsole.Log((object)("<color=" + color + ">" + text + "</color>"), false);
}
public static bool AllCameraValuesZero(GameManager g)
{
//IL_0013: 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_0067: Unknown result type (might be due to invalid IL or missing references)
bool result = true;
if (((Component)g.MainCameraController.Camera).transform.rotation.x != 0f)
{
result = false;
}
if (((Component)g.MainCameraController.Camera).transform.rotation.y != 0f)
{
result = false;
}
if (((Component)g.MainCameraController.Camera).transform.rotation.z != 0f)
{
result = false;
}
return result;
}
}
public class CameraFuckeryComp : MonoBehaviour
{
private void Start()
{
}
private void FixedUpdate()
{
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.spinPitchDegreesPersecond != 0f || Plugin.spinYawDegreesPersecond != 0f || Plugin.spinRollDegreesPersecond != 0f)
{
Plugin.currentRotPitch += Plugin.spinPitchDegreesPersecond / 50f;
Plugin.currentRotYaw += Plugin.spinYawDegreesPersecond / 50f;
Plugin.currentRotRoll += Plugin.spinRollDegreesPersecond / 50f;
((Component)GameManager.Instance.MainCameraController.Camera).transform.rotation = Quaternion.Euler(Plugin.currentRotPitch, Plugin.currentRotYaw, Plugin.currentRotRoll);
Pixelator.Instance.DoOcclusionLayer = false;
}
}
}
[HarmonyPatch(typeof(PlayerController), "Start")]
public class RunStartHook
{
[HarmonyPrefix]
private static void Prefix()
{
Plugin.InitDefaultCamera();
}
}
}