The BepInEx console will not appear when launching like it does for other games on Thunderstore (you can turn it back on in your BepInEx.cfg file). If your PEAK crashes on startup, add -dx12 to your launch parameters.
Decompiled source of Discplacement v1.0.0
Discplacement.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Discplacement.Patches; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Utilities; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Discplacement")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+c85f7c72552731bf7182c2650c7e9ee37cf8b7f8")] [assembly: AssemblyProduct("Discplacement")] [assembly: AssemblyTitle("Discplacement")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Discplacement { public class ConfigurationHandler { private ConfigFile _config = new ConfigFile(Path.Combine(Paths.ConfigPath, "Discplacement.cfg"), true); public ConfigEntry<int> ConfigBalanceUses; public ConfigEntry<bool> ConfigBalanceUsesCapped; public ConfigEntry<bool> ConfigFrisbeeReturn; public ConfigEntry<int> ConfigBalanceCooldown; public ConfigEntry<bool> ConfigBalanceCooldownEnabled; public ConfigEntry<string> ConfigMenuKey; public ConfigEntry<bool> ConfigFrisbeeParticleEffectEnabled; public InputAction MenuAction { get; set; } public int Uses => ConfigBalanceUses.Value; public bool IsUsesCapped => ConfigBalanceUsesCapped.Value; public bool IsFrisbeeReturnEnabled => ConfigFrisbeeReturn.Value; public bool IsBalanceCooldownEnabled => ConfigBalanceCooldownEnabled.Value; public int Cooldown => ConfigBalanceCooldown.Value; public bool IsFrisbeeParticleEffectEnabled => ConfigFrisbeeParticleEffectEnabled.Value; public ConfigurationHandler() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown Plugin.Logger.LogInfo((object)"ConfigurationHandler initialising"); ConfigBalanceUsesCapped = _config.Bind<bool>("Balance: Uses", "Cap Uses", false, "Whether or not the frisbee uses are capped. (false = infinite uses)"); ConfigBalanceUsesCapped.SettingChanged += OnBalanceUsesCappedChanged; Plugin.Logger.LogInfo((object)("ConfigurationHandler: Uses Cap Enabled: " + ConfigBalanceUsesCapped.Value)); ConfigBalanceUses = _config.Bind<int>("Balance: Uses", "Uses", 3, "The number of times the frisbee can teleport you."); if (ConfigBalanceUses.Value <= 0) { ConfigBalanceUses.Value = 1; } ConfigBalanceUses.SettingChanged += OnBalanceUsesChanged; Plugin.Logger.LogInfo((object)("ConfigurationHandler: Uses Loaded: " + ConfigBalanceUses.Value)); ConfigFrisbeeReturn = _config.Bind<bool>("Gameplay", "Frisbee Return", true, "Whether or not the frisbee should be returned to your inventory automatically."); ConfigFrisbeeReturn.SettingChanged += OnFrisbeeReturnChanged; Plugin.Logger.LogInfo((object)("ConfigurationHandler: Uses Cap Enabled: " + ConfigFrisbeeReturn.Value)); ConfigBalanceCooldownEnabled = _config.Bind<bool>("Balance: Cooldown", "Cooldown Enabled", true, "Whether or not the frisbee cooldown is enabled."); ConfigBalanceCooldownEnabled.SettingChanged += OnBalanceCooldownEnabledChanged; Plugin.Logger.LogInfo((object)("Set Cooldown Enabled to " + IsBalanceCooldownEnabled + "!")); ConfigFrisbeeParticleEffectEnabled = _config.Bind<bool>("General", "Frisbee Fire Particles Enabled", true, "Whether or not you want the fire particle effects on the frisbee."); ConfigFrisbeeParticleEffectEnabled.SettingChanged += OnFrisbeeParticleEffectEnabledChanged; Plugin.Logger.LogInfo((object)("Set Cooldown Enabled to " + IsFrisbeeParticleEffectEnabled + "!")); ConfigBalanceCooldown = _config.Bind<int>("Balance: Cooldown", "Cooldown Time", 8, "How long in seconds the cooldown should be."); ConfigBalanceCooldown.SettingChanged += OnBalanceCooldownChanged; Plugin.Logger.LogInfo((object)("Set the Cooldown to " + Cooldown + "!")); ConfigMenuKey = _config.Bind<string>("General", "Config Menu Key", "<Keyboard>/f3", "Control path for opening the mod configuration menu (e.g. <Keyboard>/f3, <Keyboard>/space, <Keyboard>/escape)"); Plugin.Logger.LogInfo((object)("ConfigurationHandler: Config Menu Key: " + ConfigMenuKey.Value)); SetupInputAction(); ConfigMenuKey.SettingChanged += OnMenuKeyChanged; Plugin.Logger.LogInfo((object)"ConfigurationHandler initialised"); } private void OnBalanceCooldownChanged(object sender, EventArgs e) { DiscplacementComponent.CooldownDuration = Cooldown; Plugin.Logger.LogInfo((object)("Set the Cooldown to " + Cooldown + "!")); } private void OnFrisbeeParticleEffectEnabledChanged(object sender, EventArgs e) { Plugin.Logger.LogInfo((object)("Set the Particles Enabled to " + IsFrisbeeParticleEffectEnabled + "!")); } private void OnBalanceCooldownEnabledChanged(object sender, EventArgs e) { if (ConfigBalanceCooldownEnabled.Value) { DiscplacementComponent._totalUses = 100; ConfigBalanceUsesCapped.Value = false; } Plugin.Logger.LogInfo((object)("Set Cooldown Enabled to " + IsBalanceCooldownEnabled + "!")); } private void OnBalanceUsesChanged(object sender, EventArgs e) { if (IsUsesCapped) { DiscplacementComponent._totalUses = Uses; } Plugin.Logger.LogInfo((object)("Set the Uses to " + Uses + "!")); } private void OnBalanceUsesCappedChanged(object sender, EventArgs e) { if (ConfigBalanceUsesCapped.Value) { DiscplacementComponent._totalUses = Uses; ConfigBalanceCooldownEnabled.Value = false; } Plugin.Logger.LogInfo((object)("Set the Uses Cap Enabled to " + IsUsesCapped + "!")); } private void OnFrisbeeReturnChanged(object sender, EventArgs e) { Plugin.Logger.LogInfo((object)("Set the Uses Cap Enabled to " + IsFrisbeeReturnEnabled + "!")); } private void OnMenuKeyChanged(object sender, EventArgs e) { SetupInputAction(); } private void SetupInputAction() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) InputAction menuAction = MenuAction; if (menuAction != null) { menuAction.Dispose(); } MenuAction = new InputAction((string)null, (InputActionType)1, (string)null, (string)null, (string)null, (string)null); InputActionSetupExtensions.AddBinding(MenuAction, ConfigMenuKey.Value, (string)null, (string)null, (string)null); MenuAction.Enable(); } } public class DiscplacementComponent : MonoBehaviour { public Action_ReduceUses reduceUses; private static Dictionary<Guid, float> _cooldowns = new Dictionary<Guid, float>(); private int totalUsesLastFrame; private Item item; private ItemParticles particles; private bool wasOnCappedMode; public bool HasTeleported { get; set; } = false; public static float CooldownDuration { get; set; } = 8f; public static int _totalUses { get; set; } = 100; public static ParticleSystem fireParticles { get; set; } public void Awake() { //IL_002c: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) wasOnCappedMode = Plugin.ConfigurationHandler.IsUsesCapped; GameObject val = Resources.Load<GameObject>("0_Items/Lantern"); GameObject val2 = Object.Instantiate<GameObject>(val, new Vector3(0f, 0f, 0f), Quaternion.Euler(0f, Random.Range(0f, 360f), 0f)); Item component = val2.GetComponent<Item>(); Lantern component2 = ((Component)component).GetComponent<Lantern>(); Transform transform = ((Component)component2).transform; transform.position = ((Component)component2).transform.position + new Vector3(0f, -5000f, 0f); if ((Object)(object)component2 != (Object)null && (Object)(object)component2.fireParticle != (Object)null) { ParticleSystem val3 = Object.Instantiate<ParticleSystem>(component2.fireParticle, transform); ((Component)val3).transform.localPosition = Vector3.zero; ((Component)val3).transform.localScale = Vector3.one; MainModule main = val3.main; ((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.3f, 1f, 1f)); ((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.3f, 0.6f); ((MainModule)(ref main)).simulationSpeed = 0.2f; ColorOverLifetimeModule colorOverLifetime = val3.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val4 = new Gradient(); val4.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(new Color(1f, 0.4f, 1f), 0f), new GradientColorKey(new Color(0.6f, 0f, 0.8f), 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(0.3f, 0f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val4); ParticleSystemRenderer component3 = ((Component)val3).GetComponent<ParticleSystemRenderer>(); if ((Object)(object)component3 != (Object)null && (Object)(object)((Renderer)component3).material != (Object)null) { ((Renderer)component3).material.color = new Color(1f, 0.4f, 1f, 1f); } ShapeModule shape = val3.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4; ((ShapeModule)(ref shape)).angle = 5f; ((ShapeModule)(ref shape)).radius = 0.08f; ((ShapeModule)(ref shape)).rotation = new Vector3(0f, 0f, 0f); ((ShapeModule)(ref shape)).position = new Vector3(0f, 0.01f, 0f); VelocityOverLifetimeModule velocityOverLifetime = val3.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(-0.025f, 0.025f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(-0.025f, 0.025f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.1f, 0.25f); fireParticles = val3; } if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)((Component)component).gameObject); } particles = ((Component)this).gameObject.GetComponent<ItemParticles>(); } public void Init(Item item) { reduceUses = ((Component)this).gameObject.AddComponent<Action_ReduceUses>(); ((ItemActionBase)reduceUses).item = item; reduceUses.consumeOnFullyUsed = false; if (Plugin.ConfigurationHandler.IsUsesCapped) { _totalUses = Plugin.ConfigurationHandler.Uses; } totalUsesLastFrame = _totalUses; this.item = item; this.item.totalUses = _totalUses; CooldownDuration = Plugin.ConfigurationHandler.Cooldown; } public void Update() { item.totalUses = _totalUses; OptionableIntItemData data = item.GetData<OptionableIntItemData>((DataEntryKey)2); bool isUsesCapped = Plugin.ConfigurationHandler.IsUsesCapped; if (totalUsesLastFrame != _totalUses && isUsesCapped) { Plugin.Logger.LogInfo((object)("1 now: " + _totalUses + " prev: " + totalUsesLastFrame)); data.Value = Math.Max(0, data.Value - totalUsesLastFrame + _totalUses); item.SetUseRemainingPercentage((float)data.Value / (float)item.totalUses); Plugin.Logger.LogInfo((object)("Adding the extra use. Total uses: " + _totalUses + " Actual uses: " + data.Value)); totalUsesLastFrame = _totalUses; } float value = item.GetData<FloatItemData>((DataEntryKey)11).Value; if (!wasOnCappedMode && isUsesCapped && data.HasData) { data.Value = Plugin.ConfigurationHandler.Uses; Plugin.Logger.LogInfo((object)("Switched to Capped Mode, changing the uses to: " + data.Value)); } wasOnCappedMode = isUsesCapped; if (Plugin.ConfigurationHandler.IsUsesCapped) { if (!particles.smoke.isPlaying && value > 0f) { particles.smoke.Play(); } else if (particles.smoke.isPlaying && value == 0f) { particles.smoke.Stop(); } } if (Plugin.ConfigurationHandler.IsBalanceCooldownEnabled) { Guid guid = item.data.guid; if (IsOnCooldown(guid)) { float useRemainingPercentage = 1f - CooldownTimeRemaining(guid) / CooldownDuration; item.SetUseRemainingPercentage(useRemainingPercentage); } else if (value < 1f) { item.SetUseRemainingPercentage(1f); } if (!particles.smoke.isPlaying && (double)value > 0.9) { particles.smoke.Play(); } else if (particles.smoke.isPlaying && (double)value < 0.9) { particles.smoke.Stop(); } } if (!Plugin.ConfigurationHandler.IsFrisbeeParticleEffectEnabled) { particles.smoke.Stop(); } } public void ActivateCooldown(Item item) { float value = Time.time + CooldownDuration; if (!_cooldowns.TryAdd(item.data.guid, value)) { _cooldowns[item.data.guid] = value; } item.SetUseRemainingPercentage(0f); Plugin.Logger.LogInfo((object)("Cooldown started at " + Time.time)); } public bool IsOnCooldown(Guid guid) { if (_cooldowns.TryGetValue(guid, out var value)) { return Time.time < value; } return false; } public float CooldownTimeRemaining(Guid guid) { if (_cooldowns.TryGetValue(guid, out var value)) { return Mathf.Max(0f, value - Time.time); } return 0f; } } public class ModConfigurationUI : MonoBehaviour { private List<Option> _options; private bool _visible; private int _selectedIndex; private bool _prevCursorVisible; private CursorLockMode _prevCursorLock; private bool _waitingForBinding = false; private Option _bindingTarget; private Texture2D _whiteTex; private GUIStyle _titleStyle; private GUIStyle _rowStyle; private GUIStyle _hintStyle; private string titleText = "Discplacement Settings"; private string hintText = "F2: Open/Close • Tab or ↑/↓: Move • Enter/Click: Change • Scroll Wheel or ←/→ Arrows: Adjust Numerical Values • +/-: Scale Menu"; private int RowHeight = 32; private int PanelWidth = 460; private int Pad = 12; private int TitleFontSize = 22; private int OptionFontSize = 16; private int HintFontSize = 14; private void CalculatePanelWidth() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) float num = _titleStyle.CalcSize(new GUIContent(titleText)).x; foreach (Option option in _options) { float x = _rowStyle.CalcSize(new GUIContent(option.Label + ": " + option.DisplayValue())).x; if (x > num) { num = x; } } int num2 = CalculateHintWidth(); num = Mathf.Max(num, (float)num2); PanelWidth = Mathf.Clamp((int)num + Pad * 2, 460, Screen.width - Pad * 2); } private int CalculateHintWidth() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown float num = _hintStyle.CalcHeight(new GUIContent("Test"), 9999f); float num2 = num * 2f; for (int i = 200; i < Screen.width - Pad * 2; i += 20) { float num3 = _hintStyle.CalcHeight(new GUIContent(hintText), (float)i); if (num3 <= num2) { return i; } } return Screen.width - Pad * 2; } private void Scale(int scale) { if (scale >= 0 || HintFontSize >= 2) { TitleFontSize += scale * 2; OptionFontSize += scale * 2; HintFontSize += scale * 2; RowHeight = OptionFontSize + 16; CalculatePanelWidth(); } } public void Init(List<Option> options) { _options = options ?? new List<Option>(); _selectedIndex = 0; hintText = Plugin.ConfigurationHandler.ConfigMenuKey.Value.Split("/")[^1].ToUpper() + ": Open/Close • Tab or ↑/↓: Move • Enter/Click: Change • Scroll Wheel or ←/→ Arrows: Adjust Numerical Values • +/-: Scale Menu"; } private void EnsureStyles() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0071: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00ad: Expected O, but got Unknown //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_00ca: 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_00df: Expected O, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_whiteTex == (Object)null) { _whiteTex = new Texture2D(1, 1); _whiteTex.SetPixel(0, 0, Color.white); _whiteTex.Apply(); } _titleStyle = new GUIStyle(GUI.skin.label) { fontSize = TitleFontSize, alignment = (TextAnchor)3, fontStyle = (FontStyle)1 }; _rowStyle = new GUIStyle(GUI.skin.button) { alignment = (TextAnchor)3, fontSize = OptionFontSize, padding = new RectOffset(10, 10, 4, 4) }; _hintStyle = new GUIStyle(GUI.skin.label) { fontSize = HintFontSize, alignment = (TextAnchor)3, wordWrap = true }; } private void Update() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Invalid comparison between Unknown and I4 if (_waitingForBinding && ((ButtonControl)Keyboard.current.anyKey).wasPressedThisFrame) { Enumerator<KeyControl> enumerator = Keyboard.current.allKeys.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyControl current = enumerator.Current; if (((ButtonControl)current).wasPressedThisFrame) { string path = ((InputControl)current).path; _bindingTarget.StringEntry.Value = path; Plugin.Logger.LogInfo((object)("Rebound " + _bindingTarget.Label + " to " + path)); _waitingForBinding = false; hintText = _bindingTarget.DisplayValue() + ": Open/Close • Tab or ↑/↓: Move • Enter/Click: Change • Scroll Wheel or ←/→ Arrows: Adjust Numerical Values • +/-: Scale Menu"; _bindingTarget = null; break; } } return; } finally { ((IDisposable)enumerator).Dispose(); } } if (Plugin.ConfigurationHandler.MenuAction != null && Plugin.ConfigurationHandler.MenuAction.WasPerformedThisFrame() && (PhotonNetwork.IsMasterClient || (int)GameHandler.GetService<RichPresenceService>().m_currentState == 0)) { _visible = !_visible; if (_visible) { OnOpened(); } else { OnClosed(); } } if (_visible && _options.Count != 0) { if (Input.GetKeyDown((KeyCode)9)) { bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); CycleSelection((!flag) ? 1 : (-1)); } if (Input.GetKeyDown((KeyCode)61) || Input.GetKeyDown((KeyCode)43)) { Scale(1); } if (Input.GetKeyDown((KeyCode)45)) { Scale(-1); } if (Input.GetKeyDown((KeyCode)273)) { CycleSelection(-1); } if (Input.GetKeyDown((KeyCode)274)) { CycleSelection(1); } if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)) { ToggleSelected(); } if (Input.GetKeyDown((KeyCode)276)) { AdjustInt(-1); } if (Input.GetKeyDown((KeyCode)275)) { AdjustInt(1); } float axis = Input.GetAxis("Mouse ScrollWheel"); if (axis > 0f) { AdjustInt(1); } else if (axis < 0f) { AdjustInt(-1); } } } private void ToggleSelected() { Option option = _options[_selectedIndex]; if (option.IsDisabled()) { return; } switch (option.Type) { case Option.OptionType.Bool: option.BoolEntry.Value = !option.BoolEntry.Value; break; case Option.OptionType.Int: { int num = option.IntEntry.Value + option.Step; if (num > option.MaxInt) { num = option.MinInt; } option.IntEntry.Value = num; break; } case Option.OptionType.InputAction: _waitingForBinding = true; _bindingTarget = option; break; case Option.OptionType.String: break; } } private void AdjustInt(int delta) { Option option = _options[_selectedIndex]; if (!option.IsDisabled() && option.Type == Option.OptionType.Int) { int value = Mathf.Clamp(option.IntEntry.Value + delta * option.Step, option.MinInt, option.MaxInt); option.IntEntry.Value = value; } } private void OnOpened() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) _prevCursorVisible = Cursor.visible; _prevCursorLock = Cursor.lockState; Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; if (_options.Count > 0 && _options[_selectedIndex].IsDisabled()) { CycleSelection(1); } } private void OnClosed() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) Cursor.visible = _prevCursorVisible; Cursor.lockState = _prevCursorLock; } private void CycleSelection(int delta) { if (_options.Count == 0) { return; } int selectedIndex = _selectedIndex; do { _selectedIndex = (_selectedIndex + delta) % _options.Count; if (_selectedIndex < 0) { _selectedIndex += _options.Count; } } while (_options[_selectedIndex].IsDisabled() && _selectedIndex != selectedIndex); } private void OnGUI() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) if (!_visible) { return; } EnsureStyles(); CalculatePanelWidth(); float num = _titleStyle.CalcHeight(new GUIContent(titleText), (float)(PanelWidth - Pad * 2)); float num2 = _options.Count * (RowHeight + 4); float num3 = _hintStyle.CalcHeight(new GUIContent("Test"), 9999f); float num4 = num3 * 2f; int num5 = Pad + (int)num + 8 + (int)num2 + Pad + (int)num4; Rect val = default(Rect); ((Rect)(ref val))..ctor(20f, 20f, (float)PanelWidth, (float)num5); GUI.color = new Color(0f, 0f, 0f, 0.75f); GUI.DrawTexture(val, (Texture)(object)_whiteTex); GUI.color = Color.white; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref val)).x + (float)Pad, ((Rect)(ref val)).y + (float)Pad, ((Rect)(ref val)).width - (float)(Pad * 2), num); GUI.Label(val2, titleText, _titleStyle); float num6 = ((Rect)(ref val2)).yMax + 8f; Rect val3 = default(Rect); for (int i = 0; i < _options.Count; i++) { ((Rect)(ref val3))..ctor(((Rect)(ref val)).x + (float)Pad, num6, ((Rect)(ref val)).width - (float)(Pad * 2), (float)RowHeight); Option option = _options[i]; if (((Rect)(ref val3)).Contains(Event.current.mousePosition) && !option.IsDisabled()) { _selectedIndex = i; } if ((i == _selectedIndex && !option.IsDisabled()) || !(option.Label == "Menu Key") || !_waitingForBinding) { GUI.color = new Color(1f, 1f, 1f, 0.24f); GUI.DrawTexture(val3, (Texture)(object)_whiteTex); GUI.color = Color.white; } GUI.enabled = !option.IsDisabled(); if (option.Label == "Menu Key" && _waitingForBinding) { GUI.color = new Color(0f, 0f, 0f, 0.6f); GUI.DrawTexture(val3, (Texture)(object)_whiteTex); GUI.color = Color.white; GUI.Button(val3, "Press any key...", _rowStyle); } else if (GUI.Button(val3, option.Label + ": " + option.DisplayValue(), _rowStyle) && !option.IsDisabled()) { ToggleSelected(); } GUI.enabled = true; num6 += (float)(RowHeight + 4); } Rect val4 = default(Rect); ((Rect)(ref val4))..ctor(((Rect)(ref val)).x + (float)Pad, ((Rect)(ref val)).yMax - (float)Pad - num4, ((Rect)(ref val)).width - (float)(Pad * 2), num4); GUI.Label(val4, hintText, _hintStyle); GUI.Label(val4, hintText, _hintStyle); } private void OnDestroy() { if ((Object)(object)_whiteTex != (Object)null) { Object.Destroy((Object)(object)_whiteTex); _whiteTex = null; } } } public class Option { public enum OptionType { Bool, Int, String, InputAction } public string Label { get; set; } public OptionType Type { get; set; } public ConfigEntry<bool> BoolEntry { get; set; } public ConfigEntry<int> IntEntry { get; set; } public ConfigEntry<string> StringEntry { get; set; } public int MinInt { get; set; } public int MaxInt { get; set; } public int Step { get; set; } public Func<bool> IsDisabled { get; set; } = () => false; public Func<string> DisplayValue { get; set; } = () => ""; private Option(string label, OptionType type) { Label = label; Type = type; } public static Option Bool(string label, ConfigEntry<bool> entry, Func<bool>? isDisabled = null) { ConfigEntry<bool> entry2 = entry; return new Option(label, OptionType.Bool) { BoolEntry = entry2, IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))), DisplayValue = () => entry2.Value ? "ON" : "OFF" }; } public static Option InputAction(string label, ConfigEntry<string> entry, Func<bool>? isDisabled = null) { ConfigEntry<string> entry2 = entry; return new Option(label, OptionType.InputAction) { StringEntry = entry2, IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))), DisplayValue = delegate { string[] array = entry2.Value.Split("/"); return (array.Length > 1) ? array[^1].ToUpper() : entry2.Value; } }; } public static Option Int(string label, ConfigEntry<int> entry, int min, int max, int step = 1, Func<bool>? isDisabled = null) { ConfigEntry<int> entry2 = entry; return new Option(label, OptionType.Int) { IntEntry = entry2, MinInt = min, MaxInt = max, Step = step, IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))), DisplayValue = () => entry2.Value.ToString() }; } } [BepInPlugin("Discplacement", "Discplacement", "0.1.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("Discplacement"); private ModConfigurationUI _ui; public const string Id = "Discplacement"; internal static ManualLogSource Logger { get; private set; } public static ConfigurationHandler ConfigurationHandler { get; private set; } public static string Name => "Discplacement"; public static string Version => "0.1.0"; private void Awake() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)("Plugin " + Name + " is loaded!")); ConfigurationHandler = new ConfigurationHandler(); _harmony.PatchAll(typeof(FrisbeeOnCollisionEnterPatch)); Logger.LogInfo((object)"OnCollisionEnter Patch Loaded!"); _harmony.PatchAll(typeof(FrisbeeOnEnablePatch)); Logger.LogInfo((object)"OnEnablePatch Patch Loaded!"); GameObject val = new GameObject("PEAKUnlimitedUI"); Object.DontDestroyOnLoad((Object)(object)val); _ui = val.AddComponent<ModConfigurationUI>(); _ui.Init(new List<Option> { Option.Bool("Cooldown Enabled", ConfigurationHandler.ConfigBalanceCooldownEnabled), Option.Int("Cooldown", ConfigurationHandler.ConfigBalanceCooldown, 1, 30), Option.Bool("Uses Enabled", ConfigurationHandler.ConfigBalanceUsesCapped), Option.Int("Uses", ConfigurationHandler.ConfigBalanceUses, 1, 30), Option.Bool("Frisbee Return", ConfigurationHandler.ConfigFrisbeeReturn), Option.Bool("Frisbee Particles", ConfigurationHandler.ConfigFrisbeeParticleEffectEnabled), Option.InputAction("Menu Key", ConfigurationHandler.ConfigMenuKey) }); } } } namespace Discplacement.Patches { [HarmonyPatch(typeof(Frisbee), "OnCollisionEnter")] public class FrisbeeOnCollisionEnterPatch { private static void Prefix(Frisbee __instance, out bool __state) { __state = __instance.throwValidForAchievement; } private static void Postfix(Frisbee __instance, Collision collision, bool __state) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Invalid comparison between Unknown and I4 //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Invalid comparison between Unknown and I4 //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Invalid comparison between Unknown and I4 //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) if (Plugin.ConfigurationHandler.IsUsesCapped && __instance.item.GetData<FloatItemData>((DataEntryKey)11).Value == 0f) { return; } DiscplacementComponent component = ((Component)__instance).gameObject.GetComponent<DiscplacementComponent>(); if (component.IsOnCooldown(__instance.item.data.guid) || (component.HasTeleported && (int)__instance.item.itemState == 0)) { return; } if (component.HasTeleported && (int)__instance.item.itemState == 1) { component.HasTeleported = false; } else { if ((int)__instance.item.itemState == 1) { return; } Plugin.Logger.LogInfo((object)"Frisbee has collided with:"); Plugin.Logger.LogInfo((object)((Object)((Component)collision.transform).gameObject).name); Character lastThrownCharacter = __instance.item.lastThrownCharacter; if (__instance.item.lastThrownAmount != 0f) { Plugin.Logger.LogInfo((object)("Frisbee last character: " + ((Object)lastThrownCharacter).name)); Vector3 position = ((Component)__instance).transform.position; Vector3 point = ((ContactPoint)(ref collision.contacts[0])).point; Vector3 val = position - point; Vector3 normalized = ((Vector3)(ref val)).normalized; if (Plugin.ConfigurationHandler.IsBalanceCooldownEnabled) { Plugin.Logger.LogInfo((object)"Trying to activate cooldown"); component.ActivateCooldown(__instance.item); Plugin.Logger.LogInfo((object)("Cooldown time remaining " + component.CooldownTimeRemaining(__instance.item.data.guid))); } if (Plugin.ConfigurationHandler.IsUsesCapped) { Plugin.Logger.LogInfo((object)"Trying to reduce uses"); ((ItemActionBase)component.reduceUses).RunAction(); Plugin.Logger.LogInfo((object)"Trying to reduce uses 2"); } component.HasTeleported = true; if (Plugin.ConfigurationHandler.IsFrisbeeReturnEnabled) { lastThrownCharacter.refs.items.lastEquippedSlotTime = -0.25f; __instance.item.Interact(lastThrownCharacter); } lastThrownCharacter.view.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { position + normalized * 0.7f, true }); } } } } public class FrisbeeOnEnablePatch { [HarmonyPatch(typeof(Frisbee), "OnEnable")] [HarmonyPostfix] private static void Postfix(Frisbee __instance) { DiscplacementComponent discplacementComponent = ((Component)__instance).gameObject.AddComponent<DiscplacementComponent>(); discplacementComponent.Init(__instance.item); ItemParticles component = ((Component)__instance).gameObject.GetComponent<ItemParticles>(); if ((Object)(object)DiscplacementComponent.fireParticles != (Object)null && (Object)(object)component != (Object)null) { ParticleSystem smoke = Object.Instantiate<ParticleSystem>(DiscplacementComponent.fireParticles, ((Component)__instance).transform); component.smoke = smoke; component.smoke.Clear(); component.smoke.Play(); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }