Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of AdvancedPrediction v1.0.4
AdvPrediction.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using AdvancedPrediction.Prediction; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EnemiesPlus.Content.Beetle; using EnemiesPlus.Content.Imp; using EntityStates; using EntityStates.BeetleGuardMonster; using EntityStates.Bell.BellWeapon; using EntityStates.ClayBoss; using EntityStates.ClayBoss.ClayBossWeapon; using EntityStates.GravekeeperBoss; using EntityStates.GreaterWispMonster; using EntityStates.ImpBossMonster; using EntityStates.ImpMonster; using EntityStates.LemurianBruiserMonster; using EntityStates.LemurianMonster; using EntityStates.RoboBallBoss.Weapon; using EntityStates.ScavMonster; using EntityStates.VagrantMonster.Weapon; using EntityStates.Vulture.Weapon; using HarmonyLib; using IL.EntityStates; using IL.EntityStates.BeetleGuardMonster; using IL.EntityStates.Bell.BellWeapon; using IL.EntityStates.ClayBoss; using IL.EntityStates.ClayBoss.ClayBossWeapon; using IL.EntityStates.GravekeeperBoss; using IL.EntityStates.GreaterWispMonster; using IL.EntityStates.ImpBossMonster; using IL.EntityStates.ImpMonster; using IL.EntityStates.LemurianBruiserMonster; using IL.EntityStates.LemurianMonster; using IL.EntityStates.RoboBallBoss.Weapon; using IL.EntityStates.ScavMonster; using IL.EntityStates.VagrantMonster.Weapon; using IL.EntityStates.Vulture.Weapon; using Inferno; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2.CharacterAI; using R2API.Utils; using RiftTitansMod.Modules; using RiftTitansMod.SkillStates.Chicken; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using Risky_Artifacts.Artifacts; using RoR2; using RoR2.CharacterAI; using RoR2.Projectile; 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: AssemblyCompany("AdvPrediction")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("AdvPrediction")] [assembly: AssemblyTitle("AdvPrediction")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 AdvancedPrediction { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.score.AdvancedPrediction", "AdvancedPrediction", "1.0.4")] public class AdvPredictionPlugin : BaseUnityPlugin { public const string PluginGUID = "com.score.AdvancedPrediction"; public const string PluginAuthor = "score"; public const string PluginName = "AdvancedPrediction"; public const string PluginVersion = "1.0.4"; public static AdvPredictionPlugin Instance { get; private set; } public static bool RooInstalled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); public static bool InfernoInstalled => Chainloader.PluginInfos.ContainsKey("HIFU.Inferno"); public static bool RiskyArtifactsInstalled => Chainloader.PluginInfos.ContainsKey("com.Moffein.RiskyArtifacts"); public static bool LeagueOfLiteralGays => Chainloader.PluginInfos.ContainsKey("com.phreel.TitansOfTheRiftSOTV"); public static bool EnemiesPlusInstalled => Chainloader.PluginInfos.ContainsKey("com.score.EnemiesPlusPlus"); public void Awake() { Instance = this; Log.Init(((BaseUnityPlugin)this).Logger); AdvPredictionConfig.Init(((BaseUnityPlugin)this).Config); PredictionHooks.Init(); HarmonyHooks.Init(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static float GetRiskyArtifactsWarfareProjectileSpeedMult() { if (Object.op_Implicit((Object)(object)RunArtifactManager.instance) && RunArtifactManager.instance.IsArtifactEnabled(Warfare.artifact)) { return Warfare.projSpeed; } return 1f; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static float GetInfernoProjectileSpeedMult() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Run.instance) && Run.instance.selectedDifficulty == Main.InfernoDiffIndex) { return Main.ProjectileSpeed.Value; } return 1f; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void GetProjectileSpeedModifiers(ref float speed) { if (InfernoInstalled) { speed *= GetInfernoProjectileSpeedMult(); } if (RiskyArtifactsInstalled) { speed *= GetRiskyArtifactsWarfareProjectileSpeedMult(); } } } public static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } public static void Debug(string data) { _logSource.LogDebug((object)data); } public static void Error(string data) { _logSource.LogError((object)data); } public static void Fatal(string data) { _logSource.LogFatal((object)data); } public static void Info(string data) { _logSource.LogInfo((object)data); } public static void Message(string data) { _logSource.LogMessage((object)data); } public static void Warning(string data) { _logSource.LogWarning((object)data); } } public static class AdvPredictionConfig { public static ConfigEntry<bool> enablePrediction; public static ConfigEntry<int> accuracy; private static ConfigFile PluginConfigFile { get; set; } public static void Init(ConfigFile cfg) { PluginConfigFile = cfg; string section = "Skills"; enablePrediction = PluginConfigFile.BindOption(section, "Enable Aim Prediction", defaultValue: true, "Allows enemies to use prediction."); accuracy = PluginConfigFile.BindOptionSlider(section, "Accuracy", 100, "Percent determining how accurate the prediction should be.", 0f, 100f); } public static ConfigEntry<T> BindOption<T>(this ConfigFile myConfig, string section, string name, T defaultValue, string description = "", bool restartRequired = false) { if (string.IsNullOrEmpty(description)) { description = name; } if (restartRequired) { description += " (restart required)"; } ConfigEntry<T> val = myConfig.Bind<T>(section, name, defaultValue, description); if (AdvPredictionPlugin.RooInstalled) { TryRegisterOption<T>(val, restartRequired); } return val; } public static ConfigEntry<T> BindOptionSlider<T>(this ConfigFile myConfig, string section, string name, T defaultValue, string description = "", float min = 0f, float max = 20f, bool restartRequired = false) { if (string.IsNullOrEmpty(description)) { description = name; } string text = description; T val = defaultValue; description = text + " (Default: " + val?.ToString() + ")"; if (restartRequired) { description += " (restart required)"; } ConfigEntry<T> val2 = myConfig.Bind<T>(section, name, defaultValue, description); if (AdvPredictionPlugin.RooInstalled) { TryRegisterOptionSlider<T>(val2, min, max, restartRequired); } return val2; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void TryRegisterOption<T>(ConfigEntry<T> entry, bool restartRequired) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0038: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown if (entry is ConfigEntry<string> val) { ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(val, restartRequired)); } else if (entry is ConfigEntry<float> val2) { ModSettingsManager.AddOption((BaseOption)new SliderOption(val2, new SliderConfig { min = 0f, max = 20f, formatString = "{0:0.00}", restartRequired = restartRequired })); } else if (entry is ConfigEntry<int> val3) { ModSettingsManager.AddOption((BaseOption)new IntSliderOption(val3, restartRequired)); } else if (entry is ConfigEntry<bool> val4) { ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(val4, restartRequired)); } else if (entry is ConfigEntry<KeyboardShortcut> val5) { ModSettingsManager.AddOption((BaseOption)new KeyBindOption(val5, restartRequired)); } else if (typeof(T).IsEnum) { ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)entry, restartRequired)); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void TryRegisterOptionSlider<T>(ConfigEntry<T> entry, float min, float max, bool restartRequired) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0056: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_0080: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown if (entry is ConfigEntry<int> val) { ModSettingsManager.AddOption((BaseOption)new IntSliderOption(val, new IntSliderConfig { min = (int)min, max = (int)max, formatString = "{0:0.00}", restartRequired = restartRequired })); } else if (entry is ConfigEntry<float> val2) { ModSettingsManager.AddOption((BaseOption)new SliderOption(val2, new SliderConfig { min = min, max = max, formatString = "{0:0.00}", restartRequired = restartRequired })); } } } } namespace AdvancedPrediction.Prediction { public static class HarmonyHooks { public static Harmony Patcher; public static void Init() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown Patcher = new Harmony("com.score.AdvancedPrediction"); if (AdvPredictionPlugin.LeagueOfLiteralGays) { League(); } if (AdvPredictionPlugin.EnemiesPlusInstalled) { Enemies(); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void League() { Patcher.CreateClassProcessor(typeof(RaptorPrediction)).Patch(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void Enemies() { Patcher.CreateClassProcessor(typeof(EnemiesPlusBeetle)).Patch(); Patcher.CreateClassProcessor(typeof(EnemiesPlusImp)).Patch(); } } [HarmonyPatch(typeof(Shoot), "Fire")] public class RaptorPrediction { [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction code in instructions) { yield return code; if (CodeInstructionExtensions.Calls(code, AccessTools.Method(typeof(BaseState), "GetAimRay", (Type[])null, (Type[])null))) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(EntityState), "characterBody")); yield return new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.DeclaredField(typeof(Projectiles), "chickenProjectilePrefab")); yield return new CodeInstruction(OpCodes.Call, (object)Reflection.GetMethodCached(typeof(PredictionUtils), "PredictAimray")); } } } } [HarmonyPatch(typeof(BeetleSpit), "Fire")] public class EnemiesPlusBeetle { [HarmonyILManipulator] public static void ILBeetle(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown PredictionHooks.FireProjectile<BeetleSpit>(new ILCursor(il)); } } [HarmonyPatch(typeof(ImpVoidSpike), "HandleSlash")] public class EnemiesPlusImp { [HarmonyILManipulator] public static void ILImp(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown PredictionHooks.FireProjectile<ImpVoidSpike>(new ILCursor(il)); } } public class PredictionHooks { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_FindEnemyHurtBox <>9__0_0; public static Manipulator <>9__0_1; public static Manipulator <>9__0_2; public static Manipulator <>9__0_3; public static Manipulator <>9__0_4; public static Manipulator <>9__0_5; public static Manipulator <>9__0_6; public static Manipulator <>9__0_7; public static Manipulator <>9__0_8; public static Manipulator <>9__0_9; public static Manipulator <>9__0_10; public static Manipulator <>9__0_11; public static Manipulator <>9__0_12; public static Manipulator <>9__0_13; public static Manipulator <>9__0_14; public static Manipulator <>9__0_15; public static Func<Instruction, bool> <>9__4_0; public static Func<Instruction, bool> <>9__4_2; public static Func<Instruction, bool> <>9__5_1; public static Func<Instruction, bool> <>9__5_3; public static Func<Instruction, bool> <>9__5_5; public static Func<Ray, Transform, CharacterBody, GameObject, Ray> <>9__5_0; internal HurtBox <Init>b__0_0(orig_FindEnemyHurtBox orig, BaseAI self, float maxDist, bool _, bool filterByLoS) { return orig.Invoke(self, maxDist, true, filterByLoS); } internal void <Init>b__0_1(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireSunder_FixedUpdate(new ILCursor(il)); } internal void <Init>b__0_2(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown ChargeTrioBomb_FixedUpdate(new ILCursor(il)); } internal void <Init>b__0_3(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<GenericProjectileBaseState>(new ILCursor(il)); } internal void <Init>b__0_4(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireCannons>(new ILCursor(il)); } internal void <Init>b__0_5(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireEyeBlast>(new ILCursor(il)); } internal void <Init>b__0_6(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireWindblade>(new ILCursor(il)); } internal void <Init>b__0_7(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireHook>(new ILCursor(il)); } internal void <Init>b__0_8(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireFireball>(new ILCursor(il)); } internal void <Init>b__0_9(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireMegaFireball>(new ILCursor(il)); } internal void <Init>b__0_10(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireEnergyCannon>(new ILCursor(il)); } internal void <Init>b__0_11(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireBombardment>(new ILCursor(il)); } internal void <Init>b__0_12(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireTarball>(new ILCursor(il)); } internal void <Init>b__0_13(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireSpines>(new ILCursor(il)); } internal void <Init>b__0_14(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectileGroup<JellyBarrage>(new ILCursor(il)); } internal void <Init>b__0_15(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectileGroup<FireVoidspikes>(new ILCursor(il)); } internal bool <FireSunder_FixedUpdate>b__4_0(Instruction x) { return ILPatternMatchingExt.MatchCall<BaseState>(x, "GetAimRay"); } internal bool <FireSunder_FixedUpdate>b__4_2(Instruction x) { return ILPatternMatchingExt.MatchCall(x, (MethodBase)AccessTools.PropertyGetter(typeof(ProjectileManager), "instance")); } internal bool <ChargeTrioBomb_FixedUpdate>b__5_1(Instruction x) { return ILPatternMatchingExt.MatchCall<BaseState>(x, "GetAimRay"); } internal bool <ChargeTrioBomb_FixedUpdate>b__5_3(Instruction x) { return ILPatternMatchingExt.MatchCall<ChargeTrioBomb>(x, "FindTargetChildTransformFromBombIndex"); } internal bool <ChargeTrioBomb_FixedUpdate>b__5_5(Instruction x) { return ILPatternMatchingExt.MatchCall(x, (MethodBase)AccessTools.PropertyGetter(typeof(ProjectileManager), "instance")); } internal Ray <ChargeTrioBomb_FixedUpdate>b__5_0(Ray aimRay, Transform transform, CharacterBody body, GameObject prefab) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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) ((Ray)(ref aimRay)).origin = transform.position; return PredictionUtils.PredictAimray(aimRay, body, prefab); } } public static void Init() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_0084: 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_008f: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00f3: 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_00fe: Expected O, but got Unknown //IL_0118: 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: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Expected O, but got Unknown //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { hook_FindEnemyHurtBox val = (orig_FindEnemyHurtBox orig, BaseAI self, float maxDist, bool _, bool filterByLoS) => orig.Invoke(self, maxDist, true, filterByLoS); <>c.<>9__0_0 = val; obj = (object)val; } BaseAI.FindEnemyHurtBox += (hook_FindEnemyHurtBox)obj; object obj2 = <>c.<>9__0_1; if (obj2 == null) { Manipulator val2 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireSunder_FixedUpdate(new ILCursor(il)); }; <>c.<>9__0_1 = val2; obj2 = (object)val2; } FireSunder.FixedUpdate += (Manipulator)obj2; object obj3 = <>c.<>9__0_2; if (obj3 == null) { Manipulator val3 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown ChargeTrioBomb_FixedUpdate(new ILCursor(il)); }; <>c.<>9__0_2 = val3; obj3 = (object)val3; } ChargeTrioBomb.FixedUpdate += (Manipulator)obj3; object obj4 = <>c.<>9__0_3; if (obj4 == null) { Manipulator val4 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<GenericProjectileBaseState>(new ILCursor(il)); }; <>c.<>9__0_3 = val4; obj4 = (object)val4; } GenericProjectileBaseState.FireProjectile += (Manipulator)obj4; object obj5 = <>c.<>9__0_4; if (obj5 == null) { Manipulator val5 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireCannons>(new ILCursor(il)); }; <>c.<>9__0_4 = val5; obj5 = (object)val5; } FireCannons.OnEnter += (Manipulator)obj5; object obj6 = <>c.<>9__0_5; if (obj6 == null) { Manipulator val6 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireEyeBlast>(new ILCursor(il)); }; <>c.<>9__0_5 = val6; obj6 = (object)val6; } FireEyeBlast.FixedUpdate += (Manipulator)obj6; object obj7 = <>c.<>9__0_6; if (obj7 == null) { Manipulator val7 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireWindblade>(new ILCursor(il)); }; <>c.<>9__0_6 = val7; obj7 = (object)val7; } FireWindblade.OnEnter += (Manipulator)obj7; object obj8 = <>c.<>9__0_7; if (obj8 == null) { Manipulator val8 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireHook>(new ILCursor(il)); }; <>c.<>9__0_7 = val8; obj8 = (object)val8; } FireHook.OnEnter += (Manipulator)obj8; object obj9 = <>c.<>9__0_8; if (obj9 == null) { Manipulator val9 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireFireball>(new ILCursor(il)); }; <>c.<>9__0_8 = val9; obj9 = (object)val9; } FireFireball.OnEnter += (Manipulator)obj9; object obj10 = <>c.<>9__0_9; if (obj10 == null) { Manipulator val10 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireMegaFireball>(new ILCursor(il)); }; <>c.<>9__0_9 = val10; obj10 = (object)val10; } FireMegaFireball.FixedUpdate += (Manipulator)obj10; object obj11 = <>c.<>9__0_10; if (obj11 == null) { Manipulator val11 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireEnergyCannon>(new ILCursor(il)); }; <>c.<>9__0_10 = val11; obj11 = (object)val11; } FireEnergyCannon.OnEnter += (Manipulator)obj11; object obj12 = <>c.<>9__0_11; if (obj12 == null) { Manipulator val12 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireBombardment>(new ILCursor(il)); }; <>c.<>9__0_11 = val12; obj12 = (object)val12; } FireBombardment.FireGrenade += (Manipulator)obj12; object obj13 = <>c.<>9__0_12; if (obj13 == null) { Manipulator val13 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireTarball>(new ILCursor(il)); }; <>c.<>9__0_12 = val13; obj13 = (object)val13; } FireTarball.FireSingleTarball += (Manipulator)obj13; object obj14 = <>c.<>9__0_13; if (obj14 == null) { Manipulator val14 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectile<FireSpines>(new ILCursor(il)); }; <>c.<>9__0_13 = val14; obj14 = (object)val14; } FireSpines.FixedUpdate += (Manipulator)obj14; object obj15 = <>c.<>9__0_14; if (obj15 == null) { Manipulator val15 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectileGroup<JellyBarrage>(new ILCursor(il)); }; <>c.<>9__0_14 = val15; obj15 = (object)val15; } JellyBarrage.FixedUpdate += (Manipulator)obj15; object obj16 = <>c.<>9__0_15; if (obj16 == null) { Manipulator val16 = delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown FireProjectileGroup<FireVoidspikes>(new ILCursor(il)); }; <>c.<>9__0_15 = val16; obj16 = (object)val16; } FireVoidspikes.FixedUpdate += (Manipulator)obj16; } public static void FireProjectile<T>(ILCursor c, string prefabName) { if (c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall<BaseState>(x, "GetAimRay") })) { c.EmitPredictAimray<T>(prefabName); } else { Log.Error("AccurateEnemies: Generic OnEnter IL Hook failed "); } } public static void FireProjectile<T>(ILCursor c) { if (c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall<BaseState>(x, "GetAimRay") })) { c.EmitPredictAimray<T>(); } else { Log.Error("AccurateEnemies: Generic OnEnter IL Hook failed "); } } public static void FireProjectileGroup<T>(ILCursor c) { while (c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall<BaseState>(x, "GetAimRay") })) { c.EmitPredictAimray<T>(); } } private static void FireSunder_FixedUpdate(ILCursor c) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) int loc = -1; if (c.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall<BaseState>(x, "GetAimRay") }) && c.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref loc) }) && loc != -1 && c.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)AccessTools.PropertyGetter(typeof(ProjectileManager), "instance")) })) { c.Emit(OpCodes.Ldloc, loc); c.EmitPredictAimray<FireSunder>(); c.Emit(OpCodes.Stloc, loc); } else { Log.Error("AccurateEnemies: EntityStates.BeetleGuardMonster.FireSunder.FixedUpdate IL Hook failed"); } } private static void ChargeTrioBomb_FixedUpdate(ILCursor c) { //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) int rayLoc = -1; int transformLoc = -1; if (c.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall<BaseState>(x, "GetAimRay") }) && c.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref rayLoc) }) && rayLoc != -1 && c.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall<ChargeTrioBomb>(x, "FindTargetChildTransformFromBombIndex") }) && c.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref transformLoc) }) && transformLoc != -1 && c.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)AccessTools.PropertyGetter(typeof(ProjectileManager), "instance")) })) { c.Emit(OpCodes.Ldloc, rayLoc); c.Emit(OpCodes.Ldloc, transformLoc); c.Emit(OpCodes.Ldarg_0); c.Emit(OpCodes.Call, (MethodBase)AccessTools.PropertyGetter(typeof(ChargeTrioBomb), "characterBody")); c.Emit(OpCodes.Ldsfld, AccessTools.DeclaredField(typeof(ChargeTrioBomb), "bombProjectilePrefab")); c.EmitDelegate<Func<Ray, Transform, CharacterBody, GameObject, Ray>>((Func<Ray, Transform, CharacterBody, GameObject, Ray>)delegate(Ray aimRay, Transform transform, CharacterBody body, GameObject prefab) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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) ((Ray)(ref aimRay)).origin = transform.position; return PredictionUtils.PredictAimray(aimRay, body, prefab); }); c.Emit(OpCodes.Stloc, rayLoc); } else { Log.Error("AccurateEnemies: EntityStates.Bell.BellWeapon.ChargeTrioBomb.FixedUpdate IL Hook failed"); } } } public static class PredictionUtils { private const float zero = 1E-05f; internal static void EmitPredictAimray<T>(this ILCursor c, string prefabName = "projectilePrefab") { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) c.Emit(OpCodes.Ldarg_0); c.Emit(OpCodes.Call, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "characterBody")); FieldInfo fieldInfo = AccessTools.Field(typeof(T), prefabName); if (!fieldInfo.IsStatic) { c.Emit(OpCodes.Ldarg_0); } if (!fieldInfo.IsStatic) { c.Emit(OpCodes.Ldfld, fieldInfo); } else { c.Emit(OpCodes.Ldsfld, fieldInfo); } c.Emit(OpCodes.Call, (MethodBase)Reflection.GetMethodCached(typeof(PredictionUtils), "PredictAimray")); } public static Ray PredictAimray(Ray aimRay, CharacterBody body, GameObject projectilePrefab) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_0078: Invalid comparison between Unknown and I4 //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_00b8: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) if (!AdvPredictionConfig.enablePrediction.Value || !Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.master) || !Object.op_Implicit((Object)(object)projectilePrefab)) { return aimRay; } float speed = 0f; ProjectileSimple val = default(ProjectileSimple); if (projectilePrefab.TryGetComponent<ProjectileSimple>(ref val)) { speed = val.desiredForwardSpeed; } ProjectileCharacterController val2 = default(ProjectileCharacterController); if (projectilePrefab.TryGetComponent<ProjectileCharacterController>(ref val2)) { speed = val2.velocity; } if ((int)body.teamComponent.teamIndex != 1) { AdvPredictionPlugin.GetProjectileSpeedModifiers(ref speed); } CharacterBody aimTargetBody = GetAimTargetBody(body); if (speed > 0f && Object.op_Implicit((Object)(object)aimTargetBody)) { Vector3 position = aimTargetBody.transform.position; Vector3 aP = Vector3.zero; CharacterMotor characterMotor = aimTargetBody.characterMotor; Vector3 val3; Vector3 aT; if (Object.op_Implicit((Object)(object)characterMotor) && characterMotor.hasEffectiveAuthority) { val3 = characterMotor.velocity; aT = (PreMove(characterMotor) - val3) / Time.fixedDeltaTime; } else { val3 = (position - aimTargetBody.previousPosition) / Time.fixedDeltaTime; aT = Vector3.zero; } if (((Vector3)(ref val3)).sqrMagnitude > 1E-05f) { return GetRay(aimRay, speed, aP, position, val3, aT); } } return aimRay; } private static CharacterBody GetAimTargetBody(CharacterBody body) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) BaseAI[] aiComponents = body.master.aiComponents; foreach (BaseAI val in aiComponents) { if (Object.op_Implicit((Object)(object)val) && val.hasAimTarget) { Target aimTarget = val.skillDriverEvaluation.aimTarget; if (Object.op_Implicit((Object)(object)aimTarget.characterBody) && aimTarget.characterBody.teamComponent.teamIndex != body.teamComponent.teamIndex && Object.op_Implicit((Object)(object)aimTarget.healthComponent) && aimTarget.healthComponent.alive) { return aimTarget.characterBody; } } } return null; } private static Vector3 PreMove(CharacterMotor motor) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_0137: Unknown result type (might be due to invalid IL or missing references) float num = motor.acceleration; if (motor.isAirControlForced || !motor.isGrounded) { num *= (motor.disableAirControlUntilCollision ? 0f : motor.airControl); } Vector3 val = motor.moveDirection; if (!motor.isFlying) { val.y = 0f; } if (motor.body.isSprinting) { float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 1f && magnitude > 0f) { val *= 1f / ((Vector3)(ref val)).magnitude; } } val *= motor.walkSpeed; if (!motor.isFlying) { val.y = motor.velocity.y; } Vector3 result = Vector3.MoveTowards(motor.velocity, val, num * Time.fixedDeltaTime); if (motor.useGravity) { ref float y = ref result.y; y += Physics.gravity.y * Time.fixedDeltaTime; if (motor.isGrounded) { y = Mathf.Max(y, 0f); } } return result; } private static Ray GetRay(Ray aimRay, float sP, Vector3 aP, Vector3 pT, Vector3 vT, Vector3 aT) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: 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_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) pT -= ((Ray)(ref aimRay)).origin; bool flag = ((Vector3)(ref aT)).sqrMagnitude > 1E-05f; float num = ((Vector3)(ref vT)).sqrMagnitude - sP * sP; float num2 = 2f * Vector3.Dot(vT, pT); float sqrMagnitude = ((Vector3)(ref pT)).sqrMagnitude; double[] array; if (flag) { float num3 = ((Vector3)(ref aT)).sqrMagnitude * 0.25f; float num4 = Vector3.Dot(aT, vT); num += Vector3.Dot(aT, pT); array = SolveQuartic(num3, num4, num, num2, sqrMagnitude); } else { array = SolveQuadratic(num, num2, sqrMagnitude); } if (array != null) { float num5 = float.MaxValue; for (int i = 0; i < array.Length; i++) { float num6 = (float)array[i]; if (num6 > 0f && num6 < num5) { num5 = num6; } } if (num5 > 0f && num5 < float.MaxValue) { Vector3 val = pT + vT * num5 + 0.5f * aT * num5 * num5; RaycastHit val2 = default(RaycastHit); if (Physics.Linecast(pT + ((Ray)(ref aimRay)).origin, val + ((Ray)(ref aimRay)).origin, ref val2)) { val = Vector3.MoveTowards(pT, val, ((RaycastHit)(ref val2)).distance) + ((RaycastHit)(ref val2)).normal; } Vector3 val3 = val / num5 - 0.5f * aP * num5; ((Vector3)(ref val3)).Normalize(); return new Ray(((Ray)(ref aimRay)).origin, Vector3.Lerp(((Ray)(ref aimRay)).direction, val3, (float)AdvPredictionConfig.accuracy.Value * 0.01f)); } } return aimRay; } public static double[] SolveQuadratic(double a, double b, double c) { double num = b * b - 4.0 * a * c; if (num < 0.0) { return null; } num = Math.Sqrt(num); double num2 = ((b < 0.0) ? (-0.5 * (b - num)) : (-0.5 * (b + num))); double num3 = num2 / a; double num4 = c / num2; return (!(num3 > num4)) ? new double[2] { num3, num4 } : new double[2] { num4, num3 }; } public static double[] SolveQuartic(double a, double b, double c, double d, double e) { double num = 1.0 / a; double num2 = b * num; double num3 = c * num; double num4 = d * num; double num5 = e * num; double num6 = num2 * num2; double num7 = -0.375 * num6 + num3; double num8 = 0.125 * num6 * num2 - 0.5 * num2 * num3 + num4; double num9 = -3.0 / 256.0 * num6 * num6 + 0.0625 * num6 * num3 - 0.25 * num2 * num4 + num5; double num10 = SolveCubicForQuartic(-0.5 * num7, 0.0 - num9, 0.5 * num9 * num7 - 0.125 * num8 * num8); double num11 = 2.0 * num10 - num7; if (num11 < 0.0) { if (!(num11 > 1E-10)) { return null; } num11 = 0.0; } double num12; if (num11 < 1E-10) { num12 = num10 * num10 - num9; if (num12 < 0.0) { return null; } num12 = Math.Sqrt(num12); } else { num11 = Math.Sqrt(num11); num12 = 0.5 * num8 / num11; } double num13 = num11 * num11; double num14 = -0.25 * num2; double num15 = num13 - 4.0 * (num10 - num12); double num16 = num13 - 4.0 * (num10 + num12); if (num15 >= 0.0 && num16 >= 0.0) { num15 = Math.Sqrt(num15); num16 = Math.Sqrt(num16); double[] array = new double[4] { -0.5 * (num11 + num15) + num14, -0.5 * (num11 - num15) + num14, 0.5 * (num11 + num16) + num14, 0.5 * (num11 - num16) + num14 }; for (int i = 1; i < 4; i++) { int num17 = i; while (num17 > 0 && array[num17 - 1] > array[num17]) { ref double reference = ref array[num17 - 1]; ref double reference2 = ref array[num17]; double num18 = array[num17]; double num19 = array[num17 - 1]; reference = num18; reference2 = num19; num17--; } } return array; } if (num15 >= 0.0) { num15 = Math.Sqrt(num15); return new double[2] { -0.5 * (num11 + num15) + num14, -0.5 * (num11 - num15) + num14 }; } if (num16 >= 0.0) { num16 = Math.Sqrt(num16); return new double[2] { 0.5 * (num11 - num16) + num14, 0.5 * (num11 + num16) + num14 }; } return null; } private static double SolveCubicForQuartic(double p, double q, double r) { double num = p * p; double num2 = (num - 3.0 * q) / 9.0; double num3 = (p * (num - 4.5 * q) + 13.5 * r) / 27.0; double num4 = num2 * num2 * num2; double num5 = num3 * num3; double num6 = num4 - num5; double num7 = p / 3.0; if (num6 >= 0.0) { num6 = num3 / Math.Sqrt(num4); double d = Math.Acos(num6) / 3.0; double num8 = -2.0 * Math.Sqrt(num2); return num8 * Math.Cos(d) - num7; } double num9 = Math.Pow(Math.Sqrt(num5 - num4) + Math.Abs(num3), 1.0 / 3.0); return (num3 < 0.0) ? (num9 + num2 / num9 - num7) : (0.0 - (num9 + num2 / num9) - num7); } } }