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 ChronoRSpread v1.0.1
plugins/ChronoRSpread.dll
Decompiled 3 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using RoR2; using UnityEngine; 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: AssemblyVersion("0.0.0.0")] [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 NormalAIPeople.ChronoRSpread { [BepInPlugin("normalAIPeople.ChronoRSpread", "Chrono R Spread", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class ChronoRSpreadPlugin : BaseUnityPlugin { private static ConfigEntry<float> radius; private static ConfigEntry<int> maxTargets; private static ConfigEntry<float> interval; private static ConfigEntry<float> damageCoefficient; private static ConfigEntry<float> sicknessDuration; private static ConfigEntry<bool> enableInventorySickness; private static readonly Dictionary<object, float> nextSpreadTime = new Dictionary<object, float>(); private static BuffDef sicknessBuff; private static ItemDef sicknessItem; private void Awake() { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown radius = ((BaseUnityPlugin)this).Config.Bind<float>("Chrono Legionnaire", "R Spread Radius", 16f, "Spread radius in metres."); maxTargets = ((BaseUnityPlugin)this).Config.Bind<int>("Chrono Legionnaire", "R Spread Max Targets", 4, "Maximum enemies infected per pulse."); interval = ((BaseUnityPlugin)this).Config.Bind<float>("Chrono Legionnaire", "R Spread Interval", 0.75f, "Seconds between spread pulses."); damageCoefficient = ((BaseUnityPlugin)this).Config.Bind<float>("Chrono Legionnaire", "R Spread Damage Coefficient", 0.6f, "Extra damage as a coefficient of Chrono's damage stat."); sicknessDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Chrono Legionnaire", "R Spread Sickness Duration", 8f, "Chrono Sickness duration in seconds."); enableInventorySickness = ((BaseUnityPlugin)this).Config.Bind<bool>("Chrono Legionnaire", "Enable Full Inventory Sickness", false, "Enable Red Alert's hidden sickness item on spread targets. Disabled by default because inventory mutation can cause a visible hitch."); Type type = AccessTools.TypeByName("RA2Mod.Survivors.Chrono.States.CastVanishTether"); if (!(type == null)) { Harmony val = new Harmony("normalAIPeople.ChronoRSpread"); val.Patch((MethodBase)AccessTools.Method(type, "DoDamage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ChronoRSpreadPlugin), "DoDamagePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(type, "OnExit", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ChronoRSpreadPlugin), "OnExitPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private static void DoDamagePostfix(object __instance) { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_00fc: 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) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || radius.Value <= 0f || maxTargets.Value <= 0 || (nextSpreadTime.TryGetValue(__instance, out var value) && Time.fixedTime < value)) { return; } nextSpreadTime[__instance] = Time.fixedTime + Math.Max(0.05f, interval.Value); HurtBox value2 = Traverse.Create(__instance).Field("targetHurtBox").GetValue<HurtBox>(); CharacterBody value3 = Traverse.Create(__instance).Property("characterBody", (object[])null).GetValue<CharacterBody>(); if ((Object)(object)value2 == (Object)null || (Object)(object)value2.healthComponent == (Object)null || (Object)(object)value3 == (Object)null || (Object)(object)value3.teamComponent == (Object)null) { return; } int num = 0; SphereSearch val = new SphereSearch { origin = ((Component)value2).transform.position, radius = radius.Value }; LayerIndex entityPrecise = LayerIndex.entityPrecise; val.mask = ((LayerIndex)(ref entityPrecise)).mask; HurtBox[] hurtBoxes = val.RefreshCandidates().FilterCandidatesByHurtBoxTeam(TeamMask.GetEnemyTeams(value3.teamComponent.teamIndex)).OrderCandidatesByDistance() .FilterCandidatesByDistinctHurtBoxEntities() .GetHurtBoxes(); HurtBox[] array = hurtBoxes; foreach (HurtBox val2 in array) { if (num >= maxTargets.Value) { break; } HealthComponent val3 = (((Object)(object)val2 != (Object)null) ? val2.healthComponent : null); CharacterBody val4 = (((Object)(object)val3 != (Object)null) ? val3.body : null); if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val4 == (Object)null) && !((Object)(object)val3 == (Object)(object)value2.healthComponent) && val3.alive) { ApplySickness(val4); DealDamage(value3, val3, ((Component)val2).transform.position); num++; } } } private static void OnExitPostfix(object __instance) { nextSpreadTime.Remove(__instance); } private static void ApplySickness(CharacterBody body) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_0027: 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) if ((Object)(object)sicknessBuff == (Object)null) { BuffIndex val = BuffCatalog.FindBuffIndex("ChronoDebuff"); if ((int)val != -1) { sicknessBuff = BuffCatalog.GetBuffDef(val); } } if ((Object)(object)sicknessBuff != (Object)null && !body.HasBuff(sicknessBuff)) { body.AddTimedBuff(sicknessBuff, Math.Max(0.1f, sicknessDuration.Value)); } if (enableInventorySickness.Value && !((Object)(object)body.inventory == (Object)null)) { if ((Object)(object)sicknessItem == (Object)null) { Type type = AccessTools.TypeByName("RA2Mod.Survivors.Chrono.ChronoItems"); FieldInfo fieldInfo = ((type != null) ? AccessTools.Field(type, "chronoSicknessItemDef") : null); sicknessItem = (ItemDef)((fieldInfo != null) ? /*isinst with value type is only supported in some contexts*/: null); } if ((Object)(object)sicknessItem != (Object)null && body.inventory.GetItemCount(sicknessItem) == 0) { body.inventory.GiveItem(sicknessItem.itemIndex, body.isChampion ? 1 : 2); } } } private static void DealDamage(CharacterBody attacker, HealthComponent victim, Vector3 position) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown if (!(damageCoefficient.Value <= 0f)) { DamageInfo val = new DamageInfo { attacker = ((Component)attacker).gameObject, inflictor = ((Component)attacker).gameObject, position = position, damage = attacker.damage * damageCoefficient.Value, damageColorIndex = (DamageColorIndex)0, crit = attacker.RollCrit(), force = Vector3.zero, procChainMask = default(ProcChainMask), procCoefficient = 0.5f }; victim.TakeDamage(val); GlobalEventManager.instance.OnHitEnemy(val, ((Component)victim).gameObject); GlobalEventManager.instance.OnHitAll(val, ((Component)victim).gameObject); } } } }