using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ZeroGravityMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ZeroGravityMod")] [assembly: AssemblyTitle("ZeroGravityMod")] [assembly: AssemblyVersion("1.0.0.0")] namespace ZeroGravityMod; [BepInPlugin("yourname.peak.zerogravity", "ZeroGravity", "2.2.0")] public class ZeroGravityPlugin : BaseUnityPlugin { [CompilerGenerated] private sealed class d__22 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ZeroGravityPlugin <>4__this; private int 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__22(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown int num = <>1__state; ZeroGravityPlugin zeroGravityPlugin = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; 5__2 = 0; break; case 1: <>1__state = -1; 5__2++; break; } if (5__2 < 3) { zeroGravityPlugin._alarmSource.Play(); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string GUID = "yourname.peak.zerogravity"; public const string NAME = "ZeroGravity"; public const string VERSION = "2.2.0"; internal static ManualLogSource Log; internal static ZeroGravityPlugin Instance; private ConfigEntry _countdownSeconds; private ConfigEntry _floatDurationSeconds; private ConfigEntry _triggerKey; private float _timer; private bool _loopActive; private bool _hasStarted; private bool _countingDown; private bool _floatActive; private bool _warningPlayed; private Vector3 _normalGravity; private const float LIFT = 150f; private const float WARNING_SECONDS = 3f; private AudioSource _alarmSource; private Harmony _harmony; private void Awake() { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; _countdownSeconds = ((BaseUnityPlugin)this).Config.Bind("General", "CountdownSeconds", 180f, "Seconds of countdown before float. Default: 180 (3 minutes)."); _floatDurationSeconds = ((BaseUnityPlugin)this).Config.Bind("General", "FloatDurationSeconds", 10f, "How many seconds the float lasts. Default: 10."); _triggerKey = ((BaseUnityPlugin)this).Config.Bind("General", "TriggerKey", "l", "Key to start the loop. Default: l."); _normalGravity = Physics.gravity; _alarmSource = ((Component)this).gameObject.AddComponent(); _alarmSource.spatialBlend = 0f; _alarmSource.volume = 0.8f; _alarmSource.loop = false; _alarmSource.playOnAwake = false; _alarmSource.clip = CreateBeepClip(880f, 0.18f); _harmony = new Harmony("yourname.peak.zerogravity"); _harmony.PatchAll(); Log.LogInfo((object)("ZeroGravity v2.2.0 loaded! Press " + _triggerKey.Value + " to start the loop for ALL players.")); } private void Update() { if (!_hasStarted && Input.GetKeyDown(_triggerKey.Value.ToLower())) { if ((Object)(object)Character.localCharacter != (Object)null) { Instance._hasStarted = true; ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("ZeroGravity_StartLoop", (RpcTarget)0, Array.Empty()); } else { Instance._hasStarted = true; StartLoop(); } } if (!_loopActive) { return; } _timer += Time.deltaTime; if (_countingDown) { if (!_warningPlayed && _timer >= _countdownSeconds.Value - 3f) { _warningPlayed = true; ((MonoBehaviour)this).StartCoroutine(PlayWarningBeeps()); Log.LogInfo((object)"[ZeroGravity] Warning beeps!"); } if (_timer >= _countdownSeconds.Value) { _countingDown = false; ActivateFloat(); } } else if (_floatActive && _timer >= _floatDurationSeconds.Value) { DeactivateFloat(); _countingDown = true; _warningPlayed = false; _timer = 0f; Log.LogInfo((object)$"[ZeroGravity] Next float in {_countdownSeconds.Value}s."); } } public void StartLoop() { _loopActive = true; _countingDown = true; _warningPlayed = false; _timer = 0f; Log.LogInfo((object)$"[ZeroGravity] Loop started! Float in {_countdownSeconds.Value}s."); } [IteratorStateMachine(typeof(d__22))] private IEnumerator PlayWarningBeeps() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__22(0) { <>4__this = this }; } private void FixedUpdate() { //IL_0074: 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) if (!_floatActive) { return; } foreach (Character allCharacter in Character.AllCharacters) { if ((Object)(object)allCharacter == (Object)null || allCharacter.data.dead) { continue; } foreach (Bodypart part in allCharacter.refs.ragdoll.partList) { if (!((Object)(object)part == (Object)null) && !((Object)(object)part.Rig == (Object)null)) { part.Rig.AddForce(Vector3.up * 150f, (ForceMode)5); } } } } private void ActivateFloat() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) _floatActive = true; _timer = 0f; Physics.gravity = Vector3.zero; Log.LogInfo((object)"[ZeroGravity] Float ON!"); } private void DeactivateFloat() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) _floatActive = false; Physics.gravity = _normalGravity; Log.LogInfo((object)"[ZeroGravity] Float OFF."); } private void OnDestroy() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Physics.gravity = _normalGravity; Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private static AudioClip CreateBeepClip(float frequency, float duration) { int num = 44100; int num2 = Mathf.CeilToInt((float)num * duration); float[] array = new float[num2]; for (int i = 0; i < num2; i++) { float num3 = (float)i / (float)num; float num4 = Mathf.Clamp01((float)(num2 - i) / ((float)num * 0.02f)); array[i] = Mathf.Sin(MathF.PI * 2f * frequency * num3) * num4; } AudioClip obj = AudioClip.Create("ZeroGravWarning", num2, 1, num, false); obj.SetData(array, 0); return obj; } } [HarmonyPatch(typeof(Character))] public static class CharacterPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] public static void Awake_Postfix(Character __instance) { if ((Object)(object)((Component)__instance).GetComponent() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); } } } public class ZeroGravityRPC : MonoBehaviourPun { [PunRPC] public void ZeroGravity_StartLoop() { ZeroGravityPlugin.Instance?.StartLoop(); } }