using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dolso;
using HG;
using HG.Reflection;
using JetBrains.Annotations;
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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Dolso
{
internal static class log
{
private static readonly ManualLogSource logger = Logger.CreateLogSource(Assembly.GetExecutingAssembly().GetName().Name);
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)$"ILCursor failure, skipping: {data}\n{c}");
}
internal static void LogErrorCaller(this ILCursor c, object data)
{
logger.LogError((object)$"ILCursor failed in {new StackFrame(1).GetMethod().Name}, skipping: {data}\n{c}");
}
}
internal static class HookManager
{
internal delegate bool ConfigEnabled<T>(T configValue);
private class HookedConfig<T>
{
private readonly ConfigEnabled<T> enabled;
private readonly IDetour detour;
internal HookedConfig(ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, IDetour detour)
{
this.enabled = enabled;
this.detour = detour;
configEntry.SettingChanged += ConfigChanged;
ConfigChanged(configEntry, null);
}
private void ConfigChanged(object sender, EventArgs args)
{
if (enabled(((ConfigEntry<T>)sender).Value))
{
if (!detour.IsApplied)
{
detour.Apply();
}
}
else if (detour.IsApplied)
{
detour.Undo();
}
}
}
internal const BindingFlags allFlags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
private static readonly ConfigEnabled<bool> boolConfigEnabled = BoolEnabled;
private static ILHookConfig ilHookConfig = new ILHookConfig
{
ManualApply = true
};
private static HookConfig onHookConfig = new HookConfig
{
ManualApply = true
};
internal static void Hook(Type typeFrom, string methodFrom, Manipulator ilHook)
{
Hook(GetMethod(typeFrom, methodFrom), ilHook);
}
internal static void Hook(Delegate methodFrom, Manipulator ilHook)
{
Hook(methodFrom.Method, ilHook);
}
internal static void Hook(MethodBase methodFrom, Manipulator ilHook)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
try
{
new ILHook(methodFrom, ilHook, ref ilHookConfig).Apply();
}
catch (Exception e)
{
e.LogHookError(methodFrom, ((Delegate)(object)ilHook).Method);
}
}
internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook)
{
Hook(GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target);
}
internal static void Hook(Delegate methodFrom, Delegate onHook)
{
Hook(methodFrom.Method, onHook.Method, onHook.Target);
}
internal static void Hook(MethodBase methodFrom, Delegate onHook)
{
Hook(methodFrom, onHook.Method, onHook.Target);
}
internal static void Hook(MethodBase methodFrom, MethodInfo onHook, object target = null)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
try
{
new Hook(methodFrom, onHook, target, ref onHookConfig).Apply();
}
catch (Exception e)
{
e.LogHookError(methodFrom, onHook);
}
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Delegate hook)
{
configEntry.HookConfig(boolConfigEnabled, GetMethod(typeFrom, methodFrom), hook.Method, hook.Target);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Delegate hook)
{
configEntry.HookConfig(boolConfigEnabled, methodFrom, hook.Method, hook.Target);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, MethodInfo hook)
{
configEntry.HookConfig(boolConfigEnabled, methodFrom, hook);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Delegate hook)
{
configEntry.HookConfig(enabled, GetMethod(typeFrom, methodFrom), hook.Method, hook.Target);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Delegate hook)
{
configEntry.HookConfig(enabled, methodFrom, hook.Method, hook.Target);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, MethodInfo hook, object target = null)
{
try
{
new HookedConfig<T>(configEntry, enabled, ManualDetour(methodFrom, hook, target));
}
catch (Exception e)
{
e.LogHookError(methodFrom, hook);
}
}
internal static IDetour ManualDetour(Type typeFrom, string methodFrom, Delegate hook)
{
return ManualDetour(GetMethod(typeFrom, methodFrom), hook.Method, hook.Target);
}
internal static IDetour ManualDetour(MethodBase methodFrom, Delegate hook)
{
return ManualDetour(methodFrom, hook.Method, hook.Target);
}
internal static IDetour ManualDetour(MethodBase methodFrom, MethodInfo hook, object target = null)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
try
{
ParameterInfo[] parameters = hook.GetParameters();
if (parameters.Length == 1 && parameters[0].ParameterType == typeof(ILContext))
{
return (IDetour)new ILHook(methodFrom, (Manipulator)hook.CreateDelegate(typeof(Manipulator)), ref ilHookConfig);
}
return (IDetour)new Hook(methodFrom, hook, target, ref onHookConfig);
}
catch (Exception e)
{
e.LogHookError(methodFrom, hook);
return null;
}
}
internal static MethodInfo GetMethod(Type typeFrom, string methodName)
{
if (typeFrom == null || methodName == null)
{
log.error($"Null argument in GetMethod: type={typeFrom}, name={methodName}");
return null;
}
MethodInfo[] array = (from predicate in typeFrom.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
where predicate.Name == methodName
select predicate).ToArray();
switch (array.Length)
{
case 1:
return array[0];
case 0:
log.error($"Failed to find method: {typeFrom}::{methodName}");
return null;
default:
{
log.error($"{array.Length} ambiguous matches found for: {typeFrom}::{methodName}");
MethodInfo[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
log.error(array2[i]);
}
return null;
}
}
}
internal static MethodInfo GetMethod(Type typeFrom, string methodName, params Type[] parameters)
{
if (typeFrom == null || methodName == null)
{
log.error($"Null argument in GetMethod: type={typeFrom}, name={methodName}");
return null;
}
MethodInfo? method = typeFrom.GetMethod(methodName, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, parameters, null);
if (method == null)
{
log.error($"Failed to find method: {typeFrom}::{methodName}_{parameters.Length}");
}
return method;
}
internal static void SetPriority(string[] beforeIL = null, string[] beforeOn = null, string[] afterIL = null, string[] afterOn = null)
{
ilHookConfig.Before = beforeIL;
onHookConfig.Before = beforeOn;
ilHookConfig.After = afterIL;
onHookConfig.After = afterOn;
}
internal static void LogHookError(this Exception e, MethodBase methodFrom, MethodInfo hook)
{
log.error((methodFrom == null) ? $"null methodFrom for hook: {hook.Name}\n{e}" : $"Failed to hook: {methodFrom.DeclaringType}::{methodFrom.Name} - {hook.Name}\n{e}");
}
private static bool BoolEnabled(bool configValue)
{
return configValue;
}
}
internal static class Utilities
{
private static GameObject _prefabParent;
internal static GameObject CreatePrefab(GameObject gameObject, string name = null)
{
//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 val = Object.Instantiate<GameObject>(gameObject, _prefabParent.transform);
if (name != null)
{
((Object)val).name = name;
}
return val;
}
internal static Task<TObj> GetAddressableAsync<TObj>(string addressable) where TObj : 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<TObj>((object)addressable).Task;
}
internal static Task<GameObject> GetAddressableAsync(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).Task;
}
internal static void DoAddressable<TObj>(string addressable, Action<TObj> callback) where TObj : 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<TObj> val = Addressables.LoadAssetAsync<TObj>((object)addressable);
val.Completed += delegate(AsyncOperationHandle<TObj> a)
{
callback(a.Result);
};
}
internal static void DoAddressable(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<TComp>(string addressable, Action<TComp> callback = null) where TComp : 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)
{
TComp obj = a.Result.AddComponent<TComp>();
callback?.Invoke(obj);
};
}
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>();
}
};
}
}
[MeansImplicitUse]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
internal class HookAttribute : Attribute
{
protected 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 HookAttribute()
{
}
internal static void ScanAndApply()
{
ScanAndApply((from a in Assembly.GetExecutingAssembly().GetTypes()
where a.GetCustomAttribute<HookAttribute>() != null
select a).ToArray());
}
internal static void ScanAndApply(params Type[] types)
{
for (int i = 0; i < types.Length; i++)
{
MethodInfo[] methods = types[i].GetMethods(BindingFlags.Static | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
foreach (HookAttribute customAttribute in methodInfo.GetCustomAttributes<HookAttribute>(inherit: false))
{
try
{
if (customAttribute.from == null && methodInfo.GetParameters().Length == 0)
{
methodInfo.Invoke(null, null);
}
else
{
customAttribute.Hook(methodInfo);
}
}
catch (Exception e)
{
e.LogHookError(customAttribute.from, methodInfo);
}
}
}
}
}
protected virtual void Hook(MethodInfo member)
{
IDetour obj = HookManager.ManualDetour(from, member);
if (obj != null)
{
obj.Apply();
}
}
}
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_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
try
{
string fullName = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)).FullName;
Texture2D val = new Texture2D(256, 256);
if (ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(fullName, "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 AddOption(ConfigEntryBase entry)
{
AddOption(entry, string.Empty, string.Empty);
}
internal static void AddOption(ConfigEntryBase entry, string categoryName = "", string name = "", bool restartRequired = false)
{
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Expected O, but got Unknown
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Expected O, but got Unknown
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Expected O, but got Unknown
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: 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)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Expected O, but got Unknown
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Expected O, but got Unknown
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Expected O, but got Unknown
//IL_00ba: 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_00aa: Expected O, but got Unknown
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
Type settingType = entry.SettingType;
object obj;
if (!(settingType == typeof(float)))
{
obj = ((!(settingType == typeof(string))) ? ((!(settingType == typeof(bool))) ? ((!(settingType == typeof(int))) ? ((!(settingType == typeof(Color))) ? ((!(settingType == typeof(KeyboardShortcut))) ? ((object)((!settingType.IsEnum) ? ((ChoiceOption)null) : new ChoiceOption(entry, new ChoiceConfig()))) : ((object)new KeyBindOption((ConfigEntry<KeyboardShortcut>)(object)entry, new KeyBindConfig()))) : ((object)new ColorOption((ConfigEntry<Color>)(object)entry, new ColorOptionConfig()))) : ((object)new IntFieldOption((ConfigEntry<int>)(object)entry, new IntFieldConfig()))) : ((object)new CheckBoxOption((ConfigEntry<bool>)(object)entry, new CheckBoxConfig()))) : ((object)new StringInputFieldOption((ConfigEntry<string>)(object)entry, new InputFieldConfig
{
submitOn = (SubmitEnum)6,
lineType = (LineType)0
})));
}
else if (entry.Description.AcceptableValues is AcceptableValueRange<float>)
{
obj = (object)new SliderOption((ConfigEntry<float>)(object)entry, new SliderConfig
{
min = ((AcceptableValueRange<float>)(object)entry.Description.AcceptableValues).MinValue,
max = ((AcceptableValueRange<float>)(object)entry.Description.AcceptableValues).MaxValue,
FormatString = "{0:f2}",
description = entry.DescWithDefault("{0:f2}")
});
}
else
{
ConfigEntry<float> obj2 = (ConfigEntry<float>)(object)entry;
FloatFieldConfig val = new FloatFieldConfig();
((NumericFieldConfig<float>)val).FormatString = "{0:f2}";
((BaseOptionConfig)val).description = entry.DescWithDefault("{0:f2}");
obj = (object)new FloatFieldOption(obj2, val);
}
BaseOption val2 = (BaseOption)obj;
if (val2 == null)
{
return;
}
BaseOptionConfig config = val2.GetConfig();
config.category = categoryName;
config.name = name;
config.restartRequired = restartRequired;
if (config.description == "")
{
config.description = entry.DescWithDefault();
}
try
{
ModSettingsManager.AddOption(val2);
}
catch (Exception arg)
{
log.error($"AddOption {entry.Definition} failed\n{arg}");
}
}
internal static void AddOption(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}")
{
AddFloatSlider(entry, min, max, format);
}
internal static void AddFloatSlider(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}", 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_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_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: 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 AddIntSlider(ConfigEntry<int> entry, int min, int max, 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_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_0031: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig
{
min = min,
max = max,
category = categoryName,
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
private static string DescWithDefault(this ConfigEntryBase entry, string format = "{0}")
{
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>();
internal static void DropRates_SettingChanged(object sender, EventArgs e)
{
ApplyDropRateConfig();
}
public static void ApplyDropRateConfig()
{
//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_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Invalid comparison between Unknown and I4
//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_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Invalid comparison between Unknown and I4
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: 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_00a3: 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_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
string[] array = ItemBlacklist.CreateStringArray(IBConfig.dropRates.Value);
pickupChance.Clear();
bool flag = false;
for (int i = 0; i < array.Length; i++)
{
if (string.IsNullOrEmpty(array[i]))
{
continue;
}
string[] array2 = array[i].Split('=', StringSplitOptions.RemoveEmptyEntries);
if (array2.Length != 2 || !float.TryParse(array2[1], NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.InvariantInfo, out var result))
{
log.warning("\"" + array[i] + "\" is an invalid format");
continue;
}
string text = array2[0];
ItemIndex val = ItemCatalog.FindItemIndex(text);
PickupIndex val2;
if ((int)val != -1)
{
val2 = PickupCatalog.FindPickupIndex(val);
}
else
{
EquipmentIndex val3 = EquipmentCatalog.FindEquipmentIndex(text);
if ((int)val3 != -1)
{
val2 = PickupCatalog.FindPickupIndex(val3);
}
else
{
val2 = PickupCatalog.FindPickupIndex(text);
if (!(val2 != PickupIndex.none))
{
foreach (PickupDef allPickup in PickupCatalog.allPickups)
{
if (allPickup.nameToken == null || !ItemBlacklist.ContainsString(ItemBlacklist.ReformatString(Language.GetString(allPickup.nameToken, "en")), text))
{
continue;
}
val2 = allPickup.pickupIndex;
int num = i;
string internalName = allPickup.internalName;
int num2 = allPickup.internalName.IndexOf('.') + 1;
array[num] = internalName.Substring(num2, internalName.Length - num2) + " = " + array2[1];
flag = true;
goto IL_0183;
}
log.warning("failed to find a match for " + array[i]);
continue;
}
}
}
goto IL_0183;
IL_0183:
if (!pickupChance.ContainsKey(val2))
{
pickupChance.Add(val2, result);
log.message($"Found {GetPickupName(val2)} = {result}");
continue;
}
log.warning("duplicate " + GetPickupName(val2) + " from " + array[i] + ", ignoring");
}
if (flag)
{
IBConfig.dropRates.SettingChanged -= DropRates_SettingChanged;
IBConfig.dropRates.Value = string.Join(", ", array);
IBConfig.dropRates.SettingChanged += DropRates_SettingChanged;
}
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;
}
}
[Hook]
internal static class Hooks
{
[Hook]
private static void Apply()
{
HookManager.ConfigEnabled<string> enabled = (string configValue) => !string.IsNullOrWhiteSpace(configValue);
IBConfig.dropRates.HookConfig(enabled, typeof(DoppelgangerDropTable), "GenerateWeightedSelection", new Action<Action<PickupDropTable>, PickupDropTable>(Modify_On_PickupDropTable_GenerateWeightedSelection));
IBConfig.dropRates.HookConfig(enabled, typeof(ExplicitPickupDropTable), "GenerateWeightedSelection", new Action<Action<PickupDropTable>, PickupDropTable>(Modify_On_PickupDropTable_GenerateWeightedSelection));
IBConfig.dropRates.HookConfig(enabled, typeof(ArenaMonsterItemDropTable), "GenerateWeightedSelection", new Action<Action<PickupDropTable, Run>, PickupDropTable, Run>(ModifyRun_On_PickupDropTable_GenerateWeightedSelection));
IBConfig.dropRates.HookConfig(enabled, typeof(BasicPickupDropTable), "GenerateWeightedSelection", new Action<Action<PickupDropTable, Run>, PickupDropTable, Run>(ModifyRun_On_PickupDropTable_GenerateWeightedSelection));
IBConfig.dropRates.HookConfig(enabled, typeof(FreeChestDropTable), "GenerateDropPreReplacement", new Action<ILContext>(Modify_IL_FreeChest_GenerateDropPreReplacement));
IBConfig.modifyHalcyoniteDropTables.HookConfig(typeof(HalcyoniteShrineInteractable), "DropRewards", new Action<ILContext>(BetterDropTable_IL_HalcyoniteShrineInteractable_DropRewards));
HookManager.Hook((Delegate)new Func<bool>(RuleCatalog.HiddenTestItemsConvar), (Delegate)(Func<bool>)(() => false));
}
[Hook(typeof(LocalUserBallotPersistenceManager), "OnLocalUserSignIn")]
private static void SignedIn_On_PreGameRuleVoteManager_OnLocalUserSignIn(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 FixItemRules_On_RuleDef_FromItem(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 FixEquipRules_On_RuleDef_FromEquipment(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 FilterPrinters_On_BasicPickupDropTable_GenerateWeightedSelection(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(ExplicitPickupDropTable), "GenerateWeightedSelection")]
private static void FilterExplicit_On_BasicPickupDropTable_GenerateWeightedSelection(Action<ExplicitPickupDropTable> orig, ExplicitPickupDropTable self)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
orig(self);
for (int num = self.weightedSelection.Count - 1; num >= 0; num--)
{
if (!IsExplicitPickupAvailable(self.weightedSelection.choices[num].value))
{
self.weightedSelection.RemoveChoice(num);
}
}
}
[Hook(typeof(BossGroup), "DropRewards")]
private static void Blacklist_On_BossGroup_DropRewards(Action<BossGroup> orig, BossGroup self)
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
if (self.bossDropTables != null)
{
for (int num = self.bossDropTables.Count - 1; num >= 0; num--)
{
PickupDropTable obj = self.bossDropTables[num];
ExplicitPickupDropTable val = (ExplicitPickupDropTable)(object)((obj is ExplicitPickupDropTable) ? obj : null);
if (val != null && val.weightedSelection.Count == 0)
{
self.bossDropTables.RemoveAt(num);
}
}
}
if (self.bossDrops != null)
{
for (int num2 = self.bossDrops.Count - 1; num2 >= 0; num2--)
{
if (!IsExplicitPickupAvailable(self.bossDrops[num2]))
{
self.bossDrops.RemoveAt(num2);
}
}
}
orig(self);
}
[Hook(typeof(EquipmentSlot), "FireBossHunter")]
private static void ReplaceHunterReward_IL_EquipmentSlot_FireBossHunter(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)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<PickupDropTable>(a, "GenerateDrop")
}))
{
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<PickupIndex, EquipmentSlot, PickupIndex>>((Func<PickupIndex, EquipmentSlot, PickupIndex>)delegate(PickupIndex pickupIndex, EquipmentSlot self)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: 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_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_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_0055: 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_0044: Unknown result type (might be due to invalid IL or missing references)
if (pickupIndex != PickupIndex.none)
{
return pickupIndex;
}
BasicPickupDropTable obj = Addressables.LoadAssetAsync<BasicPickupDropTable>((object)"RoR2/Base/DuplicatorWild/dtDuplicatorWild.asset").WaitForCompletion();
log.info("Replacing banned boss drop with a random boss item");
PickupIndex val2 = ((PickupDropTable)obj).GenerateDrop(self.rng);
if (val2 != PickupIndex.none)
{
return val2;
}
log.info("No boss pickup found, dropping pearl instead");
return PickupCatalog.FindPickupIndex(Items.ShinyPearl.itemIndex);
});
}
else
{
val.LogErrorCaller("Failed to find GenerateDrop");
}
}
private static bool IsExplicitPickupAvailable(PickupIndex pickupIndex)
{
//IL_0000: 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_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Invalid comparison between Unknown and I4
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
if (pickupDef == null)
{
return false;
}
if (!Object.op_Implicit((Object)(object)Run.instance) || Run.instance.IsPickupAvailable(pickupIndex))
{
return true;
}
if (((int)pickupDef.itemIndex != -1 && RuleCatalog.FindRuleDef("Items." + ((Object)ItemCatalog.GetItemDef(pickupDef.itemIndex)).name) == null) || ((int)pickupDef.equipmentIndex != -1 && RuleCatalog.FindRuleDef("Equipment." + ((Object)EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex)).name) == null))
{
return true;
}
if (Object.op_Implicit((Object)(object)pickupDef.unlockableDef) && !Run.instance.unlockablesUnlockedByAnyUser.Contains(pickupDef.unlockableDef))
{
return true;
}
return false;
}
[Hook(typeof(PickupDropTable), "GenerateDrop")]
private static PickupIndex MuteEmptyExplicit_On_PickupDropTable_GenerateDrop(Func<PickupDropTable, Xoroshiro128Plus, PickupIndex> orig, PickupDropTable self, Xoroshiro128Plus rng)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
ExplicitPickupDropTable val = (ExplicitPickupDropTable)(object)((self is ExplicitPickupDropTable) ? self : null);
if (val != null && val.weightedSelection.Count == 0)
{
return PickupIndex.none;
}
return orig(self, rng);
}
internal static void BetterDropTable_IL_HalcyoniteShrineInteractable_DropRewards(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");
}
}
else
{
val.LogErrorCaller("failed find pickerOptions");
}
}
[Hook(typeof(Run), "EnableItemDrop")]
private static void Fix_IL_Run_EnableItemDrop(ILContext il)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_0090: 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_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: 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");
}
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");
}
}
[Hook(typeof(Run), "DisableItemDrop")]
private static void Fix_IL_Run_DisableItemDrop(ILContext il)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_0090: 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_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: 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");
}
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");
}
}
[Hook(typeof(Run), "EnableEquipmentDrop")]
private static void Fix_IL_Run_EnableEquipmentDrop(ILContext il)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_0090: 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_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: 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");
}
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");
}
}
[Hook(typeof(RuleCategoryController), "SetData")]
private static void ScaleSize_IL_RuleCategoryController_SetData(ILContext il)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
MethodInfo getc = typeof(Component).GetMethod("GetComponent", Type.EmptyTypes).MakeGenericMethod(typeof(GridLayoutGroup));
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, (MethodBase)getc)
}))
{
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");
}
}
private static void Modify_On_PickupDropTable_GenerateWeightedSelection(Action<PickupDropTable> orig, PickupDropTable self)
{
orig(self);
DropRate.ModifySelector(DropRate.GetSelector(self));
}
private static void ModifyRun_On_PickupDropTable_GenerateWeightedSelection(Action<PickupDropTable, Run> orig, PickupDropTable self, Run run)
{
orig(self, run);
DropRate.ModifySelector(DropRate.GetSelector(self));
}
private static void Modify_IL_FreeChest_GenerateDropPreReplacement(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.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
val.Emit(OpCodes.Call, (MethodBase)typeof(DropRate).GetMethod("ModifySelector", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
}
else
{
val.LogErrorCaller("");
}
}
}
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.AddOption((ConfigEntryBase)(object)ibPrinterBlacklist, "Game");
RiskofOptions.AddOption((ConfigEntryBase)(object)dropRates, "Game");
RiskofOptions.AddOption((ConfigEntryBase)(object)ibItemDefaults);
RiskofOptions.AddOption((ConfigEntryBase)(object)ibEquipDefaults);
RiskofOptions.AddOption((ConfigEntryBase)(object)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.3")]
public class ItemBlacklist : BaseUnityPlugin
{
internal static HashSet<PickupIndex> printerBlacklist;
internal static GameObject buttonPrefab;
private void Awake()
{
IBConfig.DoConfig(((BaseUnityPlugin)this).Config);
IBConfig.ibPrinterBlacklist.SettingChanged += delegate
{
ApplyPrinterBlacklistConfig();
};
IBConfig.dropRates.SettingChanged += DropRate.DropRates_SettingChanged;
IBConfig.modifyHalcyoniteDropTables.SettingChanged += delegate
{
ModifyHalcyoniteDropTable();
};
if (IBConfig.modifyHalcyoniteDropTables.Value)
{
ModifyHalcyoniteDropTable();
}
HookAttribute.ScanAndApply(typeof(Hooks));
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ApplyConfig));
AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "savebutton"));
buttonPrefab = obj.LoadAsset<GameObject>("SaveButton");
obj.Unload(false);
}
private static void ModifyHalcyoniteDropTable()
{
Utilities.DoAddressable<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.DoAddressable<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 && 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 && 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 HashSet<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);
}
internal static bool ContainsString(string source, string value)
{
return CultureInfo.InvariantCulture.CompareInfo.IndexOf(source, value, CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols) >= 0;
}
}
}