Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of DeathsRegardsRevived v1.1.1
DeathsRegards.dll
Decompiled 6 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 HG.Reflection; using Microsoft.CodeAnalysis; using On.RoR2; using R2API; using R2API.Utils; using RoR2; using RoR2.Achievements; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("DeathsRegards")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("DeathsRegards")] [assembly: AssemblyTitle("DeathsRegards")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: UnverifiableCode] 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 DeathsRegardsMod { public class DeathsRegardsItem { [RegisterAchievement("DeathsRegards", "DeathsRegardsUnlock", null, 10u, typeof(DeathsRegardsAchievement))] public class DeathsRegardsAchievement : BaseAchievement { public override void OnInstall() { ((BaseAchievement)this).OnInstall(); RoR2Application.onUpdate += GrantRegards; } public override void OnUninstall() { RoR2Application.onUpdate -= GrantRegards; ((BaseAchievement)this).OnUninstall(); } private void GrantRegards() { //IL_0058: 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) if (((BaseAchievement)this).localUser != null && (Object)(object)((BaseAchievement)this).localUser.cachedBody != (Object)null && (Object)(object)((BaseAchievement)this).localUser.cachedBody.inventory != (Object)null && ((BaseAchievement)this).localUser.cachedBody.inventory.GetItemCountPermanent(ItemCatalog.GetItemDef(ItemCatalog.FindItemIndex("ExtraLifeConsumed"))) > 0 && (Object)(object)ItemCatalog.GetItemDef(ItemCatalog.FindItemIndex("ExtraLifeConsumed")) != (Object)null) { ((BaseAchievement)this).Grant(); } } } public GameObject ItemModel; public Sprite ItemSprite; public Dictionary<int, float> Cooldowns; private const float CooldownTime = 60f; private const float ShieldItemFactor = 2f; public ItemDef Definition { get; private set; } public DeathsRegardsItem() { LoadAssets(); BuildItemDefinition(); Cooldowns = new Dictionary<int, float>(); } private void LoadAssets() { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DeathsRegards.deathsregardsmod"); AssetBundle val = AssetBundle.LoadFromStream(stream); ItemModel = val.LoadAsset<GameObject>("Assets/craneo.obj"); ItemSprite = val.LoadAsset<Sprite>("Assets/icon.png"); } public void BuildItemDefinition() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) Definition = ScriptableObject.CreateInstance<ItemDef>(); ItemDef definition = Definition; UnlockableDef val = ScriptableObject.CreateInstance<UnlockableDef>(); val.cachedName = "DeathsRegardsUnlock"; val.nameToken = "DEATHS_REGARDS_UNLOCK_NAME"; val.achievementIcon = ItemSprite; ((Object)definition).name = "DeathsRegards"; definition.deprecatedTier = (ItemTier)2; definition.tags = (ItemTag[])(object)new ItemTag[2] { (ItemTag)3, (ItemTag)31 }; definition.pickupModelPrefab = ItemModel; definition.pickupIconSprite = ItemSprite; definition.nameToken = "DEATHSITEM_NAME"; definition.pickupToken = "DEATHSITEM_PICKUP"; definition.descriptionToken = "DEATHSITEM_DESC"; definition.loreToken = "DEATHSITEM_LORE"; ContentAddition.AddUnlockableDef(val); Definition.unlockableDef = val; } public ItemDisplayRuleDict BuildDisplayRules() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_001c: 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_0054: 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) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00b0: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: 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_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_047b: 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_0496: 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_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: 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_0514: 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_052f: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05be: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_05ed: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Unknown result type (might be due to invalid IL or missing references) //IL_0637: Unknown result type (might be due to invalid IL or missing references) //IL_063c: Unknown result type (might be due to invalid IL or missing references) //IL_0652: Unknown result type (might be due to invalid IL or missing references) //IL_0657: Unknown result type (might be due to invalid IL or missing references) //IL_065c: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Unknown result type (might be due to invalid IL or missing references) ItemDisplayRuleDict val = new ItemDisplayRuleDict(Array.Empty<ItemDisplayRule>()); val.Add("mdlCommandoDualies", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemModel, childName = "FootL", localPos = new Vector3(0.01159f, 0.14157f, -0.06636f), localAngles = new Vector3(300f, 180f, 180f), localScale = new Vector3(0.1f, 0.1f, 0.1f) } }); val.Add("mdlHuntress", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemModel, childName = "FootL", localPos = new Vector3(0.01371f, 0.05648f, -0.09268f), localAngles = new Vector3(300f, 180f, 180f), localScale = new Vector3(0.075f, 0.075f, 0.075f) } }); val.Add("mdlToolbot", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemModel, childName = "MainWheelL", localPos = new Vector3(-0.01748f, 1.08975f, -1.52357f), localAngles = new Vector3(300f, 0f, 0f), localScale = new Vector3(1f, 1f, 1f) } }); val.Add("mdlEngi", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemModel, childName = "FootL", localPos = new Vector3(-0.00026f, 0.20756f, -0.12849f), localAngles = new Vector3(310f, 180f, 180f), localScale = new Vector3(0.1f, 0.1f, 0.1f) } }); val.Add("mdlMage", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemModel, childName = "FootL", localPos = new Vector3(-0.0118f, 0.09237f, -0.05244f), localAngles = new Vector3(15f, 180f, 180f), localScale = new Vector3(0.075f, 0.075f, 0.075f) } }); val.Add("mdlMerc", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemModel, childName = "FootL", localPos = new Vector3(-0.00364f, 0.07695f, -0.06853f), localAngles = new Vector3(340f, 180f, 180f), localScale = new Vector3(0.075f, 0.075f, 0.075f) } }); val.Add("mdlTreebot", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemModel, childName = "FootFrontL", localPos = new Vector3(0.00159f, 0.024f, -0.00071f), localAngles = new Vector3(0f, 120f, 180f), localScale = new Vector3(0.3f, 0.3f, 0.3f) } }); val.Add("mdlLoader", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemModel, childName = "FootL", localPos = new Vector3(0.0136f, 0.0441f, -0.08881f), localAngles = new Vector3(1E-05f, 180f, 180f), localScale = new Vector3(0.1f, 0.1f, 0.1f) } }); val.Add("mdlCroco", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemModel, childName = "FootL", localPos = new Vector3(-0.1655f, 0.32189f, -1.2976f), localAngles = new Vector3(10f, 180f, 180f), localScale = new Vector3(0.5f, 0.5f, 0.5f) } }); val.Add("mdlCaptain", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemModel, childName = "FootL", localPos = new Vector3(0.05678f, 0.12228f, -0.13881f), localAngles = new Vector3(345f, 150f, 180f), localScale = new Vector3(0.08f, 0.08f, 0.08f) } }); val.Add("mdlBandit2", (ItemDisplayRule[])(object)new ItemDisplayRule[1] { new ItemDisplayRule { ruleType = (ItemDisplayRuleType)0, followerPrefab = ItemModel, childName = "FootL", localPos = new Vector3(0.02064f, 0.09363f, -0.11238f), localAngles = new Vector3(330f, 170f, 180f), localScale = new Vector3(0.1f, 0.1f, 0.1f) } }); return val; } internal void OnRunStart(orig_Start orig, Run self) { Cooldowns.Clear(); orig.Invoke(self); } internal void OnTakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo) { orig.Invoke(self, damageInfo); if ((Object)(object)self.body.inventory == (Object)null) { return; } int itemCount = self.body.inventory.GetItemCount(Definition); if (itemCount > 0 && self.combinedHealthFraction < 0.3f) { int instanceID = ((Object)self.body.inventory).GetInstanceID(); if (!Cooldowns.TryGetValue(instanceID, out var value)) { value = 0f; } float time = Time.time; if (value + CalculateCooldown(itemCount) < time) { self.AddBarrier(damageInfo.damage * 2f); Cooldowns[instanceID] = time; } } } private static float CalculateCooldown(int itemCount) { if (itemCount == 1) { return 60f; } return 60f / (1.5f * (float)(itemCount - 1)); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [R2APISubmoduleDependency(new string[] { "ItemAPI", "LanguageAPI" })] [BepInPlugin("com.phreel.deathsregardsrevived", "DeathsRegardsRevived", "1.1.1")] public class DeathsRegardsMod : BaseUnityPlugin { private const string ModVer = "1.1.1"; private const string ModName = "DeathsRegardsRevived"; private const string ModGuid = "com.phreel.deathsregardsrevived"; private static DeathsRegardsItem item; public static DeathsRegardsItem Item { get { return item; } set { item = value; } } public void Awake() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown AddLanguageTokens(); Item = new DeathsRegardsItem(); AddItem(Item); Run.Start += new hook_Start(Item.OnRunStart); HealthComponent.TakeDamage += new hook_TakeDamage(Item.OnTakeDamage); CommandHelper.AddToConsoleWhenReady(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private void AddItem(DeathsRegardsItem item) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown CustomItem val = new CustomItem(item.Definition, item.BuildDisplayRules()); if (!ItemAPI.Add(val)) { ((BaseUnityPlugin)this).Logger.LogError((object)"Unable to add Death's Regards"); } } private static void AddLanguageTokens() { LanguageAPI.Add("DEATHSITEM_NAME", "Death's Regards"); LanguageAPI.Add("DEATHSITEM_PICKUP", "Barrier after taking high damage."); LanguageAPI.Add("DEATHSITEM_DESC", "Upon taking <style=cIsDamage>damage</style> to below <style=cIsDamage>30% combined health</style>, gain a <style=cIsUtility>barrier</style> for <style=cIsUtility>200%</style> of the damage dealt. Recharges after <style=cIsUtility>60 seconds</style> <style=cStack>(-33% per stack)</style>."); LanguageAPI.Add("DEATHSITEM_LORE", "Death seldom gives his regards, but something strange resides inside you, survivor."); LanguageAPI.Add("ACHIEVEMENT_DEATHSREGARDS_NAME", "Lord Death's Regards"); LanguageAPI.Add("ACHIEVEMENT_DEATHSREGARDS_DESCRIPTION", "Cheat death by using Dio's Best Friend."); LanguageAPI.Add("DEATHS_REGARDS_UNLOCK_NAME", "Death's Regards"); } } }