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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OmniZeroG")]
[assembly: AssemblyTitle("OmniZeroG")]
[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 ZeroGMod
{
[HarmonyPatch(typeof(PlayerController))]
public static class ZeroG_HarmonyPatch
{
private class ZeroGData
{
public bool active;
public float remainingTime;
public int remainingUses;
public float useDuration;
public Rigidbody rb;
public PlayerController pc;
public bool isLocal;
public float originalCustomGravity;
public float originalDrag;
public bool originalUseGravity;
}
private static readonly Dictionary<PlayerController, ZeroGData> states = new Dictionary<PlayerController, ZeroGData>();
private const int DefaultUses = 5;
private const float DefaultSecondsPerUse = 60f;
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(PlayerController __instance)
{
if (!states.ContainsKey(__instance))
{
Rigidbody rigidbody = GetRigidbody(__instance);
ZeroGData value = new ZeroGData
{
active = false,
remainingTime = 0f,
remainingUses = 5,
useDuration = 60f,
rb = rigidbody,
pc = __instance,
isLocal = IsLocalPlayer(__instance),
originalCustomGravity = __instance.CustomGravity,
originalDrag = (((Object)(object)rigidbody != (Object)null) ? rigidbody.drag : 0f),
originalUseGravity = (!((Object)(object)rigidbody != (Object)null) || rigidbody.useGravity)
};
states[__instance] = value;
Debug.Log((object)("[ZeroG] Initialized for player " + ((Object)__instance).name));
}
}
[HarmonyPrefix]
[HarmonyPatch("Update")]
private static void Update_Prefix(PlayerController __instance)
{
if (states.TryGetValue(__instance, out ZeroGData value) && value.isLocal && Input.GetKeyDown((KeyCode)277))
{
if (value.active)
{
Deactivate(value);
}
else if (value.remainingUses > 0)
{
value.remainingUses = Mathf.Max(0, value.remainingUses - 1);
Activate(value, value.useDuration);
}
UpdateUI(value);
}
}
[HarmonyPrefix]
[HarmonyPatch("FixedUpdate")]
private static void FixedUpdate_Prefix(PlayerController __instance)
{
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: 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)
if (states.TryGetValue(__instance, out ZeroGData value) && value.active && !((Object)(object)value.rb == (Object)null))
{
value.remainingTime -= Time.fixedDeltaTime;
value.pc.CustomGravity = 0f;
value.rb.useGravity = false;
value.rb.drag = 0.1f;
Vector3 velocity = value.rb.velocity;
velocity.y = Mathf.Max(velocity.y, 0f);
value.rb.velocity = velocity;
if (value.remainingTime <= 0f)
{
Deactivate(value);
}
UpdateUI(value);
}
}
public static bool IsZeroGActive(PlayerController pc)
{
ZeroGData value;
return states.TryGetValue(pc, out value) && value.active;
}
private static void Activate(ZeroGData data, float seconds)
{
if (data != null)
{
data.remainingTime = seconds;
data.active = true;
Debug.Log((object)("[ZeroG] Activated for " + ((Object)data.pc).name));
}
}
private static void Deactivate(ZeroGData data)
{
if (data != null)
{
data.remainingTime = 0f;
data.active = false;
data.pc.CustomGravity = data.originalCustomGravity;
if ((Object)(object)data.rb != (Object)null)
{
data.rb.drag = data.originalDrag;
data.rb.useGravity = data.originalUseGravity;
}
Debug.Log((object)("[ZeroG] Deactivated for " + ((Object)data.pc).name));
}
}
private static void UpdateUI(ZeroGData data)
{
ZeroGStatusUI.zeroGActive = data.active;
ZeroGStatusUI.remainingTime = data.remainingTime;
ZeroGStatusUI.remainingUses = data.remainingUses;
}
private static Rigidbody GetRigidbody(PlayerController pc)
{
return ((Component)pc).GetComponent<Rigidbody>() ?? ((Component)pc).GetComponentInChildren<Rigidbody>();
}
private static bool IsLocalPlayer(PlayerController pc)
{
return true;
}
}
[HarmonyPatch(typeof(ChatManager), "Update")]
public static class Patch_ZeroG_UIInject
{
private static GameObject overlayHolder;
private static void Postfix()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
if ((Object)(object)overlayHolder == (Object)null)
{
overlayHolder = new GameObject("ZeroGStatusOverlay", new Type[1] { typeof(ZeroGStatusUI) });
Object.DontDestroyOnLoad((Object)(object)overlayHolder);
}
}
}
public class ZeroGStatusUI : MonoBehaviour
{
public static bool zeroGActive = false;
public static int remainingUses = 5;
public static float remainingTime = 0f;
private void OnGUI()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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_0060: Unknown result type (might be due to invalid IL or missing references)
if (zeroGActive)
{
GUI.color = Color.black;
GUI.Box(new Rect(8f, 180f, 220f, 60f), GUIContent.none);
GUI.color = Color.white;
GUILayout.BeginArea(new Rect(10f, 182f, 200f, 60f));
GUILayout.Label("<b>\ud83d\ude80 Zero-G Mode Active</b>", Array.Empty<GUILayoutOption>());
GUILayout.Label($"⏱ Time: {remainingTime:F0}s | \ud83d\ude80 Uses Left: {remainingUses}", Array.Empty<GUILayoutOption>());
GUILayout.EndArea();
}
}
}
}
namespace OmniZeroG
{
[BepInPlugin("Omniscye.OmniZeroG", "OmniZeroG", "1.0")]
public class OmniZeroG : BaseUnityPlugin
{
internal static OmniZeroG Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
}
}
}