Decompiled source of SkateboardFly v1.0.0

SkateboardFly_IL2CPP.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppScheduleOne.Skating;
using MelonLoader;
using MelonLoader.Preferences;
using SkateboardFly;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::SkateboardFly.SkateboardFly), "Skateboard Fly", "1.0", "Jumble", null)]
[assembly: MelonColor]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SkateboardFly_IL2CPP")]
[assembly: AssemblyConfiguration("Debug_IL2CPP")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SkateboardFly_IL2CPP")]
[assembly: AssemblyTitle("SkateboardFly_IL2CPP")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SkateboardFly;

public static class BuildInfo
{
	public const string Name = "Skateboard Fly";

	public const string Description = "Lets you fly with your skateboards.";

	public const string Author = "Jumble";

	public const string Company = null;

	public const string Version = "1.0";

	public const string DownloadLink = null;
}
public static class Config
{
	private static MelonPreferences_Category configCategory;

	private static MelonPreferences_Entry<bool> enabledEntry;

	private static MelonPreferences_Entry<string> flyKeyEntry;

	private static MelonPreferences_Entry<float> forwardForceEntry;

	private static MelonPreferences_Entry<float> liftForceEntry;

	private static MelonPreferences_Entry<float> throttleChangePerSecondEntry;

	private static MelonPreferences_Entry<float> pitchTorqueEntry;

	private static MelonPreferences_Entry<float> yawTorqueEntry;

	private static MelonPreferences_Entry<float> rollTorqueEntry;

	private static MelonPreferences_Entry<float> velocityDampingEntry;

	private static MelonPreferences_Entry<float> stabilizationTorqueEntry;

	private static MelonPreferences_Entry<float> maxSpeedKmhEntry;

	public static bool Enabled => enabledEntry?.Value ?? true;

	public static string FlyKey => flyKeyEntry?.Value ?? "E";

	public static float ForwardForce => forwardForceEntry?.Value ?? 18f;

	public static float LiftForce => liftForceEntry?.Value ?? 1.25f;

	public static float ThrottleChangePerSecond => throttleChangePerSecondEntry?.Value ?? 0.35f;

	public static float PitchTorque => pitchTorqueEntry?.Value ?? 4f;

	public static float YawTorque => yawTorqueEntry?.Value ?? 2.5f;

	public static float RollTorque => rollTorqueEntry?.Value ?? 5f;

	public static float VelocityDamping => velocityDampingEntry?.Value ?? 0.8f;

	public static float StabilizationTorque => stabilizationTorqueEntry?.Value ?? 3.5f;

	public static float MaxSpeedKmh => maxSpeedKmhEntry?.Value ?? 140f;

	public static void Load()
	{
		configCategory = MelonPreferences.CreateCategory("SkateboardFly");
		enabledEntry = configCategory.CreateEntry<bool>("enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		flyKeyEntry = configCategory.CreateEntry<string>("flyKey", "E", (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		forwardForceEntry = configCategory.CreateEntry<float>("forwardForce", 18f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		liftForceEntry = configCategory.CreateEntry<float>("liftForce", 1.25f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		throttleChangePerSecondEntry = configCategory.CreateEntry<float>("throttleChangePerSecond", 0.35f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		pitchTorqueEntry = configCategory.CreateEntry<float>("pitchTorque", 4f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		yawTorqueEntry = configCategory.CreateEntry<float>("yawTorque", 2.5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		rollTorqueEntry = configCategory.CreateEntry<float>("rollTorque", 5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		velocityDampingEntry = configCategory.CreateEntry<float>("velocityDamping", 0.8f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		stabilizationTorqueEntry = configCategory.CreateEntry<float>("stabilizationTorque", 3.5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		maxSpeedKmhEntry = configCategory.CreateEntry<float>("maxSpeedKmh", 140f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
	}
}
public class SkateboardFly : MelonMod
{
	internal static SkateboardFly Instance;

	private KeyCode _flyKey = (KeyCode)101;

	private bool _isFlying;

	private float _throttle;

	public override void OnInitializeMelon()
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		Config.Load();
		if (!Enum.TryParse<KeyCode>(Config.FlyKey, ignoreCase: true, out _flyKey))
		{
			MelonLogger.Warning("Invalid flyKey '" + Config.FlyKey + "'. Falling back to 'E'.");
			_flyKey = (KeyCode)101;
		}
	}

	public override void OnUpdate()
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		Skateboard board;
		Rigidbody boardRb;
		if (!Config.Enabled)
		{
			_isFlying = false;
			_throttle = 0f;
		}
		else if (!TryGetBoardAndRigidbody(out board, out boardRb))
		{
			_isFlying = false;
			_throttle = 0f;
		}
		else if (Input.GetKeyDown(_flyKey))
		{
			_isFlying = !_isFlying;
			if (!_isFlying)
			{
				_throttle = 0f;
			}
		}
	}

	public override void OnFixedUpdate()
	{
		if (!Config.Enabled || !_isFlying)
		{
			return;
		}
		if (!TryGetBoardAndRigidbody(out var board, out var boardRb))
		{
			_isFlying = false;
			_throttle = 0f;
			return;
		}
		float num = Mathf.Max(0.05f, Config.ThrottleChangePerSecond) * Time.fixedDeltaTime;
		if (Input.GetKey((KeyCode)32))
		{
			_throttle += num;
		}
		if (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)99))
		{
			_throttle -= num;
		}
		_throttle = Mathf.Clamp01(_throttle);
		ApplyFlightPhysics(board, boardRb);
	}

	private static bool TryGetBoardAndRigidbody(out Skateboard board, out Rigidbody boardRb)
	{
		board = null;
		boardRb = null;
		Player local = Player.Local;
		if ((Object)(object)local == (Object)null)
		{
			return false;
		}
		board = local.ActiveSkateboard;
		if ((Object)(object)board == (Object)null)
		{
			return false;
		}
		boardRb = board.Rb;
		if ((Object)(object)boardRb == (Object)null)
		{
			return false;
		}
		return true;
	}

	private void ApplyFlightPhysics(Skateboard board, Rigidbody boardRb)
	{
		//IL_0018: 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_003b: 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)
		//IL_005d: 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_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: 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)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		float axisRaw = Input.GetAxisRaw("Vertical");
		float axisRaw2 = Input.GetAxisRaw("Horizontal");
		boardRb.AddRelativeForce(Vector3.forward * (Config.ForwardForce * _throttle), (ForceMode)5);
		float num = Mathf.Max(0f, Vector3.Dot(boardRb.velocity, ((Component)board).transform.forward));
		boardRb.AddForce(((Component)board).transform.up * (num * Config.LiftForce), (ForceMode)5);
		boardRb.AddRelativeTorque(new Vector3(axisRaw * Config.PitchTorque, axisRaw2 * Config.YawTorque, (0f - axisRaw2) * Config.RollTorque), (ForceMode)5);
		Vector3 val = Vector3.Cross(((Component)board).transform.up, Vector3.up);
		boardRb.AddTorque(val * Config.StabilizationTorque, (ForceMode)5);
		boardRb.AddForce(-boardRb.velocity * Config.VelocityDamping, (ForceMode)5);
		float num2 = Mathf.Max(5f, Config.MaxSpeedKmh) / 3.6f;
		Vector3 velocity = boardRb.velocity;
		if (((Vector3)(ref velocity)).sqrMagnitude > num2 * num2)
		{
			velocity = boardRb.velocity;
			boardRb.velocity = ((Vector3)(ref velocity)).normalized * num2;
		}
	}
}

