using 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 Poltergeist;
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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MikesTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[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("ChubbzCrew.MikesTweaksIG", "Mike's Tweaks + Poltergeists", "1.4.2")]
public class MikesTweaks : BaseUnityPlugin
{
public const string GUID = "ChubbzCrew.MikesTweaksIG";
public const string Name = "Mike's Tweaks + Poltergeists";
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 ChubbzCrew.MikesTweaksIG 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_0012: 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_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: 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)
float value = Configs.GlobalTimeSpeedMulti.Value;
((FastBufferWriter)(ref writer)).WriteValueSafe<float>(ref value, default(ForPrimitives));
return writer;
}
public static FastBufferReader ReadConfigChanges(FastBufferReader payload)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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_0012: 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_0030: 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_004e: 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_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_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: 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)
//IL_00b5: 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_00b9: 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_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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_0055: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: 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_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_0030: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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)
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_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: 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_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: 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 = null;
private PlayerHotbarInput input = null;
private MethodInfo SwitchToSlotMethod = null;
public void OnHotbar1(CallbackContext context)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
if ((int)((CallbackContext)(ref context)).phase == 3)
{
RequestSlotChange(0);
}
}
public void OnHotbar2(CallbackContext context)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
if ((int)((CallbackContext)(ref context)).phase == 3)
{
RequestSlotChange(1);
}
}
public void OnHotbar3(CallbackContext context)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
if ((int)((CallbackContext)(ref context)).phase == 3)
{
RequestSlotChange(2);
}
}
public void OnHotbar4(CallbackContext context)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
if ((int)((CallbackContext)(ref context)).phase == 3)
{
RequestSlotChange(3);
}
}
public void OnHotbar5(CallbackContext context)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
if ((int)((CallbackContext)(ref context)).phase == 3 && InventoryTweaks.HasEnoughSlots(4))
{
RequestSlotChange(4);
}
}
public void OnHotbar6(CallbackContext context)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
if ((int)((CallbackContext)(ref context)).phase == 3 && InventoryTweaks.HasEnoughSlots(5))
{
RequestSlotChange(5);
}
}
public void OnHotbar7(CallbackContext context)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
if ((int)((CallbackContext)(ref context)).phase == 3 && InventoryTweaks.HasEnoughSlots(6))
{
RequestSlotChange(6);
}
}
public void OnHotbar8(CallbackContext context)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
if ((int)((CallbackContext)(ref context)).phase == 3 && InventoryTweaks.HasEnoughSlots(7))
{
RequestSlotChange(7);
}
}
public void OnHotbar9(CallbackContext context)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: 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_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: 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)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: 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_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: 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_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: 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_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: 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_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
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);
int currentItemSlot = 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_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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)
//IL_0047: 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_005b: 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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: 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_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: 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)
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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: 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)
{
GameObject gameObject = ((Component)__instance).gameObject;
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;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
public static void OverrideSpectateCam(PlayerControllerB __instance)
{
if (!Patches.vanillaMode)
{
__instance.playersManager.overrideSpectateCamera = true;
}
}
}
}
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_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: 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_001e: Unknown result type (might be due to invalid IL or missing references)
FastBufferWriter val = default(FastBufferWriter);
((FastBufferWriter)(ref val))..ctor(0, (Allocator)2, -1);
CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager;
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_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: 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_00b2: 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_0012: 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_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: 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)
int value = Configs.ExtraItemSlotsAmount.Value;
((FastBufferWriter)(ref writer)).WriteValueSafe<int>(ref value, default(ForPrimitives));
return writer;
}
public static FastBufferReader ReadConfigChanges(FastBufferReader payload)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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);
GrabbableObject[] array2 = array;
foreach (GrabbableObject _instance in array2)
{
ChangeTerminalItemWeights(_instance);
}
}
[HarmonyPatch(typeof(HUDManager), "Awake")]
[HarmonyPostfix]
public static void ChangeItemSlotsAmountUI(HUDManager __instance)
{
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: 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("{\n \"name\": \"PlayerHotbarInput\",\n \"maps\": [\n {\n \"name\": \"Hotbar\",\n \"id\": \"acedaef2-b06f-4287-a2ed-00f0260b63da\",\n \"actions\": [\n {\n \"name\": \"Hotbar1\",\n \"type\": \"Button\",\n \"id\": \"afdaf0de-d9cb-4835-93df-06ff8a407e18\",\n \"expectedControlType\": \"Button\",\n \"processors\": \"\",\n \"interactions\": \"Press\",\n \"initialStateCheck\": false\n },\n {\n \"name\": \"Hotbar2\",\n \"type\": \"Button\",\n \"id\": \"1cf91964-9e69-4db5-90ae-65b813acbceb\",\n \"expectedControlType\": \"Button\",\n \"processors\": \"\",\n \"interactions\": \"Press\",\n \"initialStateCheck\": false\n },\n {\n \"name\": \"Hotbar3\",\n \"type\": \"Button\",\n \"id\": \"9787ab53-1dcb-439c-91cb-683e0e6e0fc2\",\n \"expectedControlType\": \"Button\",\n \"processors\": \"\",\n \"interactions\": \"Press\",\n \"initialStateCheck\": false\n },\n {\n \"name\": \"Hotbar4\",\n \"type\": \"Button\",\n \"id\": \"a63eb6ea-bced-4246-a625-439815fb3c86\",\n \"expectedControlType\": \"Button\",\n \"processors\": \"\",\n \"interactions\": \"Press\",\n \"initialStateCheck\": false\n },\n {\n \"name\": \"Hotbar5\",\n \"type\": \"Button\",\n \"id\": \"8810962b-a9c4-4244-9202-05886a4dd217\",\n \"expectedControlType\": \"Button\",\n \"processors\": \"\",\n \"interactions\": \"Press\",\n \"initialStateCheck\": false\n },\n {\n \"name\": \"Hotbar6\",\n \"type\": \"Button\",\n \"id\": \"4e4ccd85-b20d-422d-836a-6c30d64e8ada\",\n \"expectedControlType\": \"Button\",\n \"processors\": \"\",\n \"interactions\": \"Press\",\n \"initialStateCheck\": false\n },\n {\n \"name\": \"Hotbar7\",\n \"type\": \"Button\",\n \"id\": \"cc6d7e8c-4c89-4a7f-8f69-07d40af41569\",\n \"expectedControlType\": \"Button\",\n \"processors\": \"\",\n \"interactions\": \"Press\",\n \"initialStateCheck\": false\n },\n {\n \"name\": \"Hotbar8\",\n \"type\": \"Button\",\n \"id\": \"71e7f8d9-ddd6-45de-acdb-0e427b5cf883\",\n \"expectedControlType\": \"Button\",\n \"processors\": \"\",\n \"interactions\": \"Press\",\n \"initialStateCheck\": false\n },\n {\n \"name\": \"Hotbar9\",\n \"type\": \"Button\",\n \"id\": \"9f3aee6a-4474-4e45-895f-4384d31e2651\",\n \"expectedControlType\": \"Button\",\n \"processors\": \"\",\n \"interactions\": \"Press\",\n \"initialStateCheck\": false\n }\n ],\n \"bindings\": [\n {\n \"name\": \"\",\n \"id\": \"75fed245-d23a-4c28-842f-5f5c2e244087\",\n \"path\": \"<Keyboard>/1\",\n \"interactions\": \"\",\n \"processors\": \"\",\n \"groups\": \"\",\n \"action\": \"Hotbar1\",\n \"isComposite\": false,\n \"isPartOfComposite\": false\n },\n {\n \"name\": \"\",\n \"id\": \"e3020d01-d049-4c17-98a4-c8e7b52e6f7e\",\n \"path\": \"<Keyboard>/2\",\n \"interactions\": \"\",\n \"processors\": \"\",\n \"groups\": \"\",\n \"action\": \"Hotbar2\",\n \"isComposite\": false,\n \"isPartOfComposite\": false\n },\n {\n \"name\": \"\",\n \"id\": \"fd0c3e9e-f967-4970-91eb-611774d404f3\",\n \"path\": \"<Keyboard>/3\",\n \"interactions\": \"\",\n \"processors\": \"\",\n \"groups\": \"\",\n \"action\": \"Hotbar3\",\n \"isComposite\": false,\n \"isPartOfComposite\": false\n },\n {\n \"name\": \"\",\n \"id\": \"201a61fa-e2d7-4c32-a293-89f48ce8b772\",\n \"path\": \"<Keyboard>/4\",\n \"interactions\": \"\",\n \"processors\": \"\",\n \"groups\": \"\",\n \"action\": \"Hotbar4\",\n \"isComposite\": false,\n \"isPartOfComposite\": false\n },\n {\n \"name\": \"\",\n \"id\": \"0b0ce1b1-d25e-4e30-97d3-24b67a08b018\",\n \"path\": \"<Keyboard>/5\",\n \"interactions\": \"\",\n \"processors\": \"\",\n \"groups\": \"\",\n \"action\": \"Hotbar5\",\n \"isComposite\": false,\n \"isPartOfComposite\": false\n },\n {\n \"name\": \"\",\n \"id\": \"91c0c96d-9e51-424c-a6ae-150e99cacde5\",\n \"path\": \"<Keyboard>/6\",\n \"interactions\": \"\",\n \"processors\": \"\",\n \"groups\": \"\",\n \"action\": \"Hotbar6\",\n \"isComposite\": false,\n \"isPartOfComposite\": false\n },\n {\n \"name\": \"\",\n \"id\": \"de949a83-e142-4d7e-96b4-885ec2abdd76\",\n \"path\": \"<Keyboard>/7\",\n \"interactions\": \"\",\n \"processors\": \"\",\n \"groups\": \"\",\n \"action\": \"Hotbar7\",\n \"isComposite\": false,\n \"isPartOfComposite\": false\n },\n {\n \"name\": \"\",\n \"id\": \"b40a6f2b-d2a4-4db7-8eb1-9d585882ff0e\",\n \"path\": \"<Keyboard>/8\",\n \"interactions\": \"\",\n \"processors\": \"\",\n \"groups\": \"\",\n \"action\": \"Hotbar8\",\n \"isComposite\": false,\n \"isPartOfComposite\": false\n },\n {\n \"name\": \"\",\n \"id\": \"7089d993-a703-4246-aef3-2bfa18bf49f1\",\n \"path\": \"<Keyboard>/9\",\n \"interactions\": \"\",\n \"processors\": \"\",\n \"groups\": \"\",\n \"action\": \"Hotbar9\",\n \"isComposite\": false,\n \"isPartOfComposite\": false\n }\n ]\n }\n ],\n \"controlSchemes\": []\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_0007: Unknown result type (might be due to invalid IL or missing references)
return asset.FindBinding(bindingMask, ref action);
}
}
}