using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dolso;
using Dolso.RiskofOptions;
using HG;
using HG.GeneralSerializer;
using HG.Reflection;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ContentManagement;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ItemBlacklist")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6f255536795a1139dcff6649381ca15d7b55508a")]
[assembly: AssemblyProduct("ItemBlacklist")]
[assembly: AssemblyTitle("ItemBlacklist")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Dolso
{
internal static class log
{
private static ManualLogSource logger;
internal static void start(ManualLogSource logSource)
{
logger = logSource;
}
internal static void start(string name)
{
logger = Logger.CreateLogSource(name);
}
internal static void debug(object data)
{
logger.LogDebug(data);
}
internal static void info(object data)
{
logger.LogInfo(data);
}
internal static void message(object data)
{
logger.LogMessage(data);
}
internal static void warning(object data)
{
logger.LogWarning(data);
}
internal static void error(object data)
{
logger.LogError(data);
}
internal static void fatal(object data)
{
logger.LogFatal(data);
}
internal static void LogError(this ILCursor c, object data)
{
logger.LogError((object)string.Format($"ILCursor failure, skipping: {data}\n{c}"));
}
internal static void LogErrorCaller(this ILCursor c, object data, [CallerMemberName] string callerName = "")
{
logger.LogError((object)string.Format($"ILCursor failure in {callerName}, skipping: {data}\n{c}"));
}
}
internal static class HookManager
{
internal delegate bool ConfigEnabled<T>(ConfigEntry<T> configEntry);
internal const BindingFlags allFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
private static ILHookConfig ilHookConfig = new ILHookConfig
{
ManualApply = true
};
private static HookConfig onHookConfig = new HookConfig
{
ManualApply = true
};
private static readonly ConfigEnabled<bool> boolConfigEnabled = (ConfigEntry<bool> configEntry) => configEntry.Value;
internal static void Hook(Type typeFrom, string methodFrom, Manipulator ilHook)
{
HookInternal(GetMethod(typeFrom, methodFrom), ilHook);
}
internal static void Hook(MethodBase methodFrom, Manipulator ilHook)
{
HookInternal(methodFrom, ilHook);
}
internal static void Hook(Delegate from, Manipulator ilHook)
{
HookInternal(from.Method, ilHook);
}
internal static void Hook<T>(Expression<Action<T>> from, Manipulator ilHook)
{
HookInternal(((MethodCallExpression)from.Body).Method, ilHook);
}
internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook)
{
HookInternal(GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target);
}
internal static void Hook(MethodBase methodFrom, MethodInfo onHook)
{
HookInternal(methodFrom, onHook, null);
}
internal static void Hook(MethodBase methodFrom, Delegate onHook)
{
HookInternal(methodFrom, onHook.Method, onHook.Target);
}
internal static void Hook(Delegate from, Delegate onHook)
{
HookInternal(from.Method, onHook.Method, onHook.Target);
}
internal static void Hook<T>(Expression<Action<T>> from, Delegate onHook)
{
HookInternal(((MethodCallExpression)from.Body).Method, onHook.Method, onHook.Target);
}
internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook, object instance)
{
HookInternal(GetMethod(typeFrom, methodFrom), onHook.Method, instance);
}
internal static void Hook(MethodBase methodFrom, MethodInfo onHook, object target)
{
HookInternal(methodFrom, onHook, target);
}
private static void HookInternal(MethodBase methodFrom, Manipulator ilHook)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
if (methodFrom == null)
{
log.error("null MethodFrom for hook: " + ((Delegate)(object)ilHook).Method.Name);
return;
}
try
{
new ILHook(methodFrom, ilHook, ref ilHookConfig).Apply();
}
catch (Exception ex)
{
log.error($"Failed to apply ILHook: {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
}
}
private static void HookInternal(MethodBase methodFrom, MethodInfo onHook, object target)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
if (methodFrom == null)
{
log.error("null methodFrom for hook: " + onHook.Name);
return;
}
try
{
new Hook(methodFrom, onHook, target, ref onHookConfig).Apply();
}
catch (Exception ex)
{
log.error($"Failed to apply onHook: {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Name}\n{ex}");
}
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Manipulator ilHook)
{
configEntry.AddHookConfig(enabled, GetMethod(typeFrom, methodFrom), ilHook);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Manipulator ilHook)
{
configEntry.AddHookConfig(enabled, methodFrom, ilHook);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Delegate onHook)
{
configEntry.AddHookConfig(enabled, GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Delegate onHook)
{
configEntry.AddHookConfig(enabled, methodFrom, onHook.Method, onHook.Target);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Manipulator ilHook)
{
configEntry.AddHookConfig(boolConfigEnabled, GetMethod(typeFrom, methodFrom), ilHook);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Manipulator ilHook)
{
configEntry.AddHookConfig(boolConfigEnabled, methodFrom, ilHook);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Delegate onHook)
{
configEntry.AddHookConfig(boolConfigEnabled, GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Delegate onHook)
{
configEntry.AddHookConfig(boolConfigEnabled, methodFrom, onHook.Method, onHook.Target);
}
private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Manipulator ilHook)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
if (methodFrom == null)
{
log.error("null MethodFrom for hook: " + ((Delegate)(object)ilHook).Method.Name);
return;
}
try
{
configEntry.AddHookConfig(enabled, (IDetour)new ILHook(methodFrom, ilHook, ref ilHookConfig));
}
catch (Exception ex)
{
log.error($"Failed to ilHook {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
}
}
private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, MethodInfo onHook, object target)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
if (methodFrom == null)
{
log.error("null MethodFrom for hook: " + onHook.Name);
return;
}
try
{
configEntry.AddHookConfig(enabled, (IDetour)new Hook(methodFrom, onHook, target, ref onHookConfig));
}
catch (Exception ex)
{
log.error($"Failed to onHook {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Name}\n{ex}");
}
}
private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, IDetour detour)
{
configEntry.SettingChanged += delegate(object sender, EventArgs args)
{
UpdateHook(detour, enabled(sender as ConfigEntry<T>));
};
if (enabled(configEntry))
{
detour.Apply();
}
}
private static void UpdateHook(IDetour hook, bool enabled)
{
if (enabled)
{
if (!hook.IsApplied)
{
hook.Apply();
}
}
else if (hook.IsApplied)
{
hook.Undo();
}
}
internal static void PriorityFirst()
{
ilHookConfig.Before = new string[1] { "*" };
onHookConfig.Before = new string[1] { "*" };
}
internal static void PriorityLast()
{
ilHookConfig.After = new string[1] { "*" };
onHookConfig.After = new string[1] { "*" };
}
internal static void PriorityNormal()
{
ilHookConfig.Before = null;
onHookConfig.Before = null;
ilHookConfig.After = null;
onHookConfig.After = null;
}
internal static IDetour ManualDetour(Type typeFrom, string methodFrom, Delegate onHook)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Expected O, but got Unknown
try
{
return (IDetour)new Hook((MethodBase)GetMethod(typeFrom, methodFrom), onHook, ref onHookConfig);
}
catch (Exception ex)
{
log.error($"Failed to make onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex}");
}
return null;
}
internal static MethodInfo GetMethod(Type typeFrom, string methodFrom)
{
if (typeFrom == null || methodFrom == null)
{
return null;
}
IEnumerable<MethodInfo> enumerable = from predicate in typeFrom.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
where predicate.Name == methodFrom
select predicate;
if (enumerable.Count() == 1)
{
return enumerable.First();
}
if (enumerable.Count() == 0)
{
log.error($"Failed to find method: {typeFrom}.{methodFrom}");
}
else
{
log.error($"{enumerable.Count()} ambiguous matches found for: {typeFrom}.{methodFrom}");
foreach (MethodInfo item in enumerable)
{
log.error(item);
}
}
return null;
}
internal static MethodInfo GetMethod(Type typeFrom, string methodFrom, params Type[] parameters)
{
if (typeFrom == null || methodFrom == null)
{
return null;
}
MethodInfo? method = typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, parameters, null);
if (method == null)
{
log.error($"Failed to find method: {typeFrom}.{methodFrom}_{parameters.Length}");
}
return method;
}
}
internal static class Utilities
{
private static GameObject _prefabParent;
internal static GameObject CreatePrefab(GameObject gameObject)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
if (!Object.op_Implicit((Object)(object)_prefabParent))
{
_prefabParent = new GameObject("DolsoPrefabs");
Object.DontDestroyOnLoad((Object)(object)_prefabParent);
((Object)_prefabParent).hideFlags = (HideFlags)61;
_prefabParent.SetActive(false);
}
return Object.Instantiate<GameObject>(gameObject, _prefabParent.transform);
}
internal static GameObject CreatePrefab(GameObject gameObject, string name)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
if (!Object.op_Implicit((Object)(object)_prefabParent))
{
_prefabParent = new GameObject("DolsoPrefabs");
Object.DontDestroyOnLoad((Object)(object)_prefabParent);
((Object)_prefabParent).hideFlags = (HideFlags)61;
_prefabParent.SetActive(false);
}
GameObject obj = Object.Instantiate<GameObject>(gameObject, _prefabParent.transform);
((Object)obj).name = name;
return obj;
}
internal static MethodInfo MakeGenericMethod<T>(this Type type, string methodName, params Type[] parameters)
{
return type.GetMethod(methodName, parameters).MakeGenericMethod(typeof(T));
}
internal static MethodInfo MakeGenericGetComponentG<T>() where T : Component
{
return typeof(GameObject).GetMethod("GetComponent", Type.EmptyTypes).MakeGenericMethod(typeof(T));
}
internal static MethodInfo MakeGenericGetComponentC<T>() where T : Component
{
return typeof(Component).GetMethod("GetComponent", Type.EmptyTypes).MakeGenericMethod(typeof(T));
}
internal static AssetBundle LoadAssetBundle(string bundlePathName)
{
AssetBundle result = null;
try
{
result = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), bundlePathName));
}
catch (Exception ex)
{
log.error("Failed to load assetbundle\n" + ex);
}
return result;
}
internal static Obj GetAddressable<Obj>(string addressable) where Obj : Object
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return Addressables.LoadAssetAsync<Obj>((object)addressable).WaitForCompletion();
}
internal static GameObject GetAddressable(string addressable)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return Addressables.LoadAssetAsync<GameObject>((object)addressable).WaitForCompletion();
}
internal static void GetAddressable<Obj>(string addressable, Action<Obj> callback) where Obj : Object
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
AsyncOperationHandle<Obj> val = Addressables.LoadAssetAsync<Obj>((object)addressable);
val.Completed += delegate(AsyncOperationHandle<Obj> a)
{
callback(a.Result);
};
}
internal static void GetAddressable(string addressable, Action<GameObject> callback)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
val.Completed += delegate(AsyncOperationHandle<GameObject> a)
{
callback(a.Result);
};
}
internal static void AddressableAddComp<Comp>(string addressable) where Comp : Component
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
val.Completed += delegate(AsyncOperationHandle<GameObject> a)
{
a.Result.AddComponent<Comp>();
};
}
internal static void AddressableAddComp<Comp>(string addressable, Action<Comp> callback) where Comp : Component
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
val.Completed += delegate(AsyncOperationHandle<GameObject> a)
{
callback(a.Result.AddComponent<Comp>());
};
}
internal static void AddressableAddCompSingle<Comp>(string addressable) where Comp : Component
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
val.Completed += delegate(AsyncOperationHandle<GameObject> a)
{
if (!Object.op_Implicit((Object)(object)a.Result.GetComponent<Comp>()))
{
a.Result.AddComponent<Comp>();
}
};
}
internal static void SetStateConfigIndex(this EntityStateConfiguration stateConfig, string fieldName, string newValue)
{
ref SerializedField[] serializedFields = ref stateConfig.serializedFieldsCollection.serializedFields;
for (int i = 0; i < serializedFields.Length; i++)
{
if (serializedFields[i].fieldName == fieldName)
{
serializedFields[i].fieldValue.stringValue = newValue;
return;
}
}
log.error("failed to find " + fieldName + " for " + ((Object)stateConfig).name);
}
internal static void SetStateConfigIndex(this EntityStateConfiguration stateConfig, string fieldName, Object newValue)
{
ref SerializedField[] serializedFields = ref stateConfig.serializedFieldsCollection.serializedFields;
for (int i = 0; i < serializedFields.Length; i++)
{
if (serializedFields[i].fieldName == fieldName)
{
serializedFields[i].fieldValue.objectValue = newValue;
return;
}
}
log.error("failed to find " + fieldName + " for " + ((Object)stateConfig).name);
}
internal static bool IsKeyDown(this ConfigEntry<KeyboardShortcut> key)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: 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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
KeyboardShortcut value = key.Value;
if (!Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
{
return false;
}
value = key.Value;
foreach (KeyCode modifier in ((KeyboardShortcut)(ref value)).Modifiers)
{
if (!Input.GetKey(modifier))
{
return false;
}
}
return true;
}
internal static bool IsKeyJustPressed(this ConfigEntry<KeyboardShortcut> key)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: 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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
KeyboardShortcut value = key.Value;
if (!Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey))
{
return false;
}
value = key.Value;
foreach (KeyCode modifier in ((KeyboardShortcut)(ref value)).Modifiers)
{
if (!Input.GetKey(modifier))
{
return false;
}
}
return true;
}
internal static bool ContainsString(string source, string value)
{
return CultureInfo.InvariantCulture.CompareInfo.IndexOf(source, value, CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols) >= 0;
}
}
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
internal class HookAttribute : Attribute
{
private readonly MethodInfo from;
internal HookAttribute(Type typeFrom, string methodFrom)
{
from = HookManager.GetMethod(typeFrom, methodFrom);
}
internal HookAttribute(Type typeFrom, string methodFrom, params Type[] parameters)
{
from = HookManager.GetMethod(typeFrom, methodFrom, parameters);
}
internal static void ScanAndApply()
{
ScanAndApply(Assembly.GetExecutingAssembly().GetTypes());
}
internal static void ScanAndApply(params Type[] types)
{
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Expected O, but got Unknown
for (int i = 0; i < types.Length; i++)
{
MethodInfo[] methods = types[i].GetMethods(BindingFlags.Static | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
if (!methodInfo.IsDefined(typeof(HookAttribute)))
{
continue;
}
try
{
foreach (HookAttribute customAttribute in methodInfo.GetCustomAttributes<HookAttribute>(inherit: false))
{
ParameterInfo[] parameters = methodInfo.GetParameters();
if (parameters.Length == 1 && parameters[0].ParameterType == typeof(ILContext))
{
HookManager.Hook(customAttribute.from, (Manipulator)methodInfo.CreateDelegate(typeof(Manipulator)));
}
else
{
HookManager.Hook(customAttribute.from, methodInfo);
}
}
}
catch (Exception arg)
{
log.error($"Failed to do HookAttribute on: {methodInfo.DeclaringType}.{methodInfo.Name}\n\n{arg}");
}
}
}
}
}
}
namespace Dolso.RiskofOptions
{
internal static class RiskofOptions
{
internal const string rooGuid = "com.rune580.riskofoptions";
internal static bool enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
internal static void SetSprite(Sprite sprite)
{
ModSettingsManager.SetModIcon(sprite);
}
internal static void SetSpriteDefaultIcon()
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
string path = ((!(directoryInfo.Name == "plugins")) ? directoryInfo.FullName : directoryInfo.Parent.FullName);
try
{
Texture2D val = new Texture2D(256, 256);
if (ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(path, "icon.png"))))
{
ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)));
}
else
{
log.error("Failed to load icon.png");
}
}
catch (Exception ex)
{
log.error("Failed to load icon.png\n" + ex);
}
}
internal static void AddBool(ConfigEntry<bool> entry)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
{
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddBool(ConfigEntry<bool> entry, string categoryName, string name)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
{
category = categoryName,
name = name,
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddBool(ConfigEntry<bool> entry, string categoryName)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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_001e: Expected O, but got Unknown
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
{
category = categoryName,
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddEnum<T>(ConfigEntry<T> entry) where T : Enum
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)entry, new ChoiceConfig
{
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddColor(ConfigEntry<Color> entry)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new ColorOption(entry, new ColorOptionConfig
{
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddKey(ConfigEntry<KeyboardShortcut> entry)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry, new KeyBindConfig
{
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddFloat(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}")
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig
{
min = min,
max = max,
FormatString = format,
description = ((ConfigEntryBase)(object)entry).DescWithDefault(format)
}));
}
internal static void AddFloat(ConfigEntry<float> entry, string categoryName, float min, float max, string format = "{0:f2}")
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig
{
min = min,
max = max,
FormatString = format,
category = categoryName,
description = ((ConfigEntryBase)(object)entry).DescWithDefault(format)
}));
}
internal static void AddFloatField(ConfigEntry<float> entry, float min = float.MinValue, float max = float.MaxValue, string format = "{0:f2}")
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
FloatFieldConfig val = new FloatFieldConfig();
((NumericFieldConfig<float>)val).Min = min;
((NumericFieldConfig<float>)val).Max = max;
((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault(format);
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(entry, val));
}
internal static void AddInt(ConfigEntry<int> entry, int min = int.MinValue, int max = int.MaxValue)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
IntFieldConfig val = new IntFieldConfig();
((NumericFieldConfig<int>)val).Min = min;
((NumericFieldConfig<int>)val).Max = max;
((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault();
ModSettingsManager.AddOption((BaseOption)new IntFieldOption(entry, val));
}
internal static void AddIntSlider(ConfigEntry<int> entry, int min, int max)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig
{
min = min,
max = max,
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddIntSlider(ConfigEntry<int> entry, string categoryName, int min, int max)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig
{
min = min,
max = max,
category = categoryName,
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddString(ConfigEntry<string> entry, bool restartRequired = false)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: 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_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: 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_002c: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(entry, new InputFieldConfig
{
submitOn = (SubmitEnum)6,
lineType = (LineType)0,
description = ((ConfigEntryBase)(object)entry).DescWithDefault(),
restartRequired = restartRequired
}));
}
internal static void AddString(ConfigEntry<string> entry, string categoryName, bool restartRequired = false)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: 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_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(entry, new InputFieldConfig
{
submitOn = (SubmitEnum)6,
lineType = (LineType)0,
category = categoryName,
description = ((ConfigEntryBase)(object)entry).DescWithDefault(),
restartRequired = restartRequired
}));
}
internal static void AddOption(ConfigEntry<bool> entry)
{
AddBool(entry);
}
internal static void AddOption(ConfigEntry<bool> entry, string categoryName, string name)
{
AddBool(entry, categoryName, name);
}
internal static void AddOption(ConfigEntry<bool> entry, string categoryName)
{
AddBool(entry, categoryName);
}
internal static void AddOption<T>(ConfigEntry<T> entry) where T : Enum
{
AddEnum<T>(entry);
}
internal static void AddOption(ConfigEntry<Color> entry)
{
AddColor(entry);
}
internal static void AddOption(ConfigEntry<KeyboardShortcut> entry)
{
AddKey(entry);
}
internal static void AddOption(ConfigEntry<int> entry)
{
AddInt(entry);
}
internal static void AddOption(ConfigEntry<string> entry)
{
AddString(entry);
}
private static string DescWithDefault(this ConfigEntryBase entry)
{
return $"{entry.Description.Description}\n[Default: {entry.DefaultValue}]";
}
private static string DescWithDefault(this ConfigEntryBase entry, string format)
{
return string.Format("{1}\n[Default: " + format + "]", entry.DefaultValue, entry.Description.Description);
}
}
}
namespace ItemBlacklist
{
internal static class Commands
{
[ConCommand(/*Could not decode attribute arguments.*/)]
private static void CCWhitelist(ConCommandArgs args)
{
//IL_002d: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: 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_009b: 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_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)Run.instance))
{
Debug.LogError((object)"Must be in a run");
return;
}
if (((ConCommandArgs)(ref args)).Count == 0)
{
Debug.Log((object)"--- Printing whitelist ---");
GenericStaticEnumerable<ItemIndex, AllItemsEnumerator> allItems = ItemCatalog.allItems;
AllItemsEnumerator enumerator = allItems.GetEnumerator();
try
{
while (((AllItemsEnumerator)(ref enumerator)).MoveNext())
{
ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current;
if (current.IsDropableTier() && Run.instance.availableItems.Contains(current))
{
Debug.Log((object)Language.GetString(ItemCatalog.GetItemDef(current).nameToken));
}
}
}
finally
{
((IDisposable)(AllItemsEnumerator)(ref enumerator)).Dispose();
}
GenericStaticEnumerable<EquipmentIndex, AllEquipmentEnumerator> allEquipment = EquipmentCatalog.allEquipment;
AllEquipmentEnumerator enumerator2 = allEquipment.GetEnumerator();
try
{
while (((AllEquipmentEnumerator)(ref enumerator2)).MoveNext())
{
EquipmentIndex current2 = ((AllEquipmentEnumerator)(ref enumerator2)).Current;
if (EquipmentCatalog.GetEquipmentDef(current2).canDrop && Run.instance.availableEquipment.Contains(current2))
{
Debug.Log((object)Language.GetString(EquipmentCatalog.GetEquipmentDef(current2).nameToken));
}
}
return;
}
finally
{
((IDisposable)(AllEquipmentEnumerator)(ref enumerator2)).Dispose();
}
}
string text = "";
for (int i = 0; i < ((ConCommandArgs)(ref args)).Count; i++)
{
text += ((ConCommandArgs)(ref args))[i];
}
List<ItemDef> itemDefs = ItemBlacklist.GetItemDefs(text, englishOnly: false);
if (itemDefs.Count > 0)
{
foreach (ItemDef item in itemDefs)
{
Run.instance.EnableItemDrop(item.itemIndex);
Debug.Log((object)("<color=green>Enabled: " + Language.GetString(item.nameToken) + "</color>"));
}
return;
}
List<EquipmentDef> equipDefs = ItemBlacklist.GetEquipDefs(text, englishOnly: false);
if (equipDefs.Count > 0)
{
foreach (EquipmentDef item2 in equipDefs)
{
Run.instance.EnableEquipmentDrop(item2.equipmentIndex);
Debug.Log((object)("<color=green>Enabled: " + Language.GetString(item2.nameToken) + "</color>"));
}
return;
}
Debug.LogError((object)("Failed to find " + text));
}
[ConCommand(/*Could not decode attribute arguments.*/)]
private static void CCBlacklist(ConCommandArgs args)
{
//IL_002d: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: 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_009b: 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_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)Run.instance))
{
Debug.LogError((object)"Must be in a run");
return;
}
if (((ConCommandArgs)(ref args)).Count == 0)
{
Debug.Log((object)"--- Printing blacklist ---");
GenericStaticEnumerable<ItemIndex, AllItemsEnumerator> allItems = ItemCatalog.allItems;
AllItemsEnumerator enumerator = allItems.GetEnumerator();
try
{
while (((AllItemsEnumerator)(ref enumerator)).MoveNext())
{
ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current;
if (current.IsDropableTier() && !Run.instance.availableItems.Contains(current))
{
Debug.Log((object)Language.GetString(ItemCatalog.GetItemDef(current).nameToken));
}
}
}
finally
{
((IDisposable)(AllItemsEnumerator)(ref enumerator)).Dispose();
}
GenericStaticEnumerable<EquipmentIndex, AllEquipmentEnumerator> allEquipment = EquipmentCatalog.allEquipment;
AllEquipmentEnumerator enumerator2 = allEquipment.GetEnumerator();
try
{
while (((AllEquipmentEnumerator)(ref enumerator2)).MoveNext())
{
EquipmentIndex current2 = ((AllEquipmentEnumerator)(ref enumerator2)).Current;
if (EquipmentCatalog.GetEquipmentDef(current2).canDrop && !Run.instance.availableEquipment.Contains(current2))
{
Debug.Log((object)Language.GetString(EquipmentCatalog.GetEquipmentDef(current2).nameToken));
}
}
return;
}
finally
{
((IDisposable)(AllEquipmentEnumerator)(ref enumerator2)).Dispose();
}
}
string text = "";
for (int i = 0; i < ((ConCommandArgs)(ref args)).Count; i++)
{
text += ((ConCommandArgs)(ref args))[i];
}
List<ItemDef> itemDefs = ItemBlacklist.GetItemDefs(text, englishOnly: false);
if (itemDefs.Count > 0)
{
foreach (ItemDef item in itemDefs)
{
Run.instance.DisableItemDrop(item.itemIndex);
Debug.Log((object)("<color=green>Disabled: " + Language.GetString(item.nameToken) + "</color>"));
}
return;
}
List<EquipmentDef> equipDefs = ItemBlacklist.GetEquipDefs(text, englishOnly: false);
if (equipDefs.Count > 0)
{
foreach (EquipmentDef item2 in equipDefs)
{
Run.instance.DisableEquipmentDrop(item2.equipmentIndex);
Debug.Log((object)("<color=green>Disabled: " + Language.GetString(item2.nameToken) + "</color>"));
}
return;
}
Debug.LogError((object)("Failed to find " + text));
}
[ConCommand(/*Could not decode attribute arguments.*/)]
private static void CCPrinterWhitelist(ConCommandArgs args)
{
//IL_0013: 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_001b: 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_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: 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)
if (((ConCommandArgs)(ref args)).Count == 0)
{
Debug.Log((object)"--- Printing whitelist ---");
GenericStaticEnumerable<ItemIndex, AllItemsEnumerator> allItems = ItemCatalog.allItems;
AllItemsEnumerator enumerator = allItems.GetEnumerator();
try
{
while (((AllItemsEnumerator)(ref enumerator)).MoveNext())
{
ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current;
if (current.IsDropableTier() && !ItemBlacklist.printerBlacklist.Contains(PickupCatalog.FindPickupIndex(current)))
{
Debug.Log((object)Language.GetString(ItemCatalog.GetItemDef(current).nameToken));
}
}
return;
}
finally
{
((IDisposable)(AllItemsEnumerator)(ref enumerator)).Dispose();
}
}
string text = "";
for (int i = 0; i < ((ConCommandArgs)(ref args)).Count; i++)
{
text += ((ConCommandArgs)(ref args))[i];
}
List<ItemDef> itemDefs = ItemBlacklist.GetItemDefs(text, englishOnly: false);
if (itemDefs.Count == 0)
{
Debug.LogError((object)("Failed to find " + text));
return;
}
foreach (ItemDef item2 in itemDefs)
{
PickupIndex item = PickupCatalog.FindPickupIndex(item2.itemIndex);
ItemBlacklist.printerBlacklist.Remove(item);
Debug.Log((object)("<color=green>Enabled: " + Language.GetString(item2.nameToken) + " for printers</color>"));
}
if (!Object.op_Implicit((Object)(object)Run.instance))
{
return;
}
foreach (PickupDropTable instances in PickupDropTable.instancesList)
{
BasicPickupDropTable val = (BasicPickupDropTable)(object)((instances is BasicPickupDropTable) ? instances : null);
if (val != null)
{
((PickupDropTable)val).Regenerate(Run.instance);
}
}
}
[ConCommand(/*Could not decode attribute arguments.*/)]
private static void CCPrinterBlacklist(ConCommandArgs args)
{
//IL_0022: 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)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
if (((ConCommandArgs)(ref args)).Count == 0)
{
Debug.Log((object)"--- Printing blacklist ---");
{
foreach (PickupIndex item2 in ItemBlacklist.printerBlacklist)
{
Debug.Log((object)Language.GetString(PickupCatalog.GetPickupDef(item2).nameToken));
}
return;
}
}
string text = "";
for (int i = 0; i < ((ConCommandArgs)(ref args)).Count; i++)
{
text += ((ConCommandArgs)(ref args))[i];
}
List<ItemDef> itemDefs = ItemBlacklist.GetItemDefs(text, englishOnly: false);
if (itemDefs.Count == 0)
{
Debug.LogError((object)("Failed to find " + text));
return;
}
foreach (ItemDef item3 in itemDefs)
{
PickupIndex item = PickupCatalog.FindPickupIndex(item3.itemIndex);
if (!ItemBlacklist.printerBlacklist.Contains(item))
{
ItemBlacklist.printerBlacklist.Add(item);
}
Debug.Log((object)("<color=green>Disabled: " + Language.GetString(item3.nameToken) + " for printers</color>"));
}
if (!Object.op_Implicit((Object)(object)Run.instance))
{
return;
}
foreach (PickupDropTable instances in PickupDropTable.instancesList)
{
BasicPickupDropTable val = (BasicPickupDropTable)(object)((instances is BasicPickupDropTable) ? instances : null);
if (val != null)
{
((PickupDropTable)val).Regenerate(Run.instance);
}
}
}
private static bool IsDropableTier(this ItemIndex itemindex)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(ItemCatalog.GetItemDef(itemindex).tier);
if (Object.op_Implicit((Object)(object)itemTierDef))
{
return itemTierDef.isDroppable;
}
return false;
}
}
public static class DropRate
{
private static readonly Dictionary<PickupIndex, float> pickupChance = new Dictionary<PickupIndex, float>();
public static void ApplyDropRateConfig()
{
//IL_006d: 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_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Invalid comparison between Unknown and I4
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Invalid comparison between Unknown and I4
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: 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_0095: 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_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: 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)
pickupChance.Clear();
string[] array = ItemBlacklist.CreateStringArray(IBConfig.dropRates.Value);
foreach (string text in array)
{
if (string.IsNullOrEmpty(text))
{
continue;
}
string[] array2 = text.Split('=', StringSplitOptions.RemoveEmptyEntries);
if (array2.Length != 2 || !float.TryParse(array2[1], out var result))
{
log.warning("\"" + text + "\" is an invalid format");
continue;
}
string text2 = array2[0];
ItemIndex val = ItemCatalog.FindItemIndex(text2);
PickupIndex val2;
if ((int)val != -1)
{
val2 = PickupCatalog.FindPickupIndex(val);
}
else
{
EquipmentIndex val3 = EquipmentCatalog.FindEquipmentIndex(text2);
if ((int)val3 != -1)
{
val2 = PickupCatalog.FindPickupIndex(val3);
}
else
{
val2 = PickupCatalog.FindPickupIndex(text2);
if (!(val2 != PickupIndex.none))
{
foreach (PickupDef allPickup in PickupCatalog.allPickups)
{
if (allPickup.nameToken == null || !Utilities.ContainsString(ItemBlacklist.ReformatString(Language.GetString(allPickup.nameToken, "en")), text2))
{
continue;
}
val2 = allPickup.pickupIndex;
goto IL_012d;
}
log.warning("failed to find a match for " + text);
continue;
}
}
}
goto IL_012d;
IL_012d:
if (!pickupChance.ContainsKey(val2))
{
pickupChance.Add(val2, result);
log.message($"Found {GetPickupName(val2)} = {result}");
continue;
}
log.warning("duplicate " + GetPickupName(val2) + " from " + text + ", ignoring");
}
if (Object.op_Implicit((Object)(object)Run.instance))
{
PickupDropTable.RegenerateAll(Run.instance);
Debug.Log((object)"Regenerated drop tables");
}
}
private static string GetPickupName(PickupIndex index)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return Language.GetString(PickupCatalog.GetPickupDef(index).nameToken);
}
public static void ModifySelector(WeightedSelection<PickupIndex> selector)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
if (pickupChance.Count == 0)
{
return;
}
if (selector == null)
{
log.warning("null selector");
return;
}
bool flag = false;
for (int i = 0; i < selector.Count; i++)
{
if (pickupChance.TryGetValue(selector.choices[i].value, out var value))
{
selector.choices[i].weight *= value;
flag = true;
}
}
if (flag)
{
selector.RecalculateTotalWeight();
}
}
public static WeightedSelection<PickupIndex> GetSelector(PickupDropTable table)
{
BasicPickupDropTable val = (BasicPickupDropTable)(object)((table is BasicPickupDropTable) ? table : null);
if (val == null)
{
ArenaMonsterItemDropTable val2 = (ArenaMonsterItemDropTable)(object)((table is ArenaMonsterItemDropTable) ? table : null);
if (val2 == null)
{
DoppelgangerDropTable val3 = (DoppelgangerDropTable)(object)((table is DoppelgangerDropTable) ? table : null);
if (val3 == null)
{
ExplicitPickupDropTable val4 = (ExplicitPickupDropTable)(object)((table is ExplicitPickupDropTable) ? table : null);
if (val4 == null)
{
return ((FreeChestDropTable)(((table is FreeChestDropTable) ? table : null)?)).selector;
}
return val4.weightedSelection;
}
return val3.selector;
}
return val2.selector;
}
return val.selector;
}
}
internal static class Hooks
{
[Hook(typeof(LocalUserBallotPersistenceManager), "OnLocalUserSignIn")]
private static void On_PreGameRuleVoteManager_OnLocalUserSignIn_SignedIn(Action<LocalUser> orig, LocalUser localUser)
{
orig(localUser);
Vote[] array = PreGameRuleVoteController.CreateBallot();
foreach (string item in ItemBlacklist.BuildItemRules().Concat(ItemBlacklist.BuildEquipRules()))
{
RuleDef val = RuleCatalog.FindRuleDef(item);
if (val != null)
{
((Vote)(ref array[val.globalIndex])).choiceValue = 1;
}
}
LocalUserBallotPersistenceManager.votesCache[localUser] = array;
}
[Hook(typeof(RuleDef), "FromItem")]
private static RuleDef On_RuleDef_FromItem_FixItemRules(Func<ItemIndex, RuleDef> orig, ItemIndex itemIndex)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got I4
//IL_0032->IL0032: Incompatible stack types: O vs I4
//IL_002c->IL0032: Incompatible stack types: I4 vs O
//IL_002c->IL0032: Incompatible stack types: O vs I4
object obj = orig(itemIndex);
ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
string pickupToken = itemDef.pickupToken;
ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(itemDef.tier);
int num;
if ((Object)(object)itemTierDef != (Object)null)
{
obj = itemTierDef.darkColorIndex;
num = (int)obj;
}
else
{
num = 10;
obj = num;
num = (int)obj;
}
Color tooltipNameColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)obj));
RuleChoiceDef obj2 = ((RuleDef)num).FindChoice("On");
obj2.tooltipBodyToken = pickupToken;
obj2.tooltipNameColor = tooltipNameColor;
RuleChoiceDef obj3 = ((RuleDef)num).FindChoice("Off");
obj3.tooltipBodyToken = pickupToken;
obj3.tooltipNameColor = tooltipNameColor;
return (RuleDef)(object)num;
}
[Hook(typeof(RuleDef), "FromEquipment")]
private static RuleDef On_RuleDef_FromEquipment_FixEquipRules(Func<EquipmentIndex, RuleDef> orig, EquipmentIndex equipIndex)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: 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_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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)
RuleDef obj = orig(equipIndex);
EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(equipIndex);
string pickupToken = equipmentDef.pickupToken;
Color tooltipNameColor = Color32.op_Implicit(ColorCatalog.GetColor(equipmentDef.colorIndex)) * new Color(0.75f, 0.75f, 0.75f);
RuleChoiceDef obj2 = obj.FindChoice("On");
obj2.tooltipBodyToken = pickupToken;
obj2.tooltipNameColor = tooltipNameColor;
RuleChoiceDef obj3 = obj.FindChoice("Off");
obj3.spritePath = "Textures/MiscIcons/texUnlockIcon";
obj3.tooltipBodyToken = pickupToken;
obj3.tooltipNameColor = tooltipNameColor;
return obj;
}
[Hook(typeof(BasicPickupDropTable), "GenerateWeightedSelection")]
private static void On_BasicPickupDropTable_GenerateWeightedSelection_FilterPrinters(Action<BasicPickupDropTable, Run> orig, BasicPickupDropTable self, Run run)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
orig(self, run);
if (ItemBlacklist.printerBlacklist.Count <= 0 || !((Object)self).name.StartsWith("dtDuplicator"))
{
return;
}
for (int num = self.selector.Count - 1; num >= 0; num--)
{
if (ItemBlacklist.printerBlacklist.Contains(self.selector.choices[num].value))
{
self.selector.RemoveChoice(num);
}
}
}
[Hook(typeof(BossGroup), "DropRewards")]
private static void On_BossGroup_DropRewards_Blacklist(Action<BossGroup> orig, BossGroup self)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
//IL_0097: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)Run.instance))
{
orig(self);
return;
}
if (self.bossDropTables != null)
{
int num = 0;
while (num < self.bossDropTables.Count)
{
ExplicitPickupDropTable val = (ExplicitPickupDropTable)self.bossDropTables[num];
Object pickupDef = val.pickupEntries[0].pickupDef;
ItemDef val2 = (ItemDef)(object)((pickupDef is ItemDef) ? pickupDef : null);
if (Object.op_Implicit((Object)(object)val2) && !Run.instance.IsItemAvailable(val2.itemIndex))
{
self.bossDropTables.Remove((PickupDropTable)(object)val);
}
else
{
num++;
}
}
}
if (self.bossDrops != null)
{
int num2 = 0;
while (num2 < self.bossDrops.Count)
{
PickupIndex val3 = self.bossDrops[num2];
log.info("Removed bossdrop " + Language.GetString(PickupCatalog.GetPickupDef(val3).nameToken));
if (!Run.instance.IsPickupAvailable(val3))
{
self.bossDrops.Remove(val3);
}
else
{
num2++;
}
}
}
orig(self);
}
[Hook(typeof(EquipmentSlot), "FireBossHunter")]
private static void IL_EquipmentSlot_FireBossHunter_ReplaceHunterReward(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
ILCursor val = new ILCursor(il);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<PickupDropTable>(a, "GenerateDrop")
}))
{
val.EmitDelegate<Func<PickupIndex, PickupIndex>>((Func<PickupIndex, PickupIndex>)delegate(PickupIndex pickupIndex)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
if (Run.instance.IsPickupAvailable(pickupIndex))
{
return pickupIndex;
}
BasicPickupDropTable obj = LegacyResourcesAPI.Load<BasicPickupDropTable>("DropTables/dtDuplicatorWild");
log.info("Replacing banned boss drop with a random boss item");
PickupIndex val2 = ((PickupDropTable)obj).GenerateDrop(Run.instance.treasureRng);
if (val2 != PickupIndex.none)
{
return val2;
}
log.info("No pickup found, dropping pearl instead");
return PickupCatalog.FindPickupIndex(Items.ShinyPearl.itemIndex);
});
}
else
{
val.LogErrorCaller("Failed to find GenerateDrop", "IL_EquipmentSlot_FireBossHunter_ReplaceHunterReward");
}
}
internal static void IL_HalcyoniteShrineInteractable_DropRewards_BetterDropTable(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchStfld(a, typeof(CreatePickupInfo), "pickerOptions")
}))
{
ILLabel val2 = val.MarkLabel();
int num = default(int);
if (val.TryGotoPrev(new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, typeof(CreatePickupInfo), "set_pickupIndex")
}) && val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchLdloca(a, ref num)
}))
{
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<HalcyoniteShrineInteractable, Option[]>>((Func<HalcyoniteShrineInteractable, Option[]>)((HalcyoniteShrineInteractable self) => PickupPickerController.GenerateOptionsFromDropTable(self.rewardOptionCount, (PickupDropTable)(object)self.halcyoniteDropTableTier3, self.rng)));
val.Emit(OpCodes.Br, (object)val2);
val.GotoLabel(val2, (MoveType)0, false);
val.Emit(OpCodes.Pop);
}
else
{
val.LogErrorCaller("failed find pickupIndex", "IL_HalcyoniteShrineInteractable_DropRewards_BetterDropTable");
}
}
else
{
val.LogErrorCaller("failed find pickerOptions", "IL_HalcyoniteShrineInteractable_DropRewards_BetterDropTable");
}
}
[Hook(typeof(Run), "EnableItemDrop")]
private static void IL_Run_EnableItemDrop_Fix(ILContext il)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_0095: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
int refreshLunarsFlagIndex = 1;
if (!val.TryGotoNext(new Func<Instruction, bool>[2]
{
(Instruction a) => ILPatternMatchingExt.MatchLdcI4(a, 0),
(Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref refreshLunarsFlagIndex)
}) || !val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchLdfld<Run>(a, "availableLunarItemDropList")
}))
{
val.LogErrorCaller("failed to find lunar", "IL_Run_EnableItemDrop_Fix");
}
val.Emit(OpCodes.Ldc_I4_1);
val.Emit(OpCodes.Stloc, refreshLunarsFlagIndex);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, (MethodBase)typeof(List<PickupIndex>).GetMethod("Add"))
}))
{
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldfld, typeof(Run).GetField("availableItems"));
val.Emit(OpCodes.Ldarg_1);
val.Emit(OpCodes.Callvirt, (MethodBase)typeof(ItemMask).GetMethod("Add"));
}
else
{
val.LogErrorCaller("failed to find list.Add", "IL_Run_EnableItemDrop_Fix");
}
}
[Hook(typeof(Run), "DisableItemDrop")]
private static void IL_Run_DisableItemDrop_Fix(ILContext il)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_0095: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
int refreshLunarsFlagIndex = 1;
if (!val.TryGotoNext(new Func<Instruction, bool>[2]
{
(Instruction a) => ILPatternMatchingExt.MatchLdcI4(a, 0),
(Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref refreshLunarsFlagIndex)
}) || !val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchLdfld<Run>(a, "availableLunarItemDropList")
}))
{
val.LogErrorCaller("failed to find lunar", "IL_Run_DisableItemDrop_Fix");
}
val.Emit(OpCodes.Ldc_I4_1);
val.Emit(OpCodes.Stloc, refreshLunarsFlagIndex);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, (MethodBase)typeof(List<PickupIndex>).GetMethod("Remove"))
}))
{
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldfld, typeof(Run).GetField("availableItems"));
val.Emit(OpCodes.Ldarg_1);
val.Emit(OpCodes.Callvirt, (MethodBase)typeof(ItemMask).GetMethod("Remove"));
val.Emit(OpCodes.Pop);
}
else
{
val.LogErrorCaller("failed to find list.remove", "IL_Run_DisableItemDrop_Fix");
}
}
[Hook(typeof(Run), "EnableEquipmentDrop")]
private static void IL_Run_EnableEquipmentDrop_Fix(ILContext il)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_0095: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
int refreshLunarsFlagIndex = 1;
if (!val.TryGotoNext(new Func<Instruction, bool>[2]
{
(Instruction a) => ILPatternMatchingExt.MatchLdcI4(a, 0),
(Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref refreshLunarsFlagIndex)
}) || !val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchLdfld<Run>(a, "availableLunarEquipmentDropList")
}))
{
val.LogErrorCaller("failed to find lunar", "IL_Run_EnableEquipmentDrop_Fix");
}
val.Emit(OpCodes.Ldc_I4_1);
val.Emit(OpCodes.Stloc, refreshLunarsFlagIndex);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, (MethodBase)typeof(List<PickupIndex>).GetMethod("Add"))
}))
{
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldfld, typeof(Run).GetField("availableEquipment"));
val.Emit(OpCodes.Ldarg_1);
val.Emit(OpCodes.Callvirt, (MethodBase)typeof(EquipmentMask).GetMethod("Add"));
}
else
{
val.LogErrorCaller("failed to find list.Add", "IL_Run_EnableEquipmentDrop_Fix");
}
}
[Hook(typeof(RuleCategoryController), "SetData")]
private static void IL_RuleCategoryController_SetData_ScaleSize(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, (MethodBase)Utilities.MakeGenericGetComponentC<GridLayoutGroup>())
}))
{
val.Emit(OpCodes.Dup);
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Action<GridLayoutGroup, RuleCategoryController>>((Action<GridLayoutGroup, RuleCategoryController>)delegate(GridLayoutGroup grid, RuleCategoryController self)
{
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Expected O, but got Unknown
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: 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_008b: Unknown result type (might be due to invalid IL or missing references)
int count = self.currentCategory.children.Count;
if (self.currentCategory != null && (float)count > 144f && grid.constraintCount == 9)
{
int num2 = (grid.constraintCount = (int)Math.Sqrt(1.7777778f * (float)count));
((LayoutGroup)grid).childAlignment = (TextAnchor)1;
float num3 = 64f * (float)Math.Sqrt(144f / (float)count);
RectTransform component = ((Component)self.popoutPanelInstance).GetComponent<RectTransform>();
grid.cellSize = num3 * Vector2.one;
component.sizeDelta = new Vector2(num3 * ((float)num2 - 9f), 0f);
}
if (self.currentCategory != null && self.currentCategory.subtitleToken == "RULE_HEADER_ITEMSANDEQUIPMENT_SUBTITLE")
{
GameObject obj = Object.Instantiate<GameObject>(ItemBlacklist.buttonPrefab, ((Component)self.popoutPanelInstance).transform.Find("Canvas/Main"));
HGButton component2 = obj.GetComponent<HGButton>();
((UnityEvent)((Button)component2).onClick).AddListener(new UnityAction(ItemBlacklist.SaveFromVotes));
((MPButton)component2).selectOnPointerEnter = false;
HGTextMeshProUGUI obj2 = ((Component)obj.transform.Find("Text")).gameObject.AddComponent<HGTextMeshProUGUI>();
((TMP_Text)obj2).fontSize = 24f;
((TMP_Text)obj2).outlineColor = Color32.op_Implicit(Color.black);
((TMP_Text)obj2).enableWordWrapping = false;
((TMP_Text)obj2).alignment = (TextAlignmentOptions)514;
((TMP_Text)obj2).text = "Save to config";
}
});
}
else
{
val.LogErrorCaller("failed find GridLayoutGroup", "IL_RuleCategoryController_SetData_ScaleSize");
}
}
[Hook(typeof(DoppelgangerDropTable), "GenerateWeightedSelection")]
[Hook(typeof(ExplicitPickupDropTable), "GenerateWeightedSelection")]
private static void On_Modify_PickupDropTable_GenerateWeightedSelection_Modify(Action<PickupDropTable> orig, PickupDropTable self)
{
orig(self);
DropRate.ModifySelector(DropRate.GetSelector(self));
}
[Hook(typeof(ArenaMonsterItemDropTable), "GenerateWeightedSelection")]
[Hook(typeof(BasicPickupDropTable), "GenerateWeightedSelection")]
private static void On_PickupDropTableRun_GenerateWeightedSelection_Modify(Action<PickupDropTable, Run> orig, PickupDropTable self, Run run)
{
orig(self, run);
DropRate.ModifySelector(DropRate.GetSelector(self));
}
[Hook(typeof(FreeChestDropTable), "GenerateDropPreReplacement")]
private static void IL_FreeChest_GenerateDropPreReplacement_Modify(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0038: 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)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, typeof(PickupDropTable), "GenerateDropFromWeightedSelection")
}))
{
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldfld, typeof(FreeChestDropTable).GetField("selector", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
val.Emit(OpCodes.Call, (MethodBase)typeof(DropRate).GetMethod("ModifySelector", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
}
else
{
val.LogErrorCaller("", "IL_FreeChest_GenerateDropPreReplacement_Modify");
}
}
}
internal static class IBConfig
{
private static ConfigFile configFile;
internal static ConfigEntry<string> ibItemDefaults;
internal static ConfigEntry<string> ibEquipDefaults;
internal static ConfigEntry<string> ibPrinterBlacklist;
internal static ConfigEntry<string> dropRates;
internal static ConfigEntry<bool> modifyHalcyoniteDropTables;
internal static void DoConfig(ConfigFile bepConfigFile)
{
configFile = bepConfigFile;
ibItemDefaults = configFile.Bind<string>("Default blacklist", "Items", "", "Items listed here will be disabled by default.\nCase insensitive, partial names allowed, seperated by commas, and engligh only.\nIf using internal item names they must match fully, use the item_list command to view them.\nExample: Old Guillotine, Empathy Cor,gesture, ShieldOnly");
ibEquipDefaults = configFile.Bind<string>("Default blacklist", "Equipments", "", "Equipments listed here will be disabled by default.\nCase insensitive, partial names allowed, seperated by commas, and engligh only.\nIf using internal equip names they must match fully, use the equipment_list command to view them.");
ibPrinterBlacklist = configFile.Bind<string>("Printer", "Printer Blacklist", "Gasoline, will-o", "Items listed here will only not appear in printers.\nCase insensitive, partial names allowed, seperated by commas, and engligh only.\nIf using internal item names they must match fully, use the item_list command to view them.");
dropRates = configFile.Bind<string>("Drop Rates", "Pickups", "", "Pickups listed here will multiply their drop weight by the listed multipier.\nCase insensitive, partial names allowed, seperated by commas, and engligh only.\nIf using internal item names they must match fully, use the item_list and equipment_list command to view them.\nExample: Fuel Cell = 1.5, Saw = 1.1");
modifyHalcyoniteDropTables = configFile.Bind<bool>("Fixes", "Modify Halcyonite Drop Tables", true, "SotS's Halcyonite and Geode drop tables force SotS items, which will cause issues if a high number of them are blacklisted. This fix will modify them to ignore the restrictions");
if (RiskofOptions.enabled)
{
DoRiskOfOptions();
}
}
internal static void DoRiskOfOptions()
{
RiskofOptions.SetSpriteDefaultIcon();
RiskofOptions.AddString(ibPrinterBlacklist, "Game");
RiskofOptions.AddString(dropRates, "Game");
RiskofOptions.AddString(ibItemDefaults, restartRequired: true);
RiskofOptions.AddString(ibEquipDefaults, restartRequired: true);
RiskofOptions.AddOption(modifyHalcyoniteDropTables);
}
[ConCommand(/*Could not decode attribute arguments.*/)]
private static void ReloadConfig(ConCommandArgs args)
{
configFile.Reload();
Debug.Log((object)"ItemBlacklist config reloaded");
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("dolso.ItemBlacklist", "ItemBlacklist", "1.3.0")]
public class ItemBlacklist : BaseUnityPlugin
{
internal static List<PickupIndex> printerBlacklist;
internal static GameObject buttonPrefab;
private void Awake()
{
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Expected O, but got Unknown
log.start(((BaseUnityPlugin)this).Logger);
IBConfig.DoConfig(((BaseUnityPlugin)this).Config);
IBConfig.ibPrinterBlacklist.SettingChanged += delegate
{
ApplyPrinterBlacklistConfig();
};
IBConfig.dropRates.SettingChanged += delegate
{
DropRate.ApplyDropRateConfig();
};
IBConfig.modifyHalcyoniteDropTables.SettingChanged += delegate
{
ModifyHalcyoniteDropTable();
};
if (IBConfig.modifyHalcyoniteDropTables.Value)
{
ModifyHalcyoniteDropTable();
}
IBConfig.modifyHalcyoniteDropTables.HookConfig(typeof(HalcyoniteShrineInteractable), "DropRewards", new Manipulator(Hooks.IL_HalcyoniteShrineInteractable_DropRewards_BetterDropTable));
HookManager.Hook((Delegate)new Func<bool>(RuleCatalog.HiddenTestItemsConvar), (Delegate)(Func<bool>)(() => false));
HookAttribute.ScanAndApply(typeof(Hooks));
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ApplyConfig));
AssetBundle obj = Utilities.LoadAssetBundle("savebutton");
buttonPrefab = obj.LoadAsset<GameObject>("SaveButton");
obj.Unload(false);
}
private static void ModifyHalcyoniteDropTable()
{
Utilities.GetAddressable<BasicPickupDropTable>("RoR2/DLC2/dtShrineHalcyoniteTier1.asset", (Action<BasicPickupDropTable>)delegate(BasicPickupDropTable a)
{
a.requiredItemTags = (ItemTag[])(object)(IBConfig.modifyHalcyoniteDropTables.Value ? new ItemTag[0] : new ItemTag[1] { (ItemTag)21 });
if (Object.op_Implicit((Object)(object)Run.instance))
{
((PickupDropTable)a).Regenerate(Run.instance);
}
});
Utilities.GetAddressable<BasicPickupDropTable>("RoR2/DLC2/dtShrineHalcyoniteTier3.asset", (Action<BasicPickupDropTable>)delegate(BasicPickupDropTable a)
{
a.bannedItemTags = (ItemTag[])(object)(IBConfig.modifyHalcyoniteDropTables.Value ? new ItemTag[0] : new ItemTag[1] { (ItemTag)21 });
if (Object.op_Implicit((Object)(object)Run.instance))
{
((PickupDropTable)a).Regenerate(Run.instance);
}
});
}
internal static string[] BuildItemRules()
{
List<ItemDef> itemDefs = GetItemDefs(IBConfig.ibItemDefaults.Value, englishOnly: true);
string[] array = new string[itemDefs.Count];
for (int i = 0; i < array.Length; i++)
{
array[i] = "Items." + ((Object)itemDefs[i]).name;
}
return array;
}
internal static string[] BuildEquipRules()
{
List<EquipmentDef> equipDefs = GetEquipDefs(IBConfig.ibEquipDefaults.Value, englishOnly: true);
string[] array = new string[equipDefs.Count];
for (int i = 0; i < array.Length; i++)
{
array[i] = "Equipment." + ((Object)equipDefs[i]).name;
}
return array;
}
internal static List<ItemDef> GetItemDefs(string list, bool englishOnly)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
string text = (englishOnly ? "en" : Language.currentLanguageName);
List<ItemDef> list2 = new List<ItemDef>();
string[] array = CreateStringArray(list);
foreach (string text2 in array)
{
if (string.IsNullOrEmpty(text2))
{
continue;
}
if (ItemCatalog.itemNameToIndex.TryGetValue(text2, out var value))
{
ItemDef itemDef = ItemCatalog.GetItemDef(value);
list2.Add(itemDef);
continue;
}
ItemDef[] itemDefs = ContentManager.itemDefs;
foreach (ItemDef val in itemDefs)
{
if (val.nameToken != null && Utilities.ContainsString(ReformatString(Language.GetString(val.nameToken, text)), text2))
{
list2.Add(val);
break;
}
}
}
return list2;
}
internal static List<EquipmentDef> GetEquipDefs(string list, bool englishOnly)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
string text = (englishOnly ? "en" : Language.currentLanguageName);
List<EquipmentDef> list2 = new List<EquipmentDef>();
string[] array = CreateStringArray(list);
foreach (string text2 in array)
{
if (string.IsNullOrEmpty(text2))
{
continue;
}
if (EquipmentCatalog.equipmentNameToIndex.TryGetValue(text2, out var value))
{
EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(value);
list2.Add(equipmentDef);
continue;
}
EquipmentDef[] equipmentDefs = EquipmentCatalog.equipmentDefs;
foreach (EquipmentDef val in equipmentDefs)
{
if (val.nameToken != null && Utilities.ContainsString(ReformatString(Language.GetString(val.nameToken, text)), text2))
{
list2.Add(val);
break;
}
}
}
return list2;
}
internal static void SaveFromVotes()
{
if (!LocalUserBallotPersistenceManager.votesCache.TryGetValue(LocalUserManager.GetFirstLocalUser(), out var value) || value == null)
{
return;
}
StringBuilder stringBuilder = StringBuilderPool.RentStringBuilder();
StringBuilder stringBuilder2 = StringBuilderPool.RentStringBuilder();
for (int i = 0; i < value.Length; i++)
{
if (((Vote)(ref value[i])).choiceValue == 1)
{
RuleDef ruleDef = RuleCatalog.GetRuleDef(i);
if (ruleDef.globalName.StartsWith("Items."))
{
string globalName = ruleDef.globalName;
stringBuilder.Append(", " + globalName.Substring(6, globalName.Length - 6));
}
else if (ruleDef.globalName.StartsWith("Equipment."))
{
string globalName = ruleDef.globalName;
stringBuilder2.Append(", " + globalName.Substring(10, globalName.Length - 10));
}
}
}
if (stringBuilder.Length > 2)
{
stringBuilder.Length -= 2;
}
if (stringBuilder2.Length > 2)
{
stringBuilder2.Length -= 2;
}
IBConfig.ibItemDefaults.Value = stringBuilder.ToString();
IBConfig.ibEquipDefaults.Value = stringBuilder2.ToString();
StringBuilderPool.ReturnStringBuilder(stringBuilder);
StringBuilderPool.ReturnStringBuilder(stringBuilder2);
}
private static void ApplyConfig()
{
try
{
ApplyPrinterBlacklistConfig();
DropRate.ApplyDropRateConfig();
}
catch (Exception data)
{
log.error(data);
}
}
private static void ApplyPrinterBlacklistConfig()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
List<ItemDef> itemDefs = GetItemDefs(IBConfig.ibPrinterBlacklist.Value, englishOnly: true);
printerBlacklist = new List<PickupIndex>(itemDefs.Count);
foreach (ItemDef item in itemDefs)
{
printerBlacklist.Add(PickupCatalog.FindPickupIndex(item.itemIndex));
}
if (!Object.op_Implicit((Object)(object)Run.instance))
{
return;
}
foreach (PickupDropTable instances in PickupDropTable.instancesList)
{
BasicPickupDropTable val = (BasicPickupDropTable)(object)((instances is BasicPickupDropTable) ? instances : null);
if (val != null)
{
((PickupDropTable)val).Regenerate(Run.instance);
}
}
Debug.Log((object)"Regenerated printer drop tables");
}
internal static string[] CreateStringArray(string text)
{
string[] array = text.Split(new string[2] { ", ", "," }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < array.Length; i++)
{
array[i] = ReformatString(array[i]);
}
return array;
}
internal static string ReformatString(string input)
{
return Regex.Replace(input, "[\n ',-]", string.Empty);
}
}
}