Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of SoySauceRevived v1.0.4
SoySauceRevived.dll
Decompiled 2 weeks agousing 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; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using On.RoR2; using R2API; using R2API.Utils; using RoR2; using SoySauceRevived.Items; using UnityEngine; [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("SoySauceRevived")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SoySauceRevived")] [assembly: AssemblyTitle("SoySauceRevived")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace SoySauceRevived { [BepInPlugin("com.Phreel.SoySauceRevived", "SoySauceRevived", "1.0.4")] [BepInDependency("com.bepis.r2api", "4.4.1")] [R2APISubmoduleDependency(new string[] { "ItemAPI", "LanguageAPI", "EliteAPI", "DamageAPI", "PrefabAPI" })] public class Main : BaseUnityPlugin { public const string ModGuid = "com.Phreel.SoySauceRevived"; public const string ModName = "SoySauceRevived"; public const string ModVer = "1.0.4"; public static AssetBundle MainAssets; public List<ItemBase> Items = new List<ItemBase>(); private void Awake() { using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("SoySauceRevived.soysauceassets")) { MainAssets = AssetBundle.LoadFromStream(stream); } IEnumerable<Type> enumerable = from type in Assembly.GetExecutingAssembly().GetTypes() where !type.IsAbstract && type.IsSubclassOf(typeof(ItemBase)) select type; foreach (Type item in enumerable) { ItemBase itemBase = (ItemBase)Activator.CreateInstance(item); if (ValidateItem(itemBase, Items)) { itemBase.Init(((BaseUnityPlugin)this).Config); } } } public bool ValidateItem(ItemBase item, List<ItemBase> itemList) { bool value = ((BaseUnityPlugin)this).Config.Bind<bool>("Item: " + item.ItemName, "Enable Item?", true, "Should this item appear in runs?").Value; bool value2 = ((BaseUnityPlugin)this).Config.Bind<bool>("Item: " + item.ItemName, "Blacklist Item from AI Use?", false, "Should the AI not be able to obtain this item?").Value; if (value) { itemList.Add(item); if (value2) { item.AIBlacklisted = true; } } return value; } } } namespace SoySauceRevived.Items { public abstract class ItemBase<T> : ItemBase where T : ItemBase<T> { public static T instance { get; private set; } public ItemBase() { if (instance != null) { throw new InvalidOperationException("Singleton class \"" + typeof(T).Name + "\" inheriting ItemBase was instantiated twice"); } instance = this as T; } } public abstract class ItemBase { public ItemDef ItemDef; public abstract string ItemName { get; } public abstract string ItemLangTokenName { get; } public abstract string ItemPickupDesc { get; } public abstract string ItemFullDescription { get; } public abstract string ItemLore { get; } public abstract ItemTier Tier { get; } public virtual ItemTag[] ItemTags { get; set; } = (ItemTag[])(object)new ItemTag[0]; public abstract GameObject ItemModel { get; } public abstract Sprite ItemIcon { get; } public virtual bool CanRemove { get; } = true; public virtual bool AIBlacklisted { get; set; } = false; public abstract void Init(ConfigFile config); public virtual void CreateConfig(ConfigFile config) { } protected virtual void CreateLang() { LanguageAPI.Add("ITEM_" + ItemLangTokenName + "_NAME", ItemName); LanguageAPI.Add("ITEM_" + ItemLangTokenName + "_PICKUP", ItemPickupDesc); LanguageAPI.Add("ITEM_" + ItemLangTokenName + "_DESCRIPTION", ItemFullDescription); LanguageAPI.Add("ITEM_" + ItemLangTokenName + "_LORE", ItemLore); } public abstract ItemDisplayRuleDict CreateItemDisplayRules(); protected void CreateItem() { //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown if (AIBlacklisted) { ItemTags = new List<ItemTag>(ItemTags) { (ItemTag)4 }.ToArray(); } ItemDef = ScriptableObject.CreateInstance<ItemDef>(); ((Object)ItemDef).name = "ITEM_" + ItemLangTokenName; ItemDef.nameToken = "ITEM_" + ItemLangTokenName + "_NAME"; ItemDef.pickupToken = "ITEM_" + ItemLangTokenName + "_PICKUP"; ItemDef.descriptionToken = "ITEM_" + ItemLangTokenName + "_DESCRIPTION"; ItemDef.loreToken = "ITEM_" + ItemLangTokenName + "_LORE"; ItemDef.pickupModelPrefab = ItemModel; ItemDef.pickupIconSprite = ItemIcon; ItemDef.hidden = false; ItemDef.canRemove = CanRemove; ItemDef.deprecatedTier = Tier; if (ItemTags.Length != 0) { ItemDef.tags = ItemTags; } ItemAPI.Add(new CustomItem(ItemDef, CreateItemDisplayRules())); } public virtual void Hooks() { } public int GetCount(CharacterBody body) { if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory)) { return 0; } return body.inventory.GetItemCountEffective(ItemDef); } public int GetCount(CharacterMaster master) { if (!Object.op_Implicit((Object)(object)master) || !Object.op_Implicit((Object)(object)master.inventory)) { return 0; } return master.inventory.GetItemCountEffective(ItemDef); } public int GetCountSpecific(CharacterBody body, ItemDef itemDef) { if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory)) { return 0; } return body.inventory.GetItemCountEffective(itemDef); } } internal class SoySauce : ItemBase { public static ItemDef soySauceDef; private double overallDamageBuff = 0.0; public Dictionary<GameObject, GameObject> userDictionary = new Dictionary<GameObject, GameObject>(); public override string ItemName => "Soy Sauce"; public override string ItemLangTokenName => "SOY_SAUCE"; public override string ItemPickupDesc => "Continue attacking the same target to increase your damage. Reset your bonus upon attacking a new enemy."; public override string ItemFullDescription => "Each time you attack a single target, increase your damage by <style=cIsDamage>1%</style> <style=cStack>(+0.5% per stack).</style> Upon attacking a new enemy, return your base damage to normal."; public override string ItemLore => "Mystical soy sauce that rewards continued use. No matter how much you pour out, it never seems to run dry..."; public override ItemTier Tier => (ItemTier)1; public override GameObject ItemModel => Main.MainAssets.LoadAsset<GameObject>("SoySauce.prefab"); public override Sprite ItemIcon => Main.MainAssets.LoadAsset<Sprite>("SoySauceIcon.png"); public override ItemTag[] ItemTags { get { ItemTag[] array = new ItemTag[3]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); return (ItemTag[])(object)array; } } public override void Init(ConfigFile config) { CreateLang(); CreateItem(); Hooks(); } public override ItemDisplayRuleDict CreateItemDisplayRules() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0023: 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_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_0071: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00b2: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_0105: 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_0120: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_0578: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_059d: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Unknown result type (might be due to invalid IL or missing references) GameObject itemModel = ItemModel; ItemDisplayRuleDict val = new ItemDisplayRuleDict(Array.Empty<ItemDisplayRule>()); val.Add("mdlCommandoDualies", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = itemModel, childName = "Chest", localPos = new Vector3(0.1122f, 0.168f, 0.212f), localAngles = new Vector3(350.1537f, 0.0057f, 359.9348f), localScale = new Vector3(0.04f, 0.04f, 0.04f) } }); val.Add("mdlHuntress", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = itemModel, childName = "Chest", localPos = new Vector3(0.1122f, 0.3168f, 0.212f), localAngles = new Vector3(350.1537f, 0.0057f, 359.9348f), localScale = new Vector3(0.01f, 0.01f, 0.01f) } }); val.Add("mdlToolbot", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = itemModel, childName = "Chest", localPos = new Vector3(0.4493f, 3.1995f, -1.1082f), localAngles = new Vector3(54.7524f, 359.9821f, 0.1173f), localScale = new Vector3(0.04f, 0.004f, 0.004f) } }); val.Add("mdlEngi", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = itemModel, childName = "CannonHeadR", localPos = new Vector3(-0.2175f, 0.2798f, -0.0528f), localAngles = new Vector3(0.4107f, 271.4308f, 238.6879f), localScale = new Vector3(0.01f, 0.01f, 0.01f) } }); val.Add("mdlMage", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = itemModel, childName = "Chest", localPos = new Vector3(0.1244f, 0.1703f, 0.1248f), localAngles = new Vector3(331.7253f, 358.0778f, 4.2768f), localScale = new Vector3(0.01f, 0.01f, 0.01f) } }); val.Add("mdlMerc", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = itemModel, childName = "Chest", localPos = new Vector3(0.0034f, 0.1911f, -0.2936f), localAngles = new Vector3(13.9531f, 359.9117f, 359.09f), localScale = new Vector3(0.01f, 0.01f, 0.01f) } }); val.Add("mdlLoader", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = itemModel, childName = "MechLowerArmL", localPos = new Vector3(0.0018f, 0.6337f, 0.0048f), localAngles = new Vector3(281.7989f, 159.6738f, 152.303f), localScale = new Vector3(0.01f, 0.01f, 0.01f) } }); val.Add("mdlCroco", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = itemModel, childName = "Chest", localPos = new Vector3(0f, 0.2f, 0.3f), localAngles = new Vector3(-180f, 0f, 0f), localScale = new Vector3(0.01f, 0.01f, 0.01f) } }); val.Add("mdlTreebot", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = itemModel, childName = "Eye", localPos = new Vector3(-0.0203f, 0.7649f, 0.0108f), localAngles = new Vector3(270.5436f, 0f, 0f), localScale = new Vector3(0.01f, 0.01f, 0.01f) } }); val.Add("mdlCaptain", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = itemModel, childName = "Pelvis", localPos = new Vector3(0.0545f, -0.1244f, -0.205f), localAngles = new Vector3(345.5598f, 194.8679f, 174.2104f), localScale = new Vector3(0.01f, 0.01f, 0.01f) } }); return val; } public override void Hooks() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown GlobalEventManager.OnHitEnemy += new hook_OnHitEnemy(OnHitEnemy); } private void OnHitEnemy(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim) { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_0157: 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_015e: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, damageInfo, victim); if (!Object.op_Implicit((Object)(object)damageInfo.attacker)) { return; } GameObject attacker = damageInfo.attacker; CharacterBody component = attacker.GetComponent<CharacterBody>(); int count = GetCount(component); if (count > 0) { if (!userDictionary.ContainsKey(attacker)) { userDictionary.Add(attacker, victim); } else if (!((object)victim).Equals((object?)userDictionary[attacker])) { userDictionary[attacker] = victim; overallDamageBuff = 0.0; } else { double num = 0.01 + 0.005 * (double)(count - 1); overallDamageBuff += num; } HealthComponent component2 = victim.GetComponent<HealthComponent>(); ProcChainMask procChainMask = default(ProcChainMask); DamageInfo val = new DamageInfo(); val.damageType = DamageTypeCombo.op_Implicit((DamageType)0); val.damage = (int)Math.Ceiling(overallDamageBuff * (double)damageInfo.damage); val.crit = false; val.procCoefficient = 0f; val.procChainMask = procChainMask; val.damageColorIndex = (DamageColorIndex)3; val.attacker = attacker; val.position = damageInfo.position + default(Vector3); if (overallDamageBuff != 0.0) { component2.TakeDamage(val); } } } } }