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 MithrixAntiDrone v1.0.0
MithrixAntiDrone.dll
Decompiled 10 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; 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 BepInEx.Logging; using EntityStates; using EntityStates.BrotherMonster; using Microsoft.CodeAnalysis; using MithrixAntiDrone.Changes; using MithrixAntiDrone.Modules; using On.EntityStates.BrotherMonster; using On.RoR2; using R2API; using RoR2; using RoR2.CharacterAI; using RoR2.ContentManagement; using RoR2BepInExPack.GameAssetPathsBetter; 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("MithrixAntiDrone")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MithrixAntiDrone")] [assembly: AssemblyTitle("MithrixAntiDrone")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 MithrixAntiDrone { 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); } } [BepInPlugin("com.Bloonjitsu7.MithrixAntiDrone", "MithrixAntiDrone", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MainPlugin : BaseUnityPlugin { public void Awake() { Log.Init(((BaseUnityPlugin)this).Logger); new ContentPacks().Initialize(); Main main = new Main(); Config.SetupConfig(((BaseUnityPlugin)this).Config); main.Initialize(); } } } namespace MithrixAntiDrone.Modules { public static class Buffs { internal static List<BuffDef> buffDefs = new List<BuffDef>(); internal static BuffDef AddNewBuff(string buffName, Sprite buffIcon, Color buffColor, bool canStack = false, bool isDebuff = false, bool isCooldown = false, bool isHidden = false, bool ignoreNectar = false, bool isPercent = false, bool isDOT = false, Flags buffFlag = (Flags)0) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_004e: 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) BuffDef val = ScriptableObject.CreateInstance<BuffDef>(); ((Object)val).name = buffName; val.buffColor = buffColor; val.canStack = canStack; val.isDebuff = isDebuff; val.eliteDef = null; val.iconSprite = buffIcon; val.isCooldown = isCooldown; val.isHidden = isHidden; val.ignoreGrowthNectar = ignoreNectar; val.flags = buffFlag; val.stackingDisplayMethod = (StackingDisplayMethod)(isPercent ? 1 : 0); val.isDOT = isDOT; buffDefs.Add(val); return val; } } public static class Effects { private static GameObject finder = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Mushroom.MushroomWard_prefab).WaitForCompletion(); public static List<EffectDef> effectDefs = new List<EffectDef>(); internal static void RegisterEffects() { } private static GameObject CreateTracer() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) GameObject val = CloneTracer("RoR2/Base/Huntress/TracerHuntressSnipe.prefab", "TracerStormboundAurelioniteLaser", Color.red, new Color(1f, 0.04f, 0.04f, 1f), 2f); Object.Destroy((Object)(object)((Component)val.transform.Find("TracerHead")).gameObject); return val; } private static GameObject CloneObject(string originalObjectName, string newObjectName, Color color1, Color color2, float scaleMult = 1f, float colorTemp = 0f, bool colorMesh = true, string soundName = "", bool parentToTransform = false, bool recolor = true, bool overrideEffect = false) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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) GameObject val = Addressables.LoadAssetAsync<GameObject>((object)originalObjectName).WaitForCompletion(); if ((Object)(object)val == (Object)null) { Log.Warning(originalObjectName + " is null!"); return null; } GameObject val2 = PrefabAPI.InstantiateClone(val, newObjectName, false); if ((Object)(object)val2.GetComponent<EffectComponent>() == (Object)null) { val2.AddComponent<EffectComponent>(); } if ((Object)(object)val2.GetComponent<VFXAttributes>() == (Object)null) { val2.AddComponent<VFXAttributes>(); } val2.GetComponent<VFXAttributes>().vfxPriority = (VFXPriority)2; val2.GetComponent<VFXAttributes>().DoNotPool = true; if (recolor) { val2.Recolor(color1, color2, scaleMult, colorTemp, colorMesh); } CreateEffectFromObject(val2, soundName, parentToTransform, overrideEffect); return val2; } private static GameObject CloneTracer(string originalTracerName, string newTracerName, Color color1, Color color2, float widthMult = 1f, float? speed = null, float? length = null) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0101: Unknown result type (might be due to invalid IL or missing references) GameObject val = Addressables.LoadAssetAsync<GameObject>((object)originalTracerName).WaitForCompletion(); if ((Object)(object)val == (Object)null) { Log.Warning(originalTracerName + " is null!"); return null; } GameObject val2 = PrefabAPI.InstantiateClone(val, newTracerName, false); if (!Object.op_Implicit((Object)(object)val2.GetComponent<EffectComponent>())) { val2.AddComponent<EffectComponent>(); } if (!Object.op_Implicit((Object)(object)val2.GetComponent<VFXAttributes>())) { val2.AddComponent<VFXAttributes>(); } val2.GetComponent<VFXAttributes>().vfxPriority = (VFXPriority)2; val2.GetComponent<VFXAttributes>().DoNotPool = true; if (!Object.op_Implicit((Object)(object)val2.GetComponent<NetworkIdentity>())) { val2.AddComponent<NetworkIdentity>(); } val2.GetComponent<Tracer>().speed = (speed.HasValue ? speed.Value : val2.GetComponent<Tracer>().speed); val2.GetComponent<Tracer>().length = (length.HasValue ? length.Value : val2.GetComponent<Tracer>().length); val2.Recolor(color1, color2, widthMult); CreateAndAddEffectDef(val2); return val2; } private static void Recolor(this GameObject thingToColor, Color color1, Color color2, float widthMult = 1f, float colorTemp = 0f, bool colorMesh = true) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) bool flag = true; LineRenderer[] componentsInChildren = thingToColor.GetComponentsInChildren<LineRenderer>(); foreach (LineRenderer val in componentsInChildren) { bool flag2 = true; val.startColor = color1; val.endColor = color2; if (widthMult != 1f) { val.widthMultiplier *= widthMult; } } ParticleSystem[] componentsInChildren2 = thingToColor.GetComponentsInChildren<ParticleSystem>(); foreach (ParticleSystem val2 in componentsInChildren2) { MainModule main = val2.main; MinMaxCurve startSize = ((MainModule)(ref main)).startSize; ((MainModule)(ref main)).startSize = new MinMaxCurve(((MinMaxCurve)(ref startSize)).constant * widthMult); ((MainModule)(ref main)).startColor = new MinMaxGradient(color1); TrailModule trails = val2.trails; if (((TrailModule)(ref trails)).enabled) { Gradient val3 = new Gradient(); GradientColorKey[] array = (GradientColorKey[])(object)new GradientColorKey[2]; array[0].color = color1; array[0].time = 0f; array[1].color = color2; array[1].time = 1f; GradientAlphaKey[] array2 = (GradientAlphaKey[])(object)new GradientAlphaKey[2]; array2[0].alpha = color1.a; array2[0].time = 0f; array2[1].alpha = color2.a; array2[1].time = 1f; val3.SetKeys(array, array2); ((TrailModule)(ref trails)).colorOverLifetime = new MinMaxGradient(val3); } } Light[] componentsInChildren3 = thingToColor.GetComponentsInChildren<Light>(); foreach (Light val4 in componentsInChildren3) { if (colorTemp > 0f) { val4.colorTemperature = colorTemp; val4.useColorTemperature = true; } else { val4.useColorTemperature = false; } val4.color = color1; Transform transform = ((Component)val4).transform; transform.localScale *= widthMult; } ParticleSystemRenderer[] componentsInChildren4 = thingToColor.GetComponentsInChildren<ParticleSystemRenderer>(); foreach (ParticleSystemRenderer val5 in componentsInChildren4) { ((Renderer)val5).material.SetColor("_MainColor", color1); ((Renderer)val5).material.SetColor("_Color", color1); ((Renderer)val5).material.SetColor("_TintColor", color2); } if (colorMesh) { MeshRenderer[] componentsInChildren5 = thingToColor.GetComponentsInChildren<MeshRenderer>(); foreach (MeshRenderer val6 in componentsInChildren5) { ((Renderer)val6).material.SetColor("_MainColor", color1); ((Renderer)val6).material.SetColor("_Color", color1); ((Renderer)val6).material.SetColor("_TintColor", color2); } } } internal static void AddEffectDef(EffectDef effectDef) { effectDefs.Add(effectDef); } internal static EffectDef CreateAndAddEffectDef(GameObject effectPrefab, bool donotPool = false) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (donotPool) { VFXAttributes val = effectPrefab.GetComponent<VFXAttributes>(); if ((Object)(object)val == (Object)null) { val = effectPrefab.AddComponent<VFXAttributes>(); } val.DoNotPool = true; } EffectDef val2 = new EffectDef(effectPrefab); AddEffectDef(val2); return val2; } internal static void CreateEffectFromObject(GameObject newEffect, string soundName, bool parentToTransform, bool overrideEffect) { //IL_0032: 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) //IL_0089: Unknown result type (might be due to invalid IL or missing references) newEffect.AddComponent<DestroyOnTimer>().duration = 6f; newEffect.AddComponent<NetworkIdentity>(); if (!Object.op_Implicit((Object)(object)newEffect.GetComponent<VFXAttributes>())) { newEffect.AddComponent<VFXAttributes>().vfxPriority = (VFXPriority)2; } EffectComponent component = newEffect.GetComponent<EffectComponent>(); if (!Object.op_Implicit((Object)(object)component)) { component = newEffect.AddComponent<EffectComponent>(); component.applyScale = true; component.effectIndex = (EffectIndex)(-1); component.parentToReferencedTransform = parentToTransform; component.positionAtReferencedTransform = true; component.soundName = soundName; } else if (overrideEffect) { component.applyScale = true; component.effectIndex = (EffectIndex)(-1); component.parentToReferencedTransform = parentToTransform; component.positionAtReferencedTransform = true; component.soundName = soundName; } CreateAndAddEffectDef(newEffect); } } internal class ContentPacks : IContentPackProvider { internal ContentPack contentPack = new ContentPack(); public string identifier => "com.Bloonjitsu7.MithrixAntiDrone"; public void Initialize() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown Effects.RegisterEffects(); ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders); } private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider) { addContentPackProvider.Invoke((IContentPackProvider)(object)this); } public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { contentPack.identifier = identifier; contentPack.effectDefs.Add(Effects.effectDefs.ToArray()); contentPack.buffDefs.Add(Buffs.buffDefs.ToArray()); args.ReportProgress(1f); yield break; } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(contentPack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } } } namespace MithrixAntiDrone.Changes { public class Main { public void Initialize() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) new MithrixItem().Init(); GameObject val = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Brother.BrotherHurtMaster_prefab).WaitForCompletion(); BaseAI component = val.GetComponent<BaseAI>(); if (Object.op_Implicit((Object)(object)component)) { component.prioritizePlayers = true; } } } public class MithrixItem { public static ItemDef mithrixItem; public void Init() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown CreateItem(); SpellChannelState.OnEnter += new hook_OnEnter(OnMithrixSpellEnter); HealthComponent.TakeDamageProcess += new hook_TakeDamageProcess(OnTakeDamage); } public void OnTakeDamage(orig_TakeDamageProcess orig, HealthComponent self, DamageInfo info) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)info.attacker) && Object.op_Implicit((Object)(object)self.body)) { CharacterBody component = info.attacker.GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component)) { if (Object.op_Implicit((Object)(object)component.inventory) && component.inventory.GetItemCountEffective(mithrixItem) > 0 && self.body.IsDrone) { info.damage *= Config.droneDamage.Value; info.damageType.damageType = (DamageType)(info.damageType.damageType | 2); } if (component.IsDrone && Object.op_Implicit((Object)(object)self.body.inventory) && self.body.inventory.GetItemCountEffective(mithrixItem) > 0) { info.damage *= Config.droneResist.Value; } } } orig.Invoke(self, info); } public void OnMithrixSpellEnter(orig_OnEnter orig, SpellChannelState self) { orig.Invoke(self); if (!NetworkServer.active || !Object.op_Implicit((Object)(object)((EntityState)self).characterBody) || !Object.op_Implicit((Object)(object)((EntityState)self).characterBody.inventory)) { return; } ((EntityState)self).characterBody.inventory.GiveItemPermanent(mithrixItem, 1); if (Object.op_Implicit((Object)(object)((EntityState)self).characterBody.master)) { BaseAI component = ((Component)((EntityState)self).characterBody.master).GetComponent<BaseAI>(); if (Object.op_Implicit((Object)(object)component)) { component.prioritizePlayers = true; } BaseAI[] aiComponents = ((EntityState)self).characterBody.master.aiComponents; foreach (BaseAI val in aiComponents) { val.prioritizePlayers = true; } } } public void CreateItem() { //IL_005d: 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_009c: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown mithrixItem = ScriptableObject.CreateInstance<ItemDef>(); ((Object)mithrixItem).name = "MithrixAntiDroneItem"; mithrixItem.nameToken = "MITHRIXANTIDRONE_ITEM_NAME"; mithrixItem.pickupToken = "MITHRIXANTIDRONE_ITEM_PICKUP"; mithrixItem.descriptionToken = "MITHRIXANTIDRONE_ITEM_DESC"; mithrixItem.loreToken = "MITHRIXANTIDRONE_ITEM_LORE"; mithrixItem.deprecatedTier = (ItemTier)5; mithrixItem.canRemove = false; mithrixItem.hidden = true; ItemTag[] array = new ItemTag[7]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); ItemTag[] tags = (ItemTag[])(object)array; mithrixItem.tags = tags; ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null); ItemAPI.Add(new CustomItem(mithrixItem, val)); } } public static class Config { public static ConfigEntry<float> droneDamage { get; set; } public static ConfigEntry<float> droneResist { get; set; } public static void SetupConfig(ConfigFile cfg) { droneDamage = cfg.Bind<float>("MithrixAntiDrone", "Drone Damage Multiplier", 1000f, "Damage multiplier that Phase 4 Mithrix deals against drones."); droneResist = cfg.Bind<float>("MithrixAntiDrone", "Drone Resistance", 0.05f, "Damage multiplier that Phase 4 Mithrix takes from drones."); } } public static class BuffDefs { public static BuffDef Buff; private static Sprite buffIcon = Addressables.LoadAssetAsync<Sprite>((object)RoR2_Base_Common.texBuffBleedingIcon_tif).WaitForCompletion(); public static void CreateBuffs() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) Buff = Buffs.AddNewBuff("BloonMithrixAntiDroneBuff", buffIcon, Color.red, canStack: false, isDebuff: false, isCooldown: false, isHidden: false, ignoreNectar: false, isPercent: false, isDOT: false, (Flags)0); } } public static class DamageTypes { } public static class Utils { public static List<MethodInfo> GetAnonymousMethods(Type t, string methodName) { List<MethodInfo> list = new List<MethodInfo>(); Type[] nestedTypes = t.GetNestedTypes((BindingFlags)(-1)); Type[] array = nestedTypes; foreach (Type type in array) { if (!type.Name.Contains("<>")) { continue; } MethodInfo[] methods = type.GetMethods((BindingFlags)(-1)); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name.Contains(methodName)) { list.Add(methodInfo); } } } MethodInfo[] methods2 = t.GetMethods((BindingFlags)(-1)); foreach (MethodInfo methodInfo2 in methods2) { if (methodInfo2.Name.Contains("<") && methodInfo2.Name.Contains(methodName)) { list.Add(methodInfo2); } } return list.OrderBy((MethodInfo m) => m.Name).ToList(); } public static void DumpComponents(GameObject gameObject) { Component[] componentsInChildren = gameObject.GetComponentsInChildren(typeof(Component)); foreach (Component data in componentsInChildren) { Log.Message(data); } } public static string GetStackDesc(float num, string type) { if (num > 0f) { return $" <style=cStack>(+{num}{type} per stack)</style>"; } if (num < 0f) { return $" <style=cStack>({num}{type} per stack)</style>"; } return ""; } public static float GetStackedStats(float baseStat, float stackStat, int itemCount) { return baseStat - stackStat + stackStat * (float)itemCount; } public static int GetStackedStatsInt(int baseStat, int stackStat, int itemCount) { return baseStat - stackStat + stackStat * itemCount; } public static float ConvertReductionIntoStackingDivision(float baseFraction, int itemCount) { float num = 1f - baseFraction; float num2 = (1f + num) / num - 2f; num2 *= (float)(itemCount - 1); return num2 + 1f; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }