Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of FlowareItemPack v1.2.5
FlowareItemPack.dll
Decompiled 10 months agousing 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 FlowareItemPack.Core; using FlowareItemPack.Items; using HarmonyLib; using Microsoft.CodeAnalysis; using On.RoR2; using On.RoR2.Items; using R2API; using RoR2; using RoR2.ExpansionManagement; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; [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("FlowareItemPack")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+7eca0c795921cd54507f416cd400a09b80595979")] [assembly: AssemblyProduct("FlowareItemPack")] [assembly: AssemblyTitle("FlowareItemPack")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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; } } } public abstract class BaseItem { public abstract ItemDef ItemDef { get; } public abstract void Initialize(); public virtual void Hook() { } public virtual void Unhook() { } } namespace FlowareItemPack { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Floware.FlowareItemPack", "FlowareItemPack", "1.2.5")] public class FlowareItemPack : BaseUnityPlugin { public const string PluginGUID = "Floware.FlowareItemPack"; public const string PluginAuthor = "Floware"; public const string PluginName = "FlowareItemPack"; public const string PluginVersion = "1.2.5"; private readonly List<BaseItem> _items = new List<BaseItem>(); public void Awake() { Log.Init(((BaseUnityPlugin)this).Logger); _items.Add(new BoxOMatches()); _items.Add(new DisperseObsidian()); foreach (BaseItem item in _items) { item.Initialize(); Debug.Log((object)("Initializing " + ((Object)item.ItemDef).name)); } } private void OnDestroy() { foreach (BaseItem item in _items) { item.Unhook(); } } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } } namespace FlowareItemPack.Items { public class PlaceHolderVoid : BaseItem { public override ItemDef ItemDef { get; } = ScriptableObject.CreateInstance<ItemDef>(); public override void Initialize() { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) Assets assets = new Assets(); assets.PopulateAssets("matches", "matches"); ((Object)ItemDef).name = "void_matches"; ItemDef.nameToken = "FLOWARE_VOIDMATCHES_NAME"; ItemDef.pickupToken = "FLOWARE_VOIDMATCHES_PICKUP"; ItemDef.descriptionToken = "FLOWARE_VOIDMATCHES_DESC"; ItemDef.loreToken = "FLOWARE_VOIDMATCHES_LORE"; LanguageAPI.Add("FLOWARE_VOIDMATCHES_NAME", ""); LanguageAPI.Add("FLOWARE_VOIDMATCHES_PICKUP", ""); LanguageAPI.Add("FLOWARE_VOIDMATCHES_DESC", ""); LanguageAPI.Add("FLOWARE_VOIDMATCHES_LORE", ""); ItemDef.tier = (ItemTier)6; ItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/DLC1/Common/VoidTier1Def.asset").WaitForCompletion(); ItemDef.pickupIconSprite = assets.icon; ItemDef.pickupModelPrefab = assets.prefab; ItemDef.tags = (ItemTag[])(object)new ItemTag[0]; ItemDef.canRemove = true; ItemDef.hidden = false; ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null); ItemAPI.Add(new CustomItem(ItemDef, val)); if (((ResourceAvailability)(ref ItemTierCatalog.availability)).available) { ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef((ItemTier)6); if ((Object)(object)itemTierDef != (Object)null) { itemTierDef.dropletDisplayPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/Common/VoidItemPickup.prefab").WaitForCompletion(); } } Hook(); } public override void Hook() { } public override void Unhook() { } private void OnServerDamageDealt(DamageReport report) { } } public class BoxOMatches : BaseItem { public override ItemDef ItemDef { get; } = ScriptableObject.CreateInstance<ItemDef>(); public override void Initialize() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown Assets assets = new Assets(); assets.PopulateAssets("matches", "matches"); ((Object)ItemDef).name = "Matches"; ItemDef.nameToken = "FLOWARE_MATCHES_NAME"; ItemDef.pickupToken = "FLOWARE_MATCHES_PICKUP"; ItemDef.descriptionToken = "FLOWARE_MATCHES_DESC"; ItemDef.loreToken = "FLOWARE_MATCHES_LORE"; LanguageAPI.Add("FLOWARE_MATCHES_NAME", "Box O' Matches"); LanguageAPI.Add("FLOWARE_MATCHES_PICKUP", "Light em' up, break em' down."); LanguageAPI.Add("FLOWARE_MATCHES_DESC", "5% chance (+5% per stack) to set enemies on fire for 2 seconds (+0.5s per stack), dealing 10% base damage."); LanguageAPI.Add("FLOWARE_MATCHES_LORE", "An old, half-empty box of matches. Each one a spark waiting to ignite chaos."); ItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier1Def.asset").WaitForCompletion(); ItemDef.pickupIconSprite = assets.icon; ItemDef.pickupModelPrefab = assets.prefab; ItemDef.tags = (ItemTag[])(object)new ItemTag[2] { (ItemTag)1, (ItemTag)21 }; ItemDef.canRemove = true; ItemDef.hidden = false; ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null); ItemAPI.Add(new CustomItem(ItemDef, val)); Hook(); } public override void Hook() { GlobalEventManager.onServerDamageDealt += GlobalEventManager_onServerDamageDealt; } public override void Unhook() { GlobalEventManager.onServerDamageDealt -= GlobalEventManager_onServerDamageDealt; } private void GlobalEventManager_onServerDamageDealt(DamageReport report) { //IL_0031: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Invalid comparison between Unknown and I4 //IL_013a: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)report.attackerBody) || !Object.op_Implicit((Object)(object)report.victimBody) || DamageTypeCombo.op_Implicit(report.damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)67108864)) != 0) { return; } CharacterBody attackerBody = report.attackerBody; Inventory inventory = attackerBody.inventory; if (!Object.op_Implicit((Object)(object)inventory)) { return; } int itemCount = inventory.GetItemCount(ItemDef.itemIndex); CharacterBody victimBody = report.victimBody; ItemDef itemDef = ItemCatalog.GetItemDef(ItemCatalog.FindItemIndex("StrengthenBurn")); if (itemCount > 0 && Util.CheckRoll(5f * (float)itemCount, attackerBody.master)) { float num = 2f * (float)itemCount; float num2 = report.attackerBody.baseDamage * 0.1f; int itemCount2 = inventory.GetItemCount(itemDef.itemIndex); DotIndex val = (DotIndex)((itemCount2 <= 0) ? 1 : 7); DotController val2 = DotController.FindDotController(((Component)victimBody).gameObject); if ((int)val == 7) { num2 *= (float)(4 * itemCount2); } DotController.InflictDot(((Component)report.victimBody).gameObject, ((Component)report.attackerBody).gameObject, val, num, num2, (uint?)null); } } } internal class DisperseObsidian : BaseItem { private GameObject effect; private GameObject effect2; public override ItemDef ItemDef { get; } = ScriptableObject.CreateInstance<ItemDef>(); public override void Initialize() { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_0133: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown Assets assets = new Assets(); assets.PopulateAssets("disperseobsidian", "disperseobsidian"); ((Object)ItemDef).name = "disperse_obsidian"; ItemDef.nameToken = "FLOWARE_DISPERSEOBSIDIAN_NAME"; ItemDef.pickupToken = "FLOWARE_DISPERSEOBSIDIAN_PICKUP"; ItemDef.descriptionToken = "FLOWARE_DISPERSEOBSIDIAN_DESC"; ItemDef.loreToken = "FLOWARE_DISPERSEOBSIDIAN_LORE"; LanguageAPI.Add("FLOWARE_DISPERSEOBSIDIAN_NAME", "Disperse Obsidian"); LanguageAPI.Add("FLOWARE_DISPERSEOBSIDIAN_PICKUP", "Deal bonus damage to enemies at long distance. <color=#ed7fcd>Corrupts all Focus Crystals </color>"); LanguageAPI.Add("FLOWARE_DISPERSEOBSIDIAN_DESC", "Grants a damage boost against enemies further away. Displays a pulsating effect around the player. <color=#ed7fcd>Corrupts all Focus Crystals </color>"); LanguageAPI.Add("FLOWARE_DISPERSEOBSIDIAN_LORE", "A shard that resonates with the distant echoes of battle."); ItemDef.tier = (ItemTier)6; ItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/DLC1/Common/VoidTier1Def.asset").WaitForCompletion(); ItemDef.tags = (ItemTag[])(object)new ItemTag[1] { (ItemTag)1 }; ItemDef.pickupIconSprite = assets.icon; ItemDef.pickupModelPrefab = assets.prefab; ItemDef.canRemove = true; ItemDef.hidden = false; ItemAPI.Add(new CustomItem(ItemDef, new ItemDisplayRuleDict((ItemDisplayRule[])null))); Hook(); } public override void Hook() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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 CharacterMaster.OnInventoryChanged += new hook_OnInventoryChanged(OnInventoryChanged); HealthComponent.TakeDamage += new hook_TakeDamage(OnDamageDealt); ContagiousItemManager.Init += new hook_Init(SetTransformation); } public override void Unhook() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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 CharacterMaster.OnInventoryChanged -= new hook_OnInventoryChanged(OnInventoryChanged); HealthComponent.TakeDamage -= new hook_TakeDamage(OnDamageDealt); ContagiousItemManager.Init -= new hook_Init(SetTransformation); } private unsafe void SetTransformation(orig_Init orig) { //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) ExpansionDef requiredExpansion = (ExpansionDef)Unsafe.Read<object>((void*)ExpansionCatalog.expansionDefs[0]); ItemDef.requiredExpansion = requiredExpansion; Pair val = default(Pair); val.itemDef1 = Items.NearbyDamageBonus; val.itemDef2 = ItemDef; Pair val2 = val; ItemCatalog.itemRelationships[ItemRelationshipTypes.ContagiousItem] = CollectionExtensions.AddToArray<Pair>(ItemCatalog.itemRelationships[ItemRelationshipTypes.ContagiousItem], val2); orig.Invoke(); } private void OnInventoryChanged(orig_OnInventoryChanged orig, CharacterMaster self) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); if (!Object.op_Implicit((Object)(object)self) || !Object.op_Implicit((Object)(object)self.inventory)) { return; } CharacterBody body = self.GetBody(); if (Object.op_Implicit((Object)(object)body) && body.isPlayerControlled) { int itemCount = self.inventory.GetItemCount(ItemDef.itemIndex); if (itemCount > 0) { Debug.Log((object)"DEBUG: Item added, creating effect."); InstantiateEffect(body); } else { Debug.Log((object)"DEBUG: Item removed, destroying effect."); DestroyEffect(); } } } private void InstantiateEffect(CharacterBody self) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00dc: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)"Attempting to load NearbyDamageBonusIndicator from LegacyResourcesAPI."); GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/NetworkedObjects/NearbyDamageBonusIndicator"); if ((Object)(object)val == (Object)null) { Debug.LogError((object)"Failed to load NearbyDamageBonusIndicator."); return; } Debug.Log((object)"Prefab loaded successfully. Instantiating..."); GameObject val2 = Object.Instantiate<GameObject>(val, self.corePosition, Quaternion.identity); if ((Object)(object)val2 == (Object)null) { Debug.LogError((object)"Failed to instantiate NearbyDamageBonusIndicator."); return; } NetworkIdentity val3 = default(NetworkIdentity); if (!val2.TryGetComponent<NetworkIdentity>(ref val3)) { val3 = val2.AddComponent<NetworkIdentity>(); Debug.LogWarning((object)"Added NetworkIdentity to spawnedObject."); } Debug.Log((object)"Attaching NetworkedBodyAttachment."); float num = 2.3f; Transform transform = val2.transform; transform.localScale *= num; MeshRenderer componentInChildren = val2.GetComponentInChildren<MeshRenderer>(); if ((Object)(object)componentInChildren != (Object)null) { ((Renderer)componentInChildren).material.color = Color.green; Debug.Log((object)"Ring color changed to purple."); } else { Debug.LogError((object)"No MeshRenderer found in NearbyDamageBonusIndicator."); } NetworkedBodyAttachment component = val2.GetComponent<NetworkedBodyAttachment>(); if ((Object)(object)component == (Object)null) { Debug.LogError((object)"NearbyDamageBonusIndicator is missing NetworkedBodyAttachment."); return; } Debug.LogError((object)"No Renderer found on NearbyDamageBonusIndicator."); val2.transform.SetParent(self.transform, true); component.AttachToGameObjectAndSpawn(((Component)self).gameObject, (string)null); effect = val2; } private void DestroyEffect() { if ((Object)(object)effect != (Object)null) { Object.Destroy((Object)(object)effect); effect = null; Object.Destroy((Object)(object)effect2); } } private void OnDamageDealt(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { orig.Invoke(self, damageInfo); return; } if ((Object)(object)damageInfo.attacker == (Object)null) { orig.Invoke(self, damageInfo); return; } CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>(); if ((Object)(object)component == (Object)null) { orig.Invoke(self, damageInfo); return; } Inventory inventory = component.inventory; if ((Object)(object)inventory == (Object)null) { orig.Invoke(self, damageInfo); return; } int itemCount = inventory.GetItemCount(ItemDef.itemIndex); if (itemCount <= 0) { orig.Invoke(self, damageInfo); return; } float num = Vector3.Distance(component.transform.position, ((Component)self).transform.position); if (num > 29.9f) { damageInfo.damage *= 1f + 0.2f * (float)itemCount; damageInfo.damageColorIndex = (DamageColorIndex)9; } orig.Invoke(self, damageInfo); } } } namespace FlowareItemPack.Core { public class Assets { public Sprite icon; public GameObject prefab; public static AssetBundle _assetBundle; public void PopulateAssets(string iconName, string prefabName) { if ((Object)(object)_assetBundle == (Object)null) { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("FlowareItemPack.import"); _assetBundle = AssetBundle.LoadFromStream(stream); } icon = _assetBundle.LoadAsset<Sprite>("assets/import/icons/" + iconName + ".png"); prefab = _assetBundle.LoadAsset<GameObject>("assets/import/prefabs/" + prefabName + ".prefab"); } } }