SkateboardFly_Mono.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using MelonLoader;
using MelonLoader.Preferences;
using ScheduleOne.PlayerScripts;
using ScheduleOne.Skating;
using SkateboardFly;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::SkateboardFly.SkateboardFly), "Skateboard Fly", "1.0", "Jumble", null)]
[assembly: MelonColor]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("SkateboardFly_Mono")]
[assembly: AssemblyConfiguration("Debug_Mono")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SkateboardFly_Mono")]
[assembly: AssemblyTitle("SkateboardFly_Mono")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SkateboardFly;

public static class BuildInfo
{
	public const string Name = "Skateboard Fly";

	public const string Description = "Lets you fly with your skateboards.";

	public const string Author = "Jumble";

	public const string Company = null;

	public const string Version = "1.0";

	public const string DownloadLink = null;
}
public static class Config
{
	private static MelonPreferences_Category configCategory;

	private static MelonPreferences_Entry<bool> enabledEntry;

	private static MelonPreferences_Entry<string> flyKeyEntry;

	private static MelonPreferences_Entry<float> forwardForceEntry;

	private static MelonPreferences_Entry<float> liftForceEntry;

	private static MelonPreferences_Entry<float> throttleChangePerSecondEntry;

	private static MelonPreferences_Entry<float> pitchTorqueEntry;

	private static MelonPreferences_Entry<float> yawTorqueEntry;

	private static MelonPreferences_Entry<float> rollTorqueEntry;

	private static MelonPreferences_Entry<float> velocityDampingEntry;

	private static MelonPreferences_Entry<float> stabilizationTorqueEntry;

	private static MelonPreferences_Entry<float> maxSpeedKmhEntry;

	public static bool Enabled => enabledEntry?.Value ?? true;

	public static string FlyKey => flyKeyEntry?.Value ?? "E";

	public static float ForwardForce => forwardForceEntry?.Value ?? 18f;

	public static float LiftForce => liftForceEntry?.Value ?? 1.25f;

	public static float ThrottleChangePerSecond => throttleChangePerSecondEntry?.Value ?? 0.35f;

	public static float PitchTorque => pitchTorqueEntry?.Value ?? 4f;

	public static float YawTorque => yawTorqueEntry?.Value ?? 2.5f;

	public static float RollTorque => rollTorqueEntry?.Value ?? 5f;

	public static float VelocityDamping => velocityDampingEntry?.Value ?? 0.8f;

	public static float StabilizationTorque => stabilizationTorqueEntry?.Value ?? 3.5f;

	public static float MaxSpeedKmh => maxSpeedKmhEntry?.Value ?? 140f;

	public static void Load()
	{
		configCategory = MelonPreferences.CreateCategory("SkateboardFly");
		enabledEntry = configCategory.CreateEntry<bool>("enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		flyKeyEntry = configCategory.CreateEntry<string>("flyKey", "E", (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		forwardForceEntry = configCategory.CreateEntry<float>("forwardForce", 18f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		liftForceEntry = configCategory.CreateEntry<float>("liftForce", 1.25f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		throttleChangePerSecondEntry = configCategory.CreateEntry<float>("throttleChangePerSecond", 0.35f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		pitchTorqueEntry = configCategory.CreateEntry<float>("pitchTorque", 4f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		yawTorqueEntry = configCategory.CreateEntry<float>("yawTorque", 2.5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		rollTorqueEntry = configCategory.CreateEntry<float>("rollTorque", 5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		velocityDampingEntry = configCategory.CreateEntry<float>("velocityDamping", 0.8f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		stabilizationTorqueEntry = configCategory.CreateEntry<float>("stabilizationTorque", 3.5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		maxSpeedKmhEntry = configCategory.CreateEntry<float>("maxSpeedKmh", 140f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
	}
}
public class SkateboardFly : MelonMod
{
	internal static SkateboardFly Instance;

	private KeyCode _flyKey = (KeyCode)101;

	private bool _isFlying;

	private float _throttle;

	public override void OnInitializeMelon()
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		Config.Load();
		if (!Enum.TryParse<KeyCode>(Config.FlyKey, ignoreCase: true, out _flyKey))
		{
			MelonLogger.Warning("Invalid flyKey '" + Config.FlyKey + "'. Falling back to 'E'.");
			_flyKey = (KeyCode)101;
		}
	}

	public override void OnUpdate()
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		Skateboard board;
		Rigidbody boardRb;
		if (!Config.Enabled)
		{
			_isFlying = false;
			_throttle = 0f;
		}
		else if (!TryGetBoardAndRigidbody(out board, out boardRb))
		{
			_isFlying = false;
			_throttle = 0f;
		}
		else if (Input.GetKeyDown(_flyKey))
		{
			_isFlying = !_isFlying;
			if (!_isFlying)
			{
				_throttle = 0f;
			}
		}
	}

	public override void OnFixedUpdate()
	{
		if (!Config.Enabled || !_isFlying)
		{
			return;
		}
		if (!TryGetBoardAndRigidbody(out var board, out var boardRb))
		{
			_isFlying = false;
			_throttle = 0f;
			return;
		}
		float num = Mathf.Max(0.05f, Config.ThrottleChangePerSecond) * Time.fixedDeltaTime;
		if (Input.GetKey((KeyCode)32))
		{
			_throttle += num;
		}
		if (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)99))
		{
			_throttle -= num;
		}
		_throttle = Mathf.Clamp01(_throttle);
		ApplyFlightPhysics(board, boardRb);
	}

	private static bool TryGetBoardAndRigidbody(out Skateboard board, out Rigidbody boardRb)
	{
		board = null;
		boardRb = null;
		Player local = Player.Local;
		if ((Object)(object)local == (Object)null)
		{
			return false;
		}
		board = local.ActiveSkateboard;
		if ((Object)(object)board == (Object)null)
		{
			return false;
		}
		boardRb = board.Rb;
		if ((Object)(object)boardRb == (Object)null)
		{
			return false;
		}
		return true;
	}

	private void ApplyFlightPhysics(Skateboard board, Rigidbody boardRb)
	{
		//IL_0018: 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_003b: 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)
		//IL_005d: 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_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: 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)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		float axisRaw = Input.GetAxisRaw("Vertical");
		float axisRaw2 = Input.GetAxisRaw("Horizontal");
		boardRb.AddRelativeForce(Vector3.forward * (Config.ForwardForce * _throttle), (ForceMode)5);
		float num = Mathf.Max(0f, Vector3.Dot(boardRb.velocity, ((Component)board).transform.forward));
		boardRb.AddForce(((Component)board).transform.up * (num * Config.LiftForce), (ForceMode)5);
		boardRb.AddRelativeTorque(new Vector3(axisRaw * Config.PitchTorque, axisRaw2 * Config.YawTorque, (0f - axisRaw2) * Config.RollTorque), (ForceMode)5);
		Vector3 val = Vector3.Cross(((Component)board).transform.up, Vector3.up);
		boardRb.AddTorque(val * Config.StabilizationTorque, (ForceMode)5);
		boardRb.AddForce(-boardRb.velocity * Config.VelocityDamping, (ForceMode)5);
		float num2 = Mathf.Max(5f, Config.MaxSpeedKmh) / 3.6f;
		Vector3 velocity = boardRb.velocity;
		if (((Vector3)(ref velocity)).sqrMagnitude > num2 * num2)
		{
			velocity = boardRb.velocity;
			boardRb.velocity = ((Vector3)(ref velocity)).normalized * num2;
		}
	}
}