using System;
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.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Il2CppInterop.Runtime.Injection;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SonsFlightMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SonsFlightMod")]
[assembly: AssemblyTitle("SonsFlightMod")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 SonsFlightMod
{
public class FlightController : MonoBehaviour
{
private const float SprintMult = 2.5f;
private const float SpeedStep = 2f;
private const float SpeedMin = 2f;
private const float SpeedMax = 100f;
private const float Acceleration = 12f;
private const float Deceleration = 10f;
private bool _flying;
private float _flightSpeed = 18f;
private FirstPersonCharacter? _fpc;
private float _searchCooldown;
private Vector3 _targetVelocity = Vector3.zero;
private Vector3 _smoothedVelocity = Vector3.zero;
public FlightController(IntPtr ptr)
: base(ptr)
{
}//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
private void Update()
{
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Expected O, but got Unknown
RefreshFpc();
Keyboard current = Keyboard.current;
if (current == null)
{
return;
}
if (((ButtonControl)current.jKey).wasPressedThisFrame)
{
_flying = !_flying;
ApplyFlightState(_flying);
Plugin.Logger.LogInfo((object)(_flying ? $"Flight ON (speed: {_flightSpeed})" : "Flight OFF"));
}
if (!_flying)
{
return;
}
bool flag = default(bool);
if (((ButtonControl)current.numpadPlusKey).wasPressedThisFrame)
{
_flightSpeed = Mathf.Clamp(_flightSpeed + 2f, 2f, 100f);
ManualLogSource logger = Plugin.Logger;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(14, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Flight speed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_flightSpeed);
}
logger.LogInfo(val);
}
if (((ButtonControl)current.numpadMinusKey).wasPressedThisFrame)
{
_flightSpeed = Mathf.Clamp(_flightSpeed - 2f, 2f, 100f);
ManualLogSource logger2 = Plugin.Logger;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(14, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Flight speed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_flightSpeed);
}
logger2.LogInfo(val);
}
_targetVelocity = CalcTargetVelocity(current);
}
private void FixedUpdate()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
if (_flying)
{
Rigidbody rigidbody = GetRigidbody();
if (!((Object)(object)rigidbody == (Object)null))
{
float num = ((((Vector3)(ref _targetVelocity)).sqrMagnitude > 0.01f) ? 12f : 10f);
_smoothedVelocity = Vector3.Lerp(_smoothedVelocity, _targetVelocity, Time.fixedDeltaTime * num);
rigidbody.velocity = _smoothedVelocity;
}
}
}
private void RefreshFpc()
{
if (!((Object)(object)_fpc != (Object)null))
{
_searchCooldown -= Time.deltaTime;
if (!(_searchCooldown > 0f))
{
_searchCooldown = 1f;
_fpc = Object.FindObjectOfType<FirstPersonCharacter>();
}
}
}
private void ApplyFlightState(bool enable)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_fpc == (Object)null)
{
return;
}
_fpc.SetDisabledGravity(enable);
Rigidbody rigidbody = GetRigidbody();
if (!((Object)(object)rigidbody == (Object)null))
{
rigidbody.useGravity = !enable;
if (!enable)
{
_targetVelocity = Vector3.zero;
_smoothedVelocity = Vector3.zero;
rigidbody.velocity = Vector3.zero;
}
else
{
_smoothedVelocity = rigidbody.velocity;
}
}
}
private Vector3 CalcTargetVelocity(Keyboard kb)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: 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_0064: 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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
Camera main = Camera.main;
Vector3 val = (((Object)(object)main != (Object)null) ? ((Component)main).transform.forward : Vector3.forward);
Vector3 val2 = (((Object)(object)main != (Object)null) ? ((Component)main).transform.right : Vector3.right);
val.y = 0f;
((Vector3)(ref val)).Normalize();
val2.y = 0f;
((Vector3)(ref val2)).Normalize();
Vector3 val3 = Vector3.zero;
if (((ButtonControl)kb.wKey).isPressed)
{
val3 += val;
}
if (((ButtonControl)kb.sKey).isPressed)
{
val3 -= val;
}
if (((ButtonControl)kb.dKey).isPressed)
{
val3 += val2;
}
if (((ButtonControl)kb.aKey).isPressed)
{
val3 -= val2;
}
if (((ButtonControl)kb.spaceKey).isPressed)
{
val3 += Vector3.up;
}
if (((ButtonControl)kb.leftCtrlKey).isPressed)
{
val3 -= Vector3.up;
}
if (((Vector3)(ref val3)).sqrMagnitude > 0f)
{
((Vector3)(ref val3)).Normalize();
}
float num = _flightSpeed * (((ButtonControl)kb.leftShiftKey).isPressed ? 2.5f : 1f);
return val3 * num;
}
private Rigidbody? GetRigidbody()
{
FirstPersonCharacter? fpc = _fpc;
if (fpc == null)
{
return null;
}
return fpc._rigidbody;
}
}
[BepInPlugin("com.mods.sonsflightmod", "Sons Flight Mod", "1.0.0")]
public class Plugin : BasePlugin
{
public static ManualLogSource Logger;
public override void Load()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
Logger = ((BasePlugin)this).Log;
ClassInjector.RegisterTypeInIl2Cpp<FlightController>();
((BasePlugin)this).AddComponent<FlightController>();
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(65, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Sons Flight Mod");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded! J = toggle flight, WASD = move, Space = up, LCtrl = down");
}
log.LogInfo(val);
}
}
internal static class PluginInfo
{
public const string PLUGIN_GUID = "com.mods.sonsflightmod";
public const string PLUGIN_NAME = "Sons Flight Mod";
public const string PLUGIN_VERSION = "1.0.0";
}
}