Decompiled source of UpsideDownMod v1.0.0

UpsideDownMod.dll

Decompiled 4 hours ago
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 KinematicCharacterController;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("UpsideDownMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UpsideDownMod")]
[assembly: AssemblyTitle("UpsideDownMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace UpsideDownMod;

internal class FlipBehaviour : MonoBehaviour
{
	private CharacterBody target;

	private Camera camera;

	private CameraRigController cameraRig;

	private CharacterMotor motor;

	public float speed = 65f;

	private void Awake()
	{
		camera = ((Component)this).GetComponent<Camera>();
		cameraRig = ((Component)this).GetComponentInParent<CameraRigController>();
	}

	private void Unground()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: 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)
		Vector3 velocity = cameraRig.targetBody.characterMotor.velocity;
		velocity.y = speed;
		cameraRig.targetBody.characterMotor.velocity = velocity;
		((BaseCharacterController)cameraRig.targetBody.characterMotor).Motor.ForceUnground(0.1f);
	}

	private void FixedUpdate()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: 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_00c3: 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)
		//IL_00d6: 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_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: 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_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)motor) && (motor.isGrounded || motor.velocity == Vector3.zero))
		{
			Unground();
		}
		if (Object.op_Implicit((Object)(object)target) || !Object.op_Implicit((Object)(object)cameraRig) || !Object.op_Implicit((Object)(object)cameraRig.targetBody))
		{
			return;
		}
		target = cameraRig.targetBody;
		if (MainPlugin.flipPlayer.Value)
		{
			Vector3 localScale = cameraRig.targetBody.transform.localScale;
			cameraRig.targetBody.transform.localScale = new Vector3(localScale.x, -1f, localScale.z);
			if (Object.op_Implicit((Object)(object)cameraRig.targetBody.modelLocator) && Object.op_Implicit((Object)(object)cameraRig.targetBody.modelLocator.modelTransform))
			{
				Vector3 localScale2 = cameraRig.targetBody.modelLocator.modelTransform.localScale;
				cameraRig.targetBody.modelLocator.modelTransform.localScale = new Vector3(localScale2.x, -1f, localScale2.z);
			}
		}
		if (MainPlugin.flippedGravity.Value && Object.op_Implicit((Object)(object)cameraRig.targetBody.characterMotor))
		{
			motor = cameraRig.targetBody.characterMotor;
			CharacterGravityParameters gravityParameters = motor.gravityParameters;
			gravityParameters.channeledAntiGravityGranterCount++;
			motor.gravityParameters = gravityParameters;
			Unground();
		}
	}

	private void OnPreCull()
	{
		//IL_003a: 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_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		float num = ((!MainPlugin.axisX.Value) ? 1 : (-1));
		float num2 = ((!MainPlugin.axisY.Value) ? 1 : (-1));
		float num3 = ((!MainPlugin.axisZ.Value) ? 1 : (-1));
		Matrix4x4 val = Matrix4x4.Scale(new Vector3(num, num2, num3));
		camera.ResetWorldToCameraMatrix();
		camera.ResetProjectionMatrix();
		camera.projectionMatrix *= val;
	}

	private void OnPreRender()
	{
		GL.invertCulling = true;
	}

	private void OnPostRender()
	{
		GL.invertCulling = false;
	}
}
[BepInPlugin("com.Dragonyck.UpsideDownMod", "UpsideDownMod", "1.0.0")]
public class MainPlugin : BaseUnityPlugin
{
	public const string MODUID = "com.Dragonyck.UpsideDownMod";

	public const string MODNAME = "UpsideDownMod";

	public const string VERSION = "1.0.0";

	internal static ConfigEntry<bool> flipPlayer;

	internal static ConfigEntry<bool> flippedGravity;

	internal static ConfigEntry<bool> axisX;

	internal static ConfigEntry<bool> axisY;

	internal static ConfigEntry<bool> axisZ;

	private void Awake()
	{
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		flipPlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Flip Player", false, (ConfigDescription)null);
		flippedGravity = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Flipped Gravity", false, (ConfigDescription)null);
		axisX = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Flip Sides", false, "Very buggy, experimental.");
		axisY = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Flip Up", true, (ConfigDescription)null);
		axisZ = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Flip Forward", false, "Very buggy, experimental.");
		((Component)Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Core/Main Camera.prefab").WaitForCompletion().transform.GetChild(0)).gameObject.AddComponent<FlipBehaviour>();
	}
}