Decompiled source of PEAK Scout Cannon v1.0.1
tony4twentys-PEAK Scout Cannons.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.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyTitle("PEAK Scout Cannons")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PEAK Scout Cannons")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("b38956bf-5712-4c59-8790-826a989b6b46")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace StrongerAutoScoutCannons { [BepInPlugin("tony4twentys.PEAK_Scout_Cannons", "PEAK Scout Cannons", "1.0.1")] [BepInProcess("PEAK.exe")] public class StrongerAutoScoutCannonsPlugin : BaseUnityPlugin { public const string PluginGuid = "tony4twentys.PEAK_Scout_Cannons"; public const string PluginName = "PEAK Scout Cannons"; public const string PluginVersion = "1.0.1"; internal const float MinBarrelPitch = -75f; internal const float MaxBarrelPitch = -10f; internal const float VanillaFuseSeconds = 3f; internal static ConfigEntry<bool> EnableMultipliers; internal static ConfigEntry<float> LaunchForceMultiplier; internal static ConfigEntry<float> ItemLaunchForceMultiplier; internal static ConfigEntry<float> BackpackLaunchForceMultiplier; internal static ConfigEntry<float> PullForceMultiplier; internal static ConfigEntry<float> PushForceMultiplier; internal static ConfigEntry<bool> EnableAutoFire; internal static ConfigEntry<float> FuseTimeOverride; internal static ConfigEntry<bool> EnableLaunchEverything; internal static ConfigEntry<bool> EnablePickup; internal static ConfigEntry<float> PickupHoldSeconds; internal static ConfigEntry<bool> EnableAim; internal static ConfigEntry<bool> AimWhileInside; internal static ConfigEntry<float> AngleDegreesPerTick; internal static ConfigEntry<bool> EnableSwivel; internal static ConfigEntry<float> YawDegreesPerSecond; internal static ConfigEntry<bool> EnableYawKeys; internal static ConfigEntry<KeyCode> YawLeftKey; internal static ConfigEntry<KeyCode> YawRightKey; internal static ConfigEntry<bool> EnableShiftScrollYaw; internal static ConfigEntry<bool> EnableMoveYawWhileInside; internal static ConfigEntry<bool> EnableHoldToPickup; internal static ConfigEntry<KeyCode> PickupKey; internal static ConfigEntry<bool> EnableTrajectory; internal static ConfigEntry<string> TrajectoryColor; internal static ConfigEntry<float> LandingZoneRadius; internal static ConfigEntry<float> TrajectoryViewRange; internal static ConfigEntry<float> TrajectoryLifetime; private const float RagdollImpulseScale = 1.6f; private static bool loggedAwakeError; private static Color CachedTrajectoryColor = new Color(1f, 0f, 0.03137255f, 1f); private static string CachedTrajectoryColorRaw; internal static StrongerAutoScoutCannonsPlugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; EnableMultipliers = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableMultipliers", true, "Apply launch, item, backpack, and push multipliers. Default is on. Turn off for vanilla 1x on those. Host-controlled in multiplayer. PullForceMultiplier is client-only and ignores this."); LaunchForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "LaunchForceMultiplier", 2f, "Multiplier for launching players. Set to 1 for vanilla launch force. Default is 2."); ItemLaunchForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ItemLaunchForceMultiplier", 2f, "Multiplier for launching items. Set to 1 for vanilla item launch force. Default is 2."); BackpackLaunchForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "BackpackLaunchForceMultiplier", 2f, "Multiplier for launching backpacks. Set to 1 for vanilla backpack launch force. Default is 2."); PullForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PullForceMultiplier", 5f, "Client-only. Multiplier for how hard YOU get pulled into the barrel. Set to 1 for vanilla pull force. Default is 5. Does not change how hard others are pulled."); PushForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PushForceMultiplier", 2f, "Multiplier for push force. Set to 1 for vanilla push force. Default is 2."); EnableAutoFire = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableAutoFire", true, "Client-only. Light the fuse when anything is in the barrel. Default is on. Turn off for vanilla (you light the fuse yourself)."); FuseTimeOverride = ((BaseUnityPlugin)this).Config.Bind<float>("General", "FuseTimeOverride", -1f, "Client-only. Fuse seconds before firing. Set to -1 for vanilla (3 seconds). Minimum override is 1. While someone is in the barrel, the shot uses THAT scout's fuse, not the person who placed the cannon."); EnablePickup = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnablePickup", true, "Hold interact on a placed cannon to pick it back up. Default is on. Host-controlled in multiplayer."); PickupHoldSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PickupHoldSeconds", 1.25f, "Hold time to pick up a placed cannon. Default is 1.25. Host-controlled in multiplayer."); EnableLaunchEverything = ((BaseUnityPlugin)this).Config.Bind<bool>("Launch", "EnableLaunchEverything", true, "Pull and launch mobs, birds, and other nearby physics objects. Default is on. Host-controlled in multiplayer."); EnableAim = ((BaseUnityPlugin)this).Config.Bind<bool>("Aiming", "EnableAim", true, "Scroll to change barrel pitch after placing. Default is on. Host-controlled in multiplayer."); AimWhileInside = ((BaseUnityPlugin)this).Config.Bind<bool>("Aiming", "AimWhileInside", true, "Client-only if the host has aiming on. Aim the cannon while sitting in the barrel. Default is on."); AngleDegreesPerTick = ((BaseUnityPlugin)this).Config.Bind<float>("Aiming", "AngleDegreesPerTick", 4f, "Client-only if the host has aiming on. Pitch degrees changed per scroll tick. Default is 4."); EnableSwivel = ((BaseUnityPlugin)this).Config.Bind<bool>("Aiming", "EnableSwivel", true, "Turn the whole cannon. Default is on. Host-controlled in multiplayer. Your keybinds below are yours."); YawDegreesPerSecond = ((BaseUnityPlugin)this).Config.Bind<float>("Aiming", "YawDegreesPerSecond", 90f, "Client-only if the host has aiming on. How fast the cannon turns while a yaw bind is held. Default is 90."); EnableYawKeys = ((BaseUnityPlugin)this).Config.Bind<bool>("Binds", "EnableYawKeys", true, "Client-only. Turn with YawLeftKey / YawRightKey (default Q / E). Turn off to use only Shift+scroll and/or seated movement."); YawLeftKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Binds", "YawLeftKey", (KeyCode)113, "Client-only. Hold to swivel counter-clockwise. Default is Q."); YawRightKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Binds", "YawRightKey", (KeyCode)101, "Client-only. Hold to swivel clockwise. Default is E."); EnableShiftScrollYaw = ((BaseUnityPlugin)this).Config.Bind<bool>("Binds", "EnableShiftScrollYaw", true, "Client-only. Shift + scroll turns the cannon. Turn off to keep scroll as pitch only."); EnableMoveYawWhileInside = ((BaseUnityPlugin)this).Config.Bind<bool>("Binds", "EnableMoveYawWhileInside", true, "Client-only. Left/right movement keys turn the cannon while you are sitting in it. Turn off to use only yaw keys and/or Shift+scroll. Walk-in leftover strafe is ignored until you release."); EnableHoldToPickup = ((BaseUnityPlugin)this).Config.Bind<bool>("Binds", "EnableHoldToPickup", true, "Client-only. Hold vanilla interact to pick up a placed cannon. Ignored when PickupKey is set, because that key replaces interact for cannon pickup only."); PickupKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Binds", "PickupKey", (KeyCode)0, "Client-only. Replaces vanilla interact for picking up a placed scout cannon. Hold for PickupHoldSeconds. None keeps vanilla interact. Fuse and other items still use vanilla interact."); EnableTrajectory = ((BaseUnityPlugin)this).Config.Bind<bool>("Trajectory", "EnableTrajectory", true, "Draw a landing arc out of the barrel. Default is on. Host must have the mod and this enabled or it stays off. If the host has it on, you can still turn yours off."); TrajectoryColor = ((BaseUnityPlugin)this).Config.Bind<string>("Trajectory", "TrajectoryColor", "#FF0008", "Client-only. Trajectory and landing-zone color. Default is #FF0008. Hex (#FF0008) or R,G,B (0-255)."); LandingZoneRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Trajectory", "LandingZoneRadius", 1.8f, "Client-only. Radius of the glowing landing disc. Default is 1.8."); TrajectoryViewRange = ((BaseUnityPlugin)this).Config.Bind<float>("Trajectory", "TrajectoryViewRange", 10f, "Client-only. Show the trajectory while this close to the cannon. Default is 10."); TrajectoryLifetime = ((BaseUnityPlugin)this).Config.Bind<float>("Trajectory", "TrajectoryLifetime", 20f, "Client-only. Seconds the trajectory stays visible after you walk out of range. Default is 20."); BindLiveSettings(); ((BaseUnityPlugin)this).Config.ConfigReloaded += OnHostGameplaySettingChanged; CannonNet.Ensure(); Harmony.CreateAndPatchAll(typeof(StrongerAutoScoutCannonsPlugin), "tony4twentys.PEAK_Scout_Cannons"); Harmony.CreateAndPatchAll(typeof(CannonLaunch), "tony4twentys.PEAK_Scout_Cannons.launch"); Harmony.CreateAndPatchAll(typeof(CannonPickupInteractPatch), "tony4twentys.PEAK_Scout_Cannons.pickup"); ((BaseUnityPlugin)this).Logger.LogInfo((object)("PEAK Scout Cannons v1.0.1 loaded. Photon " + (byte)157 + " (tony4twentys.PEAK_Scout_Cannons).")); } internal static void LogOnce(ref bool flag, string message, Exception ex) { if (!flag && Log != null) { flag = true; Log.LogError((object)(message + " " + ex)); } } internal static float EffectiveLaunchMult() { if (!CannonNet.HostGameplayAllowed) { return 1f; } if (CannonNet.ShouldUseHostConfig) { return CannonNet.HostEnableMultipliers ? CannonNet.HostLaunchMult : 1f; } return EnableMultipliers.Value ? LaunchForceMultiplier.Value : 1f; } internal static float EffectiveItemMult() { if (!CannonNet.HostGameplayAllowed) { return 1f; } if (CannonNet.ShouldUseHostConfig) { return CannonNet.HostEnableMultipliers ? CannonNet.HostItemMult : 1f; } return EnableMultipliers.Value ? ItemLaunchForceMultiplier.Value : 1f; } internal static float EffectiveBackpackMult() { if (!CannonNet.HostGameplayAllowed) { return 1f; } if (CannonNet.ShouldUseHostConfig) { return CannonNet.HostEnableMultipliers ? CannonNet.HostBackpackMult : 1f; } return EnableMultipliers.Value ? BackpackLaunchForceMultiplier.Value : 1f; } internal static float EffectivePullMult() { return Mathf.Max(0f, PullForceMultiplier.Value); } internal static float EffectivePushMult() { if (!CannonNet.HostGameplayAllowed) { return 1f; } if (CannonNet.ShouldUseHostConfig) { return CannonNet.HostEnableMultipliers ? CannonNet.HostPushMult : 1f; } return EnableMultipliers.Value ? PushForceMultiplier.Value : 1f; } internal static bool EffectiveAutoFire() { return EnableAutoFire.Value; } internal static float EffectiveFuseOverride() { float value = FuseTimeOverride.Value; if (value < 0f) { return -1f; } return Mathf.Max(1f, value); } internal static float ResolvedFuseSeconds() { float num = EffectiveFuseOverride(); return (num < 0f) ? 3f : num; } internal static bool EffectiveLaunchEverything() { if (!CannonNet.HostGameplayAllowed) { return false; } return CannonNet.ShouldUseHostConfig ? CannonNet.HostLaunchEverything : EnableLaunchEverything.Value; } internal static bool EffectivePickup() { if (!CannonNet.HostGameplayAllowed) { return false; } return CannonNet.ShouldUseHostConfig ? CannonNet.HostEnablePickup : EnablePickup.Value; } internal static float EffectivePickupHoldSeconds() { if (CannonNet.ShouldUseHostConfig) { return CannonNet.HostPickupHoldSeconds; } return PickupHoldSeconds.Value; } internal static bool EffectiveAim() { if (!CannonNet.HostGameplayAllowed) { return false; } return CannonNet.ShouldUseHostConfig ? CannonNet.HostEnableAim : EnableAim.Value; } internal static bool EffectiveAimWhileInside() { return EffectiveAim() && AimWhileInside.Value; } internal static float EffectiveAngleDegreesPerTick() { return AngleDegreesPerTick.Value; } internal static bool EffectiveSwivel() { if (!CannonNet.HostGameplayAllowed) { return false; } return CannonNet.ShouldUseHostConfig ? CannonNet.HostEnableSwivel : EnableSwivel.Value; } internal static float EffectiveYawDegreesPerSecond() { return YawDegreesPerSecond.Value; } internal static bool EffectiveTrajectory() { if (!CannonNet.HostGameplayAllowed) { return false; } if (CannonNet.ShouldUseHostConfig && !CannonNet.HostEnableTrajectory) { return false; } return EnableTrajectory.Value; } private static void BindLiveSettings() { EnableMultipliers.SettingChanged += OnHostGameplaySettingChanged; LaunchForceMultiplier.SettingChanged += OnHostGameplaySettingChanged; ItemLaunchForceMultiplier.SettingChanged += OnHostGameplaySettingChanged; BackpackLaunchForceMultiplier.SettingChanged += OnHostGameplaySettingChanged; PullForceMultiplier.SettingChanged += OnLocalOnlySettingChanged; PushForceMultiplier.SettingChanged += OnHostGameplaySettingChanged; EnableLaunchEverything.SettingChanged += OnHostGameplaySettingChanged; EnablePickup.SettingChanged += OnHostGameplaySettingChanged; PickupHoldSeconds.SettingChanged += OnHostGameplaySettingChanged; EnableAim.SettingChanged += OnHostGameplaySettingChanged; AimWhileInside.SettingChanged += OnLocalOnlySettingChanged; AngleDegreesPerTick.SettingChanged += OnLocalOnlySettingChanged; EnableSwivel.SettingChanged += OnHostGameplaySettingChanged; YawDegreesPerSecond.SettingChanged += OnLocalOnlySettingChanged; EnableTrajectory.SettingChanged += OnTrajectorySettingChanged; TrajectoryColor.SettingChanged += OnTrajectorySettingChanged; LandingZoneRadius.SettingChanged += OnTrajectorySettingChanged; TrajectoryViewRange.SettingChanged += OnTrajectorySettingChanged; TrajectoryLifetime.SettingChanged += OnTrajectorySettingChanged; EnableAutoFire.SettingChanged += OnLocalOnlySettingChanged; FuseTimeOverride.SettingChanged += OnFuseSettingChanged; } private static void OnHostGameplaySettingChanged(object sender, EventArgs args) { CannonControl.ReapplyAllForces(); CannonNet.NotifySettingsChanged(); } private static void OnTrajectorySettingChanged(object sender, EventArgs args) { if (sender == EnableTrajectory) { CannonNet.NotifySettingsChanged(); } CannonControl.RefreshTrajectoryDisplay(); } private static void OnLocalOnlySettingChanged(object sender, EventArgs args) { CannonControl.ReapplyAllForces(); } private static void OnFuseSettingChanged(object sender, EventArgs args) { CannonControl.ReapplyAllForces(); CannonNet.BroadcastLocalFuse(); } internal static float EstimateLaunchSpeed(float launchForce) { float num = ((Time.fixedDeltaTime > 0.0001f) ? Time.fixedDeltaTime : 0.02f); return launchForce * num * 1.6f; } internal static Color GetTrajectoryColor() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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) string text = ((TrajectoryColor != null) ? TrajectoryColor.Value : null); if (text == CachedTrajectoryColorRaw) { return CachedTrajectoryColor; } if (TryParseColor(text, out var color)) { CachedTrajectoryColorRaw = text; CachedTrajectoryColor = color; return color; } CachedTrajectoryColorRaw = text; CachedTrajectoryColor = new Color(1f, 0f, 0.03137255f, 1f); return CachedTrajectoryColor; } internal static bool TryParseColor(string raw, out Color color) { //IL_0002: 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_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) color = Color.white; if (string.IsNullOrEmpty(raw)) { return false; } raw = raw.Trim(); if (raw[0] == '#') { return ColorUtility.TryParseHtmlString(raw, ref color); } string[] array = raw.Split(new char[2] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length < 3) { return ColorUtility.TryParseHtmlString("#" + raw, ref color); } if (!float.TryParse(array[0], out var result) || !float.TryParse(array[1], out var result2) || !float.TryParse(array[2], out var result3)) { return false; } float result4 = 255f; if (array.Length > 3) { float.TryParse(array[3], out result4); } if (result > 1f || result2 > 1f || result3 > 1f || result4 > 1f) { result /= 255f; result2 /= 255f; result3 /= 255f; result4 /= 255f; } color = new Color(result, result2, result3, result4); return true; } [HarmonyPatch(typeof(ScoutCannon), "Awake")] [HarmonyPostfix] private static void AttachCannonControl(ScoutCannon __instance) { try { if (!((Object)(object)__instance == (Object)null) && (Object)(object)((Component)__instance).GetComponent<CannonControl>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<CannonControl>(); } } catch (Exception ex) { LogOnce(ref loggedAwakeError, "Scout cannon Awake postfix failed.", ex); } } } public class CannonControl : MonoBehaviour, IInteractible, IInteractibleConstant { private const int MaxDropPoints = 40; private const int ZoneRingPoints = 36; private const float TrajectoryStep = 0.04f; private const float MaxRagdollSimSeconds = 30f; private const string ItemPrefabName = "ScoutCannonItem"; private static readonly WaitForSeconds LandingPulseWait = new WaitForSeconds(0.1f); private static readonly List<CannonControl> All = new List<CannonControl>(); private static Vector3[] FlightScratch = (Vector3[])(object)new Vector3[64]; private static readonly Vector3[] DropScratch = (Vector3[])(object)new Vector3[40]; private static readonly Vector3[] RingScratch = (Vector3[])(object)new Vector3[37]; private static readonly Dictionary<int, Vector2> PendingAim = new Dictionary<int, Vector2>(); private static Material CoreLineMaterial; private static Material GlowLineMaterial; private static Material ZoneMaterial; private static Mesh DiscMesh; private static bool loggedPickupError; private ScoutCannon _cannon; private PhotonView _view; private Transform _tube; private LineRenderer _glowLine; private LineRenderer _coreLine; private LineRenderer _dropLine; private LineRenderer _zoneOuter; private LineRenderer _zoneInner; private Transform _zoneRoot; private MeshRenderer _zoneDisc; private MeshRenderer _zoneHalo; private float _vanillaLaunch; private float _vanillaItem; private float _vanillaBackpack; private float _vanillaPull; private float _vanillaPush; private float _vanillaFuse; private float _vanillaFall; private float _currentAngle = -45f; private float _currentYaw; private float _lastSentAngle = -45f; private float _lastSentYaw; private float _nextSendTime; private bool _aimSendPending; private Quaternion _placedRotation = Quaternion.identity; private float _tubeYaw; private float _tubeRoll; private bool _hovering; private bool _captured; private bool _insideLast; private bool _waitMoveYawNeutral; private bool _trajLive; private Coroutine _hideRoutine; private Coroutine _pulseRoutine; private Vector3 _landPoint; private Vector3 _landNormal = Vector3.up; public bool holdOnFinish => false; private void Awake() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_00a4: Unknown result type (might be due to invalid IL or missing references) _cannon = ((Component)this).GetComponent<ScoutCannon>(); _view = ((Component)this).GetComponent<PhotonView>(); _tube = (((Object)(object)_cannon != (Object)null) ? _cannon.tube : ((Component)this).transform.Find("Cannon")); _placedRotation = ((Component)this).transform.rotation; if ((Object)(object)_tube != (Object)null) { _currentAngle = NormalizePitch(_tube.localEulerAngles.x); _tubeYaw = _tube.localEulerAngles.y; _tubeRoll = _tube.localEulerAngles.z; _lastSentAngle = _currentAngle; } CaptureVanillaAndApply(); ApplyPendingAim(); } private void OnEnable() { if (!All.Contains(this)) { All.Add(this); } ApplyPendingAim(); } private void OnDisable() { All.Remove(this); HideTrajectory(); } internal void CaptureVanillaAndApply() { if (!((Object)(object)_cannon == (Object)null)) { if (!_captured) { _vanillaLaunch = _cannon.launchForce; _vanillaItem = _cannon.itemLaunchForce; _vanillaBackpack = _cannon.backpackLaunchForce; _vanillaPull = _cannon.pullForce; _vanillaPush = _cannon.pushForce; _vanillaFuse = _cannon.fireTime; _vanillaFall = _cannon.fallFor; _captured = true; } ApplyForces(); } } internal void ApplyForces() { if (!((Object)(object)_cannon == (Object)null) && _captured) { _cannon.launchForce = _vanillaLaunch * StrongerAutoScoutCannonsPlugin.EffectiveLaunchMult(); _cannon.itemLaunchForce = _vanillaItem * StrongerAutoScoutCannonsPlugin.EffectiveItemMult(); _cannon.backpackLaunchForce = _vanillaBackpack * StrongerAutoScoutCannonsPlugin.EffectiveBackpackMult(); _cannon.pullForce = _vanillaPull; _cannon.pushForce = _vanillaPush * StrongerAutoScoutCannonsPlugin.EffectivePushMult(); float num = StrongerAutoScoutCannonsPlugin.EffectiveFuseOverride(); _cannon.fireTime = ((num >= 0f) ? num : _vanillaFuse); _cannon.fallFor = _vanillaFall; ApplyOccupantFuse(); } } internal void ApplyOccupantFuse() { if (!((Object)(object)_cannon == (Object)null) && _captured) { Character val = CannonLaunch.FindOccupant(_cannon); if ((Object)(object)val != (Object)null) { _cannon.fireTime = CannonNet.FuseSecondsFor(val); } else if (!_cannon.lit) { float num = StrongerAutoScoutCannonsPlugin.EffectiveFuseOverride(); _cannon.fireTime = ((num >= 0f) ? num : _vanillaFuse); } } } internal static void ReapplyAllForces() { for (int i = 0; i < All.Count; i++) { if ((Object)(object)All[i] != (Object)null) { All[i].ApplyForces(); if (All[i]._trajLive) { All[i].RebuildTrajectory(); } } } } internal static void RefreshTrajectoryDisplay() { bool flag = StrongerAutoScoutCannonsPlugin.EffectiveTrajectory(); for (int i = 0; i < All.Count; i++) { CannonControl cannonControl = All[i]; if (!((Object)(object)cannonControl == (Object)null)) { if (!flag) { cannonControl.HideTrajectory(); } else if (cannonControl._trajLive) { cannonControl.RebuildTrajectory(); } } } } internal static void CollectAim(List<int> viewIds, List<float> pitches, List<float> yaws) { for (int i = 0; i < All.Count; i++) { CannonControl cannonControl = All[i]; if (!((Object)(object)cannonControl == (Object)null) && !((Object)(object)cannonControl._view == (Object)null)) { viewIds.Add(cannonControl._view.ViewID); pitches.Add(cannonControl._currentAngle); yaws.Add(cannonControl._currentYaw); } } } internal static void ApplyRemoteAim(int viewId, float pitch, float yaw) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) CannonControl cannonControl = FindByView(viewId); if ((Object)(object)cannonControl != (Object)null) { cannonControl.SetAim(pitch, yaw, send: false); } else { PendingAim[viewId] = new Vector2(pitch, yaw); } } internal static void HandlePickupGranted(int viewId, int actor) { DestroyPlacedCannon(viewId); int num = ((PhotonNetwork.LocalPlayer != null) ? PhotonNetwork.LocalPlayer.ActorNumber : (-1)); if (actor < 0 || actor == num) { TrySpawnCannonItem(); } } internal static void DestroyPlacedCannon(int viewId) { PendingAim.Remove(viewId); PhotonView photonView = PhotonNetwork.GetPhotonView(viewId); if (!((Object)(object)photonView == (Object)null)) { ((Component)photonView).gameObject.SetActive(false); if (!PhotonNetwork.InRoom) { Object.Destroy((Object)(object)((Component)photonView).gameObject); } else if (photonView.IsMine || PhotonNetwork.IsMasterClient) { PhotonNetwork.Destroy(((Component)photonView).gameObject); } } } private static CannonControl FindByView(int viewId) { for (int i = 0; i < All.Count; i++) { if ((Object)(object)All[i] != (Object)null && (Object)(object)All[i]._view != (Object)null && All[i]._view.ViewID == viewId) { return All[i]; } } return null; } private void ApplyPendingAim() { //IL_004c: 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) if (!((Object)(object)_view == (Object)null) && PendingAim.TryGetValue(_view.ViewID, out var value)) { PendingAim.Remove(_view.ViewID); SetAim(value.x, value.y, send: false); } } internal void HandleAimInput() { if ((Object)(object)_cannon != (Object)null && (Object)(object)_tube == (Object)null) { _tube = _cannon.tube; } if (!StrongerAutoScoutCannonsPlugin.EffectiveAim() || !CanAimNow()) { return; } float num = ReadScroll(); bool flag = (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) && StrongerAutoScoutCannonsPlugin.EnableShiftScrollYaw.Value; float pitch = _currentAngle; float num2 = _currentYaw; bool flag2 = false; float num3 = StrongerAutoScoutCannonsPlugin.EffectiveAngleDegreesPerTick(); if (!flag && Mathf.Abs(num) >= 0.01f) { pitch = Mathf.Clamp(_currentAngle + num * num3, -75f, -10f); flag2 = true; } if (StrongerAutoScoutCannonsPlugin.EffectiveSwivel()) { float num4 = ReadYawAxis(); if (Mathf.Abs(num4) >= 0.05f) { num2 += num4 * StrongerAutoScoutCannonsPlugin.EffectiveYawDegreesPerSecond() * Time.deltaTime; flag2 = true; } if (flag && Mathf.Abs(num) >= 0.01f) { num2 += num * num3; flag2 = true; } } if (flag2) { SetAim(pitch, Mathf.Repeat(num2, 360f), send: true); } } internal bool CanAimNow() { if (_hovering || IsHoveringThisCannon()) { return true; } return StrongerAutoScoutCannonsPlugin.EffectiveAimWhileInside() && LocalPlayerInside(); } private bool IsHoveringThisCannon() { if ((Object)(object)Interaction.instance == (Object)null || Interaction.instance.currentHovered == null) { return false; } IInteractible currentHovered = Interaction.instance.currentHovered; if ((object)currentHovered == this) { return true; } ScoutCannonFuse val = (ScoutCannonFuse)(object)((currentHovered is ScoutCannonFuse) ? currentHovered : null); return (Object)(object)val != (Object)null && (Object)(object)val.scoutCannon == (Object)(object)_cannon; } private bool LocalPlayerInside() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || (Object)(object)_cannon == (Object)null || (Object)(object)_cannon.entry == (Object)null) { return false; } return Vector3.Distance(localCharacter.Center, _cannon.entry.position) <= 1f; } private static bool PickupKeyIsHeld() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) return UsesCustomPickupKey() && Input.GetKey(StrongerAutoScoutCannonsPlugin.PickupKey.Value); } private static float ReadScroll() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) bool flag = PickupKeyIsHeld(); float y = Input.mouseScrollDelta.y; float num = 0f; Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter != (Object)null && (Object)(object)localCharacter.input != (Object)null) { if (!flag) { num = localCharacter.input.scrollInput; if (localCharacter.input.scrollForwardWasPressed) { num += 1f; } if (localCharacter.input.scrollBackwardWasPressed) { num -= 1f; } } else if (Mathf.Abs(y) >= 0.01f) { num = localCharacter.input.scrollInput; if (Mathf.Abs(num) < 0.01f) { num = y; } } } if (Mathf.Abs(num) < 0.01f && !flag) { num = y; } if (!flag) { if (Input.GetKey((KeyCode)280)) { num += 1f; } if (Input.GetKey((KeyCode)281)) { num -= 1f; } } return num; } private float ReadYawAxis() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0043: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_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_00fa: 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) float num = 0f; KeyCode val = (KeyCode)(UsesCustomPickupKey() ? ((int)StrongerAutoScoutCannonsPlugin.PickupKey.Value) : 0); if (StrongerAutoScoutCannonsPlugin.EnableYawKeys.Value) { KeyCode value = StrongerAutoScoutCannonsPlugin.YawLeftKey.Value; KeyCode value2 = StrongerAutoScoutCannonsPlugin.YawRightKey.Value; if (value != val && Input.GetKey(value)) { num -= 1f; } if (value2 != val && Input.GetKey(value2)) { num += 1f; } } bool flag = LocalPlayerInside(); if (flag && !_insideLast) { _waitMoveYawNeutral = true; } _insideLast = flag; if (StrongerAutoScoutCannonsPlugin.EnableMoveYawWhileInside.Value && flag) { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter != (Object)null && (Object)(object)localCharacter.input != (Object)null) { Vector2 movementInput = localCharacter.input.GetMovementInput(); float num2 = ((Mathf.Abs(movementInput.x) >= 0.01f) ? movementInput.x : localCharacter.input.movementInput.x); if (_waitMoveYawNeutral) { if (Mathf.Abs(num2) < 0.2f) { _waitMoveYawNeutral = false; } else { num2 = 0f; } } num += num2; } } return Mathf.Clamp(num, -1f, 1f); } private void SetAim(float pitch, float yaw, bool send) { bool flag = !Mathf.Approximately(_currentAngle, pitch); bool flag2 = Mathf.Abs(Mathf.DeltaAngle(_currentYaw, yaw)) >= 0.01f; _currentAngle = pitch; _currentYaw = yaw; ApplyAimVisuals(); if (_trajLive && (flag || flag2)) { RebuildTrajectory(); } if (send && !((Object)(object)_view == (Object)null)) { _aimSendPending = true; FlushAimSend(); } } internal void FlushAimSend() { if (_aimSendPending && !((Object)(object)_view == (Object)null) && !(Time.unscaledTime < _nextSendTime)) { if (Mathf.Abs(_currentAngle - _lastSentAngle) < 0.25f && Mathf.Abs(Mathf.DeltaAngle(_currentYaw, _lastSentYaw)) < 0.25f) { _aimSendPending = false; return; } _lastSentAngle = _currentAngle; _lastSentYaw = _currentYaw; _nextSendTime = Time.unscaledTime + 0.05f; _aimSendPending = false; CannonNet.SendRotate(_view.ViewID, _currentAngle, _currentYaw); } } private void ApplyAimVisuals() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.rotation = _placedRotation * Quaternion.Euler(0f, _currentYaw, 0f); if ((Object)(object)_tube != (Object)null) { _tube.localRotation = Quaternion.Euler(_currentAngle, _tubeYaw, _tubeRoll); } } internal void EnsureTrajectoryLive() { if (!StrongerAutoScoutCannonsPlugin.EffectiveTrajectory()) { HideTrajectory(); return; } CancelHide(); if (!_trajLive) { RebuildTrajectory(); } } internal void BeginTrajectoryHide() { if (_trajLive && _hideRoutine == null) { float value = StrongerAutoScoutCannonsPlugin.TrajectoryLifetime.Value; if (value <= 0f) { HideTrajectory(); } else { _hideRoutine = ((MonoBehaviour)this).StartCoroutine(HideTrajectoryAfter(value)); } } } internal bool IsInTrajectoryRange() { //IL_0054: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) if (LocalPlayerInside()) { return true; } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { return false; } Vector3 val = (((Object)(object)_cannon != (Object)null && (Object)(object)_cannon.entry != (Object)null) ? _cannon.entry.position : ((Component)this).transform.position); float value = StrongerAutoScoutCannonsPlugin.TrajectoryViewRange.Value; return Vector3.Distance(localCharacter.Center, val) <= Mathf.Max(1f, value); } private void RebuildTrajectory() { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_cannon == (Object)null) { return; } if ((Object)(object)_tube == (Object)null) { _tube = _cannon.tube; } EnsureVisuals(); if (!StrongerAutoScoutCannonsPlugin.EffectiveTrajectory() || (Object)(object)_tube == (Object)null) { HideTrajectory(); return; } SimulateShot(out var flightCount, out var dropCount, out var landPoint, out var landNormal, out var landed); SetLine(_glowLine, FlightScratch, flightCount); SetLine(_coreLine, FlightScratch, flightCount); if (dropCount > 1) { SetLine(_dropLine, DropScratch, dropCount); ((Renderer)_dropLine).enabled = true; } else { ((Renderer)_dropLine).enabled = false; } ((Renderer)_glowLine).enabled = flightCount > 1; ((Renderer)_coreLine).enabled = flightCount > 1; ApplyTrajectoryColors(); _trajLive = true; if (landed) { UpdateLandingZone(landPoint, landNormal); } else { HideLandingZone(); } } private IEnumerator HideTrajectoryAfter(float seconds) { yield return (object)new WaitForSeconds(seconds); _hideRoutine = null; HideTrajectory(); } private void CancelHide() { if (_hideRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_hideRoutine); _hideRoutine = null; } } private void HideTrajectory() { CancelHide(); StopLandingPulse(); _trajLive = false; SetTrajectoryVisible(visible: false); } private void SimulateShot(out int flightCount, out int dropCount, out Vector3 landPoint, out Vector3 landNormal, out bool landed) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0063: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_016f: 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_013a: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) float num = ((_vanillaFall > 0.05f) ? _vanillaFall : 1f); Vector3 gravity = Physics.gravity; Vector3 val = _tube.position + _tube.forward * 0.4f; Vector3 val2 = _tube.forward * StrongerAutoScoutCannonsPlugin.EstimateLaunchSpeed(_cannon.launchForce); flightCount = 0; dropCount = 0; landPoint = val; landNormal = Vector3.up; landed = false; num = Mathf.Min(num, 30f); EnsureFlightCapacity(Mathf.CeilToInt(num / 0.04f) + 2); for (float num2 = 0f; num2 < num; num2 += 0.04f) { if (flightCount >= FlightScratch.Length) { break; } FlightScratch[flightCount] = val; flightCount++; Vector3 val3 = val + val2 * 0.04f + 0.5f * gravity * 0.04f * 0.04f; RaycastHit val4 = HelperFunctions.LineCheck(val, val3, (LayerType)1, 0f, (QueryTriggerInteraction)1); if ((Object)(object)((RaycastHit)(ref val4)).transform != (Object)null) { FlightScratch[flightCount - 1] = ((RaycastHit)(ref val4)).point; landPoint = ((RaycastHit)(ref val4)).point; landNormal = ((RaycastHit)(ref val4)).normal; landed = true; return; } val2 += gravity * 0.04f; val = val3; } if (TryRaycastToGround(val, out var hit)) { DropScratch[0] = val; DropScratch[1] = ((RaycastHit)(ref hit)).point; dropCount = 2; landPoint = ((RaycastHit)(ref hit)).point; landNormal = ((RaycastHit)(ref hit)).normal; landed = true; } else { DropScratch[0] = val; dropCount = 1; landPoint = val; } } private static void EnsureFlightCapacity(int needed) { if (needed > FlightScratch.Length) { int num; for (num = FlightScratch.Length; num < needed; num *= 2) { } FlightScratch = (Vector3[])(object)new Vector3[num]; } } private static bool TryRaycastToGround(Vector3 from, out RaycastHit hit) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_002c: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) Vector3 val = from + Vector3.up * 0.25f; Vector3 val2 = val + Vector3.down * 2500f; hit = HelperFunctions.LineCheck(val, val2, (LayerType)1, 0f, (QueryTriggerInteraction)1); if ((Object)(object)((RaycastHit)(ref hit)).transform != (Object)null) { return true; } hit = HelperFunctions.LineCheck(val, val2, (LayerType)3, 0f, (QueryTriggerInteraction)1); if ((Object)(object)((RaycastHit)(ref hit)).transform != (Object)null) { return true; } hit = HelperFunctions.LineCheck(val, val2, (LayerType)5, 0f, (QueryTriggerInteraction)1); return (Object)(object)((RaycastHit)(ref hit)).transform != (Object)null; } private void UpdateLandingZone(Vector3 point, Vector3 normal) { //IL_0033: 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) //IL_003a: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_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_007b: 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) if (!((Object)(object)_zoneRoot == (Object)null)) { if (((Vector3)(ref normal)).sqrMagnitude < 0.01f) { normal = Vector3.up; } _landPoint = point; _landNormal = normal; ((Component)_zoneRoot).gameObject.SetActive(true); _zoneRoot.position = point + normal * 0.05f; _zoneRoot.rotation = Quaternion.FromToRotation(Vector3.up, normal); ApplyLandingPulse(); if (_pulseRoutine == null) { _pulseRoutine = ((MonoBehaviour)this).StartCoroutine(PulseLandingZone()); } } } private IEnumerator PulseLandingZone() { while (_trajLive && (Object)(object)_zoneRoot != (Object)null && ((Component)_zoneRoot).gameObject.activeSelf) { yield return LandingPulseWait; if (!_trajLive) { break; } ApplyLandingPulse(); } _pulseRoutine = null; } private void ApplyLandingPulse() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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) //IL_0131: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: 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) if (!((Object)(object)_zoneRoot == (Object)null)) { float num = 1f + 0.12f * Mathf.Sin(Time.time * 5f); float num2 = Mathf.Max(0.6f, StrongerAutoScoutCannonsPlugin.LandingZoneRadius.Value) * num; if ((Object)(object)_zoneDisc != (Object)null) { ((Component)_zoneDisc).transform.localScale = new Vector3(num2 * 2f, 1f, num2 * 2f); ((Renderer)_zoneDisc).enabled = true; } if ((Object)(object)_zoneHalo != (Object)null) { float num3 = num2 * (1.55f + 0.2f * Mathf.Sin(Time.time * 3.4f + 1f)); ((Component)_zoneHalo).transform.localScale = new Vector3(num3 * 2f, 1f, num3 * 2f); ((Renderer)_zoneHalo).enabled = true; } Color trajectoryColor = StrongerAutoScoutCannonsPlugin.GetTrajectoryColor(); WriteRing(_zoneInner, _landPoint, _landNormal, num2 * 0.72f, WithAlpha(Color.Lerp(trajectoryColor, Color.white, 0.45f), 1f)); WriteRing(_zoneOuter, _landPoint, _landNormal, num2 * 1.15f, WithAlpha(trajectoryColor, 0.95f)); SetDiscColor(_zoneDisc, WithAlpha(Color.Lerp(trajectoryColor, Color.white, 0.15f), 0.55f)); SetDiscColor(_zoneHalo, WithAlpha(trajectoryColor, 0.22f)); } } private void StopLandingPulse() { if (_pulseRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_pulseRoutine); _pulseRoutine = null; } } private void ApplyTrajectoryColors() { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_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_005e: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_0094: 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) Color trajectoryColor = StrongerAutoScoutCannonsPlugin.GetTrajectoryColor(); Color start = WithAlpha(Color.Lerp(trajectoryColor, new Color(1f, 0.2f, 0f), 0.35f), 0.55f); Color end = WithAlpha(trajectoryColor, 0.25f); Color start2 = WithAlpha(Color.Lerp(trajectoryColor, Color.white, 0.7f), 0.95f); SetLineColor(_glowLine, start, end); SetLineColor(_coreLine, WithAlpha(Color.Lerp(trajectoryColor, Color.white, 0.35f), 1f), trajectoryColor); SetLineColor(_dropLine, start2, WithAlpha(trajectoryColor, 0.7f)); } private static void SetLineColor(LineRenderer line, Color start, Color end) { //IL_0010: 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) if (!((Object)(object)line == (Object)null)) { line.startColor = start; line.endColor = end; } } private static void SetDiscColor(MeshRenderer renderer, Color color) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)renderer == (Object)null)) { Material sharedMaterial = ((Renderer)renderer).sharedMaterial; if ((Object)(object)sharedMaterial != (Object)null && sharedMaterial.HasProperty("_Color")) { sharedMaterial.SetColor("_Color", color); } } } private static Color WithAlpha(Color color, float alpha) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) color.a = alpha; return color; } private static void WriteRing(LineRenderer line, Vector3 center, Vector3 normal, float radius, Color color) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_002a: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0044: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0078: 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_0081: 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_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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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) if (!((Object)(object)line == (Object)null)) { Vector3 val = Vector3.Cross(normal, (Mathf.Abs(Vector3.Dot(normal, Vector3.up)) > 0.9f) ? Vector3.right : Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; val = Vector3.Cross(normal, normalized); Vector3 normalized2 = ((Vector3)(ref val)).normalized; for (int i = 0; i <= 36; i++) { float num = (float)i / 36f * (float)Math.PI * 2f; RingScratch[i] = center + (normalized * Mathf.Cos(num) + normalized2 * Mathf.Sin(num)) * radius + normal * 0.04f; } line.startColor = color; line.endColor = color; line.startWidth = 0.08f; line.endWidth = 0.08f; line.positionCount = 37; line.SetPositions(RingScratch); ((Renderer)line).enabled = true; } } private void SetTrajectoryVisible(bool visible) { if ((Object)(object)_glowLine != (Object)null) { ((Renderer)_glowLine).enabled = visible; } if ((Object)(object)_coreLine != (Object)null) { ((Renderer)_coreLine).enabled = visible; } if ((Object)(object)_dropLine != (Object)null) { ((Renderer)_dropLine).enabled = visible; } if ((Object)(object)_zoneInner != (Object)null) { ((Renderer)_zoneInner).enabled = visible; } if ((Object)(object)_zoneOuter != (Object)null) { ((Renderer)_zoneOuter).enabled = visible; } if ((Object)(object)_zoneDisc != (Object)null) { ((Renderer)_zoneDisc).enabled = visible; } if ((Object)(object)_zoneHalo != (Object)null) { ((Renderer)_zoneHalo).enabled = visible; } if ((Object)(object)_zoneRoot != (Object)null) { ((Component)_zoneRoot).gameObject.SetActive(visible); } } private void HideLandingZone() { StopLandingPulse(); if ((Object)(object)_zoneInner != (Object)null) { ((Renderer)_zoneInner).enabled = false; } if ((Object)(object)_zoneOuter != (Object)null) { ((Renderer)_zoneOuter).enabled = false; } if ((Object)(object)_zoneDisc != (Object)null) { ((Renderer)_zoneDisc).enabled = false; } if ((Object)(object)_zoneHalo != (Object)null) { ((Renderer)_zoneHalo).enabled = false; } if ((Object)(object)_zoneRoot != (Object)null) { ((Component)_zoneRoot).gameObject.SetActive(false); } } private static void SetLine(LineRenderer line, Vector3[] points, int count) { if ((Object)(object)line == (Object)null || count < 2) { if ((Object)(object)line != (Object)null) { ((Renderer)line).enabled = false; } } else { line.positionCount = count; line.SetPositions(points); } } private void EnsureVisuals() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_coreLine != (Object)null)) { GameObject val = new GameObject("ScoutCannonTrajectory"); val.transform.SetParent(((Component)this).transform, false); _glowLine = CreateLine(val.transform, "Glow", GetGlowMaterial(), 0.28f, 0.16f, new Color(1f, 0.35f, 0.02f, 0.55f), new Color(1f, 0.2f, 0f, 0.25f)); _coreLine = CreateLine(val.transform, "Core", GetCoreMaterial(), 0.12f, 0.08f, new Color(1f, 0.95f, 0.45f, 1f), new Color(1f, 0.75f, 0.15f, 1f)); _dropLine = CreateLine(val.transform, "Drop", GetCoreMaterial(), 0.1f, 0.04f, new Color(1f, 1f, 1f, 0.95f), new Color(1f, 0.85f, 0.4f, 0.7f)); _zoneRoot = new GameObject("LandingZone").transform; _zoneRoot.SetParent(val.transform, false); _zoneHalo = CreateDisc(_zoneRoot, "Halo", new Color(1f, 0.4f, 0.05f, 0.22f)); _zoneDisc = CreateDisc(_zoneRoot, "Disc", new Color(1f, 0.75f, 0.15f, 0.55f)); _zoneOuter = CreateLine(_zoneRoot, "OuterRing", GetGlowMaterial(), 0.1f, 0.1f, Color.white, Color.white); _zoneInner = CreateLine(_zoneRoot, "InnerRing", GetCoreMaterial(), 0.08f, 0.08f, Color.white, Color.white); SetTrajectoryVisible(visible: false); } } private static LineRenderer CreateLine(Transform parent, string name, Material material, float startWidth, float endWidth, Color start, Color end) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); LineRenderer val2 = val.AddComponent<LineRenderer>(); ((Renderer)val2).sharedMaterial = material; val2.useWorldSpace = true; val2.positionCount = 2; val2.startWidth = startWidth; val2.endWidth = endWidth; val2.numCapVertices = 4; val2.numCornerVertices = 2; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; ((Renderer)val2).allowOcclusionWhenDynamic = false; val2.textureMode = (LineTextureMode)0; val2.startColor = start; val2.endColor = end; ((Renderer)val2).enabled = false; return val2; } private static MeshRenderer CreateDisc(Transform parent, string name, Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001c: 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) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localRotation = Quaternion.identity; MeshFilter val2 = val.AddComponent<MeshFilter>(); val2.sharedMesh = GetDiscMesh(); MeshRenderer val3 = val.AddComponent<MeshRenderer>(); ((Renderer)val3).sharedMaterial = GetZoneMaterial(color); ((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val3).receiveShadows = false; ((Renderer)val3).enabled = false; return val3; } private static Mesh GetDiscMesh() { //IL_0041: 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_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_0063: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Expected O, but got Unknown if ((Object)(object)DiscMesh != (Object)null) { return DiscMesh; } Vector3[] array = (Vector3[])(object)new Vector3[33]; Vector2[] array2 = (Vector2[])(object)new Vector2[33]; Color[] array3 = (Color[])(object)new Color[33]; int[] array4 = new int[96]; array[0] = Vector3.zero; array2[0] = new Vector2(0.5f, 0.5f); array3[0] = Color.white; for (int i = 0; i < 32; i++) { float num = (float)i / 32f * (float)Math.PI * 2f; array[i + 1] = new Vector3(Mathf.Cos(num) * 0.5f, 0f, Mathf.Sin(num) * 0.5f); array2[i + 1] = new Vector2(array[i + 1].x + 0.5f, array[i + 1].z + 0.5f); array3[i + 1] = new Color(1f, 1f, 1f, 0.15f); array4[i * 3] = 0; array4[i * 3 + 1] = i + 1; array4[i * 3 + 2] = ((i + 2 > 32) ? 1 : (i + 2)); } DiscMesh = new Mesh(); ((Object)DiscMesh).name = "ScoutCannonLandingDisc"; DiscMesh.vertices = array; DiscMesh.uv = array2; DiscMesh.colors = array3; DiscMesh.triangles = array4; DiscMesh.RecalculateNormals(); DiscMesh.RecalculateBounds(); return DiscMesh; } private static Material GetCoreMaterial() { if ((Object)(object)CoreLineMaterial == (Object)null) { CoreLineMaterial = CreateAlwaysOnTopMaterial(additive: true); } return CoreLineMaterial; } private static Material GetGlowMaterial() { if ((Object)(object)GlowLineMaterial == (Object)null) { GlowLineMaterial = CreateAlwaysOnTopMaterial(additive: true); } return GlowLineMaterial; } private static Material GetZoneMaterial(Color color) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZoneMaterial == (Object)null) { ZoneMaterial = CreateAlwaysOnTopMaterial(additive: true); } Material val = new Material(ZoneMaterial); ((Object)val).hideFlags = (HideFlags)61; if (val.HasProperty("_Color")) { val.SetColor("_Color", color); } return val; } private static Material CreateAlwaysOnTopMaterial(bool additive) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Hidden/Internal-Colored"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Sprites/Default"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Unlit/Color"); } Material val2 = new Material(val); ((Object)val2).hideFlags = (HideFlags)61; val2.SetInt("_ZTest", 8); val2.SetInt("_ZWrite", 0); val2.SetInt("_Cull", 0); if (additive) { val2.SetInt("_SrcBlend", 5); val2.SetInt("_DstBlend", 1); } val2.renderQueue = 4000; if (val2.HasProperty("_Color")) { val2.SetColor("_Color", Color.white); } return val2; } private static float NormalizePitch(float eulerX) { if (eulerX > 180f) { eulerX -= 360f; } return eulerX; } private static bool HasEmptyItemSlot(Character character) { if ((Object)(object)character == (Object)null || (Object)(object)character.player == (Object)null || character.player.itemSlots == null) { return false; } ItemSlot[] itemSlots = character.player.itemSlots; for (int i = 0; i < itemSlots.Length; i++) { if (itemSlots[i] != null && itemSlots[i].IsEmpty()) { return true; } } return false; } private static void TrySpawnCannonItem() { Character localCharacter = Character.localCharacter; if (!((Object)(object)localCharacter == (Object)null) && HasEmptyItemSlot(localCharacter) && localCharacter.refs != null && !((Object)(object)localCharacter.refs.items == (Object)null)) { localCharacter.refs.items.SpawnItemInHand("ScoutCannonItem"); } } public bool IsInteractible(Character interactor) { return StrongerAutoScoutCannonsPlugin.EffectivePickup() || StrongerAutoScoutCannonsPlugin.EffectiveAim(); } public bool IsConstantlyInteractable(Character interactor) { if (!StrongerAutoScoutCannonsPlugin.EffectivePickup() || !HasEmptyItemSlot(interactor)) { return false; } if (UsesCustomPickupKey()) { return true; } return StrongerAutoScoutCannonsPlugin.EnableHoldToPickup.Value; } internal static bool UsesCustomPickupKey() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 return StrongerAutoScoutCannonsPlugin.PickupKey != null && (int)StrongerAutoScoutCannonsPlugin.PickupKey.Value > 0; } internal static bool IsCustomPickupTarget(IInteractible interactable) { return UsesCustomPickupKey() && StrongerAutoScoutCannonsPlugin.EffectivePickup() && interactable is CannonControl; } public float GetInteractTime(Character interactor) { return Mathf.Max(0.25f, StrongerAutoScoutCannonsPlugin.EffectivePickupHoldSeconds()); } public void Interact(Character interactor) { } public void Interact_CastFinished(Character interactor) { if (!((Object)(object)interactor == (Object)null) && interactor.IsLocal) { TryPickupLocal(); } } private void TryPickupLocal() { try { if (!StrongerAutoScoutCannonsPlugin.EffectivePickup()) { return; } Character localCharacter = Character.localCharacter; if (HasEmptyItemSlot(localCharacter)) { if ((Object)(object)_view != (Object)null) { CannonNet.RequestPickup(_view.ViewID); return; } TrySpawnCannonItem(); Object.Destroy((Object)(object)((Component)this).gameObject); } } catch (Exception ex) { StrongerAutoScoutCannonsPlugin.LogOnce(ref loggedPickupError, "Scout cannon pickup failed.", ex); } } public void CancelCast(Character interactor) { } public void ReleaseInteract(Character interactor) { } public void HoverEnter() { _hovering = true; if (StrongerAutoScoutCannonsPlugin.EffectiveTrajectory()) { EnsureTrajectoryLive(); } } public void HoverExit() { _hovering = false; } internal static CannonControl FindLocalAimTarget() { CannonControl cannonControl = null; CannonControl cannonControl2 = null; for (int i = 0; i < All.Count; i++) { CannonControl cannonControl3 = All[i]; if (!((Object)(object)cannonControl3 == (Object)null)) { if (cannonControl3.LocalPlayerInside()) { cannonControl = cannonControl3; break; } if ((Object)(object)cannonControl2 == (Object)null && cannonControl3.CanAimNow()) { cannonControl2 = cannonControl3; } } } return ((Object)(object)cannonControl != (Object)null) ? cannonControl : cannonControl2; } internal static void FlushPendingAimSends() { for (int i = 0; i < All.Count; i++) { CannonControl cannonControl = All[i]; if ((Object)(object)cannonControl != (Object)null && cannonControl._aimSendPending) { cannonControl.FlushAimSend(); } } } internal static void TickProximity() { bool flag = StrongerAutoScoutCannonsPlugin.EffectiveTrajectory(); for (int i = 0; i < All.Count; i++) { CannonControl cannonControl = All[i]; if (!((Object)(object)cannonControl == (Object)null)) { cannonControl.ApplyOccupantFuse(); if (!flag) { cannonControl.HideTrajectory(); } else if (cannonControl.IsInTrajectoryRange() || cannonControl.CanAimNow()) { cannonControl.EnsureTrajectoryLive(); } else { cannonControl.BeginTrajectoryHide(); } } } } public Vector3 Center() { //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_000f: Unknown result type (might be due to invalid IL or missing references) return ((Component)this).transform.position; } public Transform GetTransform() { return ((Component)this).transform; } public unsafe string GetInteractionText() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) bool flag = StrongerAutoScoutCannonsPlugin.EffectivePickup(); bool flag2 = StrongerAutoScoutCannonsPlugin.EffectiveAim(); string text = ""; if (flag) { KeyCode value = StrongerAutoScoutCannonsPlugin.PickupKey.Value; if ((int)value > 0) { text = "[" + ((object)(*(KeyCode*)(&value))/*cast due to .constrained prefix*/).ToString() + "] pick up"; } else if (StrongerAutoScoutCannonsPlugin.EnableHoldToPickup.Value) { text = "Hold pick up"; } } if (flag2) { if (text.Length > 0) { text += " / "; } text += "Scroll pitch"; if (StrongerAutoScoutCannonsPlugin.EffectiveSwivel()) { if (StrongerAutoScoutCannonsPlugin.EnableYawKeys.Value) { text = text + " / " + ((object)StrongerAutoScoutCannonsPlugin.YawLeftKey.Value/*cast due to .constrained prefix*/).ToString() + " " + ((object)StrongerAutoScoutCannonsPlugin.YawRightKey.Value/*cast due to .constrained prefix*/).ToString() + " turn"; } if (StrongerAutoScoutCannonsPlugin.EnableShiftScrollYaw.Value) { text += " / Shift+scroll turn"; } if (StrongerAutoScoutCannonsPlugin.EnableMoveYawWhileInside.Value) { text += " / move turn"; } } } return (text.Length > 0) ? text : "Scout Cannon"; } public string GetName() { return "Scout Cannon"; } } internal sealed class CannonDriver : MonoBehaviour { private static readonly WaitForSeconds ProximityWait = new WaitForSeconds(0.2f); private static bool loggedTickError; private void OnEnable() { ((MonoBehaviour)this).StartCoroutine(ProximityLoop()); } private void Update() { try { CannonControl cannonControl = CannonControl.FindLocalAimTarget(); if ((Object)(object)cannonControl != (Object)null) { cannonControl.HandleAimInput(); cannonControl.FlushAimSend(); if (StrongerAutoScoutCannonsPlugin.EffectiveTrajectory()) { cannonControl.EnsureTrajectoryLive(); } } else { CannonControl.FlushPendingAimSends(); } } catch (Exception ex) { StrongerAutoScoutCannonsPlugin.LogOnce(ref loggedTickError, "Scout cannon tick failed.", ex); } } private IEnumerator ProximityLoop() { while (true) { yield return ProximityWait; try { CannonControl.TickProximity(); } catch (Exception ex) { Exception ex2 = ex; StrongerAutoScoutCannonsPlugin.LogOnce(ref loggedTickError, "Scout cannon proximity tick failed.", ex2); } } } } internal static class CannonPickupInteractPatch { private static bool _swapped; private static bool _wasPressed; private static bool _isPressed; private static bool _wasReleased; [HarmonyPatch(typeof(Interaction), "DoInteraction")] [HarmonyPrefix] private static void BeforeDoInteraction(IInteractible interactable) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0081: 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) _swapped = false; if (CannonControl.IsCustomPickupTarget(interactable)) { Character localCharacter = Character.localCharacter; if (!((Object)(object)localCharacter == (Object)null) && !((Object)(object)localCharacter.input == (Object)null)) { KeyCode value = StrongerAutoScoutCannonsPlugin.PickupKey.Value; CharacterInput input = localCharacter.input; _wasPressed = input.interactWasPressed; _isPressed = input.interactIsPressed; _wasReleased = input.interactWasReleased; input.interactWasPressed = Input.GetKeyDown(value); input.interactIsPressed = Input.GetKey(value); input.interactWasReleased = Input.GetKeyUp(value); _swapped = true; } } } [HarmonyPatch(typeof(Interaction), "DoInteraction")] [HarmonyPostfix] private static void AfterDoInteraction() { if (_swapped) { _swapped = false; Character localCharacter = Character.localCharacter; if (!((Object)(object)localCharacter == (Object)null) && !((Object)(object)localCharacter.input == (Object)null)) { CharacterInput input = localCharacter.input; input.interactWasPressed = _wasPressed; input.interactIsPressed = _isPressed; input.interactWasReleased = _wasReleased; } } } [HarmonyPatch(typeof(GUIManager), "RefreshInteractablePrompt")] [HarmonyPostfix] private static void AfterRefreshPrompt(GUIManager __instance) { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.interactPromptPrimary == (Object)null) { return; } bool flag = (Object)(object)Interaction.instance != (Object)null && CannonControl.IsCustomPickupTarget(Interaction.instance.currentHovered); Transform transform = __instance.interactPromptPrimary.transform; InputIcon[] componentsInChildren = __instance.interactPromptPrimary.GetComponentsInChildren<InputIcon>(true); foreach (InputIcon val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).transform == (Object)(object)transform)) { ((Component)val).gameObject.SetActive(!flag); } } } } internal static class CannonLaunch { private const float InsideDistance = 0.75f; private const float ExtraRadius = 1.6f; private const float CondorLaunchSeconds = 8f; private static readonly Dictionary<int, float> LaunchedCondors = new Dictionary<int, float>(); private static readonly Collider[] Overlap = (Collider[])(object)new Collider[64]; private static readonly WaitForSeconds FusePollWait = new WaitForSeconds(0.1f); private static bool loggedFixedError; private static bool loggedFireError; private static bool loggedCondorError; private static bool loggedLightError; internal static bool AnythingInside(ScoutCannon cannon) { if ((Object)(object)cannon == (Object)null || (Object)(object)cannon.entry == (Object)null) { return false; } if (IsInside(cannon.target, cannon.entry) || AnyCharacterInside(Character.AllCharacters, cannon.entry) || AnyCharacterInside(Character.AllBotCharacters, cannon.entry)) { return true; } if (!StrongerAutoScoutCannonsPlugin.EffectiveLaunchEverything()) { return false; } return AnyExtraInside(cannon); } internal static void PullExtras(ScoutCannon cannon) { //IL_0033: 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_0086: 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_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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cannon == (Object)null || (Object)(object)cannon.tube == (Object)null || !StrongerAutoScoutCannonsPlugin.EffectiveLaunchEverything()) { return; } int num = Physics.OverlapSphereNonAlloc(cannon.tube.position, 1.6f, Overlap, LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)0)), (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { if (TryGetExtraBody(Overlap[i], cannon, includeItems: true, out var rig, out var view)) { PrepareForPhysics(rig, view); Vector3 val = cannon.tube.position - rig.worldCenterOfMass; if (((Vector3)(ref val)).sqrMagnitude > 0.0001f) { rig.AddForce(((Vector3)(ref val)).normalized * cannon.pullForce, (ForceMode)5); } } } } internal static void LaunchExtras(ScoutCannon cannon) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cannon == (Object)null || (Object)(object)cannon.tube == (Object)null || !StrongerAutoScoutCannonsPlugin.EffectiveLaunchEverything()) { return; } Vector3 velocity = cannon.tube.forward * Mathf.Max(cannon.itemLaunchForce, cannon.launchForce); int num = Physics.OverlapSphereNonAlloc(cannon.tube.position, 1.6f, Overlap, LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)0)), (QueryTriggerInteraction)1); HashSet<int> hashSet = new HashSet<int>(); for (int i = 0; i < num; i++) { if (!TryGetExtraBody(Overlap[i], cannon, includeItems: false, out var rig, out var view)) { continue; } if ((Object)(object)view != (Object)null) { if (hashSet.Add(view.ViewID)) { ApplyExtraLaunch(view.ViewID, velocity); if (PhotonNetwork.InRoom) { CannonNet.SendLaunchExtra(view.ViewID, velocity); } } } else { ApplyBodyLaunch(rig, view, velocity); } } } internal static void ApplyExtraLaunch(int viewId, Vector3 velocity) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) PhotonView photonView = PhotonNetwork.GetPhotonView(viewId); if (!((Object)(object)photonView == (Object)null)) { Rigidbody componentInChildren = ((Component)photonView).GetComponentInChildren<Rigidbody>(); ApplyBodyLaunch(componentInChildren, photonView, velocity); } } private static void ApplyBodyLaunch(Rigidbody rig, PhotonView view, Vector3 velocity) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rig == (Object)null) { return; } PrepareForPhysics(rig, view); rig.AddForce(velocity, (ForceMode)2); if ((Object)(object)view != (Object)null) { Condor component = ((Component)view).GetComponent<Condor>(); if ((Object)(object)component != (Object)null) { LaunchedCondors[view.ViewID] = Time.time + 8f; } } } private static void PrepareForPhysics(Rigidbody rig, PhotonView view) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Invalid comparison between Unknown and I4 //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 if ((Object)(object)rig != (Object)null) { rig.isKinematic = false; rig.useGravity = true; rig.constraints = (RigidbodyConstraints)0; } if (!((Object)(object)view == (Object)null)) { Mob component = ((Component)view).GetComponent<Mob>(); if ((Object)(object)component != (Object)null && (int)component.mobState != 3 && (int)component.mobState > 0) { component.mobState = (MobState)0; } } } private static bool TryGetExtraBody(Collider collider, ScoutCannon cannon, bool includeItems, out Rigidbody rig, out PhotonView view) { rig = null; view = null; if ((Object)(object)collider == (Object)null) { return false; } Transform transform = ((Component)collider).transform; if (transform.IsChildOf(((Component)cannon).transform) || ((Component)cannon).transform.IsChildOf(transform)) { return false; } if ((Object)(object)((Component)transform).GetComponentInParent<Character>() != (Object)null) { return false; } if ((Object)(object)((Component)transform).GetComponentInParent<ScoutCannon>() != (Object)null) { return false; } view = ((Component)transform).GetComponentInParent<PhotonView>(); Mob componentInParent = ((Component)transform).GetComponentInParent<Mob>(); Condor componentInParent2 = ((Component)transform).GetComponentInParent<Condor>(); Item componentInParent3 = ((Component)transform).GetComponentInParent<Item>(); if ((Object)(object)componentInParent != (Object)null) { rig = (((Object)(object)componentInParent.rig != (Object)null) ? componentInParent.rig : ((Component)componentInParent).GetComponent<Rigidbody>()); if ((Object)(object)view == (Object)null) { view = ((MonoBehaviourPun)componentInParent).photonView; } return (Object)(object)rig != (Object)null; } if ((Object)(object)componentInParent2 != (Object)null) { rig = (((Object)(object)componentInParent2.rb != (Object)null) ? componentInParent2.rb : ((Component)componentInParent2).GetComponent<Rigidbody>()); if ((Object)(object)view == (Object)null) { view = componentInParent2.view; } return (Object)(object)rig != (Object)null; } if ((Object)(object)componentInParent3 != (Object)null) { if (!includeItems || (Object)(object)componentInParent3.holderCharacter != (Object)null) { return false; } rig = componentInParent3.rig; if ((Object)(object)view == (Object)null) { view = ((MonoBehaviourPun)componentInParent3).photonView; } return (Object)(object)rig != (Object)null; } rig = ((Component)transform).GetComponentInParent<Rigidbody>(); return (Object)(object)rig != (Object)null && !rig.isKinematic; } private static bool AnyExtraInside(ScoutCannon cannon) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapSphereNonAlloc(cannon.entry.position, 0.75f, Overlap, LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)0)), (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { if (TryGetExtraBody(Overlap[i], cannon, includeItems: true, out var _, out var _)) { return true; } } return false; } private static void ApplyLocalExtraPull(ScoutCannon cannon) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Invalid comparison between Unknown and I4 //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Invalid comparison between Unknown and I4 //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Invalid comparison between Unknown and I4 //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: 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_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Invalid comparison between Unknown and I4 //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Invalid comparison between Unknown and I4 //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Invalid comparison between Unknown and I4 //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) float num = StrongerAutoScoutCannonsPlugin.EffectivePullMult() - ((!PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient) ? 1f : 0f); if ((Object)(object)cannon == (Object)null || (Object)(object)cannon.entry == (Object)null || (Object)(object)cannon.tube == (Object)null || num <= 0.01f) { return; } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || (Object)(object)cannon.target != (Object)(object)localCharacter || localCharacter.refs == null || (Object)(object)localCharacter.refs.ragdoll == (Object)null || Vector3.Distance(localCharacter.Center, cannon.entry.position) >= 1f || ((Object)(object)localCharacter.data != (Object)null && localCharacter.data.sinceJump < 0.5f)) { return; } float num2 = cannon.pullForce * num; List<Bodypart> partList = localCharacter.refs.ragdoll.partList; if (partList == null) { return; } for (int i = 0; i < partList.Count; i++) { Bodypart val = partList[i]; if ((Object)(object)val == (Object)null || (Object)(object)val.Rig == (Object)null) { continue; } BodypartType partType = val.partType; if ((int)partType == 7 || (int)partType == 10 || (int)partType == 6 || (int)partType == 9 || (int)partType == 5 || (int)partType == 8) { continue; } Vector3 val2 = Vector3.Project(val.transform.position - cannon.tube.position, cannon.tube.forward); Vector3 val3 = Vector3.ClampMagnitude(cannon.tube.position + val2 - val.transform.position, 1f); val.Rig.AddForce(val3 * num2, (ForceMode)5); if (cannon.entry.InverseTransformPoint(val.transform.position).z < 0f) { RaycastHit val4 = HelperFunctions.LineCheck(cannon.entry.position, val.transform.position, (LayerType)3, 0f, (QueryTriggerInteraction)1); if ((Object)(object)((RaycastHit)(ref val4)).transform != (Object)null) { val.Rig.AddForce(cannon.entry.forward * num2, (ForceMode)5); } } } } private static bool CheapNear(ScoutCannon cannon) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cannon == (Object)null || (Object)(object)cannon.entry == (Object)null) { return false; } if (IsInside(cannon.target, cannon.entry) || AnyCharacterInside(Character.AllCharacters, cannon.entry) || AnyCharacterInside(Character.AllBotCharacters, cannon.entry)) { return true; } Transform val = (((Object)(object)cannon.tube != (Object)null) ? cannon.tube : cannon.entry); float r = 2.5600002f; if (NearList(Character.AllCharacters, val.position, r) || NearList(Character.AllBotCharacters, val.position, r)) { return true; } return false; } private static bool NearList(List<Character> characters, Vector3 point, float r2) { //IL_0025: 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_002b: 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) if (characters == null) { return false; } for (int i = 0; i < characters.Count; i++) { Character val = characters[i]; if ((Object)(object)val != (Object)null) { Vector3 val2 = val.Center - point; if (((Vector3)(ref val2)).sqrMagnitude <= r2) { return true; } } } return false; } private static bool AnyCharacterInside(List<Character> characters, Transform entry) { if (characters == null) { return false; } for (int i = 0; i < characters.Count; i++) { if (IsInside(characters[i], entry)) { return true; } } return false; } private static bool IsInside(Character character, Transform entry) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) return (Object)(object)character != (Object)null && (Object)(object)entry != (Object)null && Vector3.Distance(character.Center, entry.position) <= 0.75f; } internal static Character FindOccupant(ScoutCannon cannon) { if ((Object)(object)cannon == (Object)null || (Object)(object)cannon.entry == (Object)null) { return null; } if (IsInside(cannon.target, cannon.entry)) { return cannon.target; } Character val = FirstInside(Character.AllCharacters, cannon.entry); return ((Object)(object)val != (Object)null) ? val : FirstInside(Character.AllBotCharacters, cannon.entry); } private static Character FirstInside(List<Character> characters, Transform entry) { if (characters == null) { return null; } for (int i = 0; i < characters.Count; i++) { if (IsInside(characters[i], entry)) { return characters[i]; } } return null; } [HarmonyPatch(typeof(ScoutCannon), "FixedUpdate")] [HarmonyPostfix] private static void AfterCannonFixedUpdate(ScoutCannon __instance) { try { if (!((Object)(object)__instance == (Object)null)) { if (PhotonNetwork.IsMasterClient && StrongerAutoScoutCannonsPlugin.EffectiveLaunchEverything() && (__instance.lit || CheapNear(__instance))) { PullExtras(__instance); } ApplyLocalExtraPull(__instance); if (StrongerAutoScoutCannonsPlugin.EffectiveAutoFire() && !CannonNet.IsLighting(__instance) && AnythingInside(__instance)) { __instance.Light(); } } } catch (Exception ex) { StrongerAutoScoutCannonsPlugin.LogOnce(ref loggedFixedError, "Scout cannon extra pull/auto-fire failed.", ex); } } [HarmonyPatch(typeof(ScoutCannon), "FireTargets")] [HarmonyPostfix] private static void AfterFireTargets(ScoutCannon __instance) { try { if (!((Object)(object)__instance == (Object)null) && PhotonNetwork.IsMasterClient) { LaunchExtras(__instance); } } catch (Exception ex) { StrongerAutoScoutCannonsPlugin.LogOnce(ref loggedFireError, "Scout cannon extra launch failed.", ex); } } [HarmonyPatch(typeof(Condor), "FixedUpdate")] [HarmonyPrefix] private static bool SkipCondorFlightWhileLaunched(Condor __instance) { try { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.view == (Object)null) { return true; } if (LaunchedCondors.TryGetValue(__instance.view.ViewID, out var value) && Time.time < value) { return false; } } catch (Exception ex) { StrongerAutoScoutCannonsPlugin.LogOnce(ref loggedCondorError, "Condor launch prefix failed.", ex); } return true; } [HarmonyPatch(typeof(ScoutCannon), "Light")] [H