Decompiled source of StaticCamera v1.0.0

StaticCamera.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
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.Logging;
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: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("StaticCamera")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Prevents the camera from moving")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StaticCamera")]
[assembly: AssemblyTitle("StaticCamera")]
[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 StaticCamera
{
	[BepInPlugin("com.PizzaMan730.StaticCamera", "StaticCamera", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource Log;

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"StaticCamera has loaded!");
			Harmony val = new Harmony("com.PizzaMan730.StaticCamera");
			val.PatchAll(typeof(Patch));
		}
	}
	[HarmonyPatch]
	public class Patch
	{
		[HarmonyPatch(typeof(PlayerAverageCamera), "UpdateCamera")]
		[HarmonyPrefix]
		public static bool UpdateCamera(ref bool ___useMinMaxForCameraX, ref float ___maxDeltaTime, ref float ___weight, ref PlayerAverageCamera __instance, ref Camera ___camera, ref float ___outsideLevelX, ref float ___MinHeightAboveFloor, ref bool ___UpdateX, ref bool ___UpdateY, ref float ___extraZoomRoom, ref float ___MAX_ZOOM, ref float ___MIN_ZOOM, ref float ___zoomWeight)
		{
			//IL_00b8: 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_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: 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_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: 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_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: 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_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: 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_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			List<Player> list = PlayerHandler.Get().PlayerList();
			if (GameLobby.isOnlineGame)
			{
				Plugin.Log.LogInfo((object)"Online game");
				for (int i = 0; i < list.Count; i++)
				{
					if (list[i].IsLocalPlayer)
					{
						list.RemoveAt(i);
					}
				}
			}
			else
			{
				Plugin.Log.LogInfo((object)"Offline Game");
				for (int j = 0; j < list.Count; j++)
				{
					if (!list[j].IsLocalPlayer)
					{
						list.RemoveAt(j);
					}
				}
			}
			Vector2 val = default(Vector2);
			float num = list.Count;
			float num2 = 0f;
			float num3 = 0f;
			for (int k = 0; k < list.Count; k++)
			{
				if (list[k].IsAlive)
				{
					Vector2 val2 = (Vector2)list[k].Position;
					val += val2;
					num2 = Mathf.Max(num2, val2.x);
					num3 = Mathf.Min(num3, val2.x);
				}
			}
			Vec2[] playerSpawns_readonly = GameSessionHandler.playerSpawns_readonly;
			val /= num;
			if (___useMinMaxForCameraX)
			{
				((Vector2)(ref val))..ctor((num3 + num2) * 0.5f, val.y);
			}
			float num4 = Mathf.Min(___maxDeltaTime, Time.unscaledDeltaTime);
			Vector2 val3 = Vector2.op_Implicit((1f - ___weight * num4) * ((Component)__instance).transform.localPosition + ___weight * num4 * Vector2.op_Implicit(val));
			float num5 = ___camera.orthographicSize * ___camera.aspect + ___outsideLevelX;
			val3.x = Mathf.Max((float)SceneBounds.Camera_XMin + num5, val3.x);
			val3.x = Mathf.Min((float)SceneBounds.Camera_XMax - num5, val3.x);
			val3.x = __instance.RoundToNearestPixel(val3.x);
			val3.y = Mathf.Max((float)SceneBounds.WaterHeight + ___MinHeightAboveFloor, val3.y);
			val3.y = Mathf.Min((float)SceneBounds.Camera_YMax, val3.y);
			val3.y = __instance.RoundToNearestPixel(val3.y);
			if (!___UpdateX)
			{
				val3.x = ((Component)__instance).transform.position.x;
			}
			if (!___UpdateY)
			{
				val3.y = ((Component)__instance).transform.position.y;
			}
			Vector3 position = default(Vector3);
			((Vector3)(ref position))..ctor(val3.x, val3.y, ((Component)__instance).transform.position.z);
			((Component)__instance).transform.position = position;
			float num6 = 0f;
			float num7 = 0f;
			for (int l = 0; l < list.Count; l++)
			{
				Vector2 val4 = (Vector2)list[l].Position;
				float num8 = Mathf.Abs(val4.x - val.x);
				num6 = Mathf.Max(num6, num8);
				num8 = Mathf.Abs(val4.y - val.y);
				num7 = Mathf.Max(num7, num8);
			}
			float num9 = Screen.width / Screen.height;
			num6 *= num9;
			float num10 = Mathf.Max(num6, num7);
			num10 += ___extraZoomRoom;
			if (num10 > ___MAX_ZOOM)
			{
				num10 = ___MAX_ZOOM;
			}
			if (num10 < ___MIN_ZOOM)
			{
				num10 = ___MIN_ZOOM;
			}
			float num11 = Mathf.Clamp((1f - ___zoomWeight * num4) * ___camera.orthographicSize + ___zoomWeight * num4 * num10, ___MIN_ZOOM, ___MAX_ZOOM);
			if (___camera.orthographicSize != num11)
			{
				___camera.orthographicSize = num11;
			}
			return false;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "StaticCamera";

		public const string PLUGIN_NAME = "StaticCamera";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}