Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of EVOS OFFICAL MODPACK v1.1.2
BepInEx/Plugins/MikesTweaks.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using MikesTweaks.Scripts.Input; using MikesTweaks.Scripts.Inventory; using MikesTweaks.Scripts.Networking; using MikesTweaks.Scripts.Player; using MikesTweaks.Scripts.World; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Utilities; using UnityEngine.UI; [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("MikesTweaks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("The tweaks")] [assembly: AssemblyFileVersion("1.4.2.0")] [assembly: AssemblyInformationalVersion("1.4.2")] [assembly: AssemblyProduct("MikesTweaks")] [assembly: AssemblyTitle("MikesTweaks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.2.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MikesTweaks { public static class PluginInfo { public const string PLUGIN_GUID = "MikesTweaks"; public const string PLUGIN_NAME = "MikesTweaks"; public const string PLUGIN_VERSION = "1.4.2"; } } namespace MikesTweaks.Scripts { public class ConfigEntrySettings<T> { private readonly T VanillaValue; private readonly string ExtraDescription; public Type type => typeof(T); public T Value => Entry.Value; public T DefaultValue { get; private set; } public string ConfigName { get; private set; } public string ConfigDesc => $"{ExtraDescription}\nVanilla Default: {VanillaValue}"; public ConfigEntry<T> Entry { get; set; } public ConfigEntrySettings(string name, T defaultValue, T vanillaValue, string extraDescription = "") { ConfigName = name; DefaultValue = defaultValue; VanillaValue = vanillaValue; ExtraDescription = extraDescription; } } [BepInPlugin("mikes.lethalcompany.mikestweaks", "Mike's Tweaks", "1.4.2")] public class MikesTweaks : BaseUnityPlugin { public const string GUID = "mikes.lethalcompany.mikestweaks"; public const string Name = "Mike's Tweaks"; public const string Version = "1.4.2"; public static ManualLogSource Log; public static MikesTweaks Instance { get; private set; } public void BindConfig<T>(ref ConfigEntrySettings<T> config, string SectionName) { config.Entry = ((BaseUnityPlugin)this).Config.Bind<T>(SectionName, config.ConfigName, config.DefaultValue, config.ConfigDesc); } public void LoadConfigs() { ((BaseUnityPlugin)this).Config.Reload(); } private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; InventoryTweaks.RegisterConfigs(((BaseUnityPlugin)this).Config); PlayerTweaks.RegisterConfigs(((BaseUnityPlugin)this).Config); WorldTweaks.RegisterConfigs(((BaseUnityPlugin)this).Config); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; Harmony.CreateAndPatchAll(typeof(NetworkManager_Patches), (string)null); Harmony.CreateAndPatchAll(typeof(ConfigsRelated_Patches), (string)null); Harmony.CreateAndPatchAll(typeof(PlayerTweaks), (string)null); Harmony.CreateAndPatchAll(typeof(PlayerControllerB_Patches), (string)null); Harmony.CreateAndPatchAll(typeof(InventoryTweaks), (string)null); Harmony.CreateAndPatchAll(typeof(WorldTweaks), (string)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin mikes.lethalcompany.mikestweaks is loaded!"); } } } namespace MikesTweaks.Scripts.World { public class WorldTweaks { private class Configs { public static ConfigEntrySettings<float> GlobalTimeSpeedMulti = new ConfigEntrySettings<float>("GlobalTimeSpeedMultiplier", 0.5f, 1f); public static string WorldTweaksSectionHeader => "WorldTweaks"; } public static void RegisterConfigs(ConfigFile config) { MikesTweaks.Instance.BindConfig(ref Configs.GlobalTimeSpeedMulti, Configs.WorldTweaksSectionHeader); ConfigsSynchronizer.OnConfigsChangedDelegate = (Action)Delegate.Combine(ConfigsSynchronizer.OnConfigsChangedDelegate, (Action)delegate { ReapplyConfigs(TimeOfDay.Instance); }); ConfigsSynchronizer.Instance.AddConfigGetter(WriteConfigsToWriter); ConfigsSynchronizer.Instance.AddConfigSetter(ReadConfigChanges); ConfigsSynchronizer.Instance.AddConfigSizeGetter(() => 4); } public static FastBufferWriter WriteConfigsToWriter(FastBufferWriter writer) { //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_001d: Unknown result type (might be due to invalid IL or missing references) float value = Configs.GlobalTimeSpeedMulti.Value; ((FastBufferWriter)(ref writer)).WriteValueSafe<float>(ref value, default(ForPrimitives)); return writer; } public static FastBufferReader ReadConfigChanges(FastBufferReader payload) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) float value = default(float); ((FastBufferReader)(ref payload)).ReadValue<float>(ref value, default(ForPrimitives)); Configs.GlobalTimeSpeedMulti.Entry.Value = value; return payload; } public static void ReapplyConfigs(TimeOfDay timeOfDay) { timeOfDay.globalTimeSpeedMultiplier = Configs.GlobalTimeSpeedMulti.Value; } [HarmonyPatch(typeof(TimeOfDay), "Start")] [HarmonyPostfix] private static void ChangeTimeSpeedMultiplier(TimeOfDay __instance) { ReapplyConfigs(__instance); } } } namespace MikesTweaks.Scripts.Player { public class PlayerTweaks { public static class Configs { public static ConfigEntrySettings<float> SprintLongevity = new ConfigEntrySettings<float>("SprintLongevity", 12f, 5f); public static ConfigEntrySettings<float> DefaultSprintMultiplier = new ConfigEntrySettings<float>("DefaultSprintMultiplier", 1.5f, 1f); public static ConfigEntrySettings<float> SprintMultiplierIncrease = new ConfigEntrySettings<float>("SprintMultiplierIncrease", 1f, 1f); public static ConfigEntrySettings<float> SprintMultiplierDecrease = new ConfigEntrySettings<float>("SprintMultiplierDecrease", 10f, 10f); public static ConfigEntrySettings<float> MaxSprintMultiplier = new ConfigEntrySettings<float>("MaxSprintMultiplier", 3f, 2.25f); public static ConfigEntrySettings<float> JumpStaminaDrain = new ConfigEntrySettings<float>("JumpStaminaDrain", 0.04f, 0.08f); public static ConfigEntrySettings<string>[] SlotKeybinds = new ConfigEntrySettings<string>[9] { new ConfigEntrySettings<string>("Slot1", "<Keyboard>/1", ""), new ConfigEntrySettings<string>("Slot2", "<Keyboard>/2", ""), new ConfigEntrySettings<string>("Slot3", "<Keyboard>/3", ""), new ConfigEntrySettings<string>("Slot4", "<Keyboard>/4", ""), new ConfigEntrySettings<string>("Slot5", "<Keyboard>/5", ""), new ConfigEntrySettings<string>("Slot6", "<Keyboard>/6", ""), new ConfigEntrySettings<string>("Slot7", "<Keyboard>/7", ""), new ConfigEntrySettings<string>("Slot8", "<Keyboard>/8", ""), new ConfigEntrySettings<string>("Slot9", "<Keyboard>/9", "") }; public static ConfigEntrySettings<string>[] EmoteKeybinds = new ConfigEntrySettings<string>[2] { new ConfigEntrySettings<string>("Emote1", "<Keyboard>/y", "<Keyboard>/1"), new ConfigEntrySettings<string>("Emote2", "<Keyboard>/u", "<Keyboard>/2") }; public static string PlayerTweaksSectionHeader => "PlayerTweaks"; public static string KeybindsSectionHeader => "Keybinds"; } [CompilerGenerated] private static class <>O { public static Func<FastBufferWriter, FastBufferWriter> <0>__WriteConfigsToWriter; public static Func<FastBufferReader, FastBufferReader> <1>__ReadConfigChanges; public static HandleNamedMessageDelegate <2>__ReceiveSwitchSlot; public static HandleNamedMessageDelegate <3>__ReceiveSwitchSlotRequest; } public static PlayerControllerB LocalPlayerController; public static string PlayerSwitchSlotChannel => "PlayerChangeSlot"; public static string PlayerSwitchSlotRequestChannel => "PlayerChangeSlotRequest"; public static void RegisterConfigs(ConfigFile config) { MikesTweaks.Instance.BindConfig(ref Configs.SprintLongevity, Configs.PlayerTweaksSectionHeader); MikesTweaks.Instance.BindConfig(ref Configs.DefaultSprintMultiplier, Configs.PlayerTweaksSectionHeader); MikesTweaks.Instance.BindConfig(ref Configs.SprintMultiplierIncrease, Configs.PlayerTweaksSectionHeader); MikesTweaks.Instance.BindConfig(ref Configs.SprintMultiplierDecrease, Configs.PlayerTweaksSectionHeader); MikesTweaks.Instance.BindConfig(ref Configs.MaxSprintMultiplier, Configs.PlayerTweaksSectionHeader); MikesTweaks.Instance.BindConfig(ref Configs.JumpStaminaDrain, Configs.PlayerTweaksSectionHeader); for (int i = 0; i < Configs.SlotKeybinds.Length; i++) { MikesTweaks.Instance.BindConfig(ref Configs.SlotKeybinds[i], Configs.KeybindsSectionHeader); } for (int j = 0; j < Configs.EmoteKeybinds.Length; j++) { MikesTweaks.Instance.BindConfig(ref Configs.EmoteKeybinds[j], Configs.KeybindsSectionHeader); } ConfigsSynchronizer.OnConfigsChangedDelegate = (Action)Delegate.Combine(ConfigsSynchronizer.OnConfigsChangedDelegate, (Action)delegate { ReapplyConfigs(LocalPlayerController, force: true, updateHud: true); }); ConfigsSynchronizer.Instance.AddConfigGetter(WriteConfigsToWriter); ConfigsSynchronizer.Instance.AddConfigSetter(ReadConfigChanges); ConfigsSynchronizer.Instance.AddConfigSizeGetter(() => 24); } public static bool IsLocallyControlled(PlayerControllerB player) { return player.playerUsername == GameNetworkManager.Instance.username; } public static bool CanSwitchSlot(PlayerControllerB player) { Type typeFromHandle = typeof(PlayerControllerB); bool flag = (bool)typeFromHandle.GetField("throwingObject", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(player); float num = (float)typeFromHandle.GetField("timeSinceSwitchingSlots", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(player); if (((!((NetworkBehaviour)player).IsOwner || !player.isPlayerControlled || (((NetworkBehaviour)player).IsServer && !player.isHostPlayerObject)) && !player.isTestingPlayer) || num < 0.3f || player.isGrabbingObjectAnimation || player.inSpecialInteractAnimation || flag || player.isTypingChat || player.twoHanded || player.activatingItem || player.jetpackControls || player.disablingJetpackControls) { return false; } return true; } public static FastBufferWriter WriteConfigsToWriter(FastBufferWriter writer) { //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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_008b: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) float value = Configs.SprintLongevity.Value; ((FastBufferWriter)(ref writer)).WriteValueSafe<float>(ref value, default(ForPrimitives)); value = Configs.DefaultSprintMultiplier.Value; ((FastBufferWriter)(ref writer)).WriteValueSafe<float>(ref value, default(ForPrimitives)); value = Configs.SprintMultiplierIncrease.Value; ((FastBufferWriter)(ref writer)).WriteValueSafe<float>(ref value, default(ForPrimitives)); value = Configs.SprintMultiplierDecrease.Value; ((FastBufferWriter)(ref writer)).WriteValueSafe<float>(ref value, default(ForPrimitives)); value = Configs.MaxSprintMultiplier.Value; ((FastBufferWriter)(ref writer)).WriteValueSafe<float>(ref value, default(ForPrimitives)); value = Configs.JumpStaminaDrain.Value; ((FastBufferWriter)(ref writer)).WriteValueSafe<float>(ref value, default(ForPrimitives)); return writer; } public static FastBufferReader ReadConfigChanges(FastBufferReader payload) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_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) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00cc: Unknown result type (might be due to invalid IL or missing references) float value = default(float); ((FastBufferReader)(ref payload)).ReadValue<float>(ref value, default(ForPrimitives)); Configs.SprintLongevity.Entry.Value = value; ((FastBufferReader)(ref payload)).ReadValue<float>(ref value, default(ForPrimitives)); Configs.DefaultSprintMultiplier.Entry.Value = value; ((FastBufferReader)(ref payload)).ReadValue<float>(ref value, default(ForPrimitives)); Configs.SprintMultiplierIncrease.Entry.Value = value; ((FastBufferReader)(ref payload)).ReadValue<float>(ref value, default(ForPrimitives)); Configs.SprintMultiplierDecrease.Entry.Value = value; ((FastBufferReader)(ref payload)).ReadValue<float>(ref value, default(ForPrimitives)); Configs.MaxSprintMultiplier.Entry.Value = value; ((FastBufferReader)(ref payload)).ReadValue<float>(ref value, default(ForPrimitives)); Configs.JumpStaminaDrain.Entry.Value = value; return payload; } public static void ReapplyConfigs(PlayerControllerB player, bool force = false, bool updateHud = false) { player.sprintTime = Configs.SprintLongevity.Value; InventoryTweaks.ChangeItemSlotsAmount(player, force); if (updateHud) { InventoryTweaks.ChangeItemSlotsAmountUI(HUDManager.Instance); } } public static void RegisterSwitchSlotMessage() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; string playerSwitchSlotChannel = PlayerSwitchSlotChannel; object obj = <>O.<2>__ReceiveSwitchSlot; if (obj == null) { HandleNamedMessageDelegate val = ReceiveSwitchSlot; <>O.<2>__ReceiveSwitchSlot = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler(playerSwitchSlotChannel, (HandleNamedMessageDelegate)obj); CustomMessagingManager customMessagingManager2 = NetworkManager.Singleton.CustomMessagingManager; string playerSwitchSlotRequestChannel = PlayerSwitchSlotRequestChannel; object obj2 = <>O.<3>__ReceiveSwitchSlotRequest; if (obj2 == null) { HandleNamedMessageDelegate val2 = ReceiveSwitchSlotRequest; <>O.<3>__ReceiveSwitchSlotRequest = val2; obj2 = (object)val2; } customMessagingManager2.RegisterNamedMessageHandler(playerSwitchSlotRequestChannel, (HandleNamedMessageDelegate)obj2); } public static void SwitchSlot_Server(int slot, ulong clientIDOfChagedSlot) { //IL_0028: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsServer) { CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(12, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref slot, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref clientIDOfChagedSlot, default(ForPrimitives)); customMessagingManager.SendNamedMessageToAll(PlayerSwitchSlotChannel, val, (NetworkDelivery)2); } } public static void ReceiveSwitchSlotRequest(ulong senderID, FastBufferReader payload) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsServer) { int slot = default(int); ((FastBufferReader)(ref payload)).ReadValueSafe<int>(ref slot, default(ForPrimitives)); SwitchSlot_Server(slot, senderID); } } public static void ReceiveSwitchSlot(ulong senderID, FastBufferReader payload) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) int slot = default(int); ((FastBufferReader)(ref payload)).ReadValueSafe<int>(ref slot, default(ForPrimitives)); ulong num = default(ulong); ((FastBufferReader)(ref payload)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (val.playerClientId == num) { ((Component)val).gameObject.GetComponent<PlayerInputRedirection>().SwitchToSlot(slot); break; } } } [HarmonyPatch(typeof(IngamePlayerSettings))] [HarmonyPatch("RebindKey")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> AllowMouseBinding(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (!(val.opcode != OpCodes.Ldstr) && !((string)val.operand != "Mouse")) { list.RemoveAt(i + 1); list.RemoveAt(i); } } return list.AsEnumerable(); } } public class PlayerInputRedirection : MonoBehaviour, PlayerHotbarInput.IHotbarActions { private PlayerControllerB owner; private PlayerHotbarInput input; private MethodInfo SwitchToSlotMethod; public void OnHotbar1(CallbackContext context) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)((CallbackContext)(ref context)).phase == 3) { RequestSlotChange(0); } } public void OnHotbar2(CallbackContext context) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)((CallbackContext)(ref context)).phase == 3) { RequestSlotChange(1); } } public void OnHotbar3(CallbackContext context) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)((CallbackContext)(ref context)).phase == 3) { RequestSlotChange(2); } } public void OnHotbar4(CallbackContext context) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)((CallbackContext)(ref context)).phase == 3) { RequestSlotChange(3); } } public void OnHotbar5(CallbackContext context) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)((CallbackContext)(ref context)).phase == 3 && InventoryTweaks.HasEnoughSlots(4)) { RequestSlotChange(4); } } public void OnHotbar6(CallbackContext context) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)((CallbackContext)(ref context)).phase == 3 && InventoryTweaks.HasEnoughSlots(5)) { RequestSlotChange(5); } } public void OnHotbar7(CallbackContext context) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)((CallbackContext)(ref context)).phase == 3 && InventoryTweaks.HasEnoughSlots(6)) { RequestSlotChange(6); } } public void OnHotbar8(CallbackContext context) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)((CallbackContext)(ref context)).phase == 3 && InventoryTweaks.HasEnoughSlots(7)) { RequestSlotChange(7); } } public void OnHotbar9(CallbackContext context) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)((CallbackContext)(ref context)).phase == 3 && InventoryTweaks.HasEnoughSlots(8)) { RequestSlotChange(8); } } public void OnEnable() { input?.Enable(); } public void OnDisable() { input?.Disable(); } public void Destroy() { input?.Dispose(); } public void BindHotbarSlots() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0098: 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_00c7: 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_00e6: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: 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_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) owner = ((Component)this).gameObject.GetComponent<PlayerControllerB>(); input = new PlayerHotbarInput(); input.Hotbar.SetCallbacks(this); input.Enable(); BindingSyntax val = InputActionSetupExtensions.ChangeBinding(input.Hotbar.Hotbar1, 0); ((BindingSyntax)(ref val)).Erase(); InputActionSetupExtensions.AddBinding(input.Hotbar.Hotbar1, PlayerTweaks.Configs.SlotKeybinds[0].Value, (string)null, (string)null, (string)null); val = InputActionSetupExtensions.ChangeBinding(input.Hotbar.Hotbar2, 0); ((BindingSyntax)(ref val)).Erase(); InputActionSetupExtensions.AddBinding(input.Hotbar.Hotbar2, PlayerTweaks.Configs.SlotKeybinds[1].Value, (string)null, (string)null, (string)null); val = InputActionSetupExtensions.ChangeBinding(input.Hotbar.Hotbar3, 0); ((BindingSyntax)(ref val)).Erase(); InputActionSetupExtensions.AddBinding(input.Hotbar.Hotbar3, PlayerTweaks.Configs.SlotKeybinds[2].Value, (string)null, (string)null, (string)null); val = InputActionSetupExtensions.ChangeBinding(input.Hotbar.Hotbar4, 0); ((BindingSyntax)(ref val)).Erase(); InputActionSetupExtensions.AddBinding(input.Hotbar.Hotbar4, PlayerTweaks.Configs.SlotKeybinds[3].Value, (string)null, (string)null, (string)null); val = InputActionSetupExtensions.ChangeBinding(input.Hotbar.Hotbar5, 0); ((BindingSyntax)(ref val)).Erase(); InputActionSetupExtensions.AddBinding(input.Hotbar.Hotbar5, PlayerTweaks.Configs.SlotKeybinds[4].Value, (string)null, (string)null, (string)null); val = InputActionSetupExtensions.ChangeBinding(input.Hotbar.Hotbar6, 0); ((BindingSyntax)(ref val)).Erase(); InputActionSetupExtensions.AddBinding(input.Hotbar.Hotbar6, PlayerTweaks.Configs.SlotKeybinds[5].Value, (string)null, (string)null, (string)null); val = InputActionSetupExtensions.ChangeBinding(input.Hotbar.Hotbar7, 0); ((BindingSyntax)(ref val)).Erase(); InputActionSetupExtensions.AddBinding(input.Hotbar.Hotbar7, PlayerTweaks.Configs.SlotKeybinds[6].Value, (string)null, (string)null, (string)null); val = InputActionSetupExtensions.ChangeBinding(input.Hotbar.Hotbar8, 0); ((BindingSyntax)(ref val)).Erase(); InputActionSetupExtensions.AddBinding(input.Hotbar.Hotbar8, PlayerTweaks.Configs.SlotKeybinds[7].Value, (string)null, (string)null, (string)null); val = InputActionSetupExtensions.ChangeBinding(input.Hotbar.Hotbar9, 0); ((BindingSyntax)(ref val)).Erase(); InputActionSetupExtensions.AddBinding(input.Hotbar.Hotbar9, PlayerTweaks.Configs.SlotKeybinds[8].Value, (string)null, (string)null, (string)null); } private void Awake() { owner = ((Component)this).gameObject.GetComponent<PlayerControllerB>(); SwitchToSlotMethod = typeof(PlayerControllerB).GetMethod("SwitchToItemSlot", BindingFlags.Instance | BindingFlags.NonPublic); } private void RequestSlotChange(int slot) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (PlayerTweaks.CanSwitchSlot(owner)) { SwitchToSlot(slot); CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref slot, default(ForPrimitives)); customMessagingManager.SendNamedMessage(PlayerTweaks.PlayerSwitchSlotRequestChannel, 0uL, val, (NetworkDelivery)2); typeof(PlayerControllerB).GetField("timeSinceSwitchingSlots", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(owner, 0f); } } public void SwitchToSlot(int slot) { ShipBuildModeManager.Instance.CancelBuildMode(true); _ = owner.currentItemSlot; owner.playerBodyAnimator.SetBool("GrabValidated", false); object[] parameters = new object[2] { slot, null }; SwitchToSlotMethod.Invoke(owner, parameters); } } [HarmonyPatch(typeof(PlayerControllerB))] public static class PlayerControllerB_Patches { private static PlayerInputRedirection inputRedirection; public static void SetupKeybinds(PlayerControllerB __instance) { //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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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) if (PlayerTweaks.IsLocallyControlled(__instance)) { inputRedirection = ((Component)__instance).gameObject.GetComponent<PlayerInputRedirection>(); inputRedirection.BindHotbarSlots(); MovementActions movement = __instance.playerActions.Movement; BindingSyntax val = InputActionSetupExtensions.ChangeBinding(((MovementActions)(ref movement)).Emote1, 0); ((BindingSyntax)(ref val)).Erase(); movement = __instance.playerActions.Movement; InputActionSetupExtensions.AddBinding(((MovementActions)(ref movement)).Emote1, PlayerTweaks.Configs.EmoteKeybinds[0].Value, (string)null, (string)null, (string)null); movement = __instance.playerActions.Movement; val = InputActionSetupExtensions.ChangeBinding(((MovementActions)(ref movement)).Emote2, 0); ((BindingSyntax)(ref val)).Erase(); movement = __instance.playerActions.Movement; InputActionSetupExtensions.AddBinding(((MovementActions)(ref movement)).Emote2, PlayerTweaks.Configs.EmoteKeybinds[1].Value, (string)null, (string)null, (string)null); } } [HarmonyPatch("Update")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Update_Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown List<CodeInstruction> instructions2 = new List<CodeInstruction>(instructions); ModifySprintMultiplierValues(ref instructions2); for (int i = 0; i < instructions2.Count; i++) { CodeInstruction val = instructions2[i]; if (!(val.opcode != OpCodes.Call) && !(val.operand as MethodInfo != typeof(PlayerControllerB).GetMethod("ConnectClientToPlayerObject"))) { instructions2.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); instructions2.Insert(i + 2, CodeInstruction.Call(typeof(PlayerControllerB_Patches), "SetupKeybinds", (Type[])null, (Type[])null)); break; } } return instructions2.AsEnumerable(); } [HarmonyPatch("Jump_performed")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> ModifyJumpDrain(IEnumerable<CodeInstruction> instructions) { float num = 0.08f; List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (!(val.opcode != OpCodes.Ldc_R4) && !(Math.Abs((float)val.operand - num) > 0.01f)) { list[i] = CodeInstruction.Call(typeof(ConfigEntrySettings<float>), "get_Value", (Type[])null, (Type[])null); list.Insert(i, CodeInstruction.LoadField(typeof(PlayerTweaks.Configs), "JumpStaminaDrain", false)); break; } } return list.AsEnumerable(); } [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start(PlayerControllerB __instance) { PlayerTweaks.RegisterSwitchSlotMessage(); } [HarmonyPatch("Awake")] [HarmonyPostfix] private static void Awake(PlayerControllerB __instance) { ((Component)__instance).gameObject.AddComponent<PlayerInputRedirection>(); PlayerTweaks.ReapplyConfigs(__instance); } private static void ModifySprintMultiplierValues(ref List<CodeInstruction> instructions) { float num = 2.25f; float num2 = 1f; float num3 = 1f; float num4 = 10f; int num5 = -1; bool flag = false; bool flag2 = false; bool flag3 = false; for (int i = 0; i < instructions.Count; i++) { CodeInstruction val = instructions[i]; if (!(val.opcode != OpCodes.Ldc_R4) && !((double)Math.Abs((float)val.operand - num) > 0.1)) { num5 = i; instructions[i] = CodeInstruction.Call(typeof(ConfigEntrySettings<float>), "get_Value", (Type[])null, (Type[])null); instructions.Insert(i, CodeInstruction.LoadField(typeof(PlayerTweaks.Configs), "MaxSprintMultiplier", false)); break; } } if (num5 == -1) { return; } for (int j = num5; j < instructions.Count; j++) { CodeInstruction val2 = instructions[j]; if (val2.opcode == OpCodes.Ldc_R4) { if (flag2 && flag3 && flag) { break; } if (!flag && (double)Math.Abs((float)val2.operand - num2) < 0.1) { instructions[j] = CodeInstruction.Call(typeof(ConfigEntrySettings<float>), "get_Value", (Type[])null, (Type[])null); instructions.Insert(j, CodeInstruction.LoadField(typeof(PlayerTweaks.Configs), "SprintMultiplierIncrease", false)); flag = true; } else if (!flag2 && (double)Math.Abs((float)val2.operand - num3) < 0.1) { instructions[j] = CodeInstruction.Call(typeof(ConfigEntrySettings<float>), "get_Value", (Type[])null, (Type[])null); instructions.Insert(j, CodeInstruction.LoadField(typeof(PlayerTweaks.Configs), "DefaultSprintMultiplier", false)); flag2 = true; } else if (!flag3 && (double)Math.Abs((float)val2.operand - num4) < 0.1) { instructions[j] = CodeInstruction.Call(typeof(ConfigEntrySettings<float>), "get_Value", (Type[])null, (Type[])null); instructions.Insert(j, CodeInstruction.LoadField(typeof(PlayerTweaks.Configs), "SprintMultiplierDecrease", false)); flag3 = true; } } } } [HarmonyPatch("OnEnable")] [HarmonyPostfix] private static void OnEnable(PlayerControllerB __instance) { if (PlayerTweaks.IsLocallyControlled(__instance)) { inputRedirection?.OnEnable(); } } [HarmonyPatch("OnDisable")] [HarmonyPostfix] private static void OnDisable(PlayerControllerB __instance) { if (PlayerTweaks.IsLocallyControlled(__instance)) { inputRedirection?.OnDisable(); } } [HarmonyPatch("OnDestroy")] [HarmonyPrefix] public static void OnDestroy(PlayerControllerB __instance) { if (PlayerTweaks.IsLocallyControlled(__instance)) { inputRedirection?.Destroy(); inputRedirection = null; } } } } namespace MikesTweaks.Scripts.Networking { public class ConfigsSynchronizer { public static Action OnConfigsChangedDelegate; private static ConfigsSynchronizer _Instance; private List<Func<int>> ConfigSizeGetters = new List<Func<int>>(); private List<Func<FastBufferReader, FastBufferReader>> ConfigSetters = new List<Func<FastBufferReader, FastBufferReader>>(); private List<Func<FastBufferWriter, FastBufferWriter>> ConfigGetters = new List<Func<FastBufferWriter, FastBufferWriter>>(); public static ConfigsSynchronizer Instance { get { if (_Instance == null) { _Instance = new ConfigsSynchronizer(); } return _Instance; } } private static string SyncChannelName => "ConfigsSync"; private static string RequestChannelName => "RequestConfigsSync"; public void AddConfigSizeGetter(Func<int> SizeGetter) { ConfigSizeGetters.Add(SizeGetter); } public void AddConfigSetter(Func<FastBufferReader, FastBufferReader> Setter) { ConfigSetters.Add(Setter); } public void AddConfigGetter(Func<FastBufferWriter, FastBufferWriter> Getter) { ConfigGetters.Add(Getter); } public void RegisterMessages() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler(SyncChannelName, new HandleNamedMessageDelegate(ReceiveConfigs)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler(RequestChannelName, new HandleNamedMessageDelegate(ReceiveRequestConfigs)); } public void RequestConfigs() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(0, (Allocator)2, -1); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(RequestChannelName, 0uL, val, (NetworkDelivery)2); } public void ReceiveRequestConfigs(ulong senderID, FastBufferReader payload) { if (NetworkManager.Singleton.IsServer) { SendConfigs(senderID); } } public void ReceiveConfigs(ulong senderID, FastBufferReader payload) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsServer) { return; } foreach (Func<FastBufferReader, FastBufferReader> configSetter in ConfigSetters) { payload = configSetter(payload); } OnConfigsChangedDelegate?.Invoke(); } private ConfigsSynchronizer() { } private void SendConfigs(ulong clientID) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (clientID == NetworkManager.Singleton.LocalClientId) { return; } int num = 0; foreach (Func<int> configSizeGetter in ConfigSizeGetters) { num += configSizeGetter(); } CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(num, (Allocator)2, -1); foreach (Func<FastBufferWriter, FastBufferWriter> configGetter in ConfigGetters) { val = configGetter(val); } customMessagingManager.SendNamedMessage(SyncChannelName, clientID, val, (NetworkDelivery)2); } } [HarmonyPatch(typeof(NetworkManager))] public static class NetworkManager_Patches { [HarmonyPatch("StartHost")] [HarmonyPostfix] private static void StartHost_Post(GameNetworkManager __instance) { ConfigsSynchronizer.Instance.RegisterMessages(); } [HarmonyPatch("StartClient")] [HarmonyPostfix] private static void StartClient_Post(GameNetworkManager __instance) { ConfigsSynchronizer.Instance.RegisterMessages(); } } [HarmonyPatch(typeof(StartOfRound))] public static class ConfigsRelated_Patches { [HarmonyPatch(typeof(StartOfRound))] [HarmonyPatch("OnPlayerConnectedClientRpc")] [HarmonyPostfix] private static void OnPlayerConnectedClientRpc(StartOfRound __instance, ulong clientId, int assignedPlayerObjectId) { PlayerTweaks.LocalPlayerController = __instance.allPlayerScripts[assignedPlayerObjectId]; if (!NetworkManager.Singleton.IsServer) { ConfigsSynchronizer.Instance.RequestConfigs(); } } [HarmonyPatch(typeof(MenuManager))] [HarmonyPatch("Start")] [HarmonyPostfix] private static void MenuManager_Start(MenuManager __instance) { MikesTweaks.Instance.LoadConfigs(); } } } namespace MikesTweaks.Scripts.Inventory { public class InventoryTweaks { public static class Configs { public static ConfigEntrySettings<int> ExtraItemSlotsAmount = new ConfigEntrySettings<int>("ExtraItemSlots", 2, 0); public static ConfigEntrySettings<int>[] TerminalItemWeights = new ConfigEntrySettings<int>[12] { new ConfigEntrySettings<int>("WalkieTalkie", 0, 0), new ConfigEntrySettings<int>("Flashlight", 0, 0), new ConfigEntrySettings<int>("Shovel", 5, 18), new ConfigEntrySettings<int>("LockPicker", 2, 15), new ConfigEntrySettings<int>("ProFlashlight", 0, 5), new ConfigEntrySettings<int>("StunGrenade", 2, 5), new ConfigEntrySettings<int>("Boombox", 5, 15), new ConfigEntrySettings<int>("TZPInhalant", 0, 0), new ConfigEntrySettings<int>("ZapGun", 4, 10), new ConfigEntrySettings<int>("Jetpack", 10, 50), new ConfigEntrySettings<int>("ExtensionLadder", 0, 0), new ConfigEntrySettings<int>("RadarBooster", 5, 18) }; public static string InventoryTweaksSectionHeader => "InventoryTweaks"; public static string TerminalItemWeightsSectionHeader => "TerminalItemWeights"; } public static void RegisterConfigs(ConfigFile config) { MikesTweaks.Instance.BindConfig(ref Configs.ExtraItemSlotsAmount, Configs.InventoryTweaksSectionHeader); for (int i = 0; i < Configs.TerminalItemWeights.Length; i++) { MikesTweaks.Instance.BindConfig(ref Configs.TerminalItemWeights[i], Configs.TerminalItemWeightsSectionHeader); } ConfigsSynchronizer.OnConfigsChangedDelegate = (Action)Delegate.Combine(ConfigsSynchronizer.OnConfigsChangedDelegate, new Action(ReapplyConfigs)); ConfigsSynchronizer.Instance.AddConfigGetter(WriteConfigsToWriter); ConfigsSynchronizer.Instance.AddConfigSetter(ReadConfigChanges); ConfigsSynchronizer.Instance.AddConfigSizeGetter(() => 4); } public static FastBufferWriter WriteConfigsToWriter(FastBufferWriter writer) { //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_001d: Unknown result type (might be due to invalid IL or missing references) int value = Configs.ExtraItemSlotsAmount.Value; ((FastBufferWriter)(ref writer)).WriteValueSafe<int>(ref value, default(ForPrimitives)); return writer; } public static FastBufferReader ReadConfigChanges(FastBufferReader payload) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) int value = default(int); ((FastBufferReader)(ref payload)).ReadValue<int>(ref value, default(ForPrimitives)); Configs.ExtraItemSlotsAmount.Entry.Value = value; return payload; } public static bool HasEnoughSlots(int slotID) { return Configs.ExtraItemSlotsAmount.Value + 4 - (slotID + 1) > -1; } public static void ChangeItemSlotsAmount(PlayerControllerB __instance, bool force = false) { if (force || Configs.ExtraItemSlotsAmount.Value != 0) { __instance.ItemSlots = (GrabbableObject[])(object)new GrabbableObject[4 + Configs.ExtraItemSlotsAmount.Value]; } } public static void ReapplyConfigs() { GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { ChangeTerminalItemWeights(array[i]); } } [HarmonyPatch(typeof(HUDManager), "Awake")] [HarmonyPostfix] public static void ChangeItemSlotsAmountUI(HUDManager __instance) { //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0193: 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_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/Inventory"); List<string> list = new List<string> { "Slot0", "Slot1", "Slot2", "Slot3" }; for (int i = 0; i < val.transform.childCount; i++) { Transform child = val.transform.GetChild(i); if (!list.Contains(((Object)((Component)child).gameObject).name)) { Object.Destroy((Object)(object)((Component)child).gameObject); } } if (Configs.ExtraItemSlotsAmount.Value != 0) { Image[] array = (Image[])(object)new Image[4 + Configs.ExtraItemSlotsAmount.Value]; array[0] = HUDManager.Instance.itemSlotIconFrames[0]; array[1] = HUDManager.Instance.itemSlotIconFrames[1]; array[2] = HUDManager.Instance.itemSlotIconFrames[2]; array[3] = HUDManager.Instance.itemSlotIconFrames[3]; Image[] array2 = (Image[])(object)new Image[4 + Configs.ExtraItemSlotsAmount.Value]; array2[0] = HUDManager.Instance.itemSlotIcons[0]; array2[1] = HUDManager.Instance.itemSlotIcons[1]; array2[2] = HUDManager.Instance.itemSlotIcons[2]; array2[3] = HUDManager.Instance.itemSlotIcons[3]; GameObject val2 = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/Inventory/Slot3"); GameObject val3 = val2; for (int j = 0; j < Configs.ExtraItemSlotsAmount.Value; j++) { GameObject val4 = Object.Instantiate<GameObject>(val2); ((Object)val4).name = $"Slot{3 + (j + 1)}"; val4.transform.parent = val.transform; Vector3 localPosition = val3.transform.localPosition; val4.transform.SetLocalPositionAndRotation(new Vector3(localPosition.x + 50f, localPosition.y, localPosition.z), val3.transform.localRotation); val3 = val4; array[3 + (j + 1)] = val4.GetComponent<Image>(); array2[3 + (j + 1)] = ((Component)val4.transform.GetChild(0)).GetComponent<Image>(); } HUDManager.Instance.itemSlotIconFrames = array; HUDManager.Instance.itemSlotIcons = array2; } } [HarmonyPatch(typeof(GrabbableObject), "Start")] [HarmonyPostfix] private static void ChangeTerminalItemWeights(GrabbableObject __instance) { if (!((Object)(object)__instance == (Object)null)) { int num = Array.FindIndex(Configs.TerminalItemWeights, (ConfigEntrySettings<int> config) => config.ConfigName == ((Object)__instance.itemProperties).name); if (num != -1) { __instance.itemProperties.weight = (float)Configs.TerminalItemWeights[num].Value / 100f + 1f; } } } } } namespace MikesTweaks.Scripts.Input { public class PlayerHotbarInput : IInputActionCollection2, IInputActionCollection, IEnumerable<InputAction>, IEnumerable, IDisposable { public struct HotbarActions { private PlayerHotbarInput m_Wrapper; public InputAction Hotbar1 => m_Wrapper.m_Hotbar_Hotbar1; public InputAction Hotbar2 => m_Wrapper.m_Hotbar_Hotbar2; public InputAction Hotbar3 => m_Wrapper.m_Hotbar_Hotbar3; public InputAction Hotbar4 => m_Wrapper.m_Hotbar_Hotbar4; public InputAction Hotbar5 => m_Wrapper.m_Hotbar_Hotbar5; public InputAction Hotbar6 => m_Wrapper.m_Hotbar_Hotbar6; public InputAction Hotbar7 => m_Wrapper.m_Hotbar_Hotbar7; public InputAction Hotbar8 => m_Wrapper.m_Hotbar_Hotbar8; public InputAction Hotbar9 => m_Wrapper.m_Hotbar_Hotbar9; public bool enabled => Get().enabled; public HotbarActions(PlayerHotbarInput wrapper) { m_Wrapper = wrapper; } public InputActionMap Get() { return m_Wrapper.m_Hotbar; } public void Enable() { Get().Enable(); } public void Disable() { Get().Disable(); } public static implicit operator InputActionMap(HotbarActions set) { return set.Get(); } public void AddCallbacks(IHotbarActions instance) { if (instance != null && !m_Wrapper.m_HotbarActionsCallbackInterfaces.Contains(instance)) { m_Wrapper.m_HotbarActionsCallbackInterfaces.Add(instance); Hotbar1.started += instance.OnHotbar1; Hotbar1.performed += instance.OnHotbar1; Hotbar1.canceled += instance.OnHotbar1; Hotbar2.started += instance.OnHotbar2; Hotbar2.performed += instance.OnHotbar2; Hotbar2.canceled += instance.OnHotbar2; Hotbar3.started += instance.OnHotbar3; Hotbar3.performed += instance.OnHotbar3; Hotbar3.canceled += instance.OnHotbar3; Hotbar4.started += instance.OnHotbar4; Hotbar4.performed += instance.OnHotbar4; Hotbar4.canceled += instance.OnHotbar4; Hotbar5.started += instance.OnHotbar5; Hotbar5.performed += instance.OnHotbar5; Hotbar5.canceled += instance.OnHotbar5; Hotbar6.started += instance.OnHotbar6; Hotbar6.performed += instance.OnHotbar6; Hotbar6.canceled += instance.OnHotbar6; Hotbar7.started += instance.OnHotbar7; Hotbar7.performed += instance.OnHotbar7; Hotbar7.canceled += instance.OnHotbar7; Hotbar8.started += instance.OnHotbar8; Hotbar8.performed += instance.OnHotbar8; Hotbar8.canceled += instance.OnHotbar8; Hotbar9.started += instance.OnHotbar9; Hotbar9.performed += instance.OnHotbar9; Hotbar9.canceled += instance.OnHotbar9; } } private void UnregisterCallbacks(IHotbarActions instance) { Hotbar1.started -= instance.OnHotbar1; Hotbar1.performed -= instance.OnHotbar1; Hotbar1.canceled -= instance.OnHotbar1; Hotbar2.started -= instance.OnHotbar2; Hotbar2.performed -= instance.OnHotbar2; Hotbar2.canceled -= instance.OnHotbar2; Hotbar3.started -= instance.OnHotbar3; Hotbar3.performed -= instance.OnHotbar3; Hotbar3.canceled -= instance.OnHotbar3; Hotbar4.started -= instance.OnHotbar4; Hotbar4.performed -= instance.OnHotbar4; Hotbar4.canceled -= instance.OnHotbar4; Hotbar5.started -= instance.OnHotbar5; Hotbar5.performed -= instance.OnHotbar5; Hotbar5.canceled -= instance.OnHotbar5; Hotbar6.started -= instance.OnHotbar6; Hotbar6.performed -= instance.OnHotbar6; Hotbar6.canceled -= instance.OnHotbar6; Hotbar7.started -= instance.OnHotbar7; Hotbar7.performed -= instance.OnHotbar7; Hotbar7.canceled -= instance.OnHotbar7; Hotbar8.started -= instance.OnHotbar8; Hotbar8.performed -= instance.OnHotbar8; Hotbar8.canceled -= instance.OnHotbar8; Hotbar9.started -= instance.OnHotbar9; Hotbar9.performed -= instance.OnHotbar9; Hotbar9.canceled -= instance.OnHotbar9; } public void RemoveCallbacks(IHotbarActions instance) { if (m_Wrapper.m_HotbarActionsCallbackInterfaces.Remove(instance)) { UnregisterCallbacks(instance); } } public void SetCallbacks(IHotbarActions instance) { foreach (IHotbarActions hotbarActionsCallbackInterface in m_Wrapper.m_HotbarActionsCallbackInterfaces) { UnregisterCallbacks(hotbarActionsCallbackInterface); } m_Wrapper.m_HotbarActionsCallbackInterfaces.Clear(); AddCallbacks(instance); } } public interface IHotbarActions { void OnHotbar1(CallbackContext context); void OnHotbar2(CallbackContext context); void OnHotbar3(CallbackContext context); void OnHotbar4(CallbackContext context); void OnHotbar5(CallbackContext context); void OnHotbar6(CallbackContext context); void OnHotbar7(CallbackContext context); void OnHotbar8(CallbackContext context); void OnHotbar9(CallbackContext context); } private readonly InputActionMap m_Hotbar; private List<IHotbarActions> m_HotbarActionsCallbackInterfaces = new List<IHotbarActions>(); private readonly InputAction m_Hotbar_Hotbar1; private readonly InputAction m_Hotbar_Hotbar2; private readonly InputAction m_Hotbar_Hotbar3; private readonly InputAction m_Hotbar_Hotbar4; private readonly InputAction m_Hotbar_Hotbar5; private readonly InputAction m_Hotbar_Hotbar6; private readonly InputAction m_Hotbar_Hotbar7; private readonly InputAction m_Hotbar_Hotbar8; private readonly InputAction m_Hotbar_Hotbar9; public InputActionAsset asset { get; } public InputBinding? bindingMask { get { return asset.bindingMask; } set { asset.bindingMask = value; } } public ReadOnlyArray<InputDevice>? devices { get { return asset.devices; } set { asset.devices = value; } } public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes; public IEnumerable<InputBinding> bindings => asset.bindings; public HotbarActions Hotbar => new HotbarActions(this); public PlayerHotbarInput() { asset = InputActionAsset.FromJson("{\r\n \"name\": \"PlayerHotbarInput\",\r\n \"maps\": [\r\n {\r\n \"name\": \"Hotbar\",\r\n \"id\": \"acedaef2-b06f-4287-a2ed-00f0260b63da\",\r\n \"actions\": [\r\n {\r\n \"name\": \"Hotbar1\",\r\n \"type\": \"Button\",\r\n \"id\": \"afdaf0de-d9cb-4835-93df-06ff8a407e18\",\r\n \"expectedControlType\": \"Button\",\r\n \"processors\": \"\",\r\n \"interactions\": \"Press\",\r\n \"initialStateCheck\": false\r\n },\r\n {\r\n \"name\": \"Hotbar2\",\r\n \"type\": \"Button\",\r\n \"id\": \"1cf91964-9e69-4db5-90ae-65b813acbceb\",\r\n \"expectedControlType\": \"Button\",\r\n \"processors\": \"\",\r\n \"interactions\": \"Press\",\r\n \"initialStateCheck\": false\r\n },\r\n {\r\n \"name\": \"Hotbar3\",\r\n \"type\": \"Button\",\r\n \"id\": \"9787ab53-1dcb-439c-91cb-683e0e6e0fc2\",\r\n \"expectedControlType\": \"Button\",\r\n \"processors\": \"\",\r\n \"interactions\": \"Press\",\r\n \"initialStateCheck\": false\r\n },\r\n {\r\n \"name\": \"Hotbar4\",\r\n \"type\": \"Button\",\r\n \"id\": \"a63eb6ea-bced-4246-a625-439815fb3c86\",\r\n \"expectedControlType\": \"Button\",\r\n \"processors\": \"\",\r\n \"interactions\": \"Press\",\r\n \"initialStateCheck\": false\r\n },\r\n {\r\n \"name\": \"Hotbar5\",\r\n \"type\": \"Button\",\r\n \"id\": \"8810962b-a9c4-4244-9202-05886a4dd217\",\r\n \"expectedControlType\": \"Button\",\r\n \"processors\": \"\",\r\n \"interactions\": \"Press\",\r\n \"initialStateCheck\": false\r\n },\r\n {\r\n \"name\": \"Hotbar6\",\r\n \"type\": \"Button\",\r\n \"id\": \"4e4ccd85-b20d-422d-836a-6c30d64e8ada\",\r\n \"expectedControlType\": \"Button\",\r\n \"processors\": \"\",\r\n \"interactions\": \"Press\",\r\n \"initialStateCheck\": false\r\n },\r\n {\r\n \"name\": \"Hotbar7\",\r\n \"type\": \"Button\",\r\n \"id\": \"cc6d7e8c-4c89-4a7f-8f69-07d40af41569\",\r\n \"expectedControlType\": \"Button\",\r\n \"processors\": \"\",\r\n \"interactions\": \"Press\",\r\n \"initialStateCheck\": false\r\n },\r\n {\r\n \"name\": \"Hotbar8\",\r\n \"type\": \"Button\",\r\n \"id\": \"71e7f8d9-ddd6-45de-acdb-0e427b5cf883\",\r\n \"expectedControlType\": \"Button\",\r\n \"processors\": \"\",\r\n \"interactions\": \"Press\",\r\n \"initialStateCheck\": false\r\n },\r\n {\r\n \"name\": \"Hotbar9\",\r\n \"type\": \"Button\",\r\n \"id\": \"9f3aee6a-4474-4e45-895f-4384d31e2651\",\r\n \"expectedControlType\": \"Button\",\r\n \"processors\": \"\",\r\n \"interactions\": \"Press\",\r\n \"initialStateCheck\": false\r\n }\r\n ],\r\n \"bindings\": [\r\n {\r\n \"name\": \"\",\r\n \"id\": \"75fed245-d23a-4c28-842f-5f5c2e244087\",\r\n \"path\": \"<Keyboard>/1\",\r\n \"interactions\": \"\",\r\n \"processors\": \"\",\r\n \"groups\": \"\",\r\n \"action\": \"Hotbar1\",\r\n \"isComposite\": false,\r\n \"isPartOfComposite\": false\r\n },\r\n {\r\n \"name\": \"\",\r\n \"id\": \"e3020d01-d049-4c17-98a4-c8e7b52e6f7e\",\r\n \"path\": \"<Keyboard>/2\",\r\n \"interactions\": \"\",\r\n \"processors\": \"\",\r\n \"groups\": \"\",\r\n \"action\": \"Hotbar2\",\r\n \"isComposite\": false,\r\n \"isPartOfComposite\": false\r\n },\r\n {\r\n \"name\": \"\",\r\n \"id\": \"fd0c3e9e-f967-4970-91eb-611774d404f3\",\r\n \"path\": \"<Keyboard>/3\",\r\n \"interactions\": \"\",\r\n \"processors\": \"\",\r\n \"groups\": \"\",\r\n \"action\": \"Hotbar3\",\r\n \"isComposite\": false,\r\n \"isPartOfComposite\": false\r\n },\r\n {\r\n \"name\": \"\",\r\n \"id\": \"201a61fa-e2d7-4c32-a293-89f48ce8b772\",\r\n \"path\": \"<Keyboard>/4\",\r\n \"interactions\": \"\",\r\n \"processors\": \"\",\r\n \"groups\": \"\",\r\n \"action\": \"Hotbar4\",\r\n \"isComposite\": false,\r\n \"isPartOfComposite\": false\r\n },\r\n {\r\n \"name\": \"\",\r\n \"id\": \"0b0ce1b1-d25e-4e30-97d3-24b67a08b018\",\r\n \"path\": \"<Keyboard>/5\",\r\n \"interactions\": \"\",\r\n \"processors\": \"\",\r\n \"groups\": \"\",\r\n \"action\": \"Hotbar5\",\r\n \"isComposite\": false,\r\n \"isPartOfComposite\": false\r\n },\r\n {\r\n \"name\": \"\",\r\n \"id\": \"91c0c96d-9e51-424c-a6ae-150e99cacde5\",\r\n \"path\": \"<Keyboard>/6\",\r\n \"interactions\": \"\",\r\n \"processors\": \"\",\r\n \"groups\": \"\",\r\n \"action\": \"Hotbar6\",\r\n \"isComposite\": false,\r\n \"isPartOfComposite\": false\r\n },\r\n {\r\n \"name\": \"\",\r\n \"id\": \"de949a83-e142-4d7e-96b4-885ec2abdd76\",\r\n \"path\": \"<Keyboard>/7\",\r\n \"interactions\": \"\",\r\n \"processors\": \"\",\r\n \"groups\": \"\",\r\n \"action\": \"Hotbar7\",\r\n \"isComposite\": false,\r\n \"isPartOfComposite\": false\r\n },\r\n {\r\n \"name\": \"\",\r\n \"id\": \"b40a6f2b-d2a4-4db7-8eb1-9d585882ff0e\",\r\n \"path\": \"<Keyboard>/8\",\r\n \"interactions\": \"\",\r\n \"processors\": \"\",\r\n \"groups\": \"\",\r\n \"action\": \"Hotbar8\",\r\n \"isComposite\": false,\r\n \"isPartOfComposite\": false\r\n },\r\n {\r\n \"name\": \"\",\r\n \"id\": \"7089d993-a703-4246-aef3-2bfa18bf49f1\",\r\n \"path\": \"<Keyboard>/9\",\r\n \"interactions\": \"\",\r\n \"processors\": \"\",\r\n \"groups\": \"\",\r\n \"action\": \"Hotbar9\",\r\n \"isComposite\": false,\r\n \"isPartOfComposite\": false\r\n }\r\n ]\r\n }\r\n ],\r\n \"controlSchemes\": []\r\n}"); m_Hotbar = asset.FindActionMap("Hotbar", true); m_Hotbar_Hotbar1 = m_Hotbar.FindAction("Hotbar1", true); m_Hotbar_Hotbar2 = m_Hotbar.FindAction("Hotbar2", true); m_Hotbar_Hotbar3 = m_Hotbar.FindAction("Hotbar3", true); m_Hotbar_Hotbar4 = m_Hotbar.FindAction("Hotbar4", true); m_Hotbar_Hotbar5 = m_Hotbar.FindAction("Hotbar5", true); m_Hotbar_Hotbar6 = m_Hotbar.FindAction("Hotbar6", true); m_Hotbar_Hotbar7 = m_Hotbar.FindAction("Hotbar7", true); m_Hotbar_Hotbar8 = m_Hotbar.FindAction("Hotbar8", true); m_Hotbar_Hotbar9 = m_Hotbar.FindAction("Hotbar9", true); } public void Dispose() { Object.Destroy((Object)(object)asset); } public bool Contains(InputAction action) { return asset.Contains(action); } public IEnumerator<InputAction> GetEnumerator() { return asset.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } public void Enable() { asset.Enable(); } public void Disable() { asset.Disable(); } public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false) { return asset.FindAction(actionNameOrId, throwIfNotFound); } public int FindBinding(InputBinding bindingMask, out InputAction action) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return asset.FindBinding(bindingMask, ref action); } } }
BepInEx/Plugins/Rozebud-FOV_Adjust/FovAdjust.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("FovAdjust")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FovAdjust")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("dfb6681a-9f25-4737-a7fe-10b3c23f65b3")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace FovAdjust; [BepInPlugin("Rozebud.FovAdjust", "FOV Adjust", "1.1.0")] public class FovAdjustBase : BaseUnityPlugin { private const string modGUID = "Rozebud.FovAdjust"; private const string modName = "FOV Adjust"; private const string modVer = "1.1.0"; private readonly Harmony harmony = new Harmony("Rozebud.FovAdjust"); private static FovAdjustBase Instance; public static ManualLogSource log; public static ConfigEntry<float> configFov; public static ConfigEntry<bool> configHideVisor; public static bool inDebugMode; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } log = Logger.CreateLogSource("Rozebud.FovAdjust"); log.LogInfo((object)"Starting."); configFov = ((BaseUnityPlugin)this).Config.Bind<float>("General", "fov", 66f, "Change the field of view of the camera. Clamped from 66 to 130 for my sanity. Also keep in mind that this is vertical FOV."); configHideVisor = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "hideVisor", false, "Changes whether the first person visor is visible."); PlayerControllerBPatches.newTargetFovBase = Mathf.Clamp(configFov.Value, 66f, 130f); PlayerControllerBPatches.hideVisor = configHideVisor.Value; log.LogInfo((object)"Configs DONE!"); harmony.PatchAll(typeof(PlayerControllerBPatches)); harmony.PatchAll(typeof(HUDManagerPatches)); log.LogInfo((object)"All FOV Adjust patches have loaded successfully."); } } public class PlayerControllerBPatches { public static float newTargetFovBase = 66f; private static float prefixCamFov = 0f; public static bool hideVisor = false; private static Vector3 visorScale; public static Vector3 visorScaleBottom = new Vector3(0.68f, 0.8f, 0.95f); public static Vector3 visorScaleTop = new Vector3(0.68f, 0.35f, 0.99f); public static float linToSinLerp = 0.6f; public static float visorScaleTopRefFOV = 130f; [HarmonyPatch(typeof(PlayerControllerB), "Awake")] [HarmonyPostfix] private static void Awake_Postfix(PlayerControllerB __instance) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) FovAdjustBase.log.LogMessage((object)__instance.localVisor.localScale); calculateVisorStuff(); __instance.localVisor.localScale = visorScale; } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPrefix] private static void Update_Prefix(PlayerControllerB __instance) { //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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_0187: Unknown result type (might be due to invalid IL or missing references) prefixCamFov = __instance.gameplayCamera.fieldOfView; if (FovAdjustBase.inDebugMode) { if (((ButtonControl)Keyboard.current.minusKey).wasPressedThisFrame) { visorScale.x -= 0.00049999997f; FovAdjustBase.log.LogMessage((object)visorScale); } else if (((ButtonControl)Keyboard.current.equalsKey).wasPressedThisFrame) { visorScale.x += 0.00049999997f; FovAdjustBase.log.LogMessage((object)visorScale); } if (((ButtonControl)Keyboard.current.leftBracketKey).wasPressedThisFrame) { visorScale.y -= 0.00049999997f; FovAdjustBase.log.LogMessage((object)visorScale); } else if (((ButtonControl)Keyboard.current.rightBracketKey).wasPressedThisFrame) { visorScale.y += 0.00049999997f; FovAdjustBase.log.LogMessage((object)visorScale); } if (((ButtonControl)Keyboard.current.semicolonKey).wasPressedThisFrame) { visorScale.z -= 0.00049999997f; FovAdjustBase.log.LogMessage((object)visorScale); } else if (((ButtonControl)Keyboard.current.quoteKey).wasPressedThisFrame) { visorScale.z += 0.00049999997f; FovAdjustBase.log.LogMessage((object)visorScale); } } if (__instance.localVisor.localScale != visorScale) { __instance.localVisor.localScale = visorScale; } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] private static void Update_Postfix(PlayerControllerB __instance) { float num = newTargetFovBase; if (__instance.inTerminalMenu) { num = 60f; } else if (__instance.IsInspectingItem) { num = 46f; } else if (__instance.isSprinting) { num *= 1.03f; } __instance.gameplayCamera.fieldOfView = Mathf.Lerp(prefixCamFov, num, 6f * Time.deltaTime); } [HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")] [HarmonyPostfix] private static void lateUpdatePostfix(PlayerControllerB __instance) { //IL_0026: 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_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_004f: Unknown result type (might be due to invalid IL or missing references) if (newTargetFovBase > 66f || FovAdjustBase.inDebugMode) { __instance.localVisor.position = __instance.localVisor.position + __instance.localVisor.rotation * new Vector3(0f, 0f, -0.003f); } } private static float easeOutSine(float x) { return Mathf.Sin(x * (float)Math.PI / 2f); } public static void calculateVisorStuff() { //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_005f: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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) if (hideVisor) { visorScale = new Vector3(0f, 0f, 0f); } else if (FovAdjustBase.inDebugMode) { float num = (newTargetFovBase - 66f) / (visorScaleTopRefFOV - 66f); num = Mathf.Lerp(num, easeOutSine(num), linToSinLerp); visorScale = Vector3.LerpUnclamped(visorScaleBottom, visorScaleTop, num); } else if (newTargetFovBase > 66f) { float num2 = (newTargetFovBase - 66f) / (visorScaleTopRefFOV - 66f); num2 = Mathf.Lerp(num2, easeOutSine(num2), linToSinLerp); visorScale = Vector3.LerpUnclamped(visorScaleBottom, visorScaleTop, num2); } else { visorScale = new Vector3(0.36f, 0.49f, 0.49f); } } } public class HUDManagerPatches { [HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")] [HarmonyPrefix] public static bool SubmitChat_performed_Prefix(HUDManager __instance) { //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) string text = __instance.chatTextField.text; if (text.StartsWith("/fov")) { string[] array = text.Split(new char[1] { ' ' }); if (array.Length > 1 && float.TryParse(array[1], out var result)) { result = Mathf.Clamp(result, 66f, 130f); PlayerControllerBPatches.newTargetFovBase = result; if (!FovAdjustBase.inDebugMode) { PlayerControllerBPatches.calculateVisorStuff(); } } } else if (text.StartsWith("/toggleVisor")) { PlayerControllerBPatches.hideVisor = !PlayerControllerBPatches.hideVisor; PlayerControllerBPatches.calculateVisorStuff(); } else if (text.StartsWith("/recalcVisor") && FovAdjustBase.inDebugMode) { PlayerControllerBPatches.calculateVisorStuff(); } else if (text.StartsWith("/setScaleBottom") && FovAdjustBase.inDebugMode) { string[] array2 = text.Split(new char[1] { ' ' }); PlayerControllerBPatches.visorScaleBottom = new Vector3(float.Parse(array2[1]), float.Parse(array2[2]), float.Parse(array2[3])); } else if (text.StartsWith("/setScaleTop") && FovAdjustBase.inDebugMode) { string[] array3 = text.Split(new char[1] { ' ' }); PlayerControllerBPatches.visorScaleTop = new Vector3(float.Parse(array3[1]), float.Parse(array3[2]), float.Parse(array3[3])); } else if (text.StartsWith("/setSinAmount") && FovAdjustBase.inDebugMode) { string[] array4 = text.Split(new char[1] { ' ' }); PlayerControllerBPatches.linToSinLerp = float.Parse(array4[1]); } else if (text.StartsWith("/setTopRef") && FovAdjustBase.inDebugMode) { string[] array5 = text.Split(new char[1] { ' ' }); PlayerControllerBPatches.visorScaleTopRefFOV = float.Parse(array5[1]); } else { if (!text.StartsWith("/gimmeMyValues") || !FovAdjustBase.inDebugMode) { return true; } ManualLogSource log = FovAdjustBase.log; Vector3 val = PlayerControllerBPatches.visorScaleBottom; log.LogMessage((object)("visorScaleBottom: " + ((object)(Vector3)(ref val)).ToString())); ManualLogSource log2 = FovAdjustBase.log; val = PlayerControllerBPatches.visorScaleTop; log2.LogMessage((object)("visorScaleTop: " + ((object)(Vector3)(ref val)).ToString())); FovAdjustBase.log.LogMessage((object)("linToSinLerp: " + PlayerControllerBPatches.linToSinLerp)); FovAdjustBase.log.LogMessage((object)("visorScaleTopRefFOV: " + PlayerControllerBPatches.visorScaleTopRefFOV)); } __instance.localPlayer = GameNetworkManager.Instance.localPlayerController; __instance.localPlayer.isTypingChat = false; __instance.chatTextField.text = ""; EventSystem.current.SetSelectedGameObject((GameObject)null); ((Behaviour)__instance.typingIndicator).enabled = false; return false; } }
BepInEx/Plugins/x753-More_Suits/MoreSuits.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; 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 = "")] [assembly: AssemblyCompany("MoreSuits")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A mod that adds more suit options to Lethal Company")] [assembly: AssemblyFileVersion("1.3.1.0")] [assembly: AssemblyInformationalVersion("1.3.1")] [assembly: AssemblyProduct("MoreSuits")] [assembly: AssemblyTitle("MoreSuits")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.1.0")] [module: UnverifiableCode] namespace MoreSuits; [BepInPlugin("x753.More_Suits", "More Suits", "1.3.1")] public class MoreSuitsMod : BaseUnityPlugin { [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch("Start")] [HarmonyPrefix] private static void StartPatch(ref StartOfRound __instance) { //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Expected O, but got Unknown //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Expected O, but got Unknown //IL_03e1: Unknown result type (might be due to invalid IL or missing references) try { if (SuitsAdded) { return; } for (int i = 0; i < __instance.unlockablesList.unlockables.Count; i++) { UnlockableItem val = __instance.unlockablesList.unlockables[i]; if (!((Object)(object)val.suitMaterial != (Object)null) || !val.alreadyUnlocked) { continue; } List<string> list = Directory.GetDirectories(Paths.PluginPath, "moresuits", SearchOption.AllDirectories).ToList(); List<string> list2 = new List<string>(); foreach (string item in list) { string[] files = Directory.GetFiles(item, "!less-suits.txt"); if (files.Length == 0) { continue; } foreach (string item2 in list) { string[] files2 = Directory.GetFiles(item, "!more-suits.txt"); if (files.Length != 0 && item2 != item) { list.Remove(item2); break; } } break; } foreach (string item3 in list) { if (item3 != "") { string[] files3 = Directory.GetFiles(item3, "*.png"); list2.AddRange(files3); } } list2.Sort(); foreach (string item4 in list2) { UnlockableItem val2; Material val3; if (Path.GetFileNameWithoutExtension(item4).ToLower() == "default") { val2 = val; val3 = val2.suitMaterial; } else { string text = JsonUtility.ToJson((object)val); val2 = JsonUtility.FromJson<UnlockableItem>(text); val3 = Object.Instantiate<Material>(val2.suitMaterial); } byte[] array = File.ReadAllBytes(item4); Texture2D val4 = new Texture2D(2, 2); ImageConversion.LoadImage(val4, array); val3.mainTexture = (Texture)(object)val4; val2.unlockableName = Path.GetFileNameWithoutExtension(item4); try { string path = Path.Combine(Path.GetDirectoryName(item4), "advanced", val2.unlockableName + ".json"); if (File.Exists(path)) { string[] array2 = File.ReadAllLines(path); string[] array3 = array2; foreach (string text2 in array3) { string[] array4 = text2.Trim().Split(':'); if (array4.Length != 2) { continue; } string text3 = array4[0].Trim('"', ' ', ','); string text4 = array4[1].Trim('"', ' ', ','); float result2; Vector4 vector; if (text3 == "PRICE" && int.TryParse(text4, out var result)) { try { AddToRotatingShop(val2, result, __instance.unlockablesList.unlockables.Count); } catch (Exception ex) { Debug.Log((object)("Something went wrong with More Suits! Could not add a suit to the rotating shop. Error: " + ex)); } } else if (text4 == "KEYWORD") { val3.EnableKeyword(text3); } else if (text4.Contains(".png")) { string path2 = Path.Combine(Path.GetDirectoryName(item4), "advanced", text4); byte[] array5 = File.ReadAllBytes(path2); Texture2D val5 = new Texture2D(2, 2); ImageConversion.LoadImage(val5, array5); val3.SetTexture(text3, (Texture)(object)val5); } else if (float.TryParse(text4, out result2)) { val3.SetFloat(text3, result2); } else if (TryParseVector4(text4, out vector)) { val3.SetVector(text3, vector); } } } } catch (Exception ex2) { Debug.Log((object)("Something went wrong with More Suits! Error: " + ex2)); } val2.suitMaterial = val3; if (val2.unlockableName.ToLower() != "default") { __instance.unlockablesList.unlockables.Add(val2); } } SuitsAdded = true; break; } } catch (Exception ex3) { Debug.Log((object)("Something went wrong with More Suits! Error: " + ex3)); } } [HarmonyPatch("PositionSuitsOnRack")] [HarmonyPrefix] private static bool PositionSuitsOnRackPatch(ref StartOfRound __instance) { //IL_0072: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00b4: Unknown result type (might be due to invalid IL or missing references) List<UnlockableSuit> source = Object.FindObjectsOfType<UnlockableSuit>().ToList(); source = source.OrderBy((UnlockableSuit suit) => suit.syncedSuitID.Value).ToList(); int num = 0; foreach (UnlockableSuit item in source) { AutoParentToShip component = ((Component)item).gameObject.GetComponent<AutoParentToShip>(); component.overrideOffset = true; component.positionOffset = new Vector3(-2.45f, 2.75f, -8.41f) + __instance.rightmostSuitPosition.forward * 0.18f * (float)num; component.rotationOffset = new Vector3(0f, 90f, 0f); num++; } return false; } } private const string modGUID = "x753.More_Suits"; private const string modName = "More Suits"; private const string modVersion = "1.3.1"; private readonly Harmony harmony = new Harmony("x753.More_Suits"); private static MoreSuitsMod Instance; public static bool SuitsAdded; private static TerminalNode cancelPurchase; private static TerminalKeyword buyKeyword; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin More Suits is loaded!"); } private static void AddToRotatingShop(UnlockableItem newSuit, int price, int unlockableID) { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Expected O, but got Unknown Terminal val = Object.FindObjectOfType<Terminal>(); for (int i = 0; i < val.terminalNodes.allKeywords.Length; i++) { if (((Object)val.terminalNodes.allKeywords[i]).name == "Buy") { buyKeyword = val.terminalNodes.allKeywords[i]; break; } } newSuit.alreadyUnlocked = false; newSuit.shopSelectionNode = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)newSuit.shopSelectionNode).name = newSuit.unlockableName + "SuitBuy1"; newSuit.shopSelectionNode.creatureName = newSuit.unlockableName + " suit"; newSuit.shopSelectionNode.displayText = "You have requested to order " + newSuit.unlockableName + " suits.\nTotal cost of item: [totalCost].\n\nPlease CONFIRM or DENY.\n\n"; newSuit.shopSelectionNode.clearPreviousText = true; newSuit.shopSelectionNode.shipUnlockableID = unlockableID; newSuit.shopSelectionNode.itemCost = price; newSuit.shopSelectionNode.overrideOptions = true; CompatibleNoun val2 = new CompatibleNoun(); val2.noun = ScriptableObject.CreateInstance<TerminalKeyword>(); val2.noun.word = "confirm"; val2.noun.isVerb = true; val2.result = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val2.result).name = newSuit.unlockableName + "SuitBuyConfirm"; val2.result.creatureName = ""; val2.result.displayText = "Ordered " + newSuit.unlockableName + " suits! Your new balance is [playerCredits].\n\n"; val2.result.clearPreviousText = true; val2.result.shipUnlockableID = unlockableID; val2.result.buyUnlockable = true; val2.result.itemCost = price; val2.result.terminalEvent = ""; CompatibleNoun val3 = new CompatibleNoun(); val3.noun = ScriptableObject.CreateInstance<TerminalKeyword>(); val3.noun.word = "deny"; val3.noun.isVerb = true; if ((Object)(object)cancelPurchase == (Object)null) { cancelPurchase = ScriptableObject.CreateInstance<TerminalNode>(); } val3.result = cancelPurchase; ((Object)val3.result).name = "MoreSuitsCancelPurchase"; val3.result.displayText = "Cancelled order.\n"; newSuit.shopSelectionNode.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2] { val2, val3 }; TerminalKeyword val4 = ScriptableObject.CreateInstance<TerminalKeyword>(); ((Object)val4).name = newSuit.unlockableName + "Suit"; val4.word = newSuit.unlockableName.ToLower() + " suit"; val4.defaultVerb = buyKeyword; CompatibleNoun val5 = new CompatibleNoun(); val5.noun = val4; val5.result = newSuit.shopSelectionNode; List<CompatibleNoun> list = buyKeyword.compatibleNouns.ToList(); list.Add(val5); buyKeyword.compatibleNouns = list.ToArray(); List<TerminalKeyword> list2 = val.terminalNodes.allKeywords.ToList(); list2.Add(val4); list2.Add(val2.noun); list2.Add(val3.noun); val.terminalNodes.allKeywords = list2.ToArray(); } public static bool TryParseVector4(string input, out Vector4 vector) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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) //IL_0065: Unknown result type (might be due to invalid IL or missing references) vector = Vector4.zero; string[] array = input.Split(','); if (array.Length == 4 && float.TryParse(array[0], out var result) && float.TryParse(array[1], out var result2) && float.TryParse(array[2], out var result3) && float.TryParse(array[3], out var result4)) { vector = new Vector4(result, result2, result3, result4); return true; } return false; } }