using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates.GoldGat;
using IL.EntityStates.GoldGat;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Chinchi")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Gesture of the Drowned and Bottled Chaos switch item tiers.")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+db983cb1bddc84dba43fa70d0711832bd1530f93")]
[assembly: AssemblyProduct("SwitchChaosAndGesture")]
[assembly: AssemblyTitle("SwitchChaosAndGesture")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/schinchi/SwitchChaosAndGesture")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace SwitchChaosAndGesture
{
internal class Hooks
{
[CompilerGenerated]
private static class <>O
{
public static hook_SetEquipmentDefs <0>__CollectGestureBlacklistedEquipment;
public static Manipulator <1>__CheckEquipmentCanBeAutocast;
public static Manipulator <2>__CheckCrowdfunderCanBeAutocast;
public static hook_OnEnable <3>__AddMasterToDict;
public static hook_OnDisable <4>__RemoveMasterFromDict;
public static Manipulator <5>__InitialiseCooldownTrackingForNewSlots;
public static Manipulator <6>__ApplyCooldownPenaltyOnChargeGain;
public static Manipulator <7>__ApplyOrQueueCooldownPenaltyOnExecute;
public static Action<Inventory> <8>__EnsureNoTrackedCooldownsWithoutChaos;
public static Action<Run> <9>__ResetMasterDict;
public static hook_GetLocalizedStringByToken <10>__FormatBottledChaosDesc;
}
private const string BASE_ERROR_MESSAGE = "Failed to patch method: ";
private static bool popNextCooldown = false;
internal static readonly Dictionary<CharacterMaster, List<float>[]> masterCooldowns = new Dictionary<CharacterMaster, List<float>[]>();
private static readonly HashSet<EquipmentIndex> bannedAutocastEquipment = new HashSet<EquipmentIndex>();
public static void Init()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_0090: 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_009b: Expected O, but got Unknown
//IL_00b0: 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_00bb: Expected O, but got Unknown
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Expected O, but got Unknown
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Expected O, but got Unknown
//IL_0150: 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_015b: Expected O, but got Unknown
object obj = <>O.<0>__CollectGestureBlacklistedEquipment;
if (obj == null)
{
hook_SetEquipmentDefs val = CollectGestureBlacklistedEquipment;
<>O.<0>__CollectGestureBlacklistedEquipment = val;
obj = (object)val;
}
EquipmentCatalog.SetEquipmentDefs += (hook_SetEquipmentDefs)obj;
object obj2 = <>O.<1>__CheckEquipmentCanBeAutocast;
if (obj2 == null)
{
Manipulator val2 = CheckEquipmentCanBeAutocast;
<>O.<1>__CheckEquipmentCanBeAutocast = val2;
obj2 = (object)val2;
}
EquipmentSlot.MyFixedUpdate += (Manipulator)obj2;
object obj3 = <>O.<2>__CheckCrowdfunderCanBeAutocast;
if (obj3 == null)
{
Manipulator val3 = CheckCrowdfunderCanBeAutocast;
<>O.<2>__CheckCrowdfunderCanBeAutocast = val3;
obj3 = (object)val3;
}
BaseGoldGatState.FixedUpdate += (Manipulator)obj3;
object obj4 = <>O.<3>__AddMasterToDict;
if (obj4 == null)
{
hook_OnEnable val4 = AddMasterToDict;
<>O.<3>__AddMasterToDict = val4;
obj4 = (object)val4;
}
CharacterMaster.OnEnable += (hook_OnEnable)obj4;
object obj5 = <>O.<4>__RemoveMasterFromDict;
if (obj5 == null)
{
hook_OnDisable val5 = RemoveMasterFromDict;
<>O.<4>__RemoveMasterFromDict = val5;
obj5 = (object)val5;
}
CharacterMaster.OnDisable += (hook_OnDisable)obj5;
object obj6 = <>O.<5>__InitialiseCooldownTrackingForNewSlots;
if (obj6 == null)
{
Manipulator val6 = InitialiseCooldownTrackingForNewSlots;
<>O.<5>__InitialiseCooldownTrackingForNewSlots = val6;
obj6 = (object)val6;
}
Inventory.SetEquipmentInternal += (Manipulator)obj6;
object obj7 = <>O.<6>__ApplyCooldownPenaltyOnChargeGain;
if (obj7 == null)
{
Manipulator val7 = ApplyCooldownPenaltyOnChargeGain;
<>O.<6>__ApplyCooldownPenaltyOnChargeGain = val7;
obj7 = (object)val7;
}
Inventory.UpdateEquipment += (Manipulator)obj7;
object obj8 = <>O.<7>__ApplyOrQueueCooldownPenaltyOnExecute;
if (obj8 == null)
{
Manipulator val8 = ApplyOrQueueCooldownPenaltyOnExecute;
<>O.<7>__ApplyOrQueueCooldownPenaltyOnExecute = val8;
obj8 = (object)val8;
}
EquipmentSlot.OnEquipmentExecuted += (Manipulator)obj8;
Inventory.onInventoryChangedGlobal += EnsureNoTrackedCooldownsWithoutChaos;
Run.onRunDestroyGlobal += ResetMasterDict;
object obj9 = <>O.<10>__FormatBottledChaosDesc;
if (obj9 == null)
{
hook_GetLocalizedStringByToken val9 = FormatBottledChaosDesc;
<>O.<10>__FormatBottledChaosDesc = val9;
obj9 = (object)val9;
}
Language.GetLocalizedStringByToken += (hook_GetLocalizedStringByToken)obj9;
}
private static void CollectGestureBlacklistedEquipment(orig_SetEquipmentDefs orig, EquipmentDef[] newEquipmentDefs)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(newEquipmentDefs);
string[] array = SwitchChaosAndGesture.bannedAutocastEquipment.Value.Split(',');
foreach (string text in array)
{
bannedAutocastEquipment.Add(EquipmentCatalog.FindEquipmentIndex(text.Trim()));
}
bannedAutocastEquipment.Remove((EquipmentIndex)(-1));
}
private static void CheckEquipmentCanBeAutocast(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_00af: 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>[4]
{
(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "AutoCastEquipment"),
(Instruction x) => ILPatternMatchingExt.MatchCall<Inventory>(x, "GetItemCount"),
(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchCgt(x)
}))
{
SwitchChaosAndGesture.Logger.LogError((object)"Failed to patch method: EquipmentSlot.FixedUpdate");
return;
}
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<bool, EquipmentSlot, bool>>((Func<bool, EquipmentSlot, bool>)((bool autocast, EquipmentSlot equipmentSlot) => autocast && !bannedAutocastEquipment.Contains(equipmentSlot.equipmentIndex)));
}
private static void CheckCrowdfunderCanBeAutocast(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
ILLabel val2 = default(ILLabel);
if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[5]
{
(Instruction x) => ILPatternMatchingExt.MatchCallvirt<Inventory>(x, "GetItemCount"),
(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchBle(x, ref val2),
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 1)
}))
{
SwitchChaosAndGesture.Logger.LogError((object)("Failed to patch method: " + ((MemberReference)il.Method).Name));
return;
}
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<bool, BaseGoldGatState, bool>>((Func<bool, BaseGoldGatState, bool>)((bool autocast, BaseGoldGatState state) => state.shouldFire || (autocast && !bannedAutocastEquipment.Contains(Equipment.GoldGat.equipmentIndex))));
}
private static void AddMasterToDict(orig_OnEnable orig, CharacterMaster self)
{
orig.Invoke(self);
if (NetworkServer.active && !masterCooldowns.ContainsKey(self))
{
masterCooldowns[self] = Array.Empty<List<float>>();
}
}
private static void RemoveMasterFromDict(orig_OnDisable orig, CharacterMaster self)
{
orig.Invoke(self);
if (NetworkServer.active && masterCooldowns.ContainsKey(self))
{
masterCooldowns.Remove(self);
}
}
private static void InitialiseCooldownTrackingForNewSlots(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: 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>[4]
{
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<Inventory>(x, "equipmentStateSlots"),
(Instruction x) => ILPatternMatchingExt.MatchLdlen(x),
(Instruction x) => ILPatternMatchingExt.MatchConvI4(x)
}))
{
SwitchChaosAndGesture.Logger.LogError((object)("Failed to patch method: " + ((MemberReference)il.Method).Name));
return;
}
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldarg_2);
val.EmitDelegate<Func<int, Inventory, uint, int>>((Func<int, Inventory, uint, int>)delegate(int num, Inventory inventory, uint slot)
{
if (NetworkServer.active)
{
CharacterMaster component = ((Component)inventory).GetComponent<CharacterMaster>();
if ((Object)(object)component != (Object)null && masterCooldowns.TryGetValue(component, out var value) && value.Length <= slot)
{
Array.Resize(ref value, (int)(slot + 1));
for (int i = num; i < value.Length; i++)
{
value[i] = new List<float>();
}
masterCooldowns[component] = value;
}
}
return num;
});
}
private static void ApplyCooldownPenaltyOnChargeGain(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: 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)
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
{
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 3),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<EquipmentState>(x, "equipmentDef"),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<EquipmentDef>(x, "cooldown")
}))
{
SwitchChaosAndGesture.Logger.LogError((object)("Failed to patch method: " + ((MemberReference)il.Method).Name));
return;
}
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldloc_1);
val.Emit(OpCodes.Ldloc_2);
val.EmitDelegate<Func<float, Inventory, uint, byte, float>>((Func<float, Inventory, uint, byte, float>)delegate(float equipmentCooldown, Inventory inventory, uint maxCharges, byte slot)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
CharacterMaster component = ((Component)inventory).GetComponent<CharacterMaster>();
if ((Object)(object)component != (Object)null && masterCooldowns.TryGetValue(component, out var value))
{
if (value.Length <= slot)
{
SwitchChaosAndGesture.Logger.LogWarning((object)"Inventory.UpdateEquipment cooldown array not resized properly.");
return equipmentCooldown;
}
List<float> list = value[slot];
if (list.Count > 0 && popNextCooldown)
{
EquipmentState val2 = inventory.equipmentStateSlots[slot];
if (val2.charges + 1 < maxCharges || ((FixedTimeStamp)(ref val2.chargeFinishTime)).isPositiveInfinity)
{
float num = list[0];
list.RemoveAt(0);
return equipmentCooldown + num * SwitchChaosAndGesture.chaosCooldownPenalty.Value;
}
}
}
return equipmentCooldown;
});
}
private static void ApplyOrQueueCooldownPenaltyOnExecute(ILContext il)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
string text = "Failed to patch method: " + ((MemberReference)il.Method).Name;
Inventory inventory = null;
CharacterMaster master = null;
byte slot = 0;
bool addCooldownNow = false;
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext(new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchCall<EquipmentSlot>(x, "get_equipmentIndex")
}))
{
SwitchChaosAndGesture.Logger.LogError((object)text);
return;
}
val.Index += 1;
val.EmitDelegate<Func<EquipmentSlot, EquipmentSlot>>((Func<EquipmentSlot, EquipmentSlot>)delegate(EquipmentSlot equipmentSlot)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
popNextCooldown = false;
inventory = equipmentSlot.inventory;
master = ((Component)inventory).GetComponent<CharacterMaster>();
slot = inventory.activeEquipmentSlot;
EquipmentState val2 = inventory.equipmentStateSlots[slot];
bool flag = inventory.GetItemCount(Items.RandomEquipmentTrigger) > 0;
if (flag)
{
masterCooldowns[master][slot].Add(0f);
}
addCooldownNow = ((FixedTimeStamp)(ref val2.chargeFinishTime)).isPositiveInfinity && flag;
return equipmentSlot;
});
if (!val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCall<EquipmentSlot>(x, "PerformEquipmentAction")
}))
{
SwitchChaosAndGesture.Logger.LogError((object)text);
return;
}
val.Index += 3;
val.EmitDelegate<Func<EquipmentIndex, EquipmentIndex>>((Func<EquipmentIndex, EquipmentIndex>)delegate(EquipmentIndex equipmentIndex)
{
//IL_0045: 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)
List<float> list = masterCooldowns[master][slot];
if (list.Count == 0)
{
SwitchChaosAndGesture.Logger.LogError((object)"EquipmentSlot.OnEquipmentExecuted: Empty cooldown queue");
}
else
{
list[list.Count - 1] += EquipmentCatalog.GetEquipmentDef(equipmentIndex).cooldown;
}
return equipmentIndex;
});
if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCall(x, typeof(EffectManager), "SpawnEffect")
}))
{
SwitchChaosAndGesture.Logger.LogError((object)text);
return;
}
val.EmitDelegate<Action>((Action)delegate
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: 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_0087: 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)
if (addCooldownNow)
{
float num = masterCooldowns[master][slot][0] * inventory.CalculateEquipmentCooldownScale() * SwitchChaosAndGesture.chaosCooldownPenalty.Value;
masterCooldowns[master][slot].RemoveAt(0);
EquipmentState equipment = inventory.GetEquipment((uint)slot);
inventory.SetEquipment(new EquipmentState(equipment.equipmentIndex, equipment.chargeFinishTime + num, equipment.charges, false), (uint)slot);
}
popNextCooldown = true;
});
}
private static void EnsureNoTrackedCooldownsWithoutChaos(Inventory inventory)
{
if (!NetworkServer.active || inventory.GetItemCount(Items.RandomEquipmentTrigger) > 0)
{
return;
}
CharacterMaster component = ((Component)inventory).GetComponent<CharacterMaster>();
if ((Object)(object)component != (Object)null && masterCooldowns.TryGetValue(component, out var value))
{
List<float>[] array = value;
for (int i = 0; i < array.Length; i++)
{
array[i].Clear();
}
}
}
private static void ResetMasterDict(Run obj)
{
masterCooldowns.Clear();
}
private static string FormatBottledChaosDesc(orig_GetLocalizedStringByToken orig, Language self, string token)
{
string text = orig.Invoke(self, token);
if (token == "ITEM_RANDOMEQUIPMENTTRIGGER_DESC")
{
text = string.Format(text, SwitchChaosAndGesture.chaosCooldownPenalty.Value * 100f);
}
return text;
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Chinchi.SwitchChaosAndGesture", "SwitchChaosAndGesture", "1.1.1")]
public class SwitchChaosAndGesture : BaseUnityPlugin
{
public const string PluginGUID = "Chinchi.SwitchChaosAndGesture";
public const string PluginAuthor = "Chinchi";
public const string PluginName = "SwitchChaosAndGesture";
public const string PluginVersion = "1.1.1";
internal static ConfigEntry<bool> isGestureAllowed;
internal static ConfigEntry<bool> isGestureBlacklisted;
internal static ConfigEntry<string> bannedAutocastEquipment;
internal static ConfigEntry<float> chaosCooldownPenalty;
internal static AssetBundle assetBundle;
internal static ManualLogSource Logger;
public void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
isGestureAllowed = ((BaseUnityPlugin)this).Config.Bind<bool>("Gesture of the Drowned", "Include In Item Pool", true, "Allow Gesture of the Drowned to be in the item pool.");
isGestureBlacklisted = ((BaseUnityPlugin)this).Config.Bind<bool>("Gesture of the Drowned", "AI Blacklist", false, "Blacklist the item for enemies.");
bannedAutocastEquipment = ((BaseUnityPlugin)this).Config.Bind<string>("Gesture of the Drowned", "Banned Equipment", "Recycle,GoldGat,BossHunter,FireBallDash", "Which equipment will not be autocast with Gesture. Run the 'equipment_list' command on the console for a list of all internal name options.");
chaosCooldownPenalty = ((BaseUnityPlugin)this).Config.Bind<float>("Bottled Chaos", "Cooldown Penalty", 0.2f, "The percent of the activated equipment's cooldown that will be added on due to Bottled Chaos' effect.");
if (chaosCooldownPenalty.Value < 0f)
{
chaosCooldownPenalty.Value = 0f;
Logger.LogWarning((object)"The 'Cooldown Penalty' config setting has a negative value. Readjusting to 0.0");
}
LoadBundle(((BaseUnityPlugin)this).Info.Location);
ModifyItems();
Hooks.Init();
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ApplyModelChanges));
}
private void LoadBundle(string directory)
{
string text = "assetdata.bundle";
assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(directory), text));
if ((Object)(object)assetBundle == (Object)null)
{
Logger.LogError((object)("Failed to load '" + text + "'"));
}
}
private static void ModifyItems()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: 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)
AsyncOperationHandle<ItemDef> val = Addressables.LoadAssetAsync<ItemDef>((object)"RoR2/Base/AutoCastEquipment/AutoCastEquipment.asset");
val.Completed += Modify;
val = Addressables.LoadAssetAsync<ItemDef>((object)"RoR2/DLC1/RandomEquipmentTrigger/RandomEquipmentTrigger.asset");
val.Completed += Modify;
static void Modify(AsyncOperationHandle<ItemDef> handle)
{
ItemDef result = handle.Result;
if (((Object)result).name == "RandomEquipmentTrigger")
{
UpdateItemDef(result, (ItemTier)3, "texBottledChaosIcon", isDroppable: true);
}
else if (((Object)result).name == "AutoCastEquipment")
{
UpdateItemDef(result, (ItemTier)2, "texFossilIcon", isGestureAllowed.Value);
ModifyItemTag(result, (ItemTag)4, isGestureBlacklisted.Value);
}
}
}
private static void UpdateItemDef(ItemDef itemDef, ItemTier tier, string sprite, bool isDroppable)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
itemDef.deprecatedTier = tier;
AssetBundle val = assetBundle;
if ((Object)(object)val != (Object)null)
{
itemDef.pickupIconSprite = val.LoadAsset<Sprite>(sprite);
}
ModifyItemTag(itemDef, (ItemTag)9, !isDroppable);
}
private static void ModifyItemTag(ItemDef itemDef, ItemTag tag, bool include)
{
//IL_0038: 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_004d: 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)
if (!include)
{
if (itemDef.tags.Contains(tag))
{
List<ItemTag> list = itemDef.tags.ToList();
list.Remove(tag);
itemDef.tags = list.ToArray();
}
}
else if (!itemDef.tags.Contains(tag))
{
List<ItemTag> list2 = itemDef.tags.ToList();
list2.Add(tag);
itemDef.tags = list2.ToArray();
}
}
private void ApplyModelChanges()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
Addressables.LoadAssetAsync<Material>((object)"RoR2/DLC1/RandomEquipmentTrigger/matBottledChaos.mat").WaitForCompletion().mainTexture = (Texture)(object)Addressables.LoadAssetAsync<Texture2D>((object)"RoR2/Base/Common/ColorRamps/texLunarWispTracer 1.png").WaitForCompletion();
GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/RandomEquipmentTrigger/RandomEquipmentTriggerProcEffect.prefab").WaitForCompletion();
SetMaterial(((Component)val.transform.Find("Vase")).gameObject, "RoR2/Base/LunarWisp/matLunarWispStones.mat", 0);
SetMaterial(((Component)val.transform.Find("Trails")).gameObject, "RoR2/Base/LunarWisp/matLunarWispMinigunTracer.mat", 1);
}
private void SetMaterial(GameObject go, string material, int index)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
ParticleSystemRenderer component = go.GetComponent<ParticleSystemRenderer>();
Material[] sharedMaterials = ((Renderer)component).sharedMaterials;
sharedMaterials[index] = Addressables.LoadAssetAsync<Material>((object)material).WaitForCompletion();
((Renderer)component).sharedMaterials = sharedMaterials;
}
}
}