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 Stagger v1.0.0
Stagger.dll
Decompiled 3 months agousing System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using On.RoR2; using R2API.Utils; 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("Stagger")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Stagger")] [assembly: AssemblyTitle("Stagger")] [assembly: AssemblyVersion("1.0.0.0")] namespace Peet; [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.MyCompanyName.Stagger", "Stagger", "1.0.0")] [R2APISubmoduleDependency(new string[] { "ItemDropAPI" })] public class StaggerDriver : BaseUnityPlugin { public class Stagger { public int curIndex; public float offset; public float[] staggerPool; public HealthComponent healthComponent; public Stagger(HealthComponent healthComponentIn) { healthComponent = healthComponentIn; curIndex = 0; offset = 0f; staggerPool = new float[numHits.Value - 1]; } public void updateTime(float deltaTime) { offset += deltaTime; while (offset > hitDelayFloat) { offset -= hitDelayFloat; if (staggerPool[curIndex] > 0f) { printStaggerPool(); dispatchDamage(staggerPool[curIndex]); staggerPool[curIndex] = 0f; } curIndex++; curIndex %= staggerPool.Length; } } public void printStaggerPool() { string text = "Stagger: "; for (int i = 0; i < staggerPool.Length; i++) { text = text + " | | " + staggerPool[i] + " | | "; } } public void dispatchDamage(float damage) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0028: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) DamageInfo val = new DamageInfo(); val.damage = 0f - (damage + getRepulsionDamage()); val.crit = false; val.position = healthComponent.body.corePosition; val.attacker = null; val.inflictor = null; val.damageType = DamageTypeCombo.op_Implicit((DamageType)1); val.procCoefficient = 0f; healthComponent.TakeDamage(val); } public void addStagger(DamageInfo damageInfo) { float num = damageInfo.damage * staggerFraction; for (int i = 0; i < staggerPool.Length; i++) { staggerPool[i] += num; } } public float getRepulsionDamage() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)healthComponent.body)) { CharacterMaster master = healthComponent.body.master; if (Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)master.inventory)) { int itemCountEffective = master.inventory.GetItemCountEffective(Items.ArmorPlate.itemIndex); if (itemCountEffective > 0) { return (float)itemCountEffective * 5f * repulRatio; } } } return 0f; } } public static ConfigEntry<int> numHits; public static ConfigEntry<int> hitDelay; public static ConfigEntry<int> bufferSize; public static ConfigEntry<int> minStaggerSize; public static ConfigEntry<int> minStaggerPercent; public Dictionary<HealthComponent, Stagger> staggers; public static float repulRatio; public const float repulAmount = 5f; public static float staggerFraction; public static float hitDelayFloat; public static float minHit; public static float minStaggerFraction; public static float staggerDur; public void Awake() { //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown numHits = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "numHits", 5, "aa"); hitDelay = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "hitDelay", 800, "aa"); minStaggerSize = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "minStaggerSize", 1, "aa"); minStaggerPercent = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "minStaggerPercent", 7, "aa"); hitDelayFloat = (float)hitDelay.Value / 1000f; staggerDur = hitDelayFloat * (float)numHits.Value; repulRatio = ((float)numHits.Value - 1f) / (float)numHits.Value; staggerFraction = 1f / (float)numHits.Value; minHit = 1f / staggerFraction * (float)minStaggerSize.Value; minStaggerFraction = (float)minStaggerPercent.Value / 100f; HealthComponent.TakeDamage += new hook_TakeDamage(StaggerIt); staggers = new Dictionary<HealthComponent, Stagger>(); HealthComponent.FixedUpdate += new hook_FixedUpdate(UpdateTimeExt); } private void StaggerIt(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo) { if (self.body.isPlayerControlled) { if (damageInfo.damage < 0f) { damageInfo.damage = 0f - damageInfo.damage; orig.Invoke(self, damageInfo); return; } Stagger stagger = getStagger(self); stagger.addStagger(damageInfo); damageInfo.damage = damageInfo.damage * staggerFraction + stagger.getRepulsionDamage(); orig.Invoke(self, damageInfo); } else { orig.Invoke(self, damageInfo); } } private void UpdateTimeExt(orig_FixedUpdate orig, HealthComponent self) { if (self.body.isPlayerControlled) { getStagger(self).updateTime(Time.fixedDeltaTime); } orig.Invoke(self); } private Stagger getStagger(HealthComponent healthComponent) { if (staggers.ContainsKey(healthComponent)) { return staggers[healthComponent]; } Stagger stagger = new Stagger(healthComponent); staggers.Add(healthComponent, stagger); return stagger; } }