using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Zichen-ModsUp-1.0.5")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c03562d3bcab710de3c04433c61c65145e8dbd6e")]
[assembly: AssemblyProduct("Zichen-ModsUp-1.0.5")]
[assembly: AssemblyTitle("Zichen-ModsUp-1.0.5")]
[assembly: AssemblyVersion("1.0.0.0")]
[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;
}
}
}
[BepInPlugin("zichen.modsup", "A.ModsUp", "1.0.5")]
public sealed class ModsUpPlugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <BetterMapAddEnemyMarkerNextFrame>d__79 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public EnemyParent enemyParent;
private int <i>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <BetterMapAddEnemyMarkerNextFrame>d__79(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<i>5__2 = 0;
break;
case 1:
<>1__state = -1;
<i>5__2++;
break;
}
if (<i>5__2 < 10)
{
if (!IsStaticModEnabled())
{
return false;
}
if (BetterMapTryAddEnemyMarker(enemyParent))
{
return false;
}
<>2__current = null;
<>1__state = 1;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForMenuAndShowPopup>d__114 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public ModsUpPlugin <>4__this;
private float <t>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForMenuAndShowPopup>d__114(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
ModsUpPlugin modsUpPlugin = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<t>5__2 = 30f;
break;
case 1:
<>1__state = -1;
<t>5__2 -= 0.2f;
break;
}
if ((Object)(object)MenuManager.instance == (Object)null && <t>5__2 > 0f)
{
<>2__current = (object)new WaitForSeconds(0.2f);
<>1__state = 1;
return true;
}
if ((Object)(object)MenuManager.instance == (Object)null || showStartupPopup == null || !showStartupPopup.Value)
{
return false;
}
(string, string, string, string)[] array = new(string, string, string, string)[4]
{
("BetterMap", modsUpPlugin.betterMapResult, "修复 v0.4x 怪物刷新与地图兼容问题", "Fixed monster spawning and map compatibility issues in v0.4x"),
("AntiTumble Cooldown", modsUpPlugin.antiTumbleResult, "修复 v0.4x 即时起身失效与摔倒后不能坐车", "Fixed instant tumble recovery and the cart issue after tumble in v0.4x"),
("ItemsBounceBack", modsUpPlugin.itemsBounceBackResult, "修复 v0.4x 可装备物品掉坑后直接销毁", "Fixed equippable items being destroyed by hurt or death pits in v0.4x"),
("MoreInventorySlots", modsUpPlugin.moreInventorySlotsResult, "修复 v0.4x 扩展槽位不可用", "Fixed extra inventory slots not working in v0.4x")
};
bool flag = false;
(string, string, string, string)[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
if (array2[i].Item2 != null)
{
flag = true;
break;
}
}
if (!flag)
{
return false;
}
string text = "ModsUp v1.0.5\n\n";
array2 = array;
for (int i = 0; i < array2.Length; i++)
{
var (text2, text3, text4, text5) = array2[i];
if (text3 != null)
{
bool flag2 = IsAppliedResult(text3);
text += (flag2 ? ("[O] " + text2 + " - " + text4 + "\n") : ("[X] " + text2 + " - " + text3 + "\n"));
if (flag2)
{
text = text + " " + text5 + "\n";
}
}
}
text += "\n此提示仅弹出一次。修改开关需重启游戏。\nThis popup only appears once.";
Color val = ((IsAppliedResult(modsUpPlugin.betterMapResult) || IsAppliedResult(modsUpPlugin.antiTumbleResult) || IsAppliedResult(modsUpPlugin.itemsBounceBackResult) || IsAppliedResult(modsUpPlugin.moreInventorySlotsResult)) ? Color.green : Color.yellow);
MenuManager.instance.PagePopUpScheduled("ModsUp v1.0.5", val, text, "确认", false);
showStartupPopup.Value = false;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public const string PluginGuid = "zichen.modsup";
public const string PluginName = "A.ModsUp";
public const string PluginVersion = "1.0.5";
private const string InfoSection = "模组信息";
private const string GlobalSection = "A.全局设置";
private const string BetterMapFixSection = "B.BetterMap v1.0.5 修复";
private const string AntiTumbleFixSection = "C.AntiTumble Cooldown v1.1.0 修复";
private const string ItemsBounceBackFixSection = "D.ItemsBounceBack v1.2.0 修复";
private const string MoreInventorySlotsFixSection = "E.MoreInventorySlots v1.0.3 修复";
private const string BetterMapTargetVersion = "1.0.5";
private const string BetterMapTargetGuid = "BetterMap";
private const string AntiTumbleTargetVersion = "1.1.0";
private const string AntiTumbleTargetGuid = "com.yourname.antitumble";
private static readonly string[] AntiTumbleWhitelistVersions = new string[2] { "1.1.0", "1.1.1" };
private const string ItemsBounceBackTargetGuid = "SeroRonin.ItemsBounceBack";
private static readonly string[] ItemsBounceBackWhitelistVersions = new string[1] { "1.2.0" };
private const string MoreInventorySlotsTargetVersion = "1.0.3";
private const string MoreInventorySlotsTargetGuid = "nickklmao.moreinventoryslots";
private static ConfigEntry<bool> modEnabled;
private static ConfigEntry<bool> fixBetterMapEnemyRefresh;
private static ConfigEntry<bool> fixAntiTumbleCooldown;
private static ConfigEntry<bool> fixItemsBounceBack;
private static ConfigEntry<bool> fixMoreInventorySlots;
private static ConfigEntry<bool> showStartupPopup;
private ConfigEntry<string> moduleNameInfo;
private ConfigEntry<string> moduleVersionInfo;
private ConfigEntry<string> contactInfo;
private Harmony harmony;
private string betterMapResult;
private string antiTumbleResult;
private string itemsBounceBackResult;
private string moreInventorySlotsResult;
private static FieldInfo _bmConfigShowEnemiesField;
private static FieldInfo _bmConfigShowTeammatesField;
private static FieldInfo _bmConfigExploreAllRoomsField;
private static FieldInfo _bmEnemyField;
private static FieldInfo _bmEnemyHasRigidbodyField;
private static FieldInfo _bmEnemyRigidbodyField;
private static FieldInfo _bmEnemySquareSpriteField;
private static FieldInfo _bmEnemyCircleSpriteField;
private static FieldInfo _bmEnemyTriangleSpriteField;
private static FieldInfo _bmPlayerColorField;
private static FieldInfo _bmMapCustomEntityField;
private static FieldInfo _atPlayerTumbleField;
private static FieldInfo _atTumbleOverrideField;
private static FieldInfo _atTumbleOverrideTimerField;
private static FieldInfo _atTumbleInputTimerField;
private static FieldInfo _atOverrideSpecialPowersTimerField;
private static FieldInfo _atIsTumblingField;
private static FieldInfo _atCanExitField;
private static bool _antiTumbleLegacyCompatActive;
private static bool _atLastLocalTumbleState;
private static object _ibbPluginInstance;
private static MethodInfo _ibbShouldItemBounceMethod;
private static MethodInfo _ibbPopulateDictionaryMethod;
private static FieldInfo _ibbShouldItemBounceDictionaryField;
private static bool _ibbLegacyCompatActive;
private static bool _ibbPopulateFailureLogged;
private static bool _ibbInvokeFailureLogged;
private static bool _misActive;
private static int _misTargetSlots;
private static bool _misHostProtection;
private static FieldInfo _misInventorySpotsField;
private static MethodInfo _misHandleInputMethod;
private static FieldInfo _misAllChildrenField;
public static ModsUpPlugin Instance { get; private set; }
private void Awake()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
DetachFromManager();
Instance = this;
ResetConfigIfVersionChanged();
BindConfig();
harmony = new Harmony("zichen.modsup.patch");
if (IsModEnabled())
{
TryFixBetterMap();
TryApplyLegacyCompatWhitelist();
TryFixMoreInventorySlots();
((MonoBehaviour)this).StartCoroutine(WaitForMenuAndShowPopup());
}
}
private void DetachFromManager()
{
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
}
private void OnDestroy()
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
harmony = null;
if (Instance == this)
{
Instance = null;
}
}
private void TryFixBetterMap()
{
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Expected O, but got Unknown
//IL_037d: Unknown result type (might be due to invalid IL or missing references)
//IL_038a: Expected O, but got Unknown
//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
//IL_03b1: Expected O, but got Unknown
//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
//IL_03d8: Expected O, but got Unknown
//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
//IL_03ff: Expected O, but got Unknown
//IL_0419: Unknown result type (might be due to invalid IL or missing references)
//IL_0426: Expected O, but got Unknown
if (!fixBetterMapEnemyRefresh.Value)
{
betterMapResult = "修复已关闭";
return;
}
if (!CheckPluginVersion("BetterMap", "1.0.5", out var detected))
{
betterMapResult = (string.IsNullOrEmpty(detected) ? "未检测到 BetterMap" : ("版本不匹配(需 1.0.5,当前 " + detected + ")"));
return;
}
try
{
Type type = null;
foreach (PluginInfo value in Chainloader.PluginInfos.Values)
{
if (!(value.Metadata.GUID != "BetterMap"))
{
type = ((object)value.Instance)?.GetType();
break;
}
}
if (type == null)
{
betterMapResult = "修复失败: 未找到 BetterMap 类型";
return;
}
_bmConfigShowEnemiesField = type.GetField("configShowEnemies", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
_bmConfigShowTeammatesField = type.GetField("configShowTeammates", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
_bmConfigExploreAllRoomsField = type.GetField("configExploreAllRooms", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
_bmEnemyField = typeof(EnemyParent).GetField("Enemy", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
_bmEnemyHasRigidbodyField = typeof(Enemy).GetField("HasRigidbody", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
_bmEnemyRigidbodyField = typeof(Enemy).GetField("Rigidbody", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
_bmEnemySquareSpriteField = type.GetField("enemySpriteSquare", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
_bmEnemyCircleSpriteField = type.GetField("enemySpriteCircle", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
_bmEnemyTriangleSpriteField = type.GetField("enemySpriteTriangle", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
_bmPlayerColorField = typeof(PlayerAvatarVisuals).GetField("color", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
_bmMapCustomEntityField = typeof(MapCustom).GetField("mapCustomEntity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
Harmony val = new Harmony("BetterMap");
(Type, string)[] array = new(Type, string)[5]
{
(typeof(EnemyParent), "SpawnRPC"),
(typeof(EnemyParent), "DespawnRPC"),
(typeof(LevelGenerator), "GenerateDone"),
(typeof(PlayerAvatar), "ReviveRPC"),
(typeof(PlayerAvatar), "PlayerDeathRPC")
};
for (int i = 0; i < array.Length; i++)
{
(Type, string) tuple = array[i];
Type item = tuple.Item1;
string item2 = tuple.Item2;
MethodInfo methodInfo = AccessTools.Method(item, item2, (Type[])null, (Type[])null);
if (methodInfo != null)
{
val.Unpatch((MethodBase)methodInfo, (HarmonyPatchType)0, "BetterMap");
}
}
MethodInfo methodInfo2 = AccessTools.Method(typeof(EnemyParent), "SpawnRPC", (Type[])null, (Type[])null);
MethodInfo methodInfo3 = AccessTools.Method(typeof(EnemyParent), "DespawnRPC", (Type[])null, (Type[])null);
MethodInfo methodInfo4 = AccessTools.Method(typeof(LevelGenerator), "GenerateDone", (Type[])null, (Type[])null);
MethodInfo methodInfo5 = AccessTools.Method(typeof(PlayerAvatar), "ReviveRPC", (Type[])null, (Type[])null);
MethodInfo methodInfo6 = AccessTools.Method(typeof(PlayerAvatar), "PlayerDeathRPC", (Type[])null, (Type[])null);
if (methodInfo2 == null || methodInfo3 == null || methodInfo4 == null || methodInfo5 == null || methodInfo6 == null)
{
betterMapResult = "修复失败: 补丁入口未找到";
return;
}
harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(ModsUpPlugin), "BetterMapEnemySpawnRpcPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(ModsUpPlugin), "BetterMapEnemyDespawnRpcPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)methodInfo4, (HarmonyMethod)null, new HarmonyMethod(typeof(ModsUpPlugin), "BetterMapGenerateDonePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)methodInfo5, (HarmonyMethod)null, new HarmonyMethod(typeof(ModsUpPlugin), "BetterMapReviveRpcPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)methodInfo6, (HarmonyMethod)null, new HarmonyMethod(typeof(ModsUpPlugin), "BetterMapPlayerDeathRpcPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
betterMapResult = "修复已应用";
}
catch (Exception ex)
{
betterMapResult = "修复失败: " + ex.Message;
}
}
private static void BetterMapGenerateDonePostfix()
{
if (!IsStaticModEnabled())
{
return;
}
BetterMapAddAllPlayersToMapSafe();
if (BetterMapExploreAllRoomsEnabled())
{
RoomVolume[] array = Object.FindObjectsOfType<RoomVolume>();
for (int i = 0; i < array.Length; i++)
{
array[i].SetExplored();
}
}
}
private static void BetterMapEnemySpawnRpcPostfix(EnemyParent __instance)
{
if (IsStaticModEnabled() && !((Object)(object)Instance == (Object)null))
{
((MonoBehaviour)Instance).StartCoroutine(BetterMapAddEnemyMarkerNextFrame(__instance));
}
}
private static void BetterMapEnemyDespawnRpcPostfix(EnemyParent __instance)
{
if (IsStaticModEnabled())
{
BetterMapRemoveEnemyMarker(__instance);
}
}
private static void BetterMapReviveRpcPostfix(PlayerAvatar __instance)
{
if (IsStaticModEnabled())
{
BetterMapAddPlayerToMapSafe(__instance);
}
}
private static void BetterMapPlayerDeathRpcPostfix(PlayerAvatar __instance)
{
if (IsStaticModEnabled())
{
BetterMapRemovePlayerFromMapSafe(__instance);
}
}
private static void BetterMapAddAllPlayersToMapSafe()
{
if (!BetterMapShowTeammatesEnabled() || (Object)(object)GameDirector.instance == (Object)null || GameDirector.instance.PlayerList == null)
{
return;
}
foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
{
BetterMapAddPlayerToMapSafe(player);
}
}
[IteratorStateMachine(typeof(<BetterMapAddEnemyMarkerNextFrame>d__79))]
private static IEnumerator BetterMapAddEnemyMarkerNextFrame(EnemyParent enemyParent)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <BetterMapAddEnemyMarkerNextFrame>d__79(0)
{
enemyParent = enemyParent
};
}
private static bool BetterMapTryAddEnemyMarker(EnemyParent enemyParent)
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
if (!BetterMapShowEnemiesEnabled())
{
return true;
}
if ((Object)(object)enemyParent == (Object)null || (Object)(object)enemyParent.EnableObject == (Object)null || !enemyParent.EnableObject.activeSelf)
{
return false;
}
Enemy val = BetterMapGetEnemyFromParent(enemyParent);
if ((Object)(object)val == (Object)null)
{
return false;
}
GameObject val2 = BetterMapGetMapCustomGameObject(val);
if ((Object)(object)val2 == (Object)null)
{
return false;
}
if ((Object)(object)val2.GetComponent<MapCustom>() != (Object)null)
{
return true;
}
MapCustom obj = val2.AddComponent<MapCustom>();
obj.sprite = BetterMapGetEnemySprite(enemyParent.difficulty);
obj.color = Color.red;
return true;
}
private static void BetterMapAddPlayerToMapSafe(PlayerAvatar playerAvatar)
{
//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)
if (BetterMapShowTeammatesEnabled() && !((Object)(object)playerAvatar == (Object)null))
{
GameObject gameObject = ((Component)playerAvatar).gameObject;
if (!((Object)(object)gameObject == (Object)null) && !((Object)(object)gameObject.GetComponent<MapCustom>() != (Object)null))
{
MapCustom obj = gameObject.AddComponent<MapCustom>();
obj.sprite = BetterMapGetSquareSprite();
obj.color = BetterMapGetPlayerColor(playerAvatar);
}
}
}
private static void BetterMapRemovePlayerFromMapSafe(PlayerAvatar playerAvatar)
{
if (!BetterMapShowTeammatesEnabled() || (Object)(object)playerAvatar == (Object)null)
{
return;
}
MapCustom component = ((Component)playerAvatar).GetComponent<MapCustom>();
if (!((Object)(object)component == (Object)null))
{
object? obj = _bmMapCustomEntityField?.GetValue(component);
Component val = (Component)((obj is Component) ? obj : null);
if (val != null && (Object)(object)val != (Object)null)
{
Object.Destroy((Object)(object)val.gameObject);
}
Object.Destroy((Object)(object)component);
}
}
private static void BetterMapRemoveEnemyMarker(EnemyParent enemyParent)
{
Enemy val = BetterMapGetEnemyFromParent(enemyParent);
if ((Object)(object)val == (Object)null)
{
return;
}
GameObject val2 = BetterMapGetMapCustomGameObject(val);
if (!((Object)(object)val2 == (Object)null))
{
MapCustom component = val2.GetComponent<MapCustom>();
if (!((Object)(object)component == (Object)null))
{
BetterMapDestroyMapCustom(component);
}
}
}
private static Enemy BetterMapGetEnemyFromParent(EnemyParent enemyParent)
{
try
{
object? obj = _bmEnemyField?.GetValue(enemyParent);
Enemy val = (Enemy)((obj is Enemy) ? obj : null);
if (val != null && (Object)(object)val != (Object)null)
{
return val;
}
}
catch
{
}
if (!((Object)(object)enemyParent != (Object)null))
{
return null;
}
return ((Component)enemyParent).GetComponentInChildren<Enemy>(true);
}
private static GameObject BetterMapGetMapCustomGameObject(Enemy enemy)
{
try
{
if (_bmEnemyHasRigidbodyField != null && (bool)_bmEnemyHasRigidbodyField.GetValue(enemy))
{
object? obj = _bmEnemyRigidbodyField?.GetValue(enemy);
EnemyRigidbody val = (EnemyRigidbody)((obj is EnemyRigidbody) ? obj : null);
if (val != null && (Object)(object)val != (Object)null)
{
return ((Component)val).gameObject;
}
}
}
catch
{
}
if (!((Object)(object)enemy != (Object)null))
{
return null;
}
return ((Component)enemy).gameObject;
}
private static void BetterMapDestroyMapCustom(MapCustom mapCustom)
{
if (!((Object)(object)mapCustom == (Object)null))
{
object? obj = _bmMapCustomEntityField?.GetValue(mapCustom);
Component val = (Component)((obj is Component) ? obj : null);
if (val != null && (Object)(object)val != (Object)null)
{
Object.Destroy((Object)(object)val.gameObject);
}
Object.Destroy((Object)(object)mapCustom);
}
}
private static bool BetterMapShowEnemiesEnabled()
{
return TryGetBetterMapConfigValue(_bmConfigShowEnemiesField, fallback: true);
}
private static bool BetterMapShowTeammatesEnabled()
{
return TryGetBetterMapConfigValue(_bmConfigShowTeammatesField, fallback: true);
}
private static bool BetterMapExploreAllRoomsEnabled()
{
return TryGetBetterMapConfigValue(_bmConfigExploreAllRoomsField, fallback: false);
}
private static bool TryGetBetterMapConfigValue(FieldInfo field, bool fallback)
{
try
{
if (field?.GetValue(null) is ConfigEntry<bool> val)
{
return val.Value;
}
}
catch
{
}
return fallback;
}
private static Color BetterMapGetPlayerColor(PlayerAvatar playerAvatar)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
try
{
if (_bmPlayerColorField != null && (Object)(object)playerAvatar?.playerAvatarVisuals != (Object)null)
{
return (Color)_bmPlayerColorField.GetValue(playerAvatar.playerAvatarVisuals);
}
}
catch
{
}
return Color.green;
}
private static Sprite BetterMapGetEnemySprite(Difficulty difficulty)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Invalid comparison between Unknown and I4
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Invalid comparison between Unknown and I4
FieldInfo fieldInfo = (((int)difficulty == 1) ? _bmEnemyCircleSpriteField : (((int)difficulty != 2) ? _bmEnemySquareSpriteField : _bmEnemyTriangleSpriteField));
FieldInfo fieldInfo2 = fieldInfo;
try
{
object? obj = fieldInfo2?.GetValue(null);
Sprite val = (Sprite)((obj is Sprite) ? obj : null);
if (val != null && (Object)(object)val != (Object)null)
{
return val;
}
}
catch
{
}
if ((int)difficulty != 1)
{
if ((int)difficulty == 2)
{
return MakeSpr(10, delegate(int x, int y)
{
float num2 = (x - 1) * 8 - 4 * (y - 1);
float num3 = (x - 7) * -8 - 7 * (y - 1);
float num4 = -(-4 * (y - 9));
return (!(num2 < 0f) && !(num3 < 0f) && !(num4 < 0f)) || (!(num2 > 0f) && !(num3 > 0f) && !(num4 > 0f));
});
}
return MakeSpr(5, (int _, int _) => true);
}
return MakeSpr(10, delegate(int x, int y)
{
float num = 4.5f;
return ((float)x - num) * ((float)x - num) + ((float)y - num) * ((float)y - num) <= 16f;
});
}
private static Sprite BetterMapGetSquareSprite()
{
return BetterMapGetEnemySprite((Difficulty)0);
}
private static Sprite MakeSpr(int s, Func<int, int, bool> fn)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
//IL_0068: 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_0032: 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_0037: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(s, s, (TextureFormat)4, false);
Color[] array = (Color[])(object)new Color[s * s];
for (int i = 0; i < s; i++)
{
for (int j = 0; j < s; j++)
{
array[i * s + j] = (fn(j, i) ? Color.white : Color.clear);
}
}
val.SetPixels(array);
val.Apply();
return Sprite.Create(val, new Rect(0f, 0f, (float)s, (float)s), new Vector2(0.5f, 0.5f));
}
private void TryApplyLegacyCompatWhitelist()
{
TryApplyAntiTumbleWhitelistCompat();
TryApplyItemsBounceBackWhitelistCompat();
}
private void TryApplyAntiTumbleWhitelistCompat()
{
if (!fixAntiTumbleCooldown.Value)
{
antiTumbleResult = "修复已关闭";
return;
}
if (!TryGetWhitelistedPlugin("com.yourname.antitumble", AntiTumbleWhitelistVersions, out var pluginInfo, out var detected))
{
antiTumbleResult = (string.IsNullOrEmpty(detected) ? "未检测到 AntiTumble Cooldown" : ("版本不兼容(目标包版本 1.1.0,当前检测 " + detected + ")"));
return;
}
try
{
Type typeFromHandle = typeof(PlayerTumble);
_atPlayerTumbleField = ResolveFieldAlias(typeof(PlayerAvatar), "tumble");
_atIsTumblingField = ResolveFieldAlias(typeFromHandle, "isTumbling", "tumbling");
_atTumbleOverrideField = ResolveFieldAlias(typeFromHandle, "tumbleOverride");
_atTumbleOverrideTimerField = ResolveFieldAlias(typeFromHandle, "tumbleOverrideTimer");
_atTumbleInputTimerField = typeof(PlayerController).GetField("tumbleInputDisableTimer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
_atOverrideSpecialPowersTimerField = typeof(PhysGrabber).GetField("overrideDisableSpecialGrabPowersTimer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
_atCanExitField = ResolveFieldAlias(typeof(TumbleUI), "canExit");
if (_atPlayerTumbleField == null || _atIsTumblingField == null || _atTumbleOverrideField == null || _atTumbleOverrideTimerField == null || _atTumbleInputTimerField == null || _atOverrideSpecialPowersTimerField == null || _atCanExitField == null)
{
antiTumbleResult = "白名单兼容失败: v0.4 字段入口未找到";
return;
}
if ((Object)(object)pluginInfo.Instance != (Object)null)
{
((Behaviour)pluginInfo.Instance).enabled = false;
}
Harmony.UnpatchID("com.yourname.antitumble");
_antiTumbleLegacyCompatActive = true;
_atLastLocalTumbleState = false;
antiTumbleResult = "修复已应用(白名单兼容)";
((BaseUnityPlugin)this).Logger.LogInfo((object)("AntiTumble whitelist bridge active. Detected plugin version: " + detected + ". Package target version: 1.1.0."));
}
catch (Exception ex)
{
antiTumbleResult = "白名单兼容失败: " + ex.Message;
}
}
private void TryApplyItemsBounceBackWhitelistCompat()
{
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Expected O, but got Unknown
if (!fixItemsBounceBack.Value)
{
itemsBounceBackResult = "修复已关闭";
return;
}
if (!TryGetWhitelistedPlugin("SeroRonin.ItemsBounceBack", ItemsBounceBackWhitelistVersions, out var pluginInfo, out var detected))
{
itemsBounceBackResult = (string.IsNullOrEmpty(detected) ? "未检测到 ItemsBounceBack" : ("版本不在白名单(允许 " + string.Join("/", ItemsBounceBackWhitelistVersions) + ",当前 " + detected + ")"));
return;
}
try
{
Type type = ((object)pluginInfo.Instance)?.GetType();
if (type == null)
{
itemsBounceBackResult = "白名单兼容失败: 未找到原模组类型";
return;
}
_ibbShouldItemBounceMethod = type.GetMethod("ShouldItemBounce", BindingFlags.Static | BindingFlags.Public);
if (_ibbShouldItemBounceMethod == null)
{
itemsBounceBackResult = "白名单兼容失败: 未找到 ShouldItemBounce";
return;
}
_ibbPluginInstance = pluginInfo.Instance;
_ibbPopulateDictionaryMethod = type.GetMethod("PopulateDictionary", BindingFlags.Static | BindingFlags.Public);
_ibbShouldItemBounceDictionaryField = type.GetField("shouldItemBounce", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
MethodInfo methodInfo = AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(HurtCollider), "ColliderCheck", (Type[])null, (Type[])null));
if (methodInfo == null)
{
itemsBounceBackResult = "白名单兼容失败: 未找到 HurtCollider.ColliderCheck";
return;
}
new Harmony("SeroRonin.ItemsBounceBack").Unpatch((MethodBase)methodInfo, (HarmonyPatchType)0, "SeroRonin.ItemsBounceBack");
harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ModsUpPlugin), "ItemsBounceBackColliderCheckTranspiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null);
_ibbLegacyCompatActive = true;
_ibbPopulateFailureLogged = false;
_ibbInvokeFailureLogged = false;
itemsBounceBackResult = "白名单兼容已应用";
EnsureItemsBounceBackDictionaryPopulated();
}
catch (Exception ex)
{
itemsBounceBackResult = "白名单兼容失败: " + ex.Message;
LogItemsBounceBackCompatFailure("Bridge apply failed: " + ex.GetBaseException().Message);
}
}
private static IEnumerable<CodeInstruction> ItemsBounceBackColliderCheckTranspiler(IEnumerable<CodeInstruction> instructions)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Expected O, but got Unknown
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Expected O, but got Unknown
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Expected O, but got Unknown
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Expected O, but got Unknown
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Expected O, but got Unknown
MethodInfo methodInfo = AccessTools.Method(typeof(ModsUpPlugin), "ItemsBounceBackShouldBounceCompat", (Type[])null, (Type[])null);
if (methodInfo == null)
{
throw new InvalidOperationException("ItemsBounceBack compatibility patch could not resolve whitelist helper.");
}
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[7]
{
new CodeMatch((OpCode?)OpCodes.Brtrue, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Brfalse, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Brtrue, (object)null, (string)null)
}).ThrowIfInvalid("ItemsBounceBack compatibility patch could not find HurtCollider destroyDisable branch.");
object operand = val.Operand;
val.Advance(-1);
val.Advance(-1);
object operand2 = val.Operand;
val.Advance(1);
val.Advance(1);
val.Advance(1);
val.Insert((CodeInstruction[])(object)new CodeInstruction[3]
{
new CodeInstruction(OpCodes.Ldloc_S, operand2),
new CodeInstruction(OpCodes.Call, (object)methodInfo),
new CodeInstruction(OpCodes.Brtrue, operand)
});
return val.InstructionEnumeration();
}
private static bool ItemsBounceBackShouldBounceCompat(PhysGrabObjectImpactDetector impactDetector)
{
if (!_ibbLegacyCompatActive || !IsStaticModEnabled())
{
return false;
}
if ((Object)(object)impactDetector == (Object)null)
{
return false;
}
GameObject gameObject = ((Component)impactDetector).gameObject;
bool result = false;
try
{
object obj = _ibbShouldItemBounceMethod?.Invoke(null, new object[1] { gameObject });
bool flag = default(bool);
int num;
if (obj is bool)
{
flag = (bool)obj;
num = 1;
}
else
{
num = 0;
}
result = (byte)((uint)num & (flag ? 1u : 0u)) != 0;
}
catch (Exception ex)
{
if (!_ibbInvokeFailureLogged)
{
_ibbInvokeFailureLogged = true;
LogItemsBounceBackCompatFailure("ShouldItemBounce invoke failed: " + ex.GetBaseException().Message);
}
}
return result;
}
private static int ItemsBounceBackDictionaryCountSafe()
{
try
{
if (_ibbPluginInstance == null || _ibbShouldItemBounceDictionaryField == null)
{
return -1;
}
if (_ibbShouldItemBounceDictionaryField.GetValue(_ibbPluginInstance) is IDictionary dictionary)
{
return dictionary.Count;
}
}
catch
{
}
return -1;
}
private static void EnsureItemsBounceBackDictionaryPopulated()
{
if (!_ibbLegacyCompatActive || !IsStaticModEnabled())
{
return;
}
int num = ItemsBounceBackDictionaryCountSafe();
if (num > 0 || _ibbPopulateDictionaryMethod == null || (Object)(object)StatsManager.instance == (Object)null || StatsManager.instance.itemDictionary == null || StatsManager.instance.itemDictionary.Count == 0)
{
return;
}
try
{
int num2 = num;
_ibbPopulateDictionaryMethod.Invoke(null, null);
int num3 = ItemsBounceBackDictionaryCountSafe();
if (num3 <= 0 && !_ibbPopulateFailureLogged)
{
_ibbPopulateFailureLogged = true;
LogItemsBounceBackCompatFailure($"PopulateDictionary forced but dictionary stayed empty. StatsManager items={StatsManager.instance.itemDictionary.Count}, dictBefore={num2}, dictAfter={num3}");
}
}
catch (Exception ex)
{
if (!_ibbPopulateFailureLogged)
{
_ibbPopulateFailureLogged = true;
LogItemsBounceBackCompatFailure("PopulateDictionary forced invoke failed: " + ex.GetBaseException().Message);
}
}
}
private static void LogItemsBounceBackCompatFailure(string message)
{
try
{
ModsUpPlugin instance = Instance;
if (instance != null)
{
((BaseUnityPlugin)instance).Logger.LogWarning((object)("[ItemsBounceBackCompat] " + message));
}
}
catch
{
}
}
private void TryFixMoreInventorySlots()
{
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Expected O, but got Unknown
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Expected O, but got Unknown
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Expected O, but got Unknown
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Expected O, but got Unknown
if (!fixMoreInventorySlots.Value)
{
moreInventorySlotsResult = "修复已关闭";
return;
}
if (!CheckPluginVersion("nickklmao.moreinventoryslots", "1.0.3", out var detected))
{
moreInventorySlotsResult = (string.IsNullOrEmpty(detected) ? "未检测到 MoreInventorySlots" : ("版本不匹配(需 1.0.3,当前 " + detected + ")"));
return;
}
try
{
ReadMoreInventorySlotsConfig(out var slots, out var hostProtection);
_misTargetSlots = slots;
_misHostProtection = hostProtection;
if (_misTargetSlots <= 3)
{
moreInventorySlotsResult = "槽位数 ≤ 3,无需修复";
return;
}
_misInventorySpotsField = typeof(Inventory).GetField("inventorySpots", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
_misAllChildrenField = typeof(SemiUI).GetField("allChildren", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
_misHandleInputMethod = typeof(InventorySpot).GetMethod("HandleInput", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (_misInventorySpotsField == null || _misHandleInputMethod == null)
{
moreInventorySlotsResult = "修复失败: 反射字段未找到";
return;
}
foreach (PluginInfo value in Chainloader.PluginInfos.Values)
{
if (!(value.Metadata.GUID != "nickklmao.moreinventoryslots"))
{
if ((Object)(object)value.Instance != (Object)null)
{
((Behaviour)value.Instance).enabled = false;
}
break;
}
}
MethodInfo method = typeof(Inventory).GetMethod("Awake", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (method != null)
{
harmony.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(typeof(ModsUpPlugin), "MISInventoryAwakePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
MethodInfo method2 = typeof(Inventory).GetMethod("InventorySpotAddAtIndex", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (method2 != null)
{
harmony.Patch((MethodBase)method2, new HarmonyMethod(typeof(ModsUpPlugin), "MISSlotAddPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
MethodInfo method3 = typeof(InventoryUI).GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (method3 != null)
{
harmony.Patch((MethodBase)method3, (HarmonyMethod)null, new HarmonyMethod(typeof(ModsUpPlugin), "MISInventoryUIStartPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
MethodInfo method4 = typeof(ItemEquippable).GetMethod("RPC_RequestEquip", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (method4 != null)
{
harmony.Patch((MethodBase)method4, new HarmonyMethod(typeof(ModsUpPlugin), "MISRequestEquipPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
_misActive = true;
moreInventorySlotsResult = $"修复已应用({_misTargetSlots} 槽位)";
}
catch (Exception ex)
{
moreInventorySlotsResult = "修复失败: " + ex.Message;
}
}
private static void MISInventoryAwakePostfix(Inventory __instance)
{
if (_misTargetSlots > 3 && !((Object)(object)Inventory.instance != (Object)(object)__instance) && _misInventorySpotsField.GetValue(__instance) is IList list)
{
while (list.Count < _misTargetSlots)
{
list.Add(null);
}
}
}
private static void MISSlotAddPrefix(Inventory __instance, int index)
{
if (index >= 3 && _misTargetSlots > 3 && _misInventorySpotsField?.GetValue(__instance) is IList list)
{
while (list.Count <= index)
{
list.Add(null);
}
}
}
private static void MISInventoryUIStartPostfix(InventoryUI __instance)
{
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
if (_misTargetSlots <= 3 || (Object)(object)__instance == (Object)null)
{
return;
}
List<GameObject> list = null;
if (_misAllChildrenField != null)
{
list = _misAllChildrenField.GetValue(__instance) as List<GameObject>;
}
Transform transform = ((Component)__instance).transform;
float num = (float)(-(_misTargetSlots * 40)) / 2f + 20f;
for (int i = 0; i < 3; i++)
{
Transform val = transform.Find($"Inventory Spot {i + 1}");
if ((Object)(object)val != (Object)null)
{
val.localPosition = new Vector3(num + (float)i * 40f, -175.3f, 0f);
}
}
Transform child = transform.GetChild(0);
if ((Object)(object)child == (Object)null)
{
return;
}
for (int j = 3; j < _misTargetSlots; j++)
{
string text = $"Inventory Spot {j + 1}";
Transform val2 = transform.Find(text);
if ((Object)(object)val2 != (Object)null)
{
val2.localPosition = new Vector3(num + (float)j * 40f, -175.3f, 0f);
InventorySpot component = ((Component)val2).GetComponent<InventorySpot>();
if ((Object)(object)component != (Object)null)
{
component.inventorySpotIndex = j;
}
continue;
}
Transform val3 = Object.Instantiate<Transform>(child, child.parent);
((Object)val3).name = text;
InventorySpot component2 = ((Component)val3).GetComponent<InventorySpot>();
if ((Object)(object)component2 != (Object)null)
{
component2.inventorySpotIndex = j;
}
if ((Object)(object)component2 != (Object)null && (Object)(object)component2.noItem != (Object)null)
{
((TMP_Text)component2.noItem).text = (j + 1).ToString();
}
Transform val4 = val3.Find("Numbers");
if ((Object)(object)val4 != (Object)null)
{
TextMeshProUGUI component3 = ((Component)val4).GetComponent<TextMeshProUGUI>();
if ((Object)(object)component3 != (Object)null)
{
((TMP_Text)component3).text = (j + 1).ToString();
}
}
val3.localPosition = new Vector3(num + (float)j * 40f, -175.3f, 0f);
if (list != null && !list.Contains(((Component)val3).gameObject))
{
list.Add(((Component)val3).gameObject);
}
}
}
private static bool MISRequestEquipPrefix(int spotIndex)
{
if (!_misActive || !_misHostProtection)
{
return true;
}
if (!SemiFunc.IsMultiplayer())
{
return true;
}
if (spotIndex < _misTargetSlots)
{
return true;
}
return false;
}
private void ReadMoreInventorySlotsConfig(out int slots, out bool hostProtection)
{
slots = 3;
hostProtection = true;
try
{
string path = Path.Combine(Paths.ConfigPath, "nickklmao.moreinventoryslots.cfg");
if (File.Exists(path))
{
string input = File.ReadAllText(path);
Match match = Regex.Match(input, "(?m)^Number\\s+Of\\s+Slots\\s*=\\s*(\\d+)");
if (match.Success && int.TryParse(match.Groups[1].Value, out var result))
{
slots = result;
}
Match match2 = Regex.Match(input, "(?m)^Host\\s+Protection\\s*=\\s*(true|false)", RegexOptions.IgnoreCase);
if (match2.Success && bool.TryParse(match2.Groups[1].Value, out var result2))
{
hostProtection = result2;
}
}
}
catch
{
}
}
private void HandleMoreInventorySlotsInput()
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
if (!_misActive || _misTargetSlots <= 3 || (Object)(object)Inventory.instance == (Object)null || (Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated || Keyboard.current == null || !(_misInventorySpotsField.GetValue(Inventory.instance) is IList list))
{
return;
}
for (int i = 3; i < _misTargetSlots && i < list.Count; i++)
{
Key val = (Key)((i == 9) ? 50 : (41 + i));
if (((ButtonControl)Keyboard.current[val]).wasPressedThisFrame)
{
object? obj = list[i];
InventorySpot val2 = (InventorySpot)((obj is InventorySpot) ? obj : null);
if ((Object)(object)val2 != (Object)null)
{
_misHandleInputMethod.Invoke(val2, null);
}
}
}
}
private static bool CheckPluginVersion(string guid, string expected, out string detected)
{
detected = null;
foreach (PluginInfo value in Chainloader.PluginInfos.Values)
{
if (value.Metadata.GUID == guid)
{
detected = value.Metadata.Version.ToString();
return detected == expected;
}
}
return false;
}
private static bool TryGetWhitelistedPlugin(string guid, string[] acceptedVersions, out PluginInfo pluginInfo, out string detected)
{
detected = null;
pluginInfo = null;
foreach (PluginInfo value in Chainloader.PluginInfos.Values)
{
if (value.Metadata.GUID != guid)
{
continue;
}
pluginInfo = value;
detected = value.Metadata.Version.ToString();
foreach (string b in acceptedVersions)
{
if (string.Equals(detected, b, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
}
return false;
}
private static FieldInfo ResolveFieldAlias(Type type, params string[] candidateNames)
{
if (type == null || candidateNames == null)
{
return null;
}
foreach (string text in candidateNames)
{
if (!string.IsNullOrWhiteSpace(text))
{
FieldInfo field = type.GetField(text, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
return field;
}
}
}
return null;
}
private static bool IsAppliedResult(string result)
{
if (!string.IsNullOrEmpty(result))
{
if (!(result == "修复已应用") && !result.StartsWith("修复已应用(", StringComparison.Ordinal))
{
return result.StartsWith("白名单兼容已应用", StringComparison.Ordinal);
}
return true;
}
return false;
}
[IteratorStateMachine(typeof(<WaitForMenuAndShowPopup>d__114))]
private IEnumerator WaitForMenuAndShowPopup()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForMenuAndShowPopup>d__114(0)
{
<>4__this = this
};
}
private void Update()
{
if (IsModEnabled() && _misActive)
{
HandleMoreInventorySlotsInput();
}
}
private void LateUpdate()
{
if (IsModEnabled())
{
RunAntiTumbleWhitelistBridge();
EnsureItemsBounceBackDictionaryPopulated();
}
}
private static void RunAntiTumbleWhitelistBridge()
{
if (!_antiTumbleLegacyCompatActive || !IsStaticModEnabled() || (Object)(object)PlayerController.instance == (Object)null || (Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated)
{
return;
}
PlayerAvatar playerAvatarScript = PlayerController.instance.playerAvatarScript;
if ((Object)(object)playerAvatarScript == (Object)null || _atPlayerTumbleField == null)
{
return;
}
PlayerTumble val = null;
try
{
object? value = _atPlayerTumbleField.GetValue(playerAvatarScript);
val = (PlayerTumble)((value is PlayerTumble) ? value : null);
}
catch
{
}
if ((Object)(object)val == (Object)null)
{
return;
}
bool flag = false;
try
{
if (_atIsTumblingField != null)
{
flag = (bool)_atIsTumblingField.GetValue(val);
}
}
catch
{
}
if (ShouldBypassAntiTumbleWhitelistBridge(playerAvatarScript))
{
_atLastLocalTumbleState = flag;
return;
}
try
{
_atTumbleOverrideField?.SetValue(val, false);
}
catch
{
}
try
{
_atTumbleOverrideTimerField?.SetValue(val, 0f);
}
catch
{
}
try
{
_atTumbleInputTimerField?.SetValue(PlayerController.instance, 0f);
}
catch
{
}
if ((Object)(object)TumbleUI.instance != (Object)null)
{
try
{
_atCanExitField?.SetValue(TumbleUI.instance, true);
if (flag != _atLastLocalTumbleState)
{
((Component)TumbleUI.instance).gameObject.SetActive(flag);
}
}
catch
{
}
}
if (!flag && _atLastLocalTumbleState && (Object)(object)playerAvatarScript.physGrabber != (Object)null && _atOverrideSpecialPowersTimerField != null)
{
try
{
_atOverrideSpecialPowersTimerField.SetValue(playerAvatarScript.physGrabber, 0f);
}
catch
{
}
}
_atLastLocalTumbleState = flag;
}
private static bool ShouldBypassAntiTumbleWhitelistBridge(PlayerAvatar playerAvatar)
{
if ((Object)(object)ArenaRace.instance != (Object)null)
{
return true;
}
return IsLocalPlayerSeatedInVehicle(playerAvatar);
}
private static bool IsLocalPlayerSeatedInVehicle(PlayerAvatar playerAvatar)
{
if ((Object)(object)playerAvatar == (Object)null)
{
return false;
}
try
{
return (Object)(object)ItemVehicle.GetVehicleForPlayer(playerAvatar) != (Object)null;
}
catch
{
return false;
}
}
private bool IsModEnabled()
{
if (modEnabled != null)
{
return modEnabled.Value;
}
return false;
}
public static bool IsStaticModEnabled()
{
if ((Object)(object)Instance != (Object)null)
{
return Instance.IsModEnabled();
}
return false;
}
private void BindConfig()
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Expected O, but got Unknown
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Expected O, but got Unknown
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Expected O, but got Unknown
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Expected O, but got Unknown
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Expected O, but got Unknown
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Expected O, but got Unknown
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_02fa: Expected O, but got Unknown
//IL_0334: Unknown result type (might be due to invalid IL or missing references)
//IL_033e: Expected O, but got Unknown
moduleNameInfo = ((BaseUnityPlugin)this).Config.Bind<string>("模组信息", "模组名称", "模组批量修复", new ConfigDescription("", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 1000,
CustomDrawer = DrawInfo,
ReadOnly = true
}
}));
moduleNameInfo.Value = "模组批量修复";
moduleVersionInfo = ((BaseUnityPlugin)this).Config.Bind<string>("模组信息", "模组版本号", "1.0.5", new ConfigDescription("", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 990,
CustomDrawer = DrawInfo,
ReadOnly = true
}
}));
moduleVersionInfo.Value = "1.0.5";
contactInfo = ((BaseUnityPlugin)this).Config.Bind<string>("模组信息", "REPO交流QQ群", "824639225", new ConfigDescription("", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 980,
CustomDrawer = DrawInfo,
ReadOnly = true
}
}));
contactInfo.Value = "824639225";
modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("A.全局设置", "模组启用", true, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 1000
}
}));
showStartupPopup = ((BaseUnityPlugin)this).Config.Bind<bool>("A.全局设置", "启动提示", true, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 890
}
}));
fixBetterMapEnemyRefresh = ((BaseUnityPlugin)this).Config.Bind<bool>("B.BetterMap v1.0.5 修复", "修复怪物刷新", true, new ConfigDescription("需要 BetterMap v1.0.5。开关修改后需重启游戏。", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 900
}
}));
fixAntiTumbleCooldown = ((BaseUnityPlugin)this).Config.Bind<bool>("C.AntiTumble Cooldown v1.1.0 修复", "修复翻滚冷却", true, new ConfigDescription("需要 AntiTumble Cooldown 包版本 v1.1.0。修复 v0.4x 下即时起身失效与相关报错问题。开关修改后需重启游戏。", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 900
}
}));
fixItemsBounceBack = ((BaseUnityPlugin)this).Config.Bind<bool>("D.ItemsBounceBack v1.2.0 修复", "修复物品弹回", true, new ConfigDescription("需要 ItemsBounceBack 白名单版本 " + string.Join("/", ItemsBounceBackWhitelistVersions) + "。开关修改后需重启游戏。", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 900
}
}));
fixMoreInventorySlots = ((BaseUnityPlugin)this).Config.Bind<bool>("E.MoreInventorySlots v1.0.3 修复", "修复扩展背包", true, new ConfigDescription("需要 MoreInventorySlots v1.0.3。开关修改后需重启游戏。", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 900
}
}));
}
private void ResetConfigIfVersionChanged()
{
try
{
string configFilePath = ((BaseUnityPlugin)this).Config.ConfigFilePath;
string text = ReadModVersion(configFilePath);
if (!string.IsNullOrWhiteSpace(text) && !(text == "1.0.5"))
{
((BaseUnityPlugin)this).Config.Clear();
if (File.Exists(configFilePath))
{
File.Delete(configFilePath);
}
((BaseUnityPlugin)this).Config.Reload();
}
}
catch
{
}
}
private static string ReadModVersion(string path)
{
if (!File.Exists(path))
{
return null;
}
Match match = Regex.Match(File.ReadAllText(path), "(?m)^模组版本号\\s*=\\s*(.+?)\\s*$");
if (!match.Success)
{
return null;
}
return match.Groups[1].Value.Trim();
}
private static void DrawInfo(ConfigEntryBase e)
{
GUILayout.Label(e.BoxedValue?.ToString() ?? "", Array.Empty<GUILayoutOption>());
}
}
internal sealed class ConfigurationManagerAttributes
{
public bool? ShowRangeAsPercent;
public Action<ConfigEntryBase> CustomDrawer;
public bool? Browsable;
public string Category;
public object DefaultValue;
public bool? HideDefaultButton;
public bool? HideSettingName;
public string Description;
public string DispName;
public int? Order;
public bool? ReadOnly;
public bool? IsAdvanced;
}