Decompiled source of UltimatePrediction v2.0.0
plugins/UltimatePrediction.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Peak; using Photon.Pun; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("UltimatePrediction")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("2.0.0.0")] [assembly: AssemblyInformationalVersion("2.0.0+bd01b4bb18c65b09300f804982c8ceea02e13330")] [assembly: AssemblyProduct("UltimatePrediction")] [assembly: AssemblyTitle("UltimatePrediction")] [assembly: AssemblyVersion("2.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace UltimatePrediction { internal enum PreviewColor { Cyan, SkyBlue, Blue, Green, Lime, Yellow, Orange, Red, Magenta, Purple, White } internal static class Palette { internal static Color Of(PreviewColor c) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) return (Color)(c switch { PreviewColor.Cyan => new Color(0f, 1f, 1f), PreviewColor.SkyBlue => new Color(0.05f, 0.7f, 1f), PreviewColor.Blue => new Color(0.15f, 0.35f, 1f), PreviewColor.Green => new Color(0.1f, 1f, 0.2f), PreviewColor.Lime => new Color(0.55f, 1f, 0.15f), PreviewColor.Yellow => new Color(1f, 0.9f, 0.05f), PreviewColor.Orange => new Color(1f, 0.45f, 0.05f), PreviewColor.Red => new Color(1f, 0.15f, 0.1f), PreviewColor.Magenta => new Color(1f, 0.2f, 0.85f), PreviewColor.Purple => new Color(0.65f, 0.3f, 1f), PreviewColor.White => new Color(1f, 1f, 1f), _ => Color.white, }); } } internal static class Cfg { internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<float> PreviewTransparency; internal static ConfigEntry<bool> HideHeldItem; internal static ConfigEntry<bool> ShowTrajectory; internal static ConfigEntry<PreviewColor> TrajectoryColor; internal static ConfigEntry<float> TrajectoryWidth; internal static ConfigEntry<bool> ShowLandingMarker; internal static ConfigEntry<PreviewColor> MarkerColor; internal static ConfigEntry<bool> ShowColliderBox; internal static ConfigEntry<PreviewColor> ColliderBoxColor; internal static ConfigEntry<bool> ShowResultGhost; internal static ConfigEntry<bool> ShowRadius; internal static ConfigEntry<PreviewColor> ExplosionColor; internal static ConfigEntry<PreviewColor> HealColor; internal static ConfigEntry<float> ColorBoost; internal static ConfigEntry<float> PulseSpeed; internal static ConfigEntry<bool> RangeScreenOverlay; internal static ConfigEntry<float> RangeScreenOverlayMaxAlpha; internal static ConfigEntry<bool> EnableMagicBean; internal static ConfigEntry<bool> EnableCloudFungus; internal static ConfigEntry<bool> EnableBounceFungus; internal static ConfigEntry<bool> EnableShelfFungus; internal static ConfigEntry<bool> EnableWarpFungus; internal static ConfigEntry<bool> EnableRemedyFungus; internal static ConfigEntry<bool> EnableDynamite; internal static ConfigEntry<bool> DynamiteUseFuseTime; internal static ConfigEntry<bool> EnableRopeCannon; internal static ConfigEntry<bool> EnableChainLauncher; internal static ConfigEntry<bool> EnableLaunchers; internal static ConfigEntry<bool> EnableGenericThrowables; internal static ConfigEntry<float> RopePreviewTransparency; internal static ConfigEntry<PreviewColor> ChainPreviewColor; internal static ConfigEntry<bool> EnableObserver; internal static ConfigEntry<float> ObserverWidth; internal static ConfigEntry<float> ObserverX; internal static ConfigEntry<float> ObserverY; internal static ConfigEntry<float> ObserverDistance; internal static ConfigEntry<float> ObserverElevation; internal static ConfigEntry<float> ObserverFov; internal static ConfigEntry<KeyCode> ObserverDragModifier; internal static ConfigEntry<bool> DebugLog; internal static ConfigEntry<bool> EnablePrecision; internal static ConfigEntry<KeyCode> PrecisionKey; internal static int Revision; internal static void Init(ConfigFile config) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Expected O, but got Unknown //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Expected O, but got Unknown //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Expected O, but got Unknown //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Expected O, but got Unknown //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Expected O, but got Unknown //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Expected O, but got Unknown //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Expected O, but got Unknown Enabled = config.Bind<bool>("1 - General", "Enabled", true, "Master switch. When off, nothing is predicted or drawn."); PreviewTransparency = config.Bind<float>("1 - General", "Preview opacity", 0.72f, new ConfigDescription("Opacity of the trajectory, landing marker, collider box, result ghost, effect radius and vine preview.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), Array.Empty<object>())); HideHeldItem = config.Bind<bool>("1 - General", "Hide held item", false, "Hide the held item model while its preview is active (raycast launchers, the rope cannon and the chain launcher)."); ShowTrajectory = config.Bind<bool>("2 - Visuals", "Show trajectory", true, "Draw the predicted flight path."); TrajectoryColor = config.Bind<PreviewColor>("2 - Visuals", "Trajectory color", PreviewColor.SkyBlue, "Color of the trajectory line."); TrajectoryWidth = config.Bind<float>("2 - Visuals", "Trajectory width", 0.07f, new ConfigDescription("Line width at a reference distance of about 10 meters, in meters. It is clamped so it neither smears the screen up close nor disappears at range.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 0.3f), Array.Empty<object>())); ShowLandingMarker = config.Bind<bool>("2 - Visuals", "Show landing marker", true, "Draw a pulsing ring at the predicted landing point."); MarkerColor = config.Bind<PreviewColor>("2 - Visuals", "Marker color", PreviewColor.Yellow, "Color of the landing ring."); ShowColliderBox = config.Bind<bool>("2 - Visuals", "Show collider box", true, "Draw the wireframe collider box of the object at the landing point."); ColliderBoxColor = config.Bind<PreviewColor>("2 - Visuals", "Collider box color", PreviewColor.Green, "Color of the collider box."); ShowResultGhost = config.Bind<bool>("2 - Visuals", "Show result ghost", true, "Draw a translucent preview of the object that will exist at the landing point."); ShowRadius = config.Bind<bool>("2 - Visuals", "Show effect radius", true, "Draw the explosion or healing radius."); ExplosionColor = config.Bind<PreviewColor>("2 - Visuals", "Explosion color", PreviewColor.Orange, "Color of the explosion radius."); HealColor = config.Bind<PreviewColor>("2 - Visuals", "Healing color", PreviewColor.Green, "Color of the healing radius."); ColorBoost = config.Bind<float>("2 - Visuals", "Color boost", 1.35f, new ConfigDescription("Overall color intensity multiplier (1 = raw).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2.5f), Array.Empty<object>())); PulseSpeed = config.Bind<float>("2 - Visuals", "Pulse speed", 2.5f, new ConfigDescription("Animation speed of the landing ring and radius pulses.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); RangeScreenOverlay = config.Bind<bool>("2 - Visuals", "Range screen overlay", true, "Tint the screen while you stand inside an explosion or healing radius."); RangeScreenOverlayMaxAlpha = config.Bind<float>("2 - Visuals", "Overlay max alpha", 0.4f, new ConfigDescription("Screen tint opacity at the center of the radius.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 0.8f), Array.Empty<object>())); EnableMagicBean = config.Bind<bool>("3 - Items", "Magic bean", true, "Predict the landing point, growth direction, vine length and vine collider."); EnableCloudFungus = config.Bind<bool>("3 - Items", "Cloud fungus", true, "Predict where the cloud fungus breaks and where the cloud forms."); EnableBounceFungus = config.Bind<bool>("3 - Items", "Bounce fungus", true, "Predict where the bounce fungus breaks and where the bounce platform lands."); EnableShelfFungus = config.Bind<bool>("3 - Items", "Shelf fungus", true, "Predict where the shelf fungus breaks and where the shelf platform lands."); EnableWarpFungus = config.Bind<bool>("3 - Items", "Warp fungus", true, "Predict the flight path and the warp destination."); EnableRemedyFungus = config.Bind<bool>("3 - Items", "Remedy fungus", true, "Predict where the remedy fungus breaks and its healing radius."); EnableDynamite = config.Bind<bool>("3 - Items", "Dynamite", true, "Predict the final position and the explosion radius."); DynamiteUseFuseTime = config.Bind<bool>("3 - Items", "Dynamite uses fuse time", false, "Off shows the radius at the resting position. On samples the position at the remaining fuse time, which can show an airborne explosion for very short fuses."); EnableRopeCannon = config.Bind<bool>("3 - Items", "Rope cannon", true, "Hold the precision key to preview the rope anchor, length and sag."); EnableChainLauncher = config.Bind<bool>("3 - Items", "Chain launcher", true, "Hold the use key to preview the chain landing point, length and sag."); EnableLaunchers = config.Bind<bool>("3 - Items", "Raycast launchers", true, "Preview the hit point of raycast launchers such as the anti-gravity cannon and the healing dart."); EnableGenericThrowables = config.Bind<bool>("3 - Items", "Generic throwables", true, "Preview basketballs, backpacks, chess pieces and any other item that either has a special throw effect such as breaking or sticking, or simply settles where it lands."); RopePreviewTransparency = config.Bind<float>("4 - Rope and Chain", "Rope preview opacity", 0.9f, new ConfigDescription("Opacity of the rope preview.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>())); ChainPreviewColor = config.Bind<PreviewColor>("4 - Rope and Chain", "Chain preview color", PreviewColor.White, "Color of the chain preview."); DebugLog = config.Bind<bool>("5 - Advanced", "Debug logging", false, "Log detailed diagnostics to the BepInEx console."); EnablePrecision = config.Bind<bool>("5 - Advanced", "Precision preview", true, "Hold the precision key to run the real physics simulation in the scene. It matches the game exactly but takes one to two seconds of real time."); PrecisionKey = config.Bind<KeyCode>("5 - Advanced", "Precision preview key", (KeyCode)324, "Hold this key to start the precision preview. Default is the right mouse button."); EnableObserver = config.Bind<bool>("6 - Landing Observer", "Enable observer", true, "Show a picture-in-picture window focused on the landing point for throwables. Raycast launchers, the rope cannon and the chain launcher are excluded."); ObserverWidth = config.Bind<float>("6 - Landing Observer", "Observer width (px)", 360f, new ConfigDescription("Window width in pixels at 1920x1080. It scales with screen height so the window keeps the same relative size on any resolution. Height follows 16:9.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(120f, 960f), Array.Empty<object>())); ObserverX = config.Bind<float>("6 - Landing Observer", "Observer X (px)", -1f, "Window left edge in pixels. A negative value pins the window to the bottom-right corner, using the 1920x1080 default margin scaled by screen height."); ObserverY = config.Bind<float>("6 - Landing Observer", "Observer Y (px)", -1f, "Window top edge in pixels. A negative value pins the window to the bottom-right corner, using the 1920x1080 default margin scaled by screen height."); ObserverDistance = config.Bind<float>("6 - Landing Observer", "Observer camera distance (m)", 4f, new ConfigDescription("Fixed distance from the camera to the landing point.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>())); ObserverElevation = config.Bind<float>("6 - Landing Observer", "Observer elevation (deg)", 25f, new ConfigDescription("Camera elevation above the landing surface normal.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-30f, 89f), Array.Empty<object>())); ObserverFov = config.Bind<float>("6 - Landing Observer", "Observer FOV (deg)", 60f, new ConfigDescription("Camera field of view. Higher is wider.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 110f), Array.Empty<object>())); ObserverDragModifier = config.Bind<KeyCode>("6 - Landing Observer", "Observer adjust modifier key", (KeyCode)307, "Hold this key to move the window with the arrow keys and resize it with plus and minus. A placeholder window is shown even without a prediction, so the position can be set any time. With the cursor unlocked (menus, item wheel) the same modifier plus the left mouse button can also drag the window."); } } internal sealed class ConfigWatcher : MonoBehaviour { private static bool _suppressArmed; private static DateTime _suppressStamp = DateTime.MinValue; private DateTime _lastWrite = DateTime.MinValue; private float _timer; internal static bool SuppressNextReload { get { return _suppressArmed; } set { _suppressArmed = value; if (value) { _suppressStamp = DateTime.MinValue; } } } private void Start() { DateTime dateTime = ReadTimestamp(); if (dateTime != DateTime.MinValue) { _lastWrite = dateTime; } } private void Update() { if (_suppressArmed && _suppressStamp == DateTime.MinValue) { DateTime dateTime = ReadTimestamp(); if (dateTime != DateTime.MinValue && dateTime != _lastWrite) { _suppressStamp = dateTime; } } _timer += Time.unscaledDeltaTime; if (_timer < 1f) { return; } _timer = 0f; UltimatePredictionPlugin instance = UltimatePredictionPlugin.Instance; if ((Object)(object)instance == (Object)null || ((BaseUnityPlugin)instance).Config == null) { return; } string configFilePath = ((BaseUnityPlugin)instance).Config.ConfigFilePath; if (string.IsNullOrEmpty(configFilePath) || !File.Exists(configFilePath)) { return; } try { DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(configFilePath); if (lastWriteTimeUtc == _lastWrite) { _suppressArmed = false; _suppressStamp = DateTime.MinValue; return; } if (_suppressArmed) { bool num = lastWriteTimeUtc == _suppressStamp; _suppressArmed = false; _suppressStamp = DateTime.MinValue; _lastWrite = lastWriteTimeUtc; if (num) { return; } } _lastWrite = lastWriteTimeUtc; ((BaseUnityPlugin)instance).Config.Reload(); Cfg.Revision++; DateTime dateTime2 = ReadTimestamp(); if (dateTime2 != DateTime.MinValue) { _lastWrite = dateTime2; } ManualLogSource log = UltimatePredictionPlugin.Log; if (log != null) { log.LogInfo((object)"[UP] 检测到配置文件变化,已热重载。"); } } catch (Exception ex) { ManualLogSource log2 = UltimatePredictionPlugin.Log; if (log2 != null) { log2.LogWarning((object)("[UP] 配置热重载失败:" + ex.Message)); } } } private static DateTime ReadTimestamp() { try { UltimatePredictionPlugin instance = UltimatePredictionPlugin.Instance; if ((Object)(object)instance != (Object)null && ((BaseUnityPlugin)instance).Config != null && File.Exists(((BaseUnityPlugin)instance).Config.ConfigFilePath)) { return File.GetLastWriteTimeUtc(((BaseUnityPlugin)instance).Config.ConfigFilePath); } } catch (Exception) { } return DateTime.MinValue; } } internal static class GameUtil { internal static bool IsTerrainLayer(int layer) { return (((LayerMask)(ref HelperFunctions.terrainMapMask)).value & (1 << layer)) != 0; } internal static int CollisionMaskForLayer(int layer) { int num = 0; for (int i = 0; i < 32; i++) { if (!Physics.GetIgnoreLayerCollision(layer, i)) { num |= 1 << i; } } return num; } internal static int WorldMaskForLayer(int layer) { int mask = LayerMask.GetMask(new string[3] { "Terrain", "Map", "Default" }); int num = 0; for (int i = 0; i < 32; i++) { if ((mask & (1 << i)) != 0 && !Physics.GetIgnoreLayerCollision(layer, i)) { num |= 1 << i; } } return num; } internal static Vector3 LookDirection(Vector2 lookValues) { //IL_0000: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_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_0038: 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) Vector3 val = Quaternion.Euler(0f - lookValues.y, lookValues.x, 0f) * Vector3.forward; if (((Vector3)(ref val)).sqrMagnitude < 1E-06f) { return Vector3.forward; } return ((Vector3)(ref val)).normalized; } internal static Vector3 ComputeThrowVelocity(Item item, Vector3 lookDir, float chargeForce) { //IL_0000: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0033: 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_003f: 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) Vector3 val = lookDir * chargeForce * 0.5f * item.throwForceMultiplier; if ((Object)(object)item.rig != (Object)null && !(item is Backpack)) { val += item.rig.linearVelocity; } return val; } internal static Vector3 ThrowOrigin(Item item) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Vector3 val = item.transform.position; if (item is Backpack) { val += 0.25f * Vector3.up; } return val; } internal static Vector3 ComputeThrowAngularVelocity(Item item, Vector3 lookDir, float chargeForce) { //IL_0001: 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_0023: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (((Enum)item.itemTags).HasFlag((Enum)(object)(ItemTags)1024)) { return Vector3.zero; } return Vector3.Cross(lookDir, Vector3.up) * chargeForce * 0.5f; } internal static float GetItemRadius(Item item) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_0159: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) float num = 0f; if ((Object)(object)item != (Object)null && item.colliders != null) { for (int i = 0; i < item.colliders.Length; i++) { Collider val = item.colliders[i]; if ((Object)(object)val == (Object)null || val.isTrigger || !val.enabled) { continue; } Vector3 lossyScale = ((Component)val).transform.lossyScale; SphereCollider val2 = (SphereCollider)(object)((val is SphereCollider) ? val : null); float num2; if (val2 != null) { num2 = val2.radius * Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Max(Mathf.Abs(lossyScale.y), Mathf.Abs(lossyScale.z))); } else { CapsuleCollider val3 = (CapsuleCollider)(object)((val is CapsuleCollider) ? val : null); if (val3 != null) { float num3 = ((val3.direction == 0) ? Mathf.Max(Mathf.Abs(lossyScale.y), Mathf.Abs(lossyScale.z)) : ((val3.direction == 2) ? Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.y)) : Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.z)))); num2 = val3.radius * num3; } else { BoxCollider val4 = (BoxCollider)(object)((val is BoxCollider) ? val : null); if (val4 != null) { Vector3 val5 = Vector3.Scale(val4.size * 0.5f, lossyScale); num2 = (Mathf.Abs(val5.x) + Mathf.Abs(val5.y) + Mathf.Abs(val5.z)) / 3f; } else { Bounds bounds = val.bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; num2 = (Mathf.Abs(extents.x) + Mathf.Abs(extents.y) + Mathf.Abs(extents.z)) / 3f; } } } if (num2 > num) { num = num2; } } } if (num < 0.02f) { num = 0.12f; } return Mathf.Clamp(num, 0.05f, 0.6f); } internal static float GetHitBounciness(Collider col) { if ((Object)(object)col == (Object)null) { return 0f; } PhysicsMaterial val = (((Object)(object)col.attachedRigidbody != (Object)null) ? col.material : col.sharedMaterial); if ((Object)(object)val != (Object)null) { return Mathf.Clamp01(val.bounciness); } return 0f; } internal static float GetHitFriction(Collider col) { if ((Object)(object)col == (Object)null) { return 0.6f; } PhysicsMaterial val = (((Object)(object)col.attachedRigidbody != (Object)null) ? col.material : col.sharedMaterial); if ((Object)(object)val != (Object)null) { return Mathf.Max(0f, val.dynamicFriction); } return 0.6f; } internal static float GetHitStaticFriction(Collider col) { if ((Object)(object)col == (Object)null) { return 0.6f; } PhysicsMaterial val = (((Object)(object)col.attachedRigidbody != (Object)null) ? col.material : col.sharedMaterial); if ((Object)(object)val != (Object)null) { return Mathf.Max(0f, val.staticFriction); } return 0.6f; } internal static PhysicsMaterialCombine GetHitBounceCombine(Collider col) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)col == (Object)null) { return (PhysicsMaterialCombine)0; } PhysicsMaterial val = (((Object)(object)col.attachedRigidbody != (Object)null) ? col.material : col.sharedMaterial); if ((Object)(object)val != (Object)null) { return val.bounceCombine; } return (PhysicsMaterialCombine)0; } internal static PhysicsMaterialCombine GetHitFrictionCombine(Collider col) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)col == (Object)null) { return (PhysicsMaterialCombine)0; } PhysicsMaterial val = (((Object)(object)col.attachedRigidbody != (Object)null) ? col.material : col.sharedMaterial); if ((Object)(object)val != (Object)null) { return val.frictionCombine; } return (PhysicsMaterialCombine)0; } internal static string PrefabNameOf(Item item) { if ((Object)(object)item == (Object)null) { return null; } string text = ((Object)((Component)item).gameObject).name; if (text.EndsWith("(Clone)")) { text = text.Substring(0, text.Length - "(Clone)".Length); } return text; } internal static GameObject LoadItemPrefab(string name) { if (string.IsNullOrEmpty(name)) { return null; } GameObject val = Resources.Load<GameObject>("0_Items/" + name); if ((Object)(object)val == (Object)null) { val = Resources.Load<GameObject>(name); } return val; } internal static void SetLayerRecursively(GameObject go, int layer) { if (!((Object)(object)go == (Object)null)) { go.layer = layer; for (int i = 0; i < go.transform.childCount; i++) { SetLayerRecursively(((Component)go.transform.GetChild(i)).gameObject, layer); } } } internal static Quaternion FromUpAndRightPrioUp(Vector3 wantedRight, Vector3 wantedUp) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0063: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_003a: 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_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) Vector3 normalized = ((Vector3)(ref wantedUp)).normalized; Vector3 val = Vector3.ProjectOnPlane(wantedRight, normalized); Vector3 val2 = Vector3.Cross(((Vector3)(ref val)).normalized, normalized); if (((Vector3)(ref val2)).sqrMagnitude < 1E-08f) { val2 = Vector3.Cross((((Vector3)(ref wantedRight)).sqrMagnitude > 1E-08f) ? ((Vector3)(ref wantedRight)).normalized : Vector3.forward, normalized); } if (((Vector3)(ref val2)).sqrMagnitude < 1E-08f) { return Quaternion.identity; } return Quaternion.LookRotation(val2, normalized); } } internal enum SimMode { Full, FirstAnyImpact, FirstTerrainImpact, FirstWarpImpact, FirstVelocityBreak } internal struct StopRule { public SimMode Mode; public float MinSpeed; public float MinTime; public float MaxTime; public float BreakVy; public bool HasBreakVy; } internal struct SimImpact { public Vector3 Point; public Vector3 Normal; public int Layer; public float Speed; public float Time; } internal enum CastShape { Sphere, Capsule, Box, Hull } internal sealed class ShapeProbe { internal Collider Source; internal CastShape Shape; internal Vector3 LocalCenter; internal Quaternion LocalRotation = Quaternion.identity; internal Vector3 LocalPosePosition; internal Quaternion LocalPoseRotation = Quaternion.identity; internal float Radius; internal float CapRadius; internal float CapHeight; internal int CapDirection; internal Vector3 BoxHalf; internal Vector3[] HullPoints; internal Vector3 LastSupportLocal; internal float Bounciness; internal float Friction; internal float StaticFriction; internal PhysicsMaterialCombine BounceCombine; internal PhysicsMaterialCombine FrictionCombine; internal float ContactOffset = 0.01f; internal float BoundingRadius() { switch (Shape) { case CastShape.Sphere: return Radius; case CastShape.Capsule: return CapHeight * 0.5f + CapRadius; case CastShape.Hull: { float num = 0f; for (int i = 0; i < HullPoints.Length; i++) { num = Mathf.Max(num, ((Vector3)(ref HullPoints[i])).magnitude); } return num; } default: return ((Vector3)(ref BoxHalf)).magnitude; } } internal Vector3 WorldCenter(Vector3 rootPos, Quaternion rootRot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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) return rootPos + rootRot * LocalCenter; } internal Quaternion WorldRotation(Quaternion rootRot) { //IL_0000: 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_0007: Unknown result type (might be due to invalid IL or missing references) return rootRot * LocalRotation; } internal float Support(Vector3 n, Quaternion worldRot) { //IL_0029: 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_003a: 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_0061: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) switch (Shape) { case CastShape.Sphere: return Radius; case CastShape.Capsule: { Vector3 val4 = worldRot * DirectionVector(CapDirection); float num3 = Mathf.Max(0f, CapHeight * 0.5f - CapRadius); return CapRadius + num3 * Mathf.Abs(Vector3.Dot(val4, n)); } case CastShape.Hull: { float num = 0f; for (int i = 0; i < HullPoints.Length; i++) { float num2 = Vector3.Dot(worldRot * HullPoints[i], n); if (num2 > num) { num = num2; } } return num; } default: { Vector3 val = worldRot * Vector3.right; Vector3 val2 = worldRot * Vector3.up; Vector3 val3 = worldRot * Vector3.forward; return Mathf.Abs(BoxHalf.x * Vector3.Dot(n, val)) + Mathf.Abs(BoxHalf.y * Vector3.Dot(n, val2)) + Mathf.Abs(BoxHalf.z * Vector3.Dot(n, val3)); } } } internal static Vector3 DirectionVector(int dir) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(dir switch { 0 => Vector3.right, 2 => Vector3.forward, _ => Vector3.up, }); } } internal sealed class InstantPredictor { private const float MaxTime = 6f; private const int MaxSteps = 900; private const int MaxBounces = 20; private const float SleepHold = 0.4f; private const float MinCastStep = 0.8f; private const int MaxCastSteps = 4; private const float ClearanceMax = 0.02f; private const float SlidingThreshold = 0.03f; private const float SettleTime = 2.5f; private const float DestroyLowY = -2000f; private const float DestroyHighY = 4000f; private const float DestroyHold = 2f; internal readonly List<Vector3> Path = new List<Vector3>(256); internal readonly List<Vector3> Velocities = new List<Vector3>(256); internal readonly List<float> Times = new List<float>(256); internal readonly List<SimImpact> Impacts = new List<SimImpact>(8); internal Vector3 RestPoint; internal bool Rested; internal bool TimedOut; internal bool Destroyed; internal bool Finished; internal float TotalTime; internal int BounceCount; internal int CastCount; internal int EmbedCount; internal float PushSumY; internal float LastCostMs; private readonly List<ShapeProbe> _probes = new List<ShapeProbe>(4); private readonly RaycastHit[] _castHits = (RaycastHit[])(object)new RaycastHit[64]; private static readonly Vector3[] EmbedDirs = BuildEmbedDirs(); private readonly Collider[] _overlapHits = (Collider[])(object)new Collider[32]; private Item _item; private Character _owner; private int _mask; private int _itemLayer; private float _castStep; private float _drag; private float _angDrag; private float _maxAngularSpeed; private float _bounceThreshold; private StopRule _stopRule; private int _bounceCap = 20; private Basketball _basketball; private float _basketballXzLoss; private float _basketballYFall; private bool _ignoreOwner; private readonly List<Collider> _overlapColliders = new List<Collider>(4); private readonly RaycastHit[] _embedHits = (RaycastHit[])(object)new RaycastHit[100]; internal int PushCount; internal float PushMax; private Collider _lastImpactCollider; private Vector3 _lastImpactNormal; private float _lastImpactTime = -999f; private float _sleepSpeed = 0.0707f; private bool _contactSupports; private float _restSince = -1f; private float _lastContactTime = -999f; private float _contactFresh = 0.15f; private float _destroyTimer; internal string StopReason = "未运行"; private static bool _closestPointUnsupported; private const int MaxHullPoints = 256; private static readonly Dictionary<int, Vector3[]> _rawHullCache = new Dictionary<int, Vector3[]>(); private static readonly Dictionary<(int, Vector3), Vector3[]> _scaledHullCache = new Dictionary<(int, Vector3), Vector3[]>(); private static readonly Dictionary<int, int> _maskCache = new Dictionary<int, int>(); internal bool HasImpact => Impacts.Count > 0; internal SimImpact FirstImpact => Impacts[0]; private static Vector3[] BuildEmbedDirs() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(26); for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { for (int k = -1; k <= 1; k++) { if (i != 0 || j != 0 || k != 0) { Vector3 val = new Vector3((float)i, (float)j, (float)k); list.Add(((Vector3)(ref val)).normalized); } } } } return list.ToArray(); } private static bool IsFinite(float f) { if (!float.IsNaN(f)) { return !float.IsInfinity(f); } return false; } private static bool IsFinite(Vector3 v) { //IL_0000: 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) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (IsFinite(v.x) && IsFinite(v.y)) { return IsFinite(v.z); } return false; } private static bool IsFinite(Quaternion q) { //IL_0000: 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) //IL_001a: 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) if (IsFinite(q.x) && IsFinite(q.y) && IsFinite(q.z)) { return IsFinite(q.w); } return false; } internal void Reset() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Path.Clear(); Velocities.Clear(); Times.Clear(); Impacts.Clear(); RestPoint = Vector3.zero; Rested = false; TimedOut = false; Destroyed = false; Finished = false; TotalTime = 0f; BounceCount = 0; CastCount = 0; StopReason = "运行中"; _lastImpactCollider = null; _lastImpactTime = -999f; _contactSupports = false; _restSince = -1f; _lastContactTime = -999f; _destroyTimer = 0f; } internal void Simulate(Item item, Character owner, Vector3 startPos, Quaternion startRot, Vector3 startVel, Vector3 startAngVel, StopRule stopRule = default(StopRule)) { //IL_0043: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_01f3: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_086f: Unknown result type (might be due to invalid IL or missing references) //IL_0871: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Unknown result type (might be due to invalid IL or missing references) //IL_0645: Unknown result type (might be due to invalid IL or missing references) //IL_0647: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_0622: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_06d9: Unknown result type (might be due to invalid IL or missing references) //IL_06e6: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Unknown result type (might be due to invalid IL or missing references) //IL_05f7: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Unknown result type (might be due to invalid IL or missing references) //IL_05fd: Unknown result type (might be due to invalid IL or missing references) //IL_05e2: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_0741: Unknown result type (might be due to invalid IL or missing references) //IL_0743: Unknown result type (might be due to invalid IL or missing references) //IL_067c: Unknown result type (might be due to invalid IL or missing references) //IL_07c3: Unknown result type (might be due to invalid IL or missing references) //IL_06a1: Unknown result type (might be due to invalid IL or missing references) //IL_06ae: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Unknown result type (might be due to invalid IL or missing references) //IL_06c5: Unknown result type (might be due to invalid IL or missing references) //IL_07d1: Unknown result type (might be due to invalid IL or missing references) //IL_080d: Unknown result type (might be due to invalid IL or missing references) //IL_080f: Unknown result type (might be due to invalid IL or missing references) //IL_079c: Unknown result type (might be due to invalid IL or missing references) //IL_079e: Unknown result type (might be due to invalid IL or missing references) //IL_0844: Unknown result type (might be due to invalid IL or missing references) //IL_0846: Unknown result type (might be due to invalid IL or missing references) Reset(); _item = item; _owner = owner; _stopRule = stopRule; SimMode mode = stopRule.Mode; _bounceCap = ((mode == SimMode.Full || mode == SimMode.FirstWarpImpact) ? 100000 : 20); if ((Object)(object)item == (Object)null || !IsFinite(startPos) || !IsFinite(startRot) || !IsFinite(startVel) || !IsFinite(startAngVel) || ((Vector3)(ref startVel)).sqrMagnitude < 0.0001f) { StopReason = "初值无效"; return; } if (!BuildProbes(item)) { StopReason = "无可用碰撞体"; return; } _basketball = ((Component)item).GetComponentInChildren<Basketball>(true); if ((Object)(object)_basketball != (Object)null) { _basketballXzLoss = _basketball.xzBounceLoss; _basketballYFall = _basketball.yFall; } EmbedCount = 0; PushSumY = 0f; PushCount = 0; PushMax = 0f; _overlapColliders.Clear(); _mask = MaskForLayer(((Component)item).gameObject.layer); _itemLayer = ((Component)item).gameObject.layer; _drag = (((Object)(object)item.rig != (Object)null) ? Mathf.Max(0f, item.rig.linearDamping) : 0f); _angDrag = (((Object)(object)item.rig != (Object)null) ? Mathf.Max(0f, item.rig.angularDamping) : 0f); _maxAngularSpeed = (((Object)(object)item.rig != (Object)null && item.rig.maxAngularVelocity > 0.01f) ? item.rig.maxAngularVelocity : Physics.defaultMaxAngularSpeed); _bounceThreshold = Mathf.Max(0f, Physics.bounceThreshold); float num = 0.15f; for (int i = 0; i < _probes.Count; i++) { num = Mathf.Max(num, _probes[i].Support(Vector3.up, Quaternion.identity)); } _castStep = Mathf.Max(0.8f, num * 3f); float num2 = Mathf.Clamp(Time.fixedDeltaTime, 0.005f, 0.05f); Vector3 gravity = Physics.gravity; _sleepSpeed = Mathf.Sqrt(Mathf.Max(1E-06f, Physics.sleepThreshold)); _contactFresh = Mathf.Max(0.15f, num2 * 6f); Vector3 p = startPos; Quaternion rot = startRot; Vector3 v = startVel; Vector3 w = startAngVel; float num3 = 0f; float num4 = 0f; _ignoreOwner = true; Depenetrate(ref p, ref rot); Path.Add(p); Velocities.Add(v); Times.Add(num3); Vector3 val = p; Quaternion val2 = rot; int num5 = 0; int num6 = Path.Count - 1; float num7 = 0f; int num8 = Mathf.Max(900, Mathf.CeilToInt(6f / num2) + 4); for (int j = 0; j < num8; j++) { _ignoreOwner = num3 < 0.5f; v += gravity * num2; if (_drag > 0f) { v *= Mathf.Max(0f, 1f - _drag * num2); } if (_angDrag > 0f && ((Vector3)(ref w)).sqrMagnitude > 1E-08f) { w *= Mathf.Max(0f, 1f - _angDrag * num2); } if (((Vector3)(ref w)).sqrMagnitude > 1E-08f) { float magnitude = ((Vector3)(ref w)).magnitude; if (magnitude > _maxAngularSpeed) { w *= _maxAngularSpeed / magnitude; } } p += v * num2; if (((Vector3)(ref w)).sqrMagnitude > 1E-08f) { float magnitude2 = ((Vector3)(ref w)).magnitude; rot = Quaternion.Normalize(Quaternion.AngleAxis(magnitude2 * num2 * 57.29578f, w / magnitude2) * rot); } num3 += num2; if (!IsFinite(p) || !IsFinite(v) || !IsFinite(w)) { StopReason = "非有限值"; RestPoint = p; TotalTime = num3; return; } num5++; Vector3 val3 = p - val; if (((Vector3)(ref val3)).sqrMagnitude >= _castStep * _castStep || num5 >= 4 || j == num8 - 1) { num5 = 0; float magnitude3 = ((Vector3)(ref val3)).magnitude; _overlapColliders.Clear(); if (magnitude3 > 0.0001f && Sweep(val, val2, val3, out var hit, out var probe, out var travel)) { float num9 = Mathf.Clamp01(travel / magnitude3); float num10 = num3 - num7; float num11 = num7 + num9 * num10; float num12 = num3 - num11; bool flag = travel <= 0.03f; if (num12 > 1E-06f) { int num13 = num6 + 1; if (num13 < Path.Count) { Path.RemoveRange(num13, Path.Count - num13); Velocities.RemoveRange(num13, Velocities.Count - num13); Times.RemoveRange(num13, Times.Count - num13); } v -= gravity * num12; if (!flag) { num3 = num11; } } if (Resolve(ref p, ref rot, ref v, ref w, hit, probe, val2, num3, val3, mode)) { Path.Add(p); Velocities.Add(v); Times.Add(num3); TotalTime = num3; return; } if (_overlapColliders.Count > 0) { PushOutOfGeometry(ref p, rot, val3); _overlapColliders.Clear(); } val = p; val2 = rot; } else { if (_overlapColliders.Count > 0) { EmbedCount++; if (!PushOutOfGeometry(ref p, rot, val3)) { Depenetrate(ref p, ref rot); } } _overlapColliders.Clear(); val = p; val2 = rot; } num6 = Path.Count; num7 = num3; } if (mode == SimMode.FirstVelocityBreak && _stopRule.HasBreakVy && num3 - num2 > _stopRule.MinTime && v.y < _stopRule.BreakVy) { StopReason = "云雾菇空中破碎"; Path.Add(p); Velocities.Add(v); Times.Add(num3); RestPoint = p; TotalTime = num3; return; } Path.Add(p); Velocities.Add(v); Times.Add(num3); bool flag2 = num3 - _lastContactTime <= _contactFresh; if (_restSince >= 0f && flag2 && num3 - _restSince >= 0.4f) { StopReason = "静止"; RestPoint = p; Rested = true; TotalTime = num3; return; } if (HasImpact && flag2 && _contactSupports) { if (((Vector3)(ref v)).sqrMagnitude < _bounceThreshold * _bounceThreshold) { num4 += num2; if (num4 >= 2.5f) { StopReason = "撞击后滑行超时"; RestPoint = p; Rested = true; TotalTime = num3; return; } } else { num4 = 0f; } } else { num4 = 0f; } if (p.y < -2000f || p.y > 4000f) { _destroyTimer += num2; if (_destroyTimer >= 2f) { StopReason = "越界销毁"; Destroyed = true; RestPoint = p; TotalTime = num3; return; } } else { _destroyTimer = 0f; } if (num3 >= 6f) { StopReason = "最大时间"; TimedOut = true; RestPoint = p; TotalTime = num3; return; } } StopReason = "最大步数"; RestPoint = p; TotalTime = num3; TimedOut = true; } private bool Sweep(Vector3 origin, Quaternion rot, Vector3 seg, out RaycastHit hit, out ShapeProbe probe, out float travel) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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) //IL_0026: 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_0061: 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_0067: 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_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_009f: 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_00c9: 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_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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_0161: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = seg / ((Vector3)(ref seg)).magnitude; float magnitude = ((Vector3)(ref seg)).magnitude; travel = 0f; float num = float.MaxValue; hit = default(RaycastHit); probe = null; _overlapColliders.Clear(); CastCount++; for (int i = 0; i < _probes.Count; i++) { ShapeProbe shapeProbe = _probes[i]; Vector3 val2 = shapeProbe.WorldCenter(origin, rot); Quaternion val3 = shapeProbe.WorldRotation(rot); float travelOffset = 0f; int num2; switch (shapeProbe.Shape) { case CastShape.Sphere: num2 = Physics.SphereCastNonAlloc(val2, shapeProbe.Radius + 0f, val, _castHits, magnitude, _mask, (QueryTriggerInteraction)1); break; case CastShape.Capsule: { Vector3 val4 = val3 * ShapeProbe.DirectionVector(shapeProbe.CapDirection); float num3 = Mathf.Max(0f, shapeProbe.CapHeight * 0.5f - shapeProbe.CapRadius); num2 = Physics.CapsuleCastNonAlloc(val2 + val4 * num3, val2 - val4 * num3, shapeProbe.CapRadius + 0f, val, _castHits, magnitude, _mask, (QueryTriggerInteraction)1); break; } case CastShape.Hull: num2 = SweepHull(shapeProbe, val2, val3, val, magnitude, out travelOffset); break; default: num2 = Physics.BoxCastNonAlloc(val2, shapeProbe.BoxHalf + Vector3.one * 0f, val, _castHits, val3, magnitude, _mask, (QueryTriggerInteraction)1); break; } for (int j = 0; j < num2; j++) { RaycastHit val5 = _castHits[j]; if ((Object)(object)((RaycastHit)(ref val5)).collider == (Object)null || IsIgnored(((RaycastHit)(ref val5)).collider)) { continue; } if (((RaycastHit)(ref val5)).distance <= 0f || !IsFinite(((RaycastHit)(ref val5)).distance)) { if (!_overlapColliders.Contains(((RaycastHit)(ref val5)).collider)) { _overlapColliders.Add(((RaycastHit)(ref val5)).collider); } } else { if (!IsFinite(((RaycastHit)(ref val5)).point) || !IsFinite(((RaycastHit)(ref val5)).normal)) { continue; } Vector3 val6 = ((RaycastHit)(ref val5)).point; if (((Vector3)(ref val6)).sqrMagnitude < 1E-06f) { continue; } val6 = ((RaycastHit)(ref val5)).normal; if (!(((Vector3)(ref val6)).sqrMagnitude < 1E-06f)) { float num4 = ((RaycastHit)(ref val5)).distance + travelOffset; if (IsFinite(num4) && num4 < num) { num = num4; hit = val5; probe = shapeProbe; } } } } } if (probe != null) { travel = num; } return probe != null; } private int SweepHull(ShapeProbe sp, Vector3 center, Quaternion worldRot, Vector3 dir, float dist, out float travelOffset) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_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_004c: 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_0074: 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_007b: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) travelOffset = 0.002f; Vector3[] hullPoints = sp.HullPoints; Quaternion val = Quaternion.Inverse(worldRot); float num = dist + 0.002f; Vector3 val2 = SupportLocal(hullPoints, val * dir); int count = Physics.RaycastNonAlloc(center + worldRot * val2 + dir * 0.002f, dir, _castHits, num, _mask, (QueryTriggerInteraction)1); if (!PickBest(count, out var bestHit, out var bestDistance)) { return 0; } Vector3 val3 = val * dir; Vector3 val4 = val * ((RaycastHit)(ref bestHit)).normal; if (Vector3.Dot(val4, val3) < 0.999f) { Vector3 val5 = SupportLocal(hullPoints, val4); Vector3 val6 = val5 - val2; if (((Vector3)(ref val6)).sqrMagnitude > 1E-08f) { count = Physics.RaycastNonAlloc(center + worldRot * val5 + dir * 0.002f, dir, _castHits, num, _mask, (QueryTriggerInteraction)1); if (PickBest(count, out var bestHit2, out var bestDistance2) && bestDistance2 < bestDistance) { bestHit = bestHit2; } } } sp.LastSupportLocal = SupportLocal(hullPoints, val * ((RaycastHit)(ref bestHit)).normal); _castHits[0] = bestHit; return 1; } private bool PickBest(int count, out RaycastHit bestHit, out float bestDistance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00e8: Unknown result type (might be due to invalid IL or missing references) bestHit = default(RaycastHit); bestDistance = float.MaxValue; for (int i = 0; i < count; i++) { RaycastHit val = _castHits[i]; if ((Object)(object)((RaycastHit)(ref val)).collider == (Object)null || IsIgnored(((RaycastHit)(ref val)).collider)) { continue; } if (((RaycastHit)(ref val)).distance <= 0f || !IsFinite(((RaycastHit)(ref val)).distance)) { if (!_overlapColliders.Contains(((RaycastHit)(ref val)).collider)) { _overlapColliders.Add(((RaycastHit)(ref val)).collider); } } else { if (!IsFinite(((RaycastHit)(ref val)).point) || !IsFinite(((RaycastHit)(ref val)).normal)) { continue; } Vector3 val2 = ((RaycastHit)(ref val)).point; if (!(((Vector3)(ref val2)).sqrMagnitude < 1E-06f)) { val2 = ((RaycastHit)(ref val)).normal; if (!(((Vector3)(ref val2)).sqrMagnitude < 1E-06f) && ((RaycastHit)(ref val)).distance < bestDistance) { bestDistance = ((RaycastHit)(ref val)).distance; bestHit = val; } } } } return bestDistance < float.MaxValue; } private static Vector3 SupportLocal(Vector3[] hull, Vector3 localDir) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_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) Vector3 result = Vector3.zero; float num = float.MinValue; for (int i = 0; i < hull.Length; i++) { float num2 = Vector3.Dot(hull[i], localDir); if (num2 > num) { num = num2; result = hull[i]; } } return result; } private bool PushOutOfGeometry(ref Vector3 p, Quaternion rot, Vector3 motionDir) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: 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) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01af: 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_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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) bool queriesHitBackfaces = Physics.queriesHitBackfaces; Physics.queriesHitBackfaces = true; try { for (int i = 0; i < _probes.Count; i++) { ShapeProbe shapeProbe = _probes[i]; Vector3 val = shapeProbe.WorldCenter(p, rot); Quaternion worldRot = shapeProbe.WorldRotation(rot); float num = shapeProbe.BoundingRadius(); float num2 = num * 2f + 0.5f; float num3 = 0f; Vector3 val2 = Vector3.zero; float num4 = float.MaxValue; float num5 = 0f; Vector3 val3 = Vector3.zero; for (int j = 0; j < EmbedDirs.Length; j++) { Vector3 val4 = EmbedDirs[j]; int num6 = Physics.RaycastNonAlloc(val, val4, _embedHits, num2, _mask, (QueryTriggerInteraction)1); bool flag = false; RaycastHit val5 = default(RaycastHit); for (int k = 0; k < num6; k++) { RaycastHit val6 = _embedHits[k]; if (!((Object)(object)((RaycastHit)(ref val6)).collider == (Object)null) && !IsIgnored(((RaycastHit)(ref val6)).collider) && IsFinite(((RaycastHit)(ref val6)).distance) && !(((RaycastHit)(ref val6)).distance <= 0f) && (!flag || ((RaycastHit)(ref val6)).distance < ((RaycastHit)(ref val5)).distance)) { flag = true; val5 = val6; } } if (!flag) { continue; } float num7 = Vector3.Dot(((RaycastHit)(ref val5)).normal, val4); if (num7 > 0f) { float num8 = ((Vector3.Dot(val4, -motionDir) > 0f) ? (((RaycastHit)(ref val5)).distance * 0.5f) : ((RaycastHit)(ref val5)).distance); if (num8 < num4) { num4 = num8; num5 = ((RaycastHit)(ref val5)).distance; val3 = val4; } } else if (num7 < -0.2f) { Vector3 normal = ((RaycastHit)(ref val5)).normal; float num9 = Vector3.Dot(val - ((RaycastHit)(ref val5)).point, normal); float num10 = shapeProbe.Support(-normal, worldRot) - num9; if (num10 > num3) { num3 = num10; val2 = normal; } } } if (num3 > 0f) { float num11 = Mathf.Min(num3 + 0.01f, num + 0.01f); p += val2 * num11; PushCount++; PushMax = Mathf.Max(PushMax, num11); PushSumY += val2.y * num11; return true; } if (num4 < float.MaxValue) { float num12 = shapeProbe.Support(-val3, worldRot); float num13 = Mathf.Min(num5, num2) + num12 + 0.01f; p += val3 * num13; PushCount++; PushMax = Mathf.Max(PushMax, num13); PushSumY += val3.y * num13; return true; } } } catch (Exception) { } finally { Physics.queriesHitBackfaces = queriesHitBackfaces; } return false; } private bool Depenetrate(ref Vector3 p, ref Quaternion rot) { //IL_002f: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: 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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_017f: 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_018d: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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_019e: Unknown result type (might be due to invalid IL or missing references) float num = 0f; bool result = false; Vector3 val5 = default(Vector3); float num4 = default(float); for (int i = 0; i < _probes.Count; i++) { ShapeProbe shapeProbe = _probes[i]; if ((Object)(object)shapeProbe.Source == (Object)null) { continue; } Vector3 val = shapeProbe.WorldCenter(p, rot); int num2 = Physics.OverlapSphereNonAlloc(val, shapeProbe.BoundingRadius() + 0.02f, _overlapHits, _mask, (QueryTriggerInteraction)1); for (int j = 0; j < num2; j++) { Collider val2 = _overlapHits[j]; if ((Object)(object)val2 == (Object)null || IsIgnored(val2)) { continue; } val = shapeProbe.WorldCenter(p, rot); float num3 = shapeProbe.ContactOffset + Physics.defaultContactOffset; Vector3 val3 = p + rot * shapeProbe.LocalPosePosition; Quaternion val4 = rot * shapeProbe.LocalPoseRotation; Vector3 dir; float push; if (Physics.ComputePenetration(shapeProbe.Source, val3, val4, val2, ((Component)val2).transform.position, ((Component)val2).transform.rotation, ref val5, ref num4) && IsFinite(val5) && IsFinite(num4) && num4 > 0f) { float num5 = 1f; if (shapeProbe.Shape == CastShape.Box) { Vector3 val6 = rot * Vector3.right; Vector3 val7 = rot * Vector3.up; Vector3 val8 = rot * Vector3.forward; num5 = Mathf.Abs(Vector3.Dot(val5, val6)) + Mathf.Abs(Vector3.Dot(val5, val7)) + Mathf.Abs(Vector3.Dot(val5, val8)); } dir = val5; push = num4 + num3 * Mathf.Max(1f, num5) + 0.002f; } else if (!TryClosestPointPush(shapeProbe, rot, val2, val, num3, out dir, out push)) { continue; } float num6 = shapeProbe.BoundingRadius() * 2f + 0.5f; if (push > num6) { push = num6; } if (num + push > 5f) { push = Mathf.Max(0f, 5f - num); } if (!(push <= 0f)) { p += dir * push; num += push; result = true; } } } return result; } private bool TryClosestPointPush(ShapeProbe sp, Quaternion rot, Collider other, Vector3 center, float skin, out Vector3 dir, out float push) { //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_0015: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_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_0077: 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_005a: 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) dir = Vector3.zero; push = 0f; if (!TryClosestExit(other, center, sp.BoundingRadius(), out var exit, out var inside)) { return false; } Vector3 val = exit - center; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.0001f) { return false; } dir = val / magnitude; if (!inside) { dir = -dir; } float num = sp.Support(-dir, sp.WorldRotation(rot)); if (inside) { push = magnitude + num + skin + 0.002f; } else { push = num + skin + 0.002f - magnitude; } return push > 0f; } private static bool TryClosestExit(Collider other, Vector3 center, float radius, out Vector3 exit, out bool inside) { //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0076: 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_007f: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00b4: Unknown result type (might be due to invalid IL or missing references) exit = center; inside = true; if (_closestPointUnsupported || !SupportsClosestPoint(other)) { return false; } try { exit = other.ClosestPoint(center); Vector3 val = exit - center; inside = ((Vector3)(ref val)).sqrMagnitude <= 1E-08f; if (!inside) { return true; } float num = float.MaxValue; for (int i = 0; i < 6; i++) { Vector3 val2 = center + AxisOffset(i) * radius; Vector3 val3 = other.ClosestPoint(val2); val = val3 - val2; if (!(((Vector3)(ref val)).sqrMagnitude <= 1E-08f)) { val = val3 - center; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; exit = val3; } } } return num < float.MaxValue; } catch (Exception) { _closestPointUnsupported = true; return false; } } private static bool SupportsClosestPoint(Collider c) { if (c is BoxCollider || c is SphereCollider || c is CapsuleCollider) { return true; } MeshCollider val = (MeshCollider)(object)((c is MeshCollider) ? c : null); if ((Object)(object)val != (Object)null) { return val.convex; } return false; } private static Vector3 AxisOffset(int i) { //IL_001c: 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_0028: 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_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) return (Vector3)(i switch { 0 => Vector3.right, 1 => Vector3.left, 2 => Vector3.up, 3 => Vector3.down, 4 => Vector3.forward, _ => Vector3.back, }); } private bool Resolve(ref Vector3 p, ref Quaternion rot, ref Vector3 v, ref Vector3 w, RaycastHit hit, ShapeProbe probe, Quaternion castRot, float t, Vector3 seg, SimMode mode) { //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_00cc: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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_0160: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: 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_0282: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: 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_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing reference