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 SpyKnifeTweak v1.0.1
SpyKnifeTweak.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using Microsoft.CodeAnalysis; using On.RoR2; using R2API; using RiskyMod.Tweaks.CharacterMechanics; using RoR2; using SpyMod.Spy.Components; using SpyMod.Spy.Content; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SpyKnifeTweak")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SpyKnifeTweak")] [assembly: AssemblyTitle("SpyKnifeTweak")] [assembly: AssemblyVersion("1.0.0.0")] 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; } } } namespace SpyKnifeTweak { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.Moffein.SpyKnifeTweak", "SpyKnifeTweak", "1.0.1")] public class SpyKnifeTweak : BaseUnityPlugin { public static bool riskymodFreeze = false; public static BuffDef riskymodFreezeDebuff = null; public static float riskymodFreezeChampionMult; public static float executeGracePeriod = 0.25f; public static float executeThreshold = 0.3f; public static float backstabDamageMultiplierOverride = 6f; private NetworkSoundEventDef backstabSound; private void Awake() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown backstabSound = ScriptableObject.CreateInstance<NetworkSoundEventDef>(); backstabSound.eventName = "sfx_spy_crit"; ContentAddition.AddNetworkSoundEventDef(backstabSound); HealthComponent.TakeDamage += new hook_TakeDamage(OverrideKnifeDamage); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad)); } private void OnLoad() { if (Chainloader.PluginInfos.ContainsKey("com.RiskyLives.RiskyMod")) { CheckRiskyModFreeze(); } GameObject val = BodyCatalog.FindBodyPrefab("SpyBody"); SurvivorDef val2 = SurvivorCatalog.FindSurvivorDefFromBody(val); SpyPassive component = val.GetComponent<SpyPassive>(); component.spyPassive.skillDescriptionToken = "<color=#62746f>Knife</color> <style=cIsHealth>Backstabs</style> deal <style=cIsDamage>6x damage</style> and are a guaranteed <style=cIsDamage>Critical Strike</style>. Executes enemies below <style=cIsHealth>30%</style> health."; component.spyPassive.keywordTokens = new string[0]; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private void CheckRiskyModFreeze() { if (FreezeChampionExecute.enabled) { riskymodFreeze = true; riskymodFreezeDebuff = FreezeChampionExecute.FreezeDebuff; riskymodFreezeChampionMult = FreezeChampionExecute.bossExecuteFractionMultiplier; } } private void OverrideKnifeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Invalid comparison between Unknown and I4 //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) bool flag = false; CharacterBody val = null; CharacterBody body = self.body; if (NetworkServer.active && DamageAPI.HasModdedDamageType(damageInfo, DamageTypes.SpyBackStab)) { DamageAPI.RemoveModdedDamageType(damageInfo, DamageTypes.SpyBackStab); if (Object.op_Implicit((Object)(object)damageInfo.attacker)) { val = damageInfo.attacker.GetComponent<CharacterBody>(); } if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)body)) { Vector3 val2 = val.corePosition - damageInfo.position; if (val.canPerformBackstab && (damageInfo.damageType & 0x4000000) != 67108864 && (((ProcChainMask)(ref damageInfo.procChainMask)).HasProc((ProcType)17) || BackstabManager.IsBackstab(-val2, body))) { flag = true; if (damageInfo.crit) { damageInfo.damage *= 1.5f; } damageInfo.damage *= backstabDamageMultiplierOverride; DamageAPI.AddModdedDamageType(damageInfo, DamageTypes.SpyExecute); if (Object.op_Implicit((Object)(object)backstabSound)) { EffectManager.SimpleSoundEffect(backstabSound.index, damageInfo.position, true); } SpyController component = ((Component)val).GetComponent<SpyController>(); if (body.isChampion || (body.isBoss && Object.op_Implicit((Object)(object)component))) { if (component.isDiamondBack) { for (int i = val.GetBuffCount(SpyBuffs.spyDiamondbackBuff); i < 3; i++) { if (val.GetBuffCount(SpyBuffs.spyDiamondbackBuff) < 5) { val.AddBuff(SpyBuffs.spyDiamondbackBuff); } } } if (component.isBigEarner) { int num = 5; float num2 = 2f; val.ClearTimedBuffs(SpyBuffs.spyBigEarnerBuff); for (int j = 0; j < num; j++) { val.AddTimedBuff(SpyBuffs.spyBigEarnerBuff, num2 * (float)(j + 1) / (float)num); } val.healthComponent.AddBarrier((val.healthComponent.fullHealth + val.healthComponent.fullShield) * 0.2f); } } else if (body.isElite && Object.op_Implicit((Object)(object)component) && component.isDiamondBack && val.GetBuffCount(SpyBuffs.spyDiamondbackBuff) < 5) { val.AddBuff(SpyBuffs.spyDiamondbackBuff); } } } } orig.Invoke(self, damageInfo); if (NetworkServer.active && !damageInfo.rejected && flag && Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)body)) { ExecuteMarker executeMarker = ((Component)self).gameObject.GetComponent<ExecuteMarker>(); if (!Object.op_Implicit((Object)(object)executeMarker)) { executeMarker = ((Component)self).gameObject.AddComponent<ExecuteMarker>(); } executeMarker.healthComponent = self; executeMarker.body = body; executeMarker.attackerBody = val; executeMarker.lifetime = executeGracePeriod; } } } public class ExecuteMarker : MonoBehaviour { public CharacterBody attackerBody; public float lifetime = 0f; public HealthComponent healthComponent; public CharacterBody body; private bool firedExecute = false; private void FixedUpdate() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && !firedExecute && Object.op_Implicit((Object)(object)attackerBody) && Object.op_Implicit((Object)(object)healthComponent) && healthComponent.combinedHealthFraction <= GetExecuteFraction()) { firedExecute = true; DamageInfo val = new DamageInfo { inflictor = ((Component)attackerBody).gameObject, attacker = ((Component)attackerBody).gameObject, procCoefficient = 0f, procChainMask = default(ProcChainMask), damage = healthComponent.combinedHealth, damageType = (DamageType)262210, crit = false, damageColorIndex = (DamageColorIndex)8, position = ((Component)this).transform.position, force = Vector3.zero }; DamageAPI.AddModdedDamageType(val, DamageTypes.SpyExecute); healthComponent.TakeDamage(val); Object.Destroy((Object)(object)this); } else { lifetime -= Time.fixedDeltaTime; if (lifetime <= 0f) { Object.Destroy((Object)(object)this); } } } public float GetExecuteFraction() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (((Enum)body.bodyFlags).HasFlag((Enum)(object)(BodyFlags)16) || body.isPlayerControlled) { return 0f; } float num = SpyKnifeTweak.executeThreshold; if (body.isChampion) { num *= 0.5f; } float num2 = 0.3f; if (SpyKnifeTweak.riskymodFreeze) { num2 *= SpyKnifeTweak.riskymodFreezeChampionMult; } if (healthComponent.isInFrozenState || ((Object)(object)SpyKnifeTweak.riskymodFreezeDebuff != (Object)null && body.HasBuff(SpyKnifeTweak.riskymodFreezeDebuff))) { num += num2; } if (Object.op_Implicit((Object)(object)attackerBody) && body.isElite) { num += attackerBody.executeEliteHealthFraction; } return num; } } }