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 Death Explosion v1.0.0
DeathExplosionMod.dll
Decompiled 6 months agousing System; 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 System.Text; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using REPOLib; 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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("yzch")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("DeathExplosionMod")] [assembly: AssemblyTitle("DeathExplosionMod")] [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.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; } } [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 DeathExplosionMod { public class ConfigFile { [JsonProperty("CameraShakeMultiplier")] public float CameraShakeMultiplier; [JsonProperty("ExplosionForceMultiplier")] public float ExplosionForceMultiplier; [JsonProperty("PlayersExplode")] public bool PlayersExplode; [JsonProperty("Players_ExplosionSize")] public float Players_ExplosionSize; [JsonProperty("Players_ExplosionDamage")] public int Players_ExplosionDamage; [JsonProperty("Players_ExplosionEnemyDamage")] public int Players_ExplosionEnemyDamage; [JsonProperty("Players_ForceMultiplier")] public float Players_ForceMultiplier; [JsonProperty("EnemiesExplode")] public bool EnemiesExplode; [JsonProperty("Enemies_ExplosionSize")] public float Enemies_ExplosionSize; [JsonProperty("Enemies_ExplosionDamage")] public int Enemies_ExplosionDamage; [JsonProperty("Enemies_ExplosionEnemyDamage")] public int Enemies_ExplosionEnemyDamage; [JsonProperty("Enemies_ForceMultiplier")] public float Enemies_ForceMultiplier; } [BepInPlugin("yzch.DeathExplosionMod", "DeathExplosionMod", "1.0")] public class DeathExplosionMod : BaseUnityPlugin { internal static readonly string MOD_ID = "yzch-DeathExplosion"; internal static string mod_folder; internal static ParticleScriptExplosion scriptExplosion; internal static GameObject _scriptExplosionPrefab; internal static ConfigFile? config; internal static DeathExplosionMod Instance { get; private set; } = null; internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; mod_folder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; BundleLoader.LoadBundle(Path.Combine(mod_folder, "deathexplosionmod"), (Action<AssetBundle>)delegate(AssetBundle assetBundle) { LoadConfigFile(); _scriptExplosionPrefab = assetBundle.LoadAsset<GameObject>("PlayerDeathExplosion"); }, false); Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_001a: 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_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal static void LoadConfigFile() { string path = Path.Combine(mod_folder, "yzch.DeathExplosion.cfg"); if (File.Exists(path)) { try { config = JsonConvert.DeserializeObject<ConfigFile>(File.ReadAllText(path, Encoding.UTF8)); Logger.LogInfo((object)"yzch.DeathExplosion.cfg loaded!"); return; } catch (Exception ex) { config = null; Logger.LogError((object)("Cannot parse yzch.DeathExplosion.cfg file: " + ex.Message)); return; } } Logger.LogError((object)("Cannot find yzch.DeathExplosion.json in: " + mod_folder)); } } [HarmonyPatch(typeof(PlayerDeathEffects))] internal static class ExamplePlayerControllerPatch { [HarmonyPatch(typeof(EnemyHealth))] [HarmonyPatch("Death")] [HarmonyPatch(new Type[] { typeof(Vector3) })] private class EnemyHealth_DeathPatch { [HarmonyPostfix] private static void Postfix(EnemyHealth __instance, Vector3 _deathDirection) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)DeathExplosionMod._scriptExplosionPrefab) && DeathExplosionMod.config != null) { ConfigFile config = DeathExplosionMod.config; if (config.EnemiesExplode) { DeathExplosionMod.Logger.LogInfo((object)"Enemy death detected!"); ParticlePrefabExplosion val = DeathExplosionMod.scriptExplosion.Spawn(((Component)__instance.enemy).transform.position, config.Enemies_ExplosionSize, config.Enemies_ExplosionDamage, config.Enemies_ExplosionEnemyDamage, config.Enemies_ForceMultiplier, false, false, config.CameraShakeMultiplier); } } } } [HarmonyPostfix] [HarmonyPatch("Start")] private static void LevelGeneratorStart_Postfix(LevelGenerator __instance) { if (Object.op_Implicit((Object)(object)DeathExplosionMod._scriptExplosionPrefab) && DeathExplosionMod.config != null) { DeathExplosionMod.Logger.LogInfo((object)"Level generator Start() finished!"); DeathExplosionMod.LoadConfigFile(); DeathExplosionMod.scriptExplosion = Object.Instantiate<GameObject>(DeathExplosionMod._scriptExplosionPrefab, (Transform)null).GetComponent<ParticleScriptExplosion>(); } } [HarmonyPostfix] [HarmonyPatch("Trigger")] private static void Start_Postfix(PlayerDeathEffects __instance) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)DeathExplosionMod._scriptExplosionPrefab) && DeathExplosionMod.config != null) { ConfigFile config = DeathExplosionMod.config; if (config.PlayersExplode) { DeathExplosionMod.Logger.LogInfo((object)"Player death detected!"); ParticlePrefabExplosion val = DeathExplosionMod.scriptExplosion.Spawn(((Component)__instance.deathLight).transform.position, config.Players_ExplosionSize, config.Players_ExplosionDamage, config.Players_ExplosionEnemyDamage, config.Players_ForceMultiplier, false, false, config.CameraShakeMultiplier); } } } } }