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 OneShotArtifact v1.0.1
plugins/OneShotArtifact/OneShotArtifact.dll
Decompiled 2 days agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using R2API; using RoR2; using UnityEngine; [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("CryptidLabs")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("OneShotArtifact")] [assembly: AssemblyTitle("OneShotArtifact")] [assembly: AssemblyVersion("1.0.0.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 OneShotArtifact { [BepInPlugin("com.cryptidlabs.oneshotartifact", "One Shot Artifact", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.cryptidlabs.oneshotartifact"; public const string PluginName = "One Shot Artifact"; public const string PluginVersion = "1.0.0"; internal static ArtifactDef OneShotArtifactDef; private void Awake() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) RegisterArtifact(); new Harmony("com.cryptidlabs.oneshotartifact").PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"One Shot Artifact loaded."); } private static void RegisterArtifact() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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) LanguageAPI.Add("ARTIFACT_ONESHOT_NAME", "Artifact of Skill"); LanguageAPI.Add("ARTIFACT_ONESHOT_DESC", "Everything dies in one hit. Fall damage is disabled."); OneShotArtifactDef = ScriptableObject.CreateInstance<ArtifactDef>(); OneShotArtifactDef.cachedName = "ArtifactOfSkill"; OneShotArtifactDef.nameToken = "ARTIFACT_ONESHOT_NAME"; OneShotArtifactDef.descriptionToken = "ARTIFACT_ONESHOT_DESC"; string directoryName = Path.GetDirectoryName(typeof(Plugin).Assembly.Location); OneShotArtifactDef.smallIconSelectedSprite = LoadSprite(Path.Combine(directoryName, "icon_selected.png"), "ArtifactOfSkillSelected") ?? CreateIcon(new Color(1f, 0.12f, 0.08f, 1f), Color.white); OneShotArtifactDef.smallIconDeselectedSprite = LoadSprite(Path.Combine(directoryName, "icon_deselected.png"), "ArtifactOfSkillDeselected") ?? CreateIcon(new Color(0.18f, 0.18f, 0.18f, 1f), new Color(0.75f, 0.75f, 0.75f, 1f)); ContentAddition.AddArtifactDef(OneShotArtifactDef); } private static Sprite LoadSprite(string path, string spriteName) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!File.Exists(path)) { return null; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ((Object)val).name = spriteName + "Texture"; ((Texture)val).wrapMode = (TextureWrapMode)1; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path), true)) { Object.Destroy((Object)(object)val); return null; } Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), (float)((Texture)val).width); ((Object)obj).name = spriteName; return obj; } private static Sprite CreateIcon(Color background, Color slash) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); ((Object)val).name = "ArtifactOfSkillIcon"; ((Texture)val).wrapMode = (TextureWrapMode)1; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { bool flag = j < 3 || i < 3 || j >= 61 || i >= 61; bool flag2 = Mathf.Abs(j - i) <= 4 || Mathf.Abs(j + i - 63) <= 4; val.SetPixel(j, i, flag2 ? slash : (flag ? Color.black : background)); } } val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 64f); } internal static bool ArtifactEnabled() { if ((Object)(object)OneShotArtifactDef != (Object)null && (Object)(object)RunArtifactManager.instance != (Object)null) { return RunArtifactManager.instance.IsArtifactEnabled(OneShotArtifactDef); } return false; } } [HarmonyPatch(typeof(HealthComponent), "TakeDamage")] internal static class OneShotDamagePatch { private static void Prefix(HealthComponent __instance, DamageInfo damageInfo) { //IL_0027: 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_002d: 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) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_004e: 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_0055: 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) if (Plugin.ArtifactEnabled() && !((Object)(object)__instance == (Object)null) && damageInfo != null && !(damageInfo.damage <= 0f)) { DamageType damageType = damageInfo.damageType.damageType; if ((damageType & 0x200000) != 0) { damageInfo.damage = 0f; damageInfo.rejected = true; return; } damageType = (DamageType)(damageType & -2); damageType = (DamageType)(damageType | 0x40002); damageInfo.damageType.damageType = damageType; damageInfo.damage = Mathf.Max(damageInfo.damage, __instance.fullCombinedHealth * 100f); } } } }