using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using On.RoR2; using PokeItems.Items; using R2API; using R2API.Utils; using RoR2; using RoR2.ExpansionManagement; using UnityEngine; using UnityEngine.AddressableAssets; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PokeItems")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+3cf9bc8fdf9575bbbbe3148196bd3f2800e82d43")] [assembly: AssemblyProduct("PokeItems")] [assembly: AssemblyTitle("PokeItems")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 PokeItems { internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } private static string Format(object data, string file, int line) { string fileName = Path.GetFileName(file); return $"[{fileName}:{line}] {data}"; } internal static void Debug(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { _logSource.LogDebug((object)Format(data, file, line)); } internal static void Error(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { _logSource.LogError((object)Format(data, file, line)); } internal static void Fatal(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { _logSource.LogFatal((object)Format(data, file, line)); } internal static void Info(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { _logSource.LogInfo((object)Format(data, file, line)); } internal static void Message(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { _logSource.LogMessage((object)Format(data, file, line)); } internal static void Warning(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { _logSource.LogWarning((object)Format(data, file, line)); } } internal class MathUtility { public static float GetLinearStacking(float value, float count, float procCoefficient = 1f) { return value * count * procCoefficient; } public static float GetLinearWithExtraStacking(float value, float extraValue, float count, float procCoefficient = 1f) { if (count <= 1f) { return GetLinearStacking(value, count, procCoefficient); } return (value + extraValue * (count - 1f)) * procCoefficient; } public static float GetExponentialPercentReductionStacking(float percent, float count) { return Mathf.Pow(1f - percent / 100f, count); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Asriel_DTPG.PokeItems", "PokeItems", "0.0.1")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class PokeItems : BaseUnityPlugin { public const string PluginGUID = "Asriel_DTPG.PokeItems"; public const string PluginAuthor = "Asriel_DTPG"; public const string PluginName = "PokeItems"; public const string PluginVersion = "0.0.1"; public static ExpansionDef sotvDLC; public static ExpansionDef sotsDLC; public void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0022: Unknown result type (might be due to invalid IL or missing references) sotvDLC = Addressables.LoadAssetAsync((object)"RoR2/DLC1/Common/DLC1.asset").WaitForCompletion(); sotsDLC = Addressables.LoadAssetAsync((object)"RoR2/DLC2/Common/DLC2.asset").WaitForCompletion(); Log.Init(((BaseUnityPlugin)this).Logger); Leftovers.Init(); FlameOrb.Init(); PoppedAirBalloon.Init(); AirBalloon.Init(); Log.Message("PokeItems mod is ready!", "C:\\Users\\dylan\\Documents\\GitHub\\PokeItemsRoR2\\PokeItems.cs", 64); } private void Update() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_006d: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown((KeyCode)283)) { Transform transform = PlayerCharacterMasterController.instances[0].master.GetBodyObject().transform; Log.Info($"Player pressed key. Spawning our custom item at coordinates {transform.position}", "C:\\Users\\dylan\\Documents\\GitHub\\PokeItemsRoR2\\PokeItems.cs", 80); PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(AirBalloon.itemDef.itemIndex), transform.position, transform.forward * 30f); } if (Input.GetKeyDown((KeyCode)284)) { Transform transform2 = PlayerCharacterMasterController.instances[0].master.GetBodyObject().transform; Log.Info($"Player pressed key. Spawning our custom item at coordinates {transform2.position}", "C:\\Users\\dylan\\Documents\\GitHub\\PokeItemsRoR2\\PokeItems.cs", 92); PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(FlameOrb.itemDef.itemIndex), transform2.position, transform2.forward * 30f); } if (Input.GetKeyDown((KeyCode)285)) { Transform transform3 = PlayerCharacterMasterController.instances[0].master.GetBodyObject().transform; Log.Info($"Player pressed key. Spawning our custom item at coordinates {transform3.position}", "C:\\Users\\dylan\\Documents\\GitHub\\PokeItemsRoR2\\PokeItems.cs", 104); PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(Leftovers.itemDef.itemIndex), transform3.position, transform3.forward * 30f); } } } } namespace PokeItems.Items { internal class AirBalloon { [CompilerGenerated] private static class <>O { public static hook_TakeDamage <0>__DamagedHooks; public static hook_FixedUpdate <1>__BehaviorHooks; } public static ItemDef itemDef; private static ItemTier tier = (ItemTier)0; public static float fallSpeedLimit = 50f; public static float fallPercentReductionPerExtraStack = 10f; public static float hpThresholdPercent = 35f; public static void Init() { //IL_0006: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0084: 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_008f: Expected O, but got Unknown itemDef = ItemManager.CreateItemDef("AIRBALLOON", tier, true, false, (ItemTag[])(object)new ItemTag[2] { (ItemTag)3, (ItemTag)31 }, fallSpeedLimit, fallPercentReductionPerExtraStack, hpThresholdPercent); object obj = <>O.<0>__DamagedHooks; if (obj == null) { hook_TakeDamage val = DamagedHooks; <>O.<0>__DamagedHooks = val; obj = (object)val; } HealthComponent.TakeDamage += (hook_TakeDamage)obj; object obj2 = <>O.<1>__BehaviorHooks; if (obj2 == null) { hook_FixedUpdate val2 = BehaviorHooks; <>O.<1>__BehaviorHooks = val2; obj2 = (object)val2; } CharacterMotor.FixedUpdate += (hook_FixedUpdate)obj2; } private static void DamagedHooks(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo) { orig.Invoke(self, damageInfo); Log.Info("Air Balloon damage hook fired", "C:\\Users\\dylan\\Documents\\GitHub\\PokeItemsRoR2\\Items\\AirBalloon.cs", 35); CharacterBody body = self.body; if ((Object)(object)body == (Object)null) { return; } int itemCountEffective = body.inventory.GetItemCountEffective(itemDef); if (itemCountEffective > 0) { float num = self.combinedHealth / self.fullCombinedHealth; if (num <= hpThresholdPercent / 100f) { PopAllBalloons(body.inventory); } } } private static void PopAllBalloons(Inventory inventory) { //IL_00ab: 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) int itemCountEffective = inventory.GetItemCountEffective(itemDef); if (itemCountEffective <= 0) { return; } Log.Info($"Removing {itemCountEffective} Air Balloons", "C:\\Users\\dylan\\Documents\\GitHub\\PokeItemsRoR2\\Items\\AirBalloon.cs", 70); inventory.RemoveItem(itemDef, itemCountEffective); Log.Info($"Giving {itemCountEffective} Popped Balloons", "C:\\Users\\dylan\\Documents\\GitHub\\PokeItemsRoR2\\Items\\AirBalloon.cs", 72); inventory.GiveItem(PoppedAirBalloon.itemDef, itemCountEffective); CharacterMaster component = ((Component)inventory).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { CharacterBody body = component.GetBody(); if (Object.op_Implicit((Object)(object)body) && body.isPlayerControlled) { CharacterMasterNotificationQueue.PushItemTransformNotification(component, itemDef.itemIndex, PoppedAirBalloon.itemDef.itemIndex, (TransformationType)0); } } } private static void BehaviorHooks(orig_FixedUpdate orig, CharacterMotor self) { //IL_00ae: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); CharacterBody body = self.body; if ((Object)(object)body == (Object)null || (Object)(object)body.inventory == (Object)null) { return; } int itemCountEffective = body.inventory.GetItemCountEffective(itemDef); if (itemCountEffective > 0 && self.velocity.y < 0f) { float num = 1f; if (itemCountEffective >= 2) { num = MathUtility.GetExponentialPercentReductionStacking(fallPercentReductionPerExtraStack, itemCountEffective - 1); } float num2 = (0f - fallSpeedLimit) * num; if (self.velocity.y < num2) { Vector3 velocity = self.velocity; velocity.y = num2; self.velocity = velocity; } } } } internal class FlameOrb { [CompilerGenerated] private static class <>O { public static hook_OnHitEnemy <0>__HitHooks; } public static ItemDef itemDef; private static ItemTier tier = (ItemTier)0; public static float procPercentPerStack = 10f; public static float debuffDuration = 4f; public static float damageMul = 1f; public static void Init() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown itemDef = ItemManager.CreateItemDef("FLAMEORB", tier, true, false, (ItemTag[])(object)new ItemTag[2] { (ItemTag)1, (ItemTag)31 }, procPercentPerStack); object obj = <>O.<0>__HitHooks; if (obj == null) { hook_OnHitEnemy val = HitHooks; <>O.<0>__HitHooks = val; obj = (object)val; } GlobalEventManager.OnHitEnemy += (hook_OnHitEnemy)obj; } private static void HitHooks(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, damageInfo, victim); if ((Object)(object)damageInfo.attacker == (Object)null || (Object)(object)victim == (Object)null) { return; } CharacterBody component = damageInfo.attacker.GetComponent(); CharacterBody component2 = victim.GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || (Object)(object)component.inventory == (Object)null) { return; } int itemCountEffective = component.inventory.GetItemCountEffective(itemDef); if (itemCountEffective > 0) { float linearStacking = MathUtility.GetLinearStacking(procPercentPerStack, itemCountEffective, damageInfo.procCoefficient); if (Util.CheckRoll(linearStacking, component.master)) { InflictDotInfo val = new InflictDotInfo { victimObject = victim, attackerObject = damageInfo.attacker, dotIndex = (DotIndex)1, duration = debuffDuration, damageMultiplier = damageMul }; StrengthenBurnUtils.CheckDotForUpgrade(component.inventory, ref val); DotController.InflictDot(ref val); } } } } internal class ItemManager { public static ItemDef itemDef; public static readonly Dictionary tokenMap = new Dictionary(); public unsafe static ItemDef CreateItemDef(string name, ItemTier tier, bool canRemove, bool hidden, ItemTag[] tags, params object[] itemTokens) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) itemDef = ScriptableObject.CreateInstance(); ((Object)itemDef).name = name; itemDef.nameToken = "ITEM_" + ((Object)itemDef).name + "_NAME"; itemDef.pickupToken = "ITEM_" + ((Object)itemDef).name + "_PICKUP"; itemDef.descriptionToken = "ITEM_" + ((Object)itemDef).name + "_DESC"; itemDef.loreToken = "ITEM_" + ((Object)itemDef).name + "_LORE"; tokenMap[itemDef.descriptionToken] = itemTokens; itemDef.deprecatedTier = tier; itemDef.pickupIconSprite = Addressables.LoadAssetAsync((object)"RoR2/Base/Common/MiscIcons/texMysteryIcon.png").WaitForCompletion(); itemDef.pickupModelPrefab = Addressables.LoadAssetAsync((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion(); itemDef.canRemove = canRemove; itemDef.hidden = hidden; itemDef.tags = tags; ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null); Language.onCurrentLanguageChanged += FormatDescription; ItemAPI.Add(new CustomItem(itemDef, val)); string text = ""; for (int i = 0; i < tags.Length; i++) { text = text + ((object)tags[i]/*cast due to .constrained prefix*/).ToString() + ", "; } Log.Info("Item created: " + name + "; Tier: " + ((object)(*(ItemTier*)(&tier))/*cast due to .constrained prefix*/).ToString() + "; Tags: " + text.Trim(), "C:\\Users\\dylan\\Documents\\GitHub\\PokeItemsRoR2\\Items\\ItemManager.cs", 58); return itemDef; } private static void FormatDescription() { foreach (KeyValuePair item in tokenMap) { string stringFormatted = Language.GetStringFormatted(item.Key, item.Value); LanguageAPI.AddOverlay(item.Key, stringFormatted); } } } internal class Leftovers { [CompilerGenerated] private static class <>O { public static StatHookEventHandler <0>__StatHooks; } public static ItemDef itemDef; private static ItemTier tier = (ItemTier)1; public static float regenBonusPerStack = 4f; public static float regenBonusPerExtraStack = 2f; public static void Init() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown itemDef = ItemManager.CreateItemDef("LEFTOVERS", tier, true, false, (ItemTag[])(object)new ItemTag[2] { (ItemTag)2, (ItemTag)31 }, regenBonusPerStack, regenBonusPerExtraStack); object obj = <>O.<0>__StatHooks; if (obj == null) { StatHookEventHandler val = StatHooks; <>O.<0>__StatHooks = val; obj = (object)val; } RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj; } private static void StatHooks(CharacterBody body, StatHookEventArgs args) { if (Object.op_Implicit((Object)(object)body.inventory)) { int itemCountEffective = body.inventory.GetItemCountEffective(itemDef); if (itemCountEffective > 0) { args.baseRegenAdd += MathUtility.GetLinearWithExtraStacking(regenBonusPerStack, regenBonusPerExtraStack, itemCountEffective); } } } } internal class PoppedAirBalloon { public static ItemDef itemDef; private static ItemTier tier = (ItemTier)5; public static void Init() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) itemDef = ItemManager.CreateItemDef("POPPEDAIRBALLOON", tier, false, false, Array.Empty()); } } }