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 Armored Core 6 Raven v1.1.0
plugins/AC6Mod.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using AC6Mod.Core; using AC6Mod.Mech; using AC6Mod.Mech.States; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using HG.BlendableTypes; using HG.GeneralSerializer; using HG.Reflection; using KinematicCharacterController; using MonoMod.RuntimeDetour; using R2API; using R2API.Utils; using Rewired; using RoR2; using RoR2.CameraModes; using RoR2.CharacterAI; using RoR2.ContentManagement; using RoR2.Networking; using RoR2.Projectile; using RoR2.Skills; using RoR2.SurvivorMannequins; using RoR2.UI; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.UI; using UnityEngine.Video; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("AC6Mod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c228ca9992d39d5981930d2a4e8974e71c1fb07e")] [assembly: AssemblyProduct("AC6Mod")] [assembly: AssemblyTitle("AC6Mod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace AC6Mod { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.trevor.ac6mech", "AC6_Raven", "1.1.0")] public class AC6MechPlugin : BaseUnityPlugin { public const string MODUID = "com.trevor.ac6mech"; public const string MODNAME = "AC6_Raven"; public const string MODVERSION = "1.1.0"; public const string DEVELOPER_PREFIX = "AC6"; public static AC6MechPlugin instance; private void Awake() { instance = this; Log.Init(((BaseUnityPlugin)this).Logger); VanillaRefs.ResolveSetup(); Hooks.InstallSetup(); try { MechSetup.Run(); } catch (Exception ex) { Log.Error("[AC6] mech setup failed: " + ex); } if (MechSetup.Loaded) { Hooks.InstallGame(); } else { Log.Error("[AC6] the mech is NOT loaded (see the [AC6] error above). " + VanillaRefs.Summary()); } if (RoR2Application.loadFinished) { OnGameLoaded(); } else { RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnGameLoaded)); } if (AC6MechConfig.frameTimeSampler != null && AC6MechConfig.frameTimeSampler.Value) { ((Component)this).gameObject.AddComponent<FrameTimeSampler>(); } ContentCheck.Register(MechSetup.Loaded); if (MechSetup.Loaded) { new ContentPacks().Initialize(); } } private static void OnGameLoaded() { try { if (MechSetup.Loaded) { VanillaRefs.ResolveLate(); Hooks.InstallUi(); Log.Info("[AC6] " + SafeHook.Summary()); Log.Info("[AC6] " + VanillaRefs.Summary()); } Log.Info("[AC6] " + ContentCheck.GameSummary()); } catch (Exception ex) { Log.Error("[AC6] load checks failed: " + ex); } } } internal static class Log { internal static ManualLogSource _logSource; internal static bool VerboseEnabled { get { if (AC6MechConfig.verboseLogging != null) { return AC6MechConfig.verboseLogging.Value; } return false; } } 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 Verbose(object data) { if (VerboseEnabled) { _logSource.LogInfo(data); } } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } public static class AC6Names { public static class Bundle { public const string Name = "ac6mechassets"; public const string ModelPrefab = "mdlAC6Mech"; public const string DisplayPrefab = "AC6MechDisplay"; public const string Portrait = "texAC6MechIcon"; public const string IconPrimary = "texPrimaryIcon"; public const string IconSecondary = "texSecondaryIcon"; public const string IconUtility = "texUtilityIcon"; public const string IconSpecial = "texSpecialIcon"; public const string IconDefaultSkin = "texMainSkin"; public const string IconBoostDodge = "texBoostDodgeIcon"; public const string IconAssaultArmor = "texAssaultArmorIcon"; public const string IconAutoMissile = "texAutoMissileIcon"; public const string IconWeaponBay = "texWeaponBayIcon"; public const string IconWeaponBayNone = "texWeaponBayNoneIcon"; public const string UIAdditiveShader = "AC6UIAdditive"; public const string FlashSphereShader = "AC6FlashSphere"; public const string IconLudlow = "texWeapon1820Icon"; public const string IconAshmead = "texWeapon0010Icon"; public const string IconSweetSixteen = "texWeapon1520Icon"; public const string IconCurtis = "texWeapon1620Icon"; public const string IconTherapist = "texWeapon2130Icon"; public const string IconHml = "texWeapon2210Icon"; public const string IconTaiYang = "texWeapon0510Icon"; public const string IconBml = "texWeapon4251Icon"; public const string IconSongbird = "texWeapon4410Icon"; public const string IconTrueno = "texWeapon4330Icon"; } public static class Layer { public const string Body = "Body"; public const string Dodge = "Dodge, Override"; public const string RightArm = "Right Arm, Override"; public const string LeftArm = "Left Arm, Override"; public const string CurtisFire = "Curtis Fire, Override"; public const string FullBody = "FullBody, Override"; public const string SprintFire = "Sprint Fire, Override"; public const string BmlDoorsL = "BML Doors L, Override"; public const string BmlDoorsR = "BML Doors R, Override"; public const string SongbirdBraceL = "Songbird L, Override"; public const string SongbirdBraceR = "Songbird R, Override"; public const string TaiYang = "TaiYang, Override"; public const string AssaultArmor = "Assault Armor, Override"; public const string SwapR = "Swap R, Override"; public const string SwapL = "Swap L, Override"; public const string SongbirdLauncherL = "Songbird Launcher L"; public const string SongbirdLauncherR = "Songbird Launcher R"; public const string HmlLauncherL = "HML Launcher L"; public const string HmlLauncherR = "HML Launcher R"; public const string TruenoLauncherL = "Trueno Launcher L"; public const string TruenoLauncherR = "Trueno Launcher R"; public const string LoaderRailL = "Loader Rail L"; public const string LoaderRailR = "Loader Rail R"; public static string Arm(WeaponHand h) { if (h != WeaponHand.Left) { return "Right Arm, Override"; } return "Left Arm, Override"; } public static string Swap(WeaponHand h) { if (h != WeaponHand.Left) { return "Swap R, Override"; } return "Swap L, Override"; } public static string HmlLauncher(WeaponHand h) { if (h != WeaponHand.Left) { return "HML Launcher R"; } return "HML Launcher L"; } public static string LoaderRail(WeaponHand h) { if (h != WeaponHand.Left) { return "Loader Rail R"; } return "Loader Rail L"; } } public static class State { public const string Empty = "Empty"; public const string GroundMove = "GroundMove"; public const string Airborne = "Airborne"; public const string SprintStart = "SprintStart"; public const string Sprint = "Sprint"; public const string JumpTakeoff = "JumpTakeoff"; public const string Land = "Land"; public const string Idle = "Idle"; public const string AscendDescend = "AscendDescend"; public const string FireMG = "FireMG"; public const string ChargeCurtis = "ChargeCurtis"; public const string FireCurtisBody = "FireCurtisBody"; public const string FireCurtisBodyL = "FireCurtisBody_L"; public const string PileBunker = "PileBunker"; public const string AssaultBoostShooting = "AssaultBoost_Shooting"; public const string BmlFireDoorsL = "BMLFireDoorsL"; public const string BmlFireDoorsR = "BMLFireDoorsR"; public const string SongbirdFire = "SongbirdFire"; public const string TaiYangFire = "TaiYangFire"; public const string AssaultArmorCharge = "AssaultArmorCharge"; public const string SwapR = "SwapR"; public const string SwapL = "SwapL"; public const string BoostDodgeFwd = "BoostDodgeFwd"; public const string BoostDodgeBack = "BoostDodgeBack"; public const string BoostDodgeLeft = "BoostDodgeLeft"; public const string BoostDodgeRight = "BoostDodgeRight"; public const string Rest = "Rest"; public const string Fire = "Fire"; public const string Fire1 = "Fire1"; public const string Fire2 = "Fire2"; public const string Retract = "Retract"; public const string Extend = "Extend"; public const string ExtendToReady = "ExtendToReady"; public const string Ready = "Ready"; public const string ReadyToExtend = "ReadyToExtend"; public const string RestToFire = "RestToFire"; public const string FireToRest = "FireToRest"; public static readonly string[] SongbirdChain = new string[6] { "Extend", "ExtendToReady", "Fire1", "Fire2", "Ready", "ReadyToExtend" }; public static readonly string[] TruenoChain = new string[5] { "Rest", "RestToFire", "Fire1", "Fire2", "FireToRest" }; public static readonly string[] HmlChain = new string[2] { "Rest", "Fire" }; public static readonly string[] LoaderChain = new string[3] { "Rest", "Extend", "Retract" }; public static string Swap(WeaponHand h) { if (h != WeaponHand.Left) { return "SwapR"; } return "SwapL"; } public static string FireCurtis(WeaponHand h) { if (h != WeaponHand.Left) { return "FireCurtisBody"; } return "FireCurtisBody_L"; } } public static class Param { public const string ForwardSpeed = "forwardSpeed"; public const string RightSpeed = "rightSpeed"; public const string UpSpeed = "upSpeed"; public const string WalkSpeed = "walkSpeed"; public const string IsMoving = "isMoving"; public const string IsSprinting = "isSprinting"; public const string IsGrounded = "isGrounded"; public const string FireMGRate = "FireMG.playbackRate"; public const string PileBunkerRate = "PileBunker.playbackRate"; } public static class Clip { public const string PileBunker = "PileBunker"; public const string CurtisFire = "Curtis Fire"; public const string CurtisFireL = "Curtis Fire L"; public const string TaiYangFire = "TaiYangFire"; public const string SwapR = "SwapR"; public const string SwapL = "SwapL"; public static string Swap(WeaponHand h) { if (h != WeaponHand.Left) { return "SwapR"; } return "SwapL"; } public static string CurtisFireFor(WeaponHand h) { if (h != WeaponHand.Left) { return "Curtis Fire"; } return "Curtis Fire L"; } public static string SongbirdPrefix(WeaponHand side) { if (side != WeaponHand.Left) { return "SongbirdR_"; } return "SongbirdL_"; } public static string TruenoPrefix(WeaponHand side) { if (side != WeaponHand.Left) { return "TruenoR_"; } return "TruenoL_"; } public static string HmlPrefix(WeaponHand side) { if (side != WeaponHand.Left) { return "HMLR_"; } return "HMLL_"; } public static string LoaderPrefix(WeaponHand side) { if (side != WeaponHand.Left) { return "LoaderR_"; } return "LoaderL_"; } } public static class Child { public const string MainHurtbox = "MainHurtbox"; public const string PileBunkerAnchor = "PileBunkerAnchor"; public const string ForearmR = "ForearmR"; public const string ForearmL = "ForearmL"; public const string MuzzleGun = "MuzzleGun"; public const string MuzzleWeaponR = "MuzzleWeaponR"; public const string MuzzleWeaponL = "MuzzleWeaponL"; public const string BoosterL = "Thruster_BoosterL_01"; public const string BoosterR = "Thruster_BoosterR_01"; public const string ShoulderL1 = "Thruster_ShoulderL_01"; public const string ShoulderL2 = "Thruster_ShoulderL_02"; public const string ShoulderL3 = "Thruster_ShoulderL_03"; public const string ShoulderL4 = "Thruster_ShoulderL_04"; public const string ShoulderR1 = "Thruster_ShoulderR_01"; public const string ShoulderR2 = "Thruster_ShoulderR_02"; public const string ShoulderR3 = "Thruster_ShoulderR_03"; public const string ShoulderR4 = "Thruster_ShoulderR_04"; public const string ThighL = "Thruster_ThighL_01"; public const string ThighR = "Thruster_ThighR_01"; public const string CalfL = "Thruster_CalfL_01"; public const string CalfR = "Thruster_CalfR_01"; public static readonly string[] Thrusters = new string[14] { "Thruster_BoosterL_01", "Thruster_BoosterR_01", "Thruster_ShoulderL_01", "Thruster_ShoulderL_02", "Thruster_ShoulderL_03", "Thruster_ShoulderL_04", "Thruster_ShoulderR_01", "Thruster_ShoulderR_02", "Thruster_ShoulderR_03", "Thruster_ShoulderR_04", "Thruster_ThighL_01", "Thruster_ThighR_01", "Thruster_CalfL_01", "Thruster_CalfR_01" }; public static string Forearm(WeaponHand h) { if (h != WeaponHand.Left) { return "ForearmR"; } return "ForearmL"; } public static string MuzzleWeapon(WeaponHand h) { if (h != WeaponHand.Left) { return "MuzzleWeaponR"; } return "MuzzleWeaponL"; } public static string MissileMuzzle(WeaponHand side, int port) { return ((side == WeaponHand.Left) ? "MuzzleMissileL" : "MuzzleMissileR") + port; } public static string SongbirdBarrel(WeaponHand side, int barrel) { return ((side == WeaponHand.Left) ? "SongbirdL_Front" : "SongbirdR_Front") + barrel; } public static string TruenoMuzzle(WeaponHand side, bool outer) { return ((side == WeaponHand.Left) ? "MuzzleTruenoL_" : "MuzzleTruenoR_") + (outer ? "Outer" : "Inner"); } public static string BayRail(WeaponHand side) { if (side != WeaponHand.Left) { return "WP_R_8950_baked"; } return "WP_L_8950_baked"; } public static string BackRail(WeaponHand side) { if (side != WeaponHand.Left) { return "WP_R_8955_baked"; } return "WP_L_8955_baked"; } } public static class Model { public const string SceneMech = "ac6_mech"; public const string JetFlame = "Jet_Flame"; public const string BoostParticlePrefix = "Boost_particle"; public const string BoostParticleL = "Boost_particle-L"; public const string BoostParticleR = "Boost_particle-R"; public const string PileBunkerSparks = "PileBunker_Sparks"; public const string PileBunkerFireball = "PileBunker_Fireball"; public const string ThrusterPrefix = "Thruster_"; public const string ElbowR = "elbow.R"; public const string ElbowL = "elbow.L"; public const string HandR = "hand.R"; public const string HandL = "hand.L"; public const string HeadBone = "head"; public const string PileBunkerHitBone = "WP_L_0010_23"; public const string PileBunkerTipBone = "WP_L_0010_24"; public const string PaintZone = "FLAT_TAN"; public const string PaintMaterial = "matFLAT_TAN"; public static readonly string[] PaintExcludedRenderers = new string[2] { "WP_L_0010_Material #0", "StowL_0010" }; public static string SongbirdAimBone(WeaponHand side) { if (side != WeaponHand.Left) { return "WP_R_4410_03"; } return "WP_L_4410_03"; } public static string SongbirdBarrelBone(WeaponHand side) { if (side != WeaponHand.Left) { return "WP_R_4410_05"; } return "WP_L_4410_05"; } } public static class Weapons { public static readonly WeaponModel Ludlow = new WeaponModel("1820", WeaponHand.Right, back: false, 0, bindPoseBounds: false); public static readonly WeaponModel Ashmead = new WeaponModel("0010", WeaponHand.Left, back: false, 0, bindPoseBounds: false); public static readonly WeaponModel SweetSixteen = new WeaponModel("1520", WeaponHand.Both, back: false, 1, bindPoseBounds: false); public static readonly WeaponModel Curtis = new WeaponModel("1620", WeaponHand.Both, back: false, 1, bindPoseBounds: false); public static readonly WeaponModel Therapist = new WeaponModel("2130", WeaponHand.Both, back: false, 1, bindPoseBounds: true); public static readonly WeaponModel Hml = new WeaponModel("2210", WeaponHand.Both, back: false, 4, bindPoseBounds: true); public static readonly WeaponModel TaiYang = new WeaponModel("0510", WeaponHand.Left, back: false, 1, bindPoseBounds: true); public static readonly WeaponModel Bml = new WeaponModel("4251", WeaponHand.Both, back: true, 0, bindPoseBounds: false); public static readonly WeaponModel Songbird = new WeaponModel("4410", WeaponHand.Both, back: true, 0, bindPoseBounds: true); public static readonly WeaponModel Trueno = new WeaponModel("4330", WeaponHand.Both, back: true, 0, bindPoseBounds: true); public static readonly WeaponModel[] Hand = new WeaponModel[7] { Ludlow, Ashmead, SweetSixteen, Curtis, Therapist, Hml, TaiYang }; public static readonly WeaponModel[] Back = new WeaponModel[3] { Bml, Songbird, Trueno }; public static readonly WeaponModel DefaultBack = Bml; } public struct LayerStates { public readonly string layer; public readonly string[] states; public LayerStates(string layer, params string[] states) { this.layer = layer; this.states = states; } } public const float ClipFps = 30f; public const int PileBunkerClipFrames = 52; public const float CurtisFireClipSpeed = 0.5f; public const int SongbirdReadyHoldFrames = 30; public const int SwapBlendOutFrames = 7; public static readonly LayerStates[] AnimatorLayers = new LayerStates[23] { new LayerStates("Body", "GroundMove", "Airborne", "SprintStart", "Sprint", "JumpTakeoff"), new LayerStates("Dodge, Override", "Empty", "BoostDodgeFwd", "BoostDodgeBack", "BoostDodgeLeft", "BoostDodgeRight"), new LayerStates("Right Arm, Override", "Empty", "FireMG", "ChargeCurtis"), new LayerStates("Left Arm, Override", "Empty", "FireMG", "ChargeCurtis"), new LayerStates("Curtis Fire, Override", "Empty", "FireCurtisBody", "FireCurtisBody_L"), new LayerStates("FullBody, Override", "Empty", "PileBunker"), new LayerStates("Sprint Fire, Override", "Empty", "AssaultBoost_Shooting"), new LayerStates("BML Doors L, Override", "Empty", "BMLFireDoorsL"), new LayerStates("BML Doors R, Override", "Empty", "BMLFireDoorsR"), new LayerStates("Songbird L, Override", "Empty", "SongbirdFire"), new LayerStates("Songbird R, Override", "Empty", "SongbirdFire"), new LayerStates("TaiYang, Override", "Empty", "TaiYangFire"), new LayerStates("Assault Armor, Override", "Empty", "AssaultArmorCharge"), new LayerStates("Swap R, Override", "Empty", "SwapR"), new LayerStates("Swap L, Override", "Empty", "SwapL"), new LayerStates("Songbird Launcher L", State.SongbirdChain), new LayerStates("Songbird Launcher R", State.SongbirdChain), new LayerStates("HML Launcher L", State.HmlChain), new LayerStates("HML Launcher R", State.HmlChain), new LayerStates("Trueno Launcher L", State.TruenoChain), new LayerStates("Trueno Launcher R", State.TruenoChain), new LayerStates("Loader Rail L", State.LoaderChain), new LayerStates("Loader Rail R", State.LoaderChain) }; public static readonly string[] AnimatorParams = new string[9] { "forwardSpeed", "rightSpeed", "upSpeed", "walkSpeed", "isMoving", "isSprinting", "isGrounded", "FireMG.playbackRate", "PileBunker.playbackRate" }; public static readonly WeaponHand[] Sides = new WeaponHand[2] { WeaponHand.Right, WeaponHand.Left }; public static IEnumerable<string> TimedClips() { yield return "PileBunker"; yield return "Curtis Fire"; yield return "Curtis Fire L"; yield return "TaiYangFire"; yield return "SwapR"; yield return "SwapL"; WeaponHand[] sides = Sides; foreach (WeaponHand side in sides) { yield return Clip.SongbirdPrefix(side) + "ExtendToReady"; yield return Clip.SongbirdPrefix(side) + "Fire1"; yield return Clip.SongbirdPrefix(side) + "Fire2"; yield return Clip.TruenoPrefix(side) + "RestToFire"; yield return Clip.TruenoPrefix(side) + "Fire1"; yield return Clip.TruenoPrefix(side) + "Fire2"; yield return Clip.TruenoPrefix(side) + "FireToRest"; } } public static IEnumerable<string> ChildLocatorNames() { yield return "MainHurtbox"; yield return "PileBunkerAnchor"; yield return "ForearmR"; yield return "ForearmL"; yield return "MuzzleGun"; yield return "MuzzleWeaponR"; yield return "MuzzleWeaponL"; string[] thrusters = Child.Thrusters; for (int i = 0; i < thrusters.Length; i++) { yield return thrusters[i]; } WeaponHand[] sides = Sides; foreach (WeaponHand side in sides) { yield return Child.BayRail(side); yield return Child.BackRail(side); for (int port = 1; port <= 4; port++) { yield return Child.MissileMuzzle(side, port); } yield return Child.SongbirdBarrel(side, 1); yield return Child.SongbirdBarrel(side, 2); yield return Child.TruenoMuzzle(side, outer: true); yield return Child.TruenoMuzzle(side, outer: false); WeaponModel[] hand = Weapons.Hand; for (int port = 0; port < hand.Length; port++) { WeaponModel w = hand[port]; if (w.Allows(side)) { yield return w.HandMesh(side); yield return w.StowMesh(side); if (w.muzzles == 1) { yield return w.Muzzle(side); } int n = 1; while (w.muzzles > 1 && n <= w.muzzles) { yield return w.Muzzle(side, n); n++; } } } hand = Weapons.Back; foreach (WeaponModel weaponModel in hand) { yield return weaponModel.LauncherMesh(side); } } } } [Flags] public enum WeaponHand { None = 0, Right = 1, Left = 2, Both = 3 } public readonly struct WeaponModel { public readonly string id; public readonly WeaponHand hands; public readonly bool back; public readonly int muzzles; public readonly bool bindPoseBounds; public WeaponModel(string id, WeaponHand hands, bool back, int muzzles, bool bindPoseBounds) { this.id = id; this.hands = hands; this.back = back; this.muzzles = muzzles; this.bindPoseBounds = bindPoseBounds; } public bool Allows(WeaponHand hand) { if (!back) { return (hands & hand) != 0; } return false; } public string HandMesh(WeaponHand hand) { return ((hand == WeaponHand.Left) ? "WeaponL_" : "WeaponR_") + id; } public string StowMesh(WeaponHand hand) { return ((hand == WeaponHand.Left) ? "StowL_" : "StowR_") + id; } public string Muzzle(WeaponHand hand, int n = 0) { return ((hand == WeaponHand.Left) ? "MuzzleWeaponL_" : "MuzzleWeaponR_") + id + ((n > 0) ? ("_" + n) : ""); } public string LauncherMesh(WeaponHand side) { return ((side == WeaponHand.Left) ? "WP_L_" : "WP_R_") + id + "_baked"; } public string Armature(WeaponHand side) { return ((side == WeaponHand.Left) ? "WP_L_" : "WP_R_") + id; } } } namespace AC6Mod.Mech { [DefaultExecutionOrder(15000)] public class AC6BackWeaponController : MonoBehaviour { private class Launch { public bool active; public BackWeaponDef w; public IBackWeaponVolley vol; public float startTime; public float[] shotTimes; public int shotsFired; public float commitEnd; public bool committedHeld; public bool queued; public BackWeaponDef queuedW; public List<HurtBox> lockedTargets; public List<HurtBox> queuedTargets; public float readyHoldUntil; public BackWeaponDef lastW; } private readonly Launch left = new Launch(); private readonly Launch right = new Launch(); private bool fireLeftNext = true; private bool leftAvailable = true; private bool rightAvailable = true; private CharacterBody body; private MechContext ctx; private MechMovementLock moveLock; private bool SingleSide => leftAvailable != rightAvailable; private void Awake() { ctx = MechContext.Of(((Component)this).gameObject); body = ctx.Body; moveLock = ctx.MoveLock; } public bool NextSide() { if (SingleSide) { return leftAvailable; } bool result = fireLeftNext; fireLeftNext = !fireLeftNext; return result; } public bool WouldRefire(BackWeaponDef w, bool goLeft) { Launch launch = (goLeft ? left : right); if (w != null && w.SupportsRefire && !launch.active) { return Time.fixedTime <= launch.readyHoldUntil; } return false; } public bool IsNextLauncherFree() { return !((SingleSide ? leftAvailable : fireLeftNext) ? left : right).active; } public void SetAvailableLaunchers(bool left, bool right) { leftAvailable = left; rightAvailable = right; } public void Fire(BackWeaponDef w, bool goLeft, bool refire, List<HurtBox> lockedTargets = null) { if (w != null) { Launch launch = (goLeft ? left : right); if (!launch.active) { launch.lockedTargets = lockedTargets; BeginVolley(launch, goLeft, w, refire && w.SupportsRefire); } else { launch.queued = true; launch.queuedW = w; launch.queuedTargets = lockedTargets; } } } public void ForceExtend() { ForceExtend(left, isLeft: true); ForceExtend(right, isLeft: false); } private void ForceExtend(Launch ls, bool isLeft) { if (!ls.active && ls.lastW != null && ls.lastW.HasLauncherChain) { ls.readyHoldUntil = 0f; CrossFade(isLeft ? ls.lastW.launcherLayerLeft : ls.lastW.launcherLayerRight, ls.lastW.launcherIdleState, 0.1f); } } private void BeginVolley(Launch ls, bool goLeft, BackWeaponDef w, bool refire) { ls.active = true; ls.w = w; ls.lastW = w; ls.vol = ((w.createVolley != null) ? w.createVolley() : null); ls.startTime = Time.fixedTime; ls.shotsFired = 0; ls.readyHoldUntil = 0f; bool flag = (Object)(object)body != (Object)null && Util.HasEffectiveAuthority(((Component)body).gameObject); if (flag && ls.vol != null) { ls.vol.Begin(body, goLeft, ls.lockedTargets); } ls.lockedTargets = null; float decelTime; if (w.HasLauncherChain) { float num = (refire ? 0f : ClipLength(goLeft, w, w.launcherStartState)); decelTime = num; ls.shotTimes = new float[w.launcherShotStates.Length]; for (int i = 0; i < w.launcherShotStates.Length; i++) { int num2 = ((w.launcherShotFrames == null || i >= w.launcherShotFrames.Length) ? 1 : w.launcherShotFrames[i]); ls.shotTimes[i] = num + (float)Mathf.Max(0, num2 - 1) / 30f; num += ClipLength(goLeft, w, w.launcherShotStates[i]); } if (w.launcherTailStates != null) { string[] launcherTailStates = w.launcherTailStates; foreach (string state in launcherTailStates) { num += ClipLength(goLeft, w, state); } } ls.commitEnd = num; CrossFade(goLeft ? w.launcherLayerLeft : w.launcherLayerRight, refire ? w.launcherShotStates[0] : w.launcherStartState, 0.05f); } else { float num3 = (((Object)(object)body != (Object)null) ? Mathf.Max(0.1f, body.attackSpeed) : 1f); ls.shotTimes = new float[w.shots]; for (int k = 0; k < w.shots; k++) { ls.shotTimes[k] = w.fireStartDelay + (float)k * w.shotInterval / num3; } ls.commitEnd = w.volleyDuration; decelTime = w.lockDecelTime; if (!string.IsNullOrEmpty(w.launchSound)) { Util.PlaySound(w.launchSound, ((Component)this).gameObject); } } CrossFade(goLeft ? w.animLayerLeft : w.animLayerRight, goLeft ? w.animStateLeft : w.animStateRight, 0.05f); if (w.committed && (Object)(object)body != (Object)null && flag && (Object)(object)moveLock != (Object)null) { moveLock.Begin(ls, decelTime); ls.committedHeld = true; } } private void FixedUpdate() { bool authority = (Object)(object)body != (Object)null && Util.HasEffectiveAuthority(((Component)body).gameObject); TickLaunch(left, goLeft: true, authority); TickLaunch(right, goLeft: false, authority); if ((Object)(object)moveLock != (Object)null) { if (left.active && left.committedHeld) { moveLock.Tick(left); } if (right.active && right.committedHeld) { moveLock.Tick(right); } } } private void LateUpdate() { bool authority = (Object)(object)body != (Object)null && Util.HasEffectiveAuthority(((Component)body).gameObject); FireDueShots(left, goLeft: true, authority, chainOnly: true); FireDueShots(right, goLeft: false, authority, chainOnly: true); } private void FireDueShots(Launch ls, bool goLeft, bool authority, bool chainOnly) { if (!ls.active || (chainOnly && !ls.w.HasLauncherChain)) { return; } float num = Time.fixedTime - ls.startTime; while (ls.shotsFired < ls.shotTimes.Length && num >= ls.shotTimes[ls.shotsFired]) { if (authority && ls.vol != null) { ls.vol.FireShot(body, goLeft, ls.shotsFired); } if (ls.w.shotSounds != null) { string[] shotSounds = ls.w.shotSounds; for (int i = 0; i < shotSounds.Length; i++) { Util.PlaySound(shotSounds[i], ((Component)this).gameObject); } } if (ls.w.shotSoundNode != 0) { WwiseNode.Play(ls.w.shotSoundNode, ((Component)this).gameObject); } ls.shotsFired++; } } private void TickLaunch(Launch ls, bool goLeft, bool authority) { if (!ls.active) { return; } float num = Time.fixedTime - ls.startTime; if (!ls.w.HasLauncherChain || num >= ls.commitEnd) { FireDueShots(ls, goLeft, authority, chainOnly: false); } if (num >= ls.commitEnd) { BackWeaponDef w = ls.w; EndVolley(ls, goLeft); if (w.SupportsRefire) { ls.readyHoldUntil = Time.fixedTime + w.readyHoldSeconds; } if (ls.queued) { BackWeaponDef queuedW = ls.queuedW; ls.queued = false; ls.queuedW = null; ls.lockedTargets = ls.queuedTargets; ls.queuedTargets = null; BeginVolley(ls, goLeft, queuedW, queuedW.SupportsRefire); } } } private void EndVolley(Launch ls, bool goLeft) { CrossFade(goLeft ? ls.w.animLayerLeft : ls.w.animLayerRight, "Empty", 0.1f); if (ls.committedHeld && (Object)(object)moveLock != (Object)null) { moveLock.End(ls); ls.committedHeld = false; } ls.active = false; ls.vol = null; ls.w = null; } private float ClipLength(bool goLeft, BackWeaponDef w, string state) { float value = 0f; if (w.launcherFallbackSeconds != null) { w.launcherFallbackSeconds.TryGetValue(state, out value); } string name = (goLeft ? w.launcherClipLeft : w.launcherClipRight) + state; return MechAnim.ClipLength(ctx.Animator, name, value); } private void CrossFade(string layer, string state, float duration) { Animator animator = ctx.Animator; if (!((Object)(object)animator == (Object)null) && !string.IsNullOrEmpty(layer) && !string.IsNullOrEmpty(state)) { int layerIndex = animator.GetLayerIndex(layer); if (layerIndex >= 0) { animator.CrossFadeInFixedTime(state, duration, layerIndex); } } } } [RequireComponent(typeof(CharacterBody))] public class AC6WeaponBayController : MonoBehaviour { private class Bay { public WeaponHand hand; public GenericSkill slot; public GenericSkill slot2; public SkillDef def1; public SkillDef def2; public bool swapped; public int stowedStock; public float stowedStopwatch; public int bonus1; public int bonus2; public float lockoutUntil; public bool pending; public bool swapping; public bool HasBay => (Object)(object)def2 != (Object)null; public SkillDef InHand { get { if (!swapped) { return def1; } return def2; } } public SkillDef Stowed { get { if (!HasBay) { return null; } if (!swapped) { return def2; } return def1; } } public int StowedBonus { get { if (!swapped) { return bonus2; } return bonus1; } } public int InHandBonus { get { if (!swapped) { return bonus1; } return bonus2; } } } private readonly Bay right = new Bay { hand = WeaponHand.Right }; private readonly Bay left = new Bay { hand = WeaponHand.Left }; private Bay[] bays; private CharacterBody body; private MechContext ctx; private SkillLocator skillLocator; private InputBankTest inputBank; private AC6BackWeaponController backWeapons; private WeaponBaySync sync; private SkillDef appliedSpecialOverride; private SkillDef appliedUtilityOverride; private bool modeResolved; private SkillDef appliedUtility; private SkillDef appliedRight1; private SkillDef appliedLeft1; private SkillDef appliedRight2; private SkillDef appliedLeft2; private SkillDef appliedSpecial; private int gamePrimaryBonus; private int gameSecondaryBonus; private int gameSpecialBonus; public bool Active { get; private set; } public int Version { get; private set; } public bool BothBays { get { if (Active && right.HasBay) { return left.HasBay; } return false; } } private Bay B(WeaponHand h) { if (h != WeaponHand.Left) { return right; } return left; } public bool HasBay(WeaponHand h) { if (Active) { return B(h).HasBay; } return false; } public SkillDef InHand(WeaponHand h) { if (!Active) { return null; } return B(h).InHand; } public SkillDef Stowed(WeaponHand h) { if (!Active) { return null; } return B(h).Stowed; } public int StowedStock(WeaponHand h) { if (!HasBay(h)) { return 0; } return B(h).stowedStock; } public int StowedMaxStock(WeaponHand h) { if (!HasBay(h)) { return 0; } return StowedMax(B(h)); } public bool CanSwap(WeaponHand h) { Bay bay = B(h); if (Active && bay.HasBay && !bay.pending && !bay.swapping && Time.fixedTime >= bay.lockoutUntil && (Object)(object)body != (Object)null && (Object)(object)body.healthComponent != (Object)null) { return body.healthComponent.alive; } return false; } public bool BlocksHandSkill(GenericSkill slot) { if (!Active || (Object)(object)slot == (Object)null) { return false; } if ((Object)(object)slot == (Object)(object)right.slot) { if (!right.swapping) { return right.pending; } return true; } if ((Object)(object)slot == (Object)(object)left.slot) { if (!left.swapping) { return left.pending; } return true; } return false; } private void Awake() { bays = new Bay[2] { right, left }; ctx = MechContext.Of(((Component)this).gameObject); body = ctx.Body; skillLocator = ctx.Skills; inputBank = ctx.InputBank; backWeapons = ctx.BackWeapons; sync = ((Component)this).GetComponent<WeaponBaySync>(); } private void Start() { if ((Object)(object)skillLocator != (Object)null) { right.slot = skillLocator.primary; left.slot = skillLocator.secondary; right.slot2 = skillLocator.FindSkill("Primary2"); left.slot2 = skillLocator.FindSkill("Secondary2"); } RefreshMode(); } private void OnEnable() { if ((Object)(object)body != (Object)null) { body.onRecalculateStats += OnRecalculateStats; } } private void OnDisable() { if ((Object)(object)body != (Object)null) { body.onRecalculateStats -= OnRecalculateStats; } } private void FixedUpdate() { if (BaseSkillsChanged()) { RefreshMode(); } if (Active && Util.HasEffectiveAuthority(((Component)this).gameObject)) { TickStowed(right); TickStowed(left); PollQueuedPresses(); if (right.pending) { TryStart(right); } if (left.pending) { TryStart(left); } } } private static SkillDef BaseOf(GenericSkill s) { if (!((Object)(object)s != (Object)null)) { return null; } if (!((Object)(object)s.baseSkill != (Object)null)) { return s.skillDef; } return s.baseSkill; } private bool BaseSkillsChanged() { if ((Object)(object)skillLocator == (Object)null) { return false; } if (modeResolved && !((Object)(object)BaseOf(skillLocator.utility) != (Object)(object)appliedUtility) && !((Object)(object)BaseOf(right.slot) != (Object)(object)appliedRight1) && !((Object)(object)BaseOf(left.slot) != (Object)(object)appliedLeft1) && !((Object)(object)BaseOf(right.slot2) != (Object)(object)appliedRight2) && !((Object)(object)BaseOf(left.slot2) != (Object)(object)appliedLeft2)) { return (Object)(object)BaseOf(skillLocator.special) != (Object)(object)appliedSpecial; } return true; } private void RefreshMode() { if ((Object)(object)skillLocator == (Object)null) { return; } modeResolved = true; appliedUtility = BaseOf(skillLocator.utility); appliedRight1 = BaseOf(right.slot); appliedLeft1 = BaseOf(left.slot); appliedRight2 = BaseOf(right.slot2); appliedLeft2 = BaseOf(left.slot2); appliedSpecial = BaseOf(skillLocator.special); Bay[] array = bays; foreach (Bay bay in array) { if (bay.swapped && (Object)(object)bay.slot != (Object)null && (Object)(object)bay.def2 != (Object)null) { bay.slot.UnsetSkillOverride((object)this, bay.def2, (SkillOverridePriority)1); } bay.swapped = false; bay.pending = false; bay.swapping = false; bay.lockoutUntil = 0f; } if ((Object)(object)appliedSpecialOverride != (Object)null && (Object)(object)skillLocator.special != (Object)null) { skillLocator.special.UnsetSkillOverride((object)this, appliedSpecialOverride, (SkillOverridePriority)1); } if ((Object)(object)appliedUtilityOverride != (Object)null && (Object)(object)skillLocator.utility != (Object)null) { skillLocator.utility.UnsetSkillOverride((object)this, appliedUtilityOverride, (SkillOverridePriority)1); } appliedSpecialOverride = (appliedUtilityOverride = null); WeaponBayMode weaponBayMode = WeaponBayRules.Resolve(appliedUtility, appliedRight1, appliedLeft1, appliedRight2, appliedLeft2); Resolve(right, weaponBayMode.right, appliedRight2, weaponBayMode.utility); Resolve(left, weaponBayMode.left, appliedLeft2, weaponBayMode.utility); Active = weaponBayMode.Active; if (Active && (Object)(object)skillLocator.special != (Object)null && (Object)(object)skillLocator.utility != (Object)null) { SkillDef value = null; if (AC6MechBackWeapons.bySkillDef.TryGetValue(appliedSpecial, out var value2)) { AC6MechBackWeapons.singleLauncherSkillDef.TryGetValue(value2, out value); } if (left.HasBay) { appliedSpecialOverride = (SkillDef)(object)AC6MechWeaponBaySkills.leftSwap; if (!right.HasBay) { appliedUtilityOverride = value; } } else { appliedSpecialOverride = value; } if ((Object)(object)appliedSpecialOverride != (Object)null) { skillLocator.special.SetSkillOverride((object)this, appliedSpecialOverride, (SkillOverridePriority)1); } if ((Object)(object)appliedUtilityOverride != (Object)null) { skillLocator.utility.SetSkillOverride((object)this, appliedUtilityOverride, (SkillOverridePriority)1); } } backWeapons.SetAvailableLaunchers(!Active || !left.HasBay, !Active || !right.HasBay); ApplyItemBonuses(); array = bays; foreach (Bay bay2 in array) { if (bay2.HasBay) { bay2.stowedStock = StowedMax(bay2); bay2.stowedStopwatch = 0f; } } Version++; if ((Object)(object)sync != (Object)null && NetworkServer.active) { sync.ServerSet(WeaponHand.Right, swapped: false); sync.ServerSet(WeaponHand.Left, swapped: false); } ReconcileFromSync(); } private void Resolve(Bay b, bool hasBay, SkillDef pick, bool bayUtility) { b.def1 = BaseOf(b.slot); b.def2 = (hasBay ? pick : null); if (bayUtility && !hasBay && (Object)(object)pick != (Object)null && (Object)(object)pick == (Object)(object)b.def1 && WeaponBayRules.IsWeapon(pick)) { Log.Warning($"[AC6] weapon bay: {b.hand} weapon 2 is the same as weapon 1 ({pick.skillName}); bay ignored."); } } public void ReconcileFromSync() { if ((Object)(object)sync == (Object)null || !Active || NetworkServer.active || Util.HasEffectiveAuthority(((Component)this).gameObject)) { return; } Bay[] array = bays; foreach (Bay bay in array) { if (bay.HasBay && !bay.swapping && bay.swapped != sync.Swapped(bay.hand)) { ApplySwap(bay.hand, sync.Swapped(bay.hand)); } } } public void RequestSwap(WeaponHand h) { if (CanSwap(h)) { Bay bay = B(h); bay.pending = true; TryStart(bay); } } private void PollQueuedPresses() { EntityStateMachine bodyMachine = ctx.BodyMachine; if (!((Object)(object)inputBank == (Object)null) && !((Object)(object)bodyMachine == (Object)null) && !bodyMachine.IsInMainState() && !MechSpawnIntro.IsActive(bodyMachine)) { if (right.HasBay && MechInput.SlotJustPressed(inputBank, (SkillSlot)2)) { RequestSwap(WeaponHand.Right); } if (left.HasBay && MechInput.SlotJustPressed(inputBank, (SkillSlot)3)) { RequestSwap(WeaponHand.Left); } } } private void TryStart(Bay b) { //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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (!Active || !b.HasBay) { b.pending = false; return; } EntityStateMachine val = ctx.HandMachine(b.hand); if ((Object)(object)val == (Object)null) { b.pending = false; return; } InterruptPriority val2 = AC6MechPriority.Activation(MechAction.WeaponSwap); if (!IsBusyUninterruptible(b, val, val2) && val.SetInterruptState((EntityState)(object)new SwapWeapon { hand = b.hand, toWeapon2 = !b.swapped }, val2)) { b.pending = false; b.swapping = true; b.lockoutUntil = Time.fixedTime + 1f; } } private bool IsBusyUninterruptible(Bay b, EntityStateMachine handMachine, InterruptPriority swapPriority) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (!handMachine.CanInterruptState(swapPriority)) { return true; } EntityStateMachine bodyMachine = ctx.BodyMachine; if ((Object)(object)b.InHand != (Object)null && AC6MechWeapons.bySkillDef.TryGetValue(b.InHand, out (WeaponDef, WeaponHand) value) && value.Item1.fullBody && (Object)(object)bodyMachine != (Object)null && !bodyMachine.IsInMainState() && !bodyMachine.CanInterruptState(swapPriority)) { return true; } return false; } public void OnSwapStarted(WeaponHand h) { if (Active) { B(h).swapping = true; } } public void OnSwapEnded(WeaponHand h) { B(h).swapping = false; ReconcileFromSync(); } public void ApplySwap(WeaponHand h, bool toWeapon2) { Bay bay = B(h); if (Active && bay.HasBay && !((Object)(object)bay.slot == (Object)null) && bay.swapped != toWeapon2) { bool num = Util.HasEffectiveAuthority(((Component)this).gameObject); bool flag = (Object)(object)bay.slot.skillDef == (Object)(object)bay.InHand; int stock = bay.slot.stock; float rechargeStopwatch = bay.slot.rechargeStopwatch; if (toWeapon2) { bay.slot.SetSkillOverride((object)this, bay.def2, (SkillOverridePriority)1); } else { bay.slot.UnsetSkillOverride((object)this, bay.def2, (SkillOverridePriority)1); } bay.swapped = toWeapon2; if (h == WeaponHand.Left) { bay.slot.SetBonusStockFromBody(bay.InHandBonus); } if (num && flag) { bay.slot.stock = bay.stowedStock; bay.slot.rechargeStopwatch = bay.stowedStopwatch; bay.stowedStock = stock; bay.stowedStopwatch = rechargeStopwatch; } if ((Object)(object)sync != (Object)null && NetworkServer.active) { sync.ServerSet(h, toWeapon2); } Version++; } } public float SwapSeconds(WeaponHand h) { return MechAnim.ClipLength(ctx.Animator, AC6Names.Clip.Swap(h), 4f / 15f); } private int StowedMax(Bay b) { SkillDef stowed = b.Stowed; if ((Object)(object)stowed == (Object)null || (Object)(object)b.slot == (Object)null) { return 0; } return stowed.GetMaxStock(b.slot) + ((!stowed.dontAllowPastMaxStocks) ? b.StowedBonus : 0); } private void TickStowed(Bay b) { SkillDef stowed = b.Stowed; if ((Object)(object)stowed == (Object)null || (Object)(object)b.slot == (Object)null) { return; } int num = StowedMax(b); if (b.stowedStock >= num) { b.stowedStock = num; b.stowedStopwatch = 0f; return; } float rechargeInterval = stowed.GetRechargeInterval(b.slot); if (rechargeInterval <= 0f) { b.stowedStock = num; b.stowedStopwatch = 0f; return; } float num2 = Mathf.Min(rechargeInterval, Mathf.Max(0.5f, rechargeInterval * b.slot.cooldownScale - b.slot.flatCooldownReduction)) + b.slot.temporaryCooldownPenalty; b.stowedStopwatch += Time.fixedDeltaTime; if (b.stowedStopwatch >= num2) { b.stowedStock = Mathf.Min(num, b.stowedStock + stowed.GetRechargeStock(b.slot)); b.stowedStopwatch = 0f; } } private void OnRecalculateStats(CharacterBody _) { if ((Object)(object)skillLocator != (Object)null) { gamePrimaryBonus = BonusOf(skillLocator.primary); gameSecondaryBonus = BonusOf(skillLocator.secondary); gameSpecialBonus = BonusOf(skillLocator.special); } ApplyItemBonuses(); } private static int BonusOf(GenericSkill s) { if (!((Object)(object)s != (Object)null)) { return 0; } return s.bonusStockFromBody; } private void ApplyItemBonuses() { if (Active && !((Object)(object)left.slot == (Object)null)) { right.bonus1 = (right.bonus2 = gamePrimaryBonus); left.bonus1 = gameSecondaryBonus; left.bonus2 = (left.HasBay ? gameSpecialBonus : 0); left.slot.SetBonusStockFromBody(left.InHandBonus); } } } [RequireComponent(typeof(CharacterBody))] public class AutoMissileController : MonoBehaviour { private CharacterBody body; private MechContext ctx; private MechHud hud; private bool auto; private bool triggering; private float lockoutUntil; private float nextCheck; private float hideDotsUntil; private readonly object dotSource = new object(); public bool Equipped { get { if ((Object)(object)body != (Object)null && (Object)(object)body.skillLocator != (Object)null && (Object)(object)body.skillLocator.utility != (Object)null) { return body.skillLocator.utility.skillDef is AutoMissileSkillDef; } return false; } } public bool IsAuto { get { if (auto) { return Equipped; } return false; } } public bool BlocksManual { get { if (IsAuto) { return !triggering; } return false; } } public bool CanToggle => Time.time >= lockoutUntil; private void Awake() { ctx = MechContext.Of(((Component)this).gameObject); body = ctx.Body; hud = ctx.Hud; } private void OnEnable() { auto = true; } public void Toggle() { if (CanToggle) { auto = !auto; lockoutUntil = Time.time + 1f; ClearDots(); } } private void FixedUpdate() { if (!IsAuto || !Util.HasEffectiveAuthority(((Component)this).gameObject)) { ClearDots(); } else if (!(Time.fixedTime < nextCheck)) { nextCheck = Time.fixedTime + 0.1f; SkillLocator skillLocator = body.skillLocator; EntityStateMachine bodyMachine = ctx.BodyMachine; bool bodyFree = (Object)(object)body.healthComponent != (Object)null && body.healthComponent.alive && ((Object)(object)bodyMachine == (Object)null || bodyMachine.IsInMainState()); bool fired = false; int previewLocks = 0; TryAutoFire(skillLocator.primary, bodyFree, ref fired, ref previewLocks); TryAutoFire(skillLocator.secondary, bodyFree, ref fired, ref previewLocks); TryAutoFire(skillLocator.special, bodyFree, ref fired, ref previewLocks); if (fired) { hideDotsUntil = Time.fixedTime + 1f; } if (previewLocks == 0 || Time.fixedTime < hideDotsUntil) { ClearDots(); } else if ((Object)(object)hud != (Object)null) { hud.SetDots(dotSource, MissileTargeting.Lock(body, previewLocks)); } } } private void TryAutoFire(GenericSkill slot, bool bodyFree, ref bool fired, ref int previewLocks) { if ((Object)(object)slot == (Object)null || !MissileWeapons.TryGet(slot.skillDef, out var lockTargets, out var _, out var back)) { return; } if (bodyFree && slot.IsReady() && SlotFree(slot, back)) { triggering = true; try { fired |= slot.ExecuteIfReady(); return; } finally { triggering = false; } } previewLocks = Mathf.Max(previewLocks, lockTargets); } private bool SlotFree(GenericSkill slot, BackWeaponDef back) { if ((Object)(object)slot.stateMachine == (Object)null || !slot.stateMachine.IsInMainState()) { return false; } if (back != null) { if ((Object)(object)ctx.BackWeapons != (Object)null) { return ctx.BackWeapons.IsNextLauncherFree(); } return false; } return true; } private void ClearDots() { if ((Object)(object)hud != (Object)null) { hud.ClearDots(dotSource); } } private void OnDisable() { ClearDots(); } } public class BmlMissileVolley : IBackWeaponVolley { private List<HurtBox> targets; private Transform[] muzzles; public static int LockTargets => MissileTargeting.LockCount(4, 2); public void Begin(CharacterBody body, bool left, List<HurtBox> lockedTargets) { muzzles = GetMuzzles(body, (!left) ? WeaponHand.Right : WeaponHand.Left); targets = MissileTargeting.Refresh(body, lockedTargets, LockTargets); } public void FireShot(CharacterBody body, bool left, int index) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)AC6MechAssets.missileProjectilePrefab == (Object)null)) { MechContext mechContext = MechContext.Of(body); if ((Object)(object)mechContext != (Object)null) { mechContext.Missiles.Record(1); } Transform val = ((muzzles != null && index < muzzles.Length) ? muzzles[index] : null); Vector3 position = (Object.op_Implicit((Object)(object)val) ? val.position : body.corePosition); HurtBox val2 = MissileTargeting.TargetFor(targets, index, 2); ProjectileManager.instance.FireProjectile(new FireProjectileInfo { projectilePrefab = AC6MechAssets.missileProjectilePrefab, position = position, rotation = Quaternion.LookRotation(Vector3.up, Vector3.forward), owner = ((Component)body).gameObject, damage = 1.25f * body.damage, force = 100f, crit = Util.CheckRoll(body.crit, body.master), target = (Object.op_Implicit((Object)(object)val2) ? ((Component)val2).gameObject : null), procChainMask = default(ProcChainMask), damageColorIndex = (DamageColorIndex)0, damageTypeOverride = DamageTypeCombo.GenericSpecial }); } } private static Transform[] GetMuzzles(CharacterBody body, WeaponHand side) { MechContext mechContext = MechContext.Of(body); ChildLocator val = (((Object)(object)mechContext != (Object)null) ? mechContext.ChildLocator : null); List<Transform> list = new List<Transform>(); if ((Object)(object)val != (Object)null) { for (int i = 1; i <= 4; i++) { Transform val2 = val.FindChild(AC6Names.Child.MissileMuzzle(side, i)); if (Object.op_Implicit((Object)(object)val2)) { list.Add(val2); } } } Transform[] result = list.ToArray(); if ((Object)(object)mechContext != (Object)null && (Object)(object)mechContext.Model != (Object)null) { SortInnerToOuter(result, mechContext.Model); } return result; } private static void SortInnerToOuter(Transform[] muzzles, Transform model) { //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) float[] array = new float[muzzles.Length]; for (int i = 0; i < muzzles.Length; i++) { array[i] = Mathf.Abs(model.InverseTransformPoint(muzzles[i].position).x); } for (int j = 1; j < muzzles.Length; j++) { Transform val = muzzles[j]; float num = array[j]; int num2 = j - 1; while (num2 >= 0 && array[num2] > num) { muzzles[num2 + 1] = muzzles[num2]; array[num2 + 1] = array[num2]; num2--; } muzzles[num2 + 1] = val; array[num2 + 1] = num; } } } public class CurtisFireQueue : MonoBehaviour { private float busyUntil; public float Reserve(float animDuration) { float num = Mathf.Max(Time.fixedTime, busyUntil); busyUntil = num + animDuration; return num; } public void ReserveAt(float start, float animDuration) { busyUntil = Mathf.Max(busyUntil, start + animDuration); } public bool HasShotAfter(float time) { return busyUntil > time + 0.05f; } } public interface IBackWeaponVolley { void Begin(CharacterBody body, bool left, List<HurtBox> lockedTargets); void FireShot(CharacterBody body, bool left, int shotIndex); } public interface IMissileTargetReceiver { List<HurtBox> LockedTargets { set; } } [RequireComponent(typeof(CharacterBody))] public class JetpackController : MonoBehaviour { private CharacterBody body; private CharacterMotor motor; private InputBankTest inputBank; private StaminaController stamina; private EntityStateMachine jetStateMachine; private EntityStateMachine bodyMachine; private bool depleted; private bool wasGrounded; private float jumpGrace; public static bool IsJetpacking(EntityStateMachine jet) { if ((Object)(object)jet != (Object)null) { return jet.state is JetpackOn; } return false; } private void Awake() { MechContext mechContext = MechContext.Of(((Component)this).gameObject); body = mechContext.Body; motor = mechContext.Motor; inputBank = mechContext.InputBank; stamina = mechContext.Stamina; jetStateMachine = mechContext.JetMachine; bodyMachine = mechContext.BodyMachine; } private void FixedUpdate() { if (!((Object)(object)body == (Object)null) && !((Object)(object)motor == (Object)null) && !((Object)(object)inputBank == (Object)null) && body.hasEffectiveAuthority) { bool flag = (Object)(object)body.healthComponent != (Object)null && body.healthComponent.alive; SyncJetState(flag && TryThrust()); } } private bool TryThrust() { //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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) if (depleted && (Object)(object)stamina != (Object)null && stamina.Fraction >= 0.1f) { depleted = false; } bool isGrounded = motor.isGrounded; if (wasGrounded && !isGrounded && inputBank.jump.down) { jumpGrace = 0.5f; } if (isGrounded) { jumpGrace = 0f; } else if (jumpGrace > 0f) { jumpGrace -= Time.fixedDeltaTime; } wasGrounded = isGrounded; if (isGrounded || MechSpawnIntro.IsActive(bodyMachine) || !inputBank.jump.down || body.isSprinting || motor.disableAirControlUntilCollision || depleted) { return false; } if (!(jumpGrace > 0f) && (Object)(object)stamina != (Object)null && !stamina.TryDrainThisTick(40f)) { depleted = true; return false; } Vector3 velocity = motor.velocity; float num = velocity.y + 100f * Time.fixedDeltaTime; float num2 = Mathf.Max(20f, velocity.y); velocity.y = Mathf.Min(num, num2); motor.velocity = velocity; return true; } private void SyncJetState(bool thrusting) { if (!((Object)(object)jetStateMachine == (Object)null) && !jetStateMachine.HasPendingState()) { bool flag = jetStateMachine.state is JetpackOn; if (thrusting && !flag) { jetStateMachine.SetNextState((EntityState)(object)new JetpackOn()); } else if (!thrusting && flag) { jetStateMachine.SetNextStateToMain(); } } } private void OnDisable() { if ((Object)(object)body != (Object)null && body.hasEffectiveAuthority && (Object)(object)jetStateMachine != (Object)null && jetStateMachine.state is JetpackOn) { jetStateMachine.SetNextStateToMain(); } } } public static class MechAim { public const float MaxDistance = 1000f; private static RaycastHit[] hits = (RaycastHit[])(object)new RaycastHit[64]; public static Vector3 ReticlePoint(CharacterBody body) { //IL_002b: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_011a: Unknown result type (might be due to invalid IL or missing references) Ray val = (Ray)(Object.op_Implicit((Object)(object)body.inputBank) ? body.inputBank.GetAimRay() : new Ray(body.corePosition, body.transform.forward)); int num = LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask) | LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.entityPrecise)).mask); int num2; for (num2 = Physics.RaycastNonAlloc(val, hits, 1000f, num, (QueryTriggerInteraction)1); num2 == hits.Length; num2 = Physics.RaycastNonAlloc(val, hits, 1000f, num, (QueryTriggerInteraction)1)) { hits = (RaycastHit[])(object)new RaycastHit[hits.Length * 2]; } float num3 = 1000f; for (int i = 0; i < num2; i++) { HurtBox component = ((Component)((RaycastHit)(ref hits[i])).collider).GetComponent<HurtBox>(); if ((!((Object)(object)component != (Object)null) || !((Object)(object)component.healthComponent != (Object)null) || !((Object)(object)component.healthComponent == (Object)(object)body.healthComponent)) && ((RaycastHit)(ref hits[i])).distance < num3) { num3 = ((RaycastHit)(ref hits[i])).distance; } } return ((Ray)(ref val)).GetPoint(num3); } public static Vector3 DirectionFrom(CharacterBody body, Vector3 from) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_002e: 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) Vector3 val = ReticlePoint(body) - from; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = (Object.op_Implicit((Object)(object)body.inputBank) ? body.inputBank.aimDirection : body.transform.forward); } return ((Vector3)(ref val)).normalized; } } [RequireComponent(typeof(CharacterBody))] public class MechContext : MonoBehaviour { private bool resolved; public CharacterBody Body { get; private set; } public CharacterMotor Motor { get; private set; } public InputBankTest InputBank { get; private set; } public SkillLocator Skills { get; private set; } public CharacterDirection Direction { get; private set; } public Transform Model { get; private set; } public Animator Animator { get; private set; } public ChildLocator ChildLocator { get; private set; } public EntityStateMachine BodyMachine { get; private set; } public EntityStateMachine RightMachine { get; private set; } public EntityStateMachine BackMachine { get; private set; } public EntityStateMachine LeftMachine { get; private set; } public EntityStateMachine JetMachine { get; private set; } public StaminaController Stamina { get; private set; } public MechMovementLock MoveLock { get; private set; } public AC6BackWeaponController BackWeapons { get; private set; } public AC6WeaponBayController Bay { get; private set; } public SprintFlightController SprintFlight { get; private set; } public AutoMissileController AutoMissile { get; private set; } public CurtisFireQueue CurtisQueue { get; private set; } public MechHud Hud { get; private set; } public MechCamera Camera { get; private set; } public MissileBudget Missiles { get; } = new MissileBudget(); public static MechContext Of(GameObject bodyObject) { if ((Object)(object)bodyObject == (Object)null) { return null; } MechContext component = bodyObject.GetComponent<MechContext>(); if ((Object)(object)component != (Object)null) { component.Resolve(); } return component; } public static MechContext Of(CharacterBody body) { if (!((Object)(object)body != (Object)null)) { return null; } return Of(((Component)body).gameObject); } public EntityStateMachine HandMachine(WeaponHand hand) { if (hand != WeaponHand.Left) { return RightMachine; } return LeftMachine; } private void Awake() { Resolve(); } private void Resolve() { if (!resolved) { resolved = true; Body = ((Component)this).GetComponent<CharacterBody>(); Motor = ((Component)this).GetComponent<CharacterMotor>(); InputBank = ((Component)this).GetComponent<InputBankTest>(); Skills = ((Component)this).GetComponent<SkillLocator>(); Direction = ((Component)this).GetComponent<CharacterDirection>(); ModelLocator component = ((Component)this).GetComponent<ModelLocator>(); Model = (((Object)(object)component != (Object)null) ? component.modelTransform : null); if ((Object)(object)Model != (Object)null) { Animator = ((Component)Model).GetComponent<Animator>(); ChildLocator = ((Component)Model).GetComponent<ChildLocator>(); } BodyMachine = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Body"); RightMachine = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Weapon"); BackMachine = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Weapon2"); LeftMachine = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Weapon3"); JetMachine = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Jet"); Stamina = ((Component)this).GetComponent<StaminaController>(); MoveLock = ((Component)this).GetComponent<MechMovementLock>(); BackWeapons = ((Component)this).GetComponent<AC6BackWeaponController>(); Bay = ((Component)this).GetComponent<AC6WeaponBayController>(); SprintFlight = ((Component)this).GetComponent<SprintFlightController>(); AutoMissile = ((Component)this).GetComponent<AutoMissileController>(); CurtisQueue = ((Component)this).GetComponent<CurtisFireQueue>(); Hud = ((Component)this).GetComponent<MechHud>(); Camera = ((Component)this).GetComponent<MechCamera>(); } } private void Update() { if ((Object)(object)Hud != (Object)null) { Hud.SetOwner(MechHud.LocalUserFor(Body)); } } } public static class MechInput { public static ButtonState Button(InputBankTest input, SkillSlot slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected I4, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) return (ButtonState)((int)slot switch { 0 => input.skill1, 1 => input.skill2, 2 => input.skill3, 3 => input.skill4, _ => default(ButtonState), }); } public static bool SlotDown(InputBankTest input, SkillSlot slot) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)input != (Object)null) { return Button(input, slot).down; } return false; } public static bool SlotJustPressed(InputBankTest input, SkillSlot slot) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)input != (Object)null) { ButtonState val = Button(input, slot); return ((ButtonState)(ref val)).justPressed; } return false; } public static bool HandDown(InputBankTest input, WeaponHand hand) { return SlotDown(input, (SkillSlot)(hand == WeaponHand.Left)); } } public class MechMovementLock : MonoBehaviour { private const int ownerTimeoutSteps = 3; private readonly Dictionary<object, float> lastTick = new Dictionary<object, float>(); private readonly HashSet<object> gravityHolds = new HashSet<object>(); private readonly HashSet<object> airHolds = new HashSet<object>(); private readonly List<object> stale = new List<object>(); private CharacterMotor motor; private bool gravityHeld; private bool airBlocked; private bool airControlZeroed; private float savedAirControl; private float decelTime; private float startTime; private Vector3 entryVel; private void Awake() { motor = ((Component)this).GetComponent<CharacterMotor>(); } public void Begin(object owner, float decelTime) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) lastTick[owner] = Time.fixedTime; this.decelTime = Mathf.Max(0f, decelTime); entryVel = (((Object)(object)motor != (Object)null) ? motor.velocity : Vector3.zero); startTime = Time.fixedTime; Hold(owner, gravityOff: true); } public void Tick(object owner) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (!lastTick.ContainsKey(owner)) { return; } lastTick[owner] = Time.fixedTime; if (!((Object)(object)motor == (Object)null)) { float num = Time.fixedTime - startTime; if (decelTime > 0f && num < decelTime) { float num2 = 1f - num / decelTime; motor.velocity = new Vector3(entryVel.x * num2, 0f, entryVel.z * num2); } else { motor.velocity = Vector3.zero; } } } public void End(object owner) { lastTick.Remove(owner); Release(owner); } public void Hold(object owner, bool gravityOff) { airHolds.Add(owner); if (gravityOff) { gravityHolds.Add(owner); } Apply(); } public void Release(object owner) { if (airHolds.Remove(owner) | gravityHolds.Remove(owner)) { Apply(); } } private void FixedUpdate() { if (lastTick.Count == 0) { return; } float num = 3f * Time.fixedDeltaTime; stale.Clear(); foreach (KeyValuePair<object, float> item in lastTick) { if (Time.fixedTime - item.Value > num) { stale.Add(item.Key); } } if (stale.Count == 0) { return; } foreach (object item2 in stale) { lastTick.Remove(item2); airHolds.Remove(item2); gravityHolds.Remove(item2); } Log.Warning($"[MechMovementLock] released {stale.Count} hold(s) whose owner stopped ticking ({stale[0]})"); Apply(); } private void OnDisable() { lastTick.Clear(); airHolds.Clear(); gravityHolds.Clear(); Apply(); } private void Apply() { if (!((Object)(object)motor == (Object)null)) { bool flag = gravityHolds.Count > 0; if (flag != gravityHeld) { SetAntiGravity(flag ? 1 : (-1)); gravityHeld = flag; } bool num = airHolds.Count > 0; if (num) { motor.disableAirControlUntilCollision = true; airBlocked = true; } else if (airBlocked) { motor.disableAirControlUntilCollision = false; airBlocked = false; } bool flag2 = num && gravityHeld; if (flag2 && !airControlZeroed) { savedAirControl = motor.airControl; motor.airControl = 0f; airControlZeroed = true; } else if (!flag2 && airControlZeroed) { motor.airControl = savedAirControl; airControlZeroed = false; } } } private void SetAntiGravity(int delta) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0027: Unknown result type (might be due to invalid IL or missing references) CharacterGravityParameters gravityParameters = motor.gravityParameters; gravityParameters.channeledAntiGravityGranterCount = Mathf.Max(0, gravityParameters.channeledAntiGravityGranterCount + delta); motor.gravityParameters = gravityParameters; } } public class MissileBudget { private readonly Queue<float> fireTimes = new Queue<float>(); public bool HasRoom { get { Prune(); return fireTimes.Count < 80; } } public void Record(int missiles) { float fixedTime = Time.fixedTime; for (int i = 0; i < missiles; i++) { fireTimes.Enqueue(fixedTime); } } private void Prune() { float num = Time.fixedTime - 7f; while (fireTimes.Count > 0 && fireTimes.Peek() <= num) { fireTimes.Dequeue(); } } } public static class MissileTargeting { public static List<HurtBox> Acquire(CharacterBody body) { //IL_004a: 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_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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) List<HurtBox> list = new List<HurtBox>(); if ((Object)(object)body == (Object)null || (Object)(object)body.teamComponent == (Object)null) { return list; } Ray val = (Ray)(Object.op_Implicit((Object)(object)body.inputBank) ? body.inputBank.GetAimRay() : new Ray(body.corePosition, body.transform.forward)); BullseyeSearch val2 = new BullseyeSearch { teamMaskFilter = TeamMask.GetEnemyTeams(body.teamComponent.teamIndex), filterByLoS = true, searchOrigin = ((Ray)(ref val)).origin, searchDirection = ((Ray)(ref val)).direction, sortMode = (SortMode)3, maxDistanceFilter = 150f, maxAngleFilter = 40f }; val2.RefreshCandidates(); HashSet<HealthComponent> hashSet = new HashSet<HealthComponent>(); foreach (HurtBox result in val2.GetResults()) { if (IsAlive(result) && hashSet.Add(result.healthComponent)) { list.Add(result); } } return list; } public static List<HurtBox> Lock(CharacterBody body, int lockCount) { List<HurtBox> list = Acquire(body); int num = Mathf.Clamp(lockCount, 1, int.MaxValue); if (list.Count > num) { list.RemoveRange(num, list.Count - num); } return list; } public static int LockCount(int missiles, int perTarget) { return Mathf.Max(1, Mathf.CeilToInt((float)missiles / (float)Mathf.Max(1, perTarget))); } public static HurtBox TargetFor(List<HurtBox> locked, int index, int perTarget) { if (locked == null || locked.Count == 0) { return null; } return locked[index / Mathf.Max(1, perTarget) % locked.Count]; } public static List<HurtBox> Refresh(CharacterBody body, List<HurtBox> locked, int lockCount) { if (locked == null) { return Lock(body, lockCount); } if (locked.Count == 0) { return locked; } List<HurtBox> list = locked.FindAll(IsAlive); if (list.Count <= 0) { return Lock(body, lockCount); } return list; } public static bool IsAlive(HurtBox hb) { if (Object.op_Implicit((Object)(object)hb) && Object.op_Implicit((Object)(object)hb.healthComponent)) { return hb.healthComponent.alive; } return false; } } public class SongbirdVolley : IBackWeaponVolley { public void Begin(CharacterBody body, bool left, List<HurtBox> lockedTargets) { } public void FireShot(CharacterBody body, bool left, int index) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_0085: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)AC6MechAssets.songbirdProjectilePrefab == (Object)null)) { MechContext mechContext = MechContext.Of(body); ChildLocator val = (((Object)(object)mechContext != (Object)null) ? mechContext.ChildLocator : null); Transform val2 = (Object.op_Implicit((Object)(object)val) ? val.FindChild(AC6Names.Child.SongbirdBarrel((!left) ? WeaponHand.Right : WeaponHand.Left, index + 1)) : null); Vector3 val3 = (Object.op_Implicit((Object)(object)val2) ? val2.position : body.corePosition); ProjectileManager.instance.FireProjectile(new FireProjectileInfo { projectilePrefab = AC6MechAssets.songbirdProjectilePrefab, position = val3, rotation = Quaternion.LookRotation(MechAim.DirectionFrom(body, val3)), owner = ((Component)body).gameObject, damage = 4.5f * body.damage, force = 0f, crit = Util.CheckRoll(body.crit, body.master), procChainMask = default(ProcChainMask), damageColorIndex = (DamageColorIndex)0, damageTypeOverride = DamageTypeCombo.GenericSpecial }); } } } public class SprintFlightController : MonoBehaviour { private CharacterBody body; private CharacterMotor motor; private KinematicCharacterMotor kcc; private InputBankTest inputBank; private CharacterDirection direction; private StaminaController stamina; private MechMovementLock moveLock; private MechContext ctx; private static readonly int sSprintStart = Animator.StringToHash("SprintStart"); private static readonly int sSprint = Animator.StringToHash("Sprint"); private static readonly int pIsSprinting = Animator.StringToHash("isSprinting"); private static readonly int pRightSpeed = Animator.StringToHash("rightSpeed"); private bool flying; private bool depleted; private bool interrupted; private bool wasJumpDown; private Vector3 flightDir = Vector3.forward; private float bank; private float bankVel; public void Interrupt() { interrupted = true; if (flying) { ExitFlight(); } } private void Awake() { ctx = MechContext.Of(((Component)this).gameObject); body = ctx.Body; motor = ctx.Motor; kcc = ((Component)this).GetComponent<KinematicCharacterMotor>(); inputBank = ctx.InputBank; direction = ctx.Direction; stamina = ctx.Stamina; moveLock = ctx.MoveLock; } private void FixedUpdate() { if (depleted && (Object)(object)stamina != (Object)null && stamina.Fraction >= 0.1f) { depleted = false; } if (interrupted && ((Object)(object)body == (Object)null || !body.isSprinting)) { interrupted = false; } bool flag = (Object)(object)inputBank != (Object)null && inputBank.jump.down; if (flag && !wasJumpDown && flying) { Interrupt(); } wasJumpDown = flag; bool flag2 = Object.op_Implicit((Object)(object)body) && body.isSprinting && Object.op_Implicit((Object)(object)motor) && Object.op_Implicit((Object)(object)inputBank) && !depleted && !interrupted; if (flag2 && !flying && (Object)(object)stamina != (Object)null && stamina.Fraction < 0.05f) { if (body.hasEffectiveAuthority) { body.isSprinting = false; } flag2 = false; } bool flag3 = flag2 && InAssaultBoostStartup(); if (flag2 && !flag3 && body.hasEffectiveAuthority && (Object)(object)stamina != (Object)null && !stamina.TryDrainThisTick(25f)) { depleted = true; flag2 = false; body.isSprinting = false; } if (flag2) { if (!flying) { EnterFlight(); } UpdateFlight(); } else if (flying) { ExitFlight(); } } private void Update() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_00bd: 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_0132: 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) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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) if (!flying && (Object)(object)stamina != (Object)null && stamina.Fraction < 0.05f) { Animator animator = ctx.Animator; if ((Object)(object)animator != (Object)null) { animator.SetBool(pIsSprinting, false); } } if (!flying) { bank = 0f; bankVel = 0f; return; } Animator animator2 = ctx.Animator; if ((Object)(object)animator2 == (Object)null) { return; } Vector3 normalized; if ((Object)(object)inputBank != (Object)null) { Vector3 aimDirection = inputBank.aimDirection; if (((Vector3)(ref aimDirection)).sqrMagnitude > 0.01f) { aimDirection = inputBank.aimDirection; normalized = ((Vector3)(ref aimDirection)).normalized; goto IL_00c6; } } normalized = flightDir; goto IL_00c6; IL_00c6: Vector3 val = normalized; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(flightDir.x, 0f, flightDir.z); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(val.x, 0f, val.z); float num = 0f; if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f && ((Vector3)(ref val3)).sqrMagnitude > 0.0001f) { ((Vector3)(ref val2)).Normalize(); ((Vector3)(ref val3)).Normalize(); Vector3 val4 = Vector3.Cross(Vector3.up, val2); num = Mathf.Clamp(Vector3.Dot(val3, val4) * 2.5f, -1f, 1f); } bank = Mathf.SmoothDamp(bank, num, ref bankVel, 0.12f); animator2.SetFloat(pRightSpeed, bank); } private bool InAssaultBoostStartup() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_002f: Unknown result type (might be due to invalid IL or missing references) Animator animator = ctx.Animator; if ((Object)(object)animator == (Object)null) { return false; } AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0); if (animator.IsInTransition(0)) { AnimatorStateInfo nextAnimatorStateInfo = animator.GetNextAnimatorStateInfo(0); if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash == sSprintStart && ((AnimatorStateInfo)(ref nextAnimatorStateInfo)).shortNameHash == sSprint) { return false; } if (((AnimatorStateInfo)(ref nextAnimatorStateInfo)).shortNameHash == sSprintStart) { return true; } } return ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash == sSprintStart; } private void EnterFlight() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0053: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) flying = true; Vector3 aimDirection = inputBank.aimDirection; Vector3 val = ((((Vector3)(ref aimDirection)).sqrMagnitude > 0.01f) ? inputBank.aimDirection : (Object.op_Implicit((Object)(object)direction) ? direction.forward : ((Component)this).transform.forward)); flightDir = ((Vector3)(ref val)).normalized; } private void UpdateFlight() { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_0109: 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_00f7: 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) //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_0112: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) if (!body.hasEffectiveAuthority) { return; } Vector3 val; if (InAssaultBoostStartup()) { if (Object.op_Implicit((Object)(object)kcc)) { kcc.ForceUnground(0.1f); } HoldMotor(); motor.velocity = Vector3.zero; val = inputBank.aimDirection; Vector3 normalized; if (!(((Vector3)(ref val)).sqrMagnitude > 0.01f)) { normalized = flightDir; } else { val = inputBank.aimDirection; normalized = ((Vector3)(ref val)).normalized; } Vector3 val2 = normalized; flightDir = val2; if (Object.op_Implicit((Object)(object)direction)) { Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(flightDir.x, 0f, flightDir.z); if (((Vector3)(ref val3)).sqrMagnitude > 0.0001f) { direction.moveVector = ((Vector3)(ref val3)).normalized; } } return; } val = inputBank.aimDirection; Vector3 normalized2; if (!(((Vector3)(ref val)).sqrMagnitude > 0.01f)) { normalized2 = flightDir; } else { val = inputBank.aimDirection; normalized2 = ((Vector3)(ref val)).normalized; } Vector3 val4 = normalized2; float num = MathF.PI / 6f * Time.fixedDeltaTime; val = Vector3.RotateTowards(flightDir, val4, num, 0f); flightDir = ((Vector3)(ref val)).normalized; if (Object.op_Implicit((Object)(object)kcc)) { kcc.ForceUnground(0.1f); } HoldMotor(); float num2 = body.moveSpeed * body.sprintingSpeedMultiplier; motor.velocity = flightDir * num2; if (Object.op_Implicit((Object)(object)direction)) { Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(flightDir.x, 0f, flightDir.z); if (((Vector3)(ref val5)).sqrMagnitude > 0.0001f) { direction.moveVector = ((Vector3)(ref val5)).normalized; } } } private void ExitFlight() { flying = false; if ((Object)(object)moveLock != (Object)null) { moveLock.Release(this); } } private void HoldMotor() { if ((Object)(object)moveLock != (Object)null) { moveLock.Hold(this, gravityOff: true); } } private void OnDisable() { if (flying) { ExitFlight(); } } } [RequireComponent(typeof(CharacterBody))] public class StaminaController : MonoBehaviour { private CharacterMotor _motor; private float _regenSuppressedUntil; public float MaxStamina { get; private set; } public float CurrentStamina { get; private set; } public float Fraction { get { if (!(MaxStamina <= 0f)) { return Mathf.Clamp01(CurrentStamina / MaxStamina); } return 0f; } } public bool IsEmpty => CurrentStamina <= 0f; public bool IsFull => CurrentStamina >= MaxStamina; private void Awake() { _motor = ((Component)this).GetComponent<CharacterMotor>(); MaxStamina = 100f; CurrentStamina = MaxStamina; } private void OnEnable() { RefillAll(); } public bool HasStamina(float amount) { return CurrentStamina >= amount; } public bool TrySpend(float amount) { if (amount <= 0f) { return true; } if (CurrentStamina < amount) { return false; } CurrentStamina -= amount; SuppressRegen(); return true; } public bool TryDrainThisTick(float costPerSecond) { if (costPerSecond <= 0f) { return true; } if (IsEmpty) { return false; } CurrentStamina = Mathf.Max(0f, CurrentStamina - costPerSecond * Time.fixedDeltaTime); SuppressRegen(); return !IsEmpty; } public void RefillAll() { CurrentStamina = MaxStamina; } private void SuppressRegen() { _regenSuppressedUntil = Time.time + 2.5f; } private void FixedUpdate() { if (!IsFull && !(Time.time < _regenSuppressedUntil)) { CurrentStamina = Mathf.Min(MaxStamina, CurrentStamina + 90f * Time.fixedDeltaTime); } } } public class TruenoVolley : IBackWeaponVolley { private bool crit; public void Begin(CharacterBody body, bool left, List<HurtBox> lockedTargets) { crit = Util.CheckRoll(body.crit, body.master); } public void FireShot(CharacterBody body, bool left, int index) { //IL_004f: 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) //IL_0054: 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_006d: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_0141: Unknown result type (might be due to invalid IL or missing references) string text = AC6Names.Child.TruenoMuzzle((!left) ? WeaponHand.Right : WeaponHand.Left, index == 0); MechContext mechContext = MechContext.Of(body); ChildLocator val = (((Object)(object)mechContext != (Object)null) ? mechContext.ChildLocator : null); Transform val2 = (Object.op_Implicit((Object)(object)val) ? val.FindChild(text) : null); Vector3 val3 = (Object.op_Implicit((Object)(object)val2) ? val2.position : body.corePosition); EffectManager.SimpleMuzzleFlash(VanillaRefs.RebarMuzzleFlash, ((Component)body).gameObject, text, true); new BulletAttack { owner = ((Component)body).gameObject, weapon = ((Component)body).gameObject, origin = val3, aimVector = MechAim.DirectionFrom(body, val3), muzzleName = text, damage = 6f * body.damage, procCoefficient = 1f, isCrit = crit, force = 400f, falloffModel = (FalloffModel)0, maxDistance = 1000f, stopperMask = ((LayerIndex)(ref LayerIndex.world)).mask, hitMask = CommonMasks.bullet, radius = 0.5f, smartCollision = true, minSpread = 0f, maxSpread = 0f, damageType = DamageTypeCombo.GenericSpecial, tracerEffectPrefab = VanillaRefs.RebarTracer, hitEffectPrefab = VanillaRefs.RebarImpact }.Fire(); } } internal class WeaponVisualSync : MonoBehaviour { private MechContext ctx; private SkillLocator skillLocator; private AC6WeaponBayController bay; private bool visualsApplied; private SkillDef appliedPrimary; private SkillDef appliedSecondary; private SkillDef appliedSpecial; private int appliedBayVersion = -1; private void Awake() { ctx = MechContext.Of(((Component)this).gameObject); skillLocator = ctx.Skills; bay = ctx.Bay; } private void Start() { TryApplyWeaponVisuals(); } private void FixedUpdate() { if (!visualsApplied || BaseSkillsChanged()) { TryApplyWeaponVisuals(); } } public void TryApplyWeaponVisuals() { if (!((Object)(object)skillLocator == (Object)null) && !((Object)(object)ctx.ChildLocator == (Object)null)) { SkillDef val = Base(skillLocator.primary); SkillDef val2 = Base(skillLocator.secondary); SkillDef back = Base(skillLocator.special); bool flag = (Object)(object)bay != (Object)null && bay.HasBay(WeaponHand.Right); bool flag2 = (Object)(object)bay != (Object)null && bay.HasBay(WeaponHand.Left); WeaponVisuals.Apply(ctx.ChildLocator, flag ? bay.InHand(WeaponHand.Right) : val, flag2 ? bay.InHand(WeaponHand.Left) : val2, flag ? bay.Stowed(WeaponHand.Right) : null, flag2 ? bay.Stowed(WeaponHand.Left) : null, back); appliedPrimary = val; appliedSecondary = val2; appliedSpecial = back; appliedBayVersion = (((Object)(object)bay != (Object)null) ? bay.Version : (-1)); visualsApplied = true; } } private static SkillDef Base(GenericSkill slot) { if (!((Object)(object)slot != (Object)null)) { return null; } if (!((Object)(object)slot.baseSkill != (Object)null)) { return slot.skillDef; } return slot.baseSkill; } private bool BaseSkillsChanged() { if ((Object)(object)skillLocator != (Object)null) { if (!((Object)(object)Base(skillLocator.primary) != (Object)(object)appliedPrimary) && !((Object)(object)Base(skillLocator.secondary) != (Object)(object)appliedSecondary) && !((Object)(object)Base(skillLocator.special) != (Object)(object)appliedSpecial)) { if ((Object)(object)bay != (Object)null) { return bay.Version != appliedBayVersion; } return false; } return true; } return false; } } public abstract class CameraBehaviour { protected readonly MechCamera Camera; protected CameraBehaviour(MechCamera camera) { Camera = camera; } public virtual void Tick(float deltaTime) { } public virtual void Stop() { } } public enum CameraEase { Linear, Smooth, Step }