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.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: AssemblyCompany("ShieldSledding")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.9.0")] [assembly: AssemblyInformationalVersion("1.0.9")] [assembly: AssemblyProduct("ShieldSledding")] [assembly: AssemblyTitle("ShieldSledding")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.9.0")] [module: UnverifiableCode] [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 ShieldSledding { internal sealed class AudioController { private AudioSource _slideSource; private AudioSource _windSource; private float _lastImpactTime; private static AudioClip _slideClip; private static AudioClip _windClip; private static AudioClip _impactClip; internal static AudioController Instance { get; private set; } internal AudioController() { Instance = this; } internal static void Prewarm() { if (!Utility.IsDedicatedServer()) { EnsureClips(); } } internal void Begin(Player player) { EnsureSources(player); } internal void End(Player player) { if ((Object)(object)_slideSource != (Object)null) { _slideSource.Stop(); } if ((Object)(object)_windSource != (Object)null) { _windSource.Stop(); } } internal void Update(Player player, float speed) { if (!ConfigManager.EnableSoundEffects.Value || (Object)(object)player == (Object)null || Utility.IsDedicatedServer()) { if ((Object)(object)_slideSource != (Object)null && _slideSource.isPlaying) { _slideSource.Stop(); } if ((Object)(object)_windSource != (Object)null && _windSource.isPlaying) { _windSource.Stop(); } return; } EnsureSources(player); float num = 12f; if (Utility.TrySampleGround(player, out var sample)) { num = Mathf.Max(6f, ShieldSpeedRegistry.EstimateNaturalSpeed(in sample)); } float num2 = Mathf.Clamp01(speed / num); if ((Object)(object)_slideSource != (Object)null) { if (speed > 1.5f) { if (!_slideSource.isPlaying) { _slideSource.Play(); } _slideSource.volume = 0.15f + num2 * 0.45f; _slideSource.pitch = 0.85f + num2 * 0.45f; } else { _slideSource.Stop(); } } if (!((Object)(object)_windSource != (Object)null)) { return; } if (speed > 6f) { if (!_windSource.isPlaying) { _windSource.Play(); } _windSource.volume = num2 * 0.4f; _windSource.pitch = 0.95f + num2 * 0.7f; } else { _windSource.Stop(); } } internal void OnLanding(Player player, float impact) { PlayImpact(player, impact); } internal void PlayImpact(Player player, float impact) { if (ConfigManager.EnableSoundEffects.Value && !((Object)(object)player == (Object)null) && !(impact < 4f) && !(Time.time - _lastImpactTime < 0.2f)) { _lastImpactTime = Time.time; EnsureSources(player); if ((Object)(object)_slideSource != (Object)null && (Object)(object)_impactClip != (Object)null) { _slideSource.PlayOneShot(_impactClip, Mathf.Clamp01(impact / 20f) * 0.85f); } } } private void EnsureSources(Player player) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown EnsureClips(); if (!((Object)(object)_slideSource != (Object)null)) { GameObject val = new GameObject("ShieldSledding_Audio"); val.transform.SetParent(((Component)player).transform, false); _slideSource = val.AddComponent(); _slideSource.loop = true; _slideSource.spatialBlend = 0f; _slideSource.playOnAwake = false; _slideSource.clip = _slideClip; _slideSource.volume = 0.4f; _windSource = val.AddComponent(); _windSource.loop = true; _windSource.spatialBlend = 0f; _windSource.playOnAwake = false; _windSource.clip = _windClip; _windSource.volume = 0.25f; _windSource.pitch = 1.1f; } } private static void EnsureClips() { if ((Object)(object)_slideClip == (Object)null) { _slideClip = CreateNoiseClip("ShieldSled_Slide", 0.55f, 0.35f, soft: true); } if ((Object)(object)_windClip == (Object)null) { _windClip = CreateNoiseClip("ShieldSled_Wind", 0.8f, 0.22f, soft: true); } if ((Object)(object)_impactClip == (Object)null) { _impactClip = CreateNoiseClip("ShieldSled_Impact", 0.12f, 0.85f, soft: false); } } private static AudioClip CreateNoiseClip(string name, float seconds, float amplitude, bool soft) { int num = 22050; int num2 = Mathf.Max(256, Mathf.RoundToInt((float)num * seconds)); float[] array = new float[num2]; float num3 = 0f; for (int i = 0; i < num2; i++) { float num4 = (float)i / (float)(num2 - 1); float num5 = (soft ? 1f : (Mathf.Exp((0f - num4) * 14f) * (1f - num4))); float num6 = Random.value * 2f - 1f; float num7 = (soft ? ((num3 + 0.02f * num6) / 1.02f) : num6); num3 = num7; array[i] = num7 * amplitude * num5; } AudioClip obj = AudioClip.Create(name, num2, 1, num, false); if (!TrySetClipData(obj, array)) { Plugin.Log.LogWarning((object)"Shield Sledding: AudioClip.SetData unavailable — using empty baked clip."); } return obj; } private static bool TrySetClipData(AudioClip clip, float[] buffer) { if ((Object)(object)clip == (Object)null || buffer == null) { return false; } try { MethodInfo method = typeof(AudioClip).GetMethod("SetData", new Type[2] { typeof(float[]), typeof(int) }); if (method == null) { return false; } return !(method.Invoke(clip, new object[2] { buffer, 0 }) is bool flag) || flag; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Shield Sledding: AudioClip.SetData failed — " + ex.Message)); return false; } } } internal sealed class CollisionController { private Vector3 _lastVelocity; private float _cooldownUntil; internal void Begin(Player player) { //IL_0012: 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_0017: Unknown result type (might be due to invalid IL or missing references) _lastVelocity = (((Object)(object)player != (Object)null) ? ((Character)player).GetVelocity() : Vector3.zero); _cooldownUntil = 0f; } internal void Tick(Player player, ItemData shield, PhysicsResult result) { //IL_0021: 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_004e: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return; } WildlifeImpact.TryRam(player, shield, result); if (Time.time < _cooldownUntil) { _lastVelocity = result.Velocity; return; } float horizontalSpeed = result.HorizontalSpeed; if (horizontalSpeed < ConfigManager.CollisionSpeedThreshold.Value) { _lastVelocity = result.Velocity; return; } Vector3 val = Utility.Flatten(result.Velocity - _lastVelocity); float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 4f) { _lastVelocity = result.Velocity; return; } if (!TryFindObstacle(player, out var hit)) { _lastVelocity = result.Velocity; return; } float impact = magnitude * ConfigManager.CollisionSpeedDamageScale.Value; ApplyImpact(player, shield, ((RaycastHit)(ref hit)).point, ((RaycastHit)(ref hit)).normal, impact, horizontalSpeed); _cooldownUntil = Time.time + 0.35f; _lastVelocity = result.Velocity; } internal void OnLanding(Player player, float impact) { if (!(impact < 8f) && Utility.IsLocalPlayer(player)) { EffectController.Instance?.ShakeCamera(impact * ConfigManager.CameraShakeStrength.Value * 0.05f); AudioController.Instance?.PlayImpact(player, impact); } } private bool TryFindObstacle(Player player, out RaycastHit hit) { //IL_0001: 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_0012: 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_003a: 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_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) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) hit = default(RaycastHit); Vector3 val = ((Component)player).transform.position + Vector3.up * 0.6f; Vector3 val2 = Utility.Flatten((ShieldSledController.Instance != null) ? ShieldSledController.Instance.SimulatedVelocity : ((Character)player).GetVelocity()); if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = ((Component)player).transform.forward; } ((Vector3)(ref val2)).Normalize(); return Physics.SphereCast(val, 0.4f, val2, ref hit, 1.2f, -1); } private void ApplyImpact(Player player, ItemData shield, Vector3 point, Vector3 normal, float impact, float speed) { //IL_000c: 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_0034: Unknown result type (might be due to invalid IL or missing references) EffectController.Instance?.OnCollision(player, point, normal, impact); AudioController.Instance?.PlayImpact(player, impact); MultiplayerSync.Instance?.SendImpactEvent(player, point, impact); } } internal static class ConfigManager { internal static ConfigEntry EnableShieldSledding; internal static ConfigEntry ActivationKey; internal static ConfigEntry ActivationWindow; internal static ConfigEntry ArmedWindow; internal static ConfigEntry MinimumSlope; internal static ConfigEntry ShowActivationHints; internal static ConfigEntry SledGroundClearance; internal static ConfigEntry EnableWaterSledding; internal static ConfigEntry WaterSledMinSpeed; internal static ConfigEntry WaterSledSustainSpeed; internal static ConfigEntry WaterSledFriction; internal static ConfigEntry MinimumSledSpeed; internal static ConfigEntry BaseAcceleration; internal static ConfigEntry MaximumSpeed; internal static ConfigEntry MinBlockSkillSpeedScale; internal static ConfigEntry MaxBlockSkillSpeedScale; internal static ConfigEntry GravityMultiplier; internal static ConfigEntry FrictionMultiplier; internal const float CoastFrictionScale = 0.28f; internal const float CoastFlatDecelScale = 0.35f; internal static ConfigEntry AirControl; internal static ConfigEntry SteeringStrength; internal static ConfigEntry InvertSteering; internal static ConfigEntry CameraRelativeSteering; internal static ConfigEntry BrakeStrength; internal static ConfigEntry ForwardLeanBonus; internal static ConfigEntry SteeringSpeedFalloff; internal static ConfigEntry UphillPenalty; internal static ConfigEntry SlopeTransitionRetention; internal const float ClimbFrictionScale = 0.38f; internal static ConfigEntry FlatDeceleration; internal static ConfigEntry AbsorbDamageToShield; internal static ConfigEntry EndSledOnCombatHit; internal static ConfigEntry StaggerOnCombatHit; internal static ConfigEntry CombatHitMinDamage; internal static ConfigEntry EnableDurabilityLoss; internal static ConfigEntry DurabilityPerMeter; internal static ConfigEntry DurabilityPerSecond; internal static ConfigEntry LandingDamageMultiplier; internal static ConfigEntry DamageToDurabilityMultiplier; internal static ConfigEntry StumbleOnShieldBreak; internal static ConfigEntry SnowFriction; internal static ConfigEntry GrassFriction; internal static ConfigEntry BlackForestFriction; internal static ConfigEntry SwampFriction; internal static ConfigEntry AshlandsFriction; internal static ConfigEntry MountainFriction; internal static ConfigEntry MeadowsFriction; internal static ConfigEntry MistlandsFriction; internal static ConfigEntry OceanFriction; internal static ConfigEntry DeepNorthFriction; internal static ConfigEntry AshlandsDurabilityWearMultiplier; internal static ConfigEntry EnableShieldSurf; internal static ConfigEntry ShieldSurfFriction; internal static ConfigEntry CollisionSpeedThreshold; internal static ConfigEntry CollisionSpeedDamageScale; internal static ConfigEntry EnableWildlifeImpactKill; internal static ConfigEntry StaminaMode; internal static ConfigEntry StaminaActivationCost; internal static ConfigEntry StaminaPerSecond; internal static ConfigEntry StaminaJumpCost; internal static ConfigEntry EnableParticles; internal static ConfigEntry EnableCameraEffects; internal static ConfigEntry EnableSoundEffects; internal static ConfigEntry EnableSpeedometer; internal static ConfigEntry CameraShakeStrength; internal static ConfigEntry SpeedFovIncrease; internal static ConfigEntry CameraTiltStrength; internal static ConfigEntry EnableShieldSparks; internal static ConfigEntry ConfigSchemaVersion; private static ConfigDescription FloatRange(float min, float max, string description = "") { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown return new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange(min, max), Array.Empty()); } private static ConfigDescription IntRange(int min, int max, string description = "") { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown return new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange(min, max), Array.Empty()); } internal static void Init(ConfigFile config) { //IL_0048: 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_008f: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Expected O, but got Unknown //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Expected O, but got Unknown //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Expected O, but got Unknown //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Expected O, but got Unknown //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Expected O, but got Unknown //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Expected O, but got Unknown //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Expected O, but got Unknown //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Expected O, but got Unknown //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Expected O, but got Unknown //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Expected O, but got Unknown //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Expected O, but got Unknown //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Expected O, but got Unknown //IL_04e1: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Expected O, but got Unknown //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Expected O, but got Unknown //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Expected O, but got Unknown //IL_0589: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Expected O, but got Unknown //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Expected O, but got Unknown //IL_064a: Unknown result type (might be due to invalid IL or missing references) //IL_0654: Expected O, but got Unknown //IL_0985: Unknown result type (might be due to invalid IL or missing references) //IL_098f: Expected O, but got Unknown //IL_09bd: Unknown result type (might be due to invalid IL or missing references) //IL_09c7: Expected O, but got Unknown ConfigSchemaVersion = config.Bind("General", "ConfigSchemaVersion", 1, "Internal config migration version. Do not edit unless you know what you are doing."); EnableShieldSledding = config.Bind("General", "EnableShieldSledding", true, "Master toggle for shield sledding."); ActivationKey = config.Bind("General", "ActivationKey", new KeyboardShortcut((KeyCode)103, Array.Empty()), "Press while airborne after a jump to arm shield sled mode."); ActivationWindow = config.Bind("General", "ActivationWindow", 2.5f, new ConfigDescription("Seconds after jumping during which G can arm sled mode.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 5f), Array.Empty())); ArmedWindow = config.Bind("General", "ArmedWindow", 6f, new ConfigDescription("Seconds after arming to land and start sledding before the arm expires.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 15f), Array.Empty())); MinimumSlope = config.Bind("General", "MinimumSlope", 8f, new ConfigDescription("Minimum ground slope in degrees required to start sledding on landing.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 45f), Array.Empty())); ShowActivationHints = config.Bind("General", "ShowActivationHints", true, "Show on-screen center messages for arming, flat landing, and other sled hints."); SledGroundClearance = config.Bind("Physics", "SledGroundClearance", 0f, new ConfigDescription("Target height of the player's feet above the slope while sledding (meters). 0 = full contact.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 0.6f), Array.Empty())); EnableWaterSledding = config.Bind("Physics", "EnableWaterSledding", true, "Allow sledding across water when moving fast enough."); WaterSledMinSpeed = config.Bind("Physics", "WaterSledMinSpeed", 6f, new ConfigDescription("Minimum speed (m/s) to START water skim. Clamped up to WaterSledSustainSpeed so skim cannot engage below the cancel floor.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 20f), Array.Empty())); WaterSledSustainSpeed = config.Bind("Physics", "WaterSledSustainSpeed", 6f, new ConfigDescription("ONLY water speed restriction while skimming: end skim when horizontal speed falls below this (m/s). Default 6. Short flicker grace only — cancel should read ~6, not ~3.", (AcceptableValueBase)(object)new AcceptableValueRange(2f, 25f), Array.Empty())); WaterSledFriction = config.Bind("Physics", "WaterSledFriction", 0.4f, new ConfigDescription("Friction while skimming water only (not multiplied by OceanFriction). Lower = longer skim. No W-propulsion on water — skim must coast in.", (AcceptableValueBase)(object)new AcceptableValueRange(0.05f, 2f), Array.Empty())); MinimumSledSpeed = config.Bind("Physics", "MinimumSledSpeed", 4f, new ConfigDescription("Minimum horizontal speed (m/s) required to stay in sledding on ground. Drop below this (with a short grace) and sledding ends. 0 = disabled. Skipped while water-skimming.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 20f), Array.Empty())); BaseAcceleration = config.Bind("Physics", "BaseAcceleration", 10f, new ConfigDescription("Slope pull strength (~10 ≈ gravity). Higher = faster coast on the same hill.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 100f), Array.Empty())); MaximumSpeed = config.Bind("Physics", "MaximumSpeed", 0f, new ConfigDescription("Optional safety speed cap in m/s. 0 = disabled — speed follows slope steepness and terrain friction.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 80f), Array.Empty())); MinBlockSkillSpeedScale = config.Bind("Physics", "BlockSkillSpeedScaleMin", 0.8f, new ConfigDescription("Blocking skill speed scale at skill 0. Lerps to BlockSkillSpeedScaleMax at Blocking 100. Affects slope pull, coast speed, and the optional MaximumSpeed cap.", (AcceptableValueBase)(object)new AcceptableValueRange(0.35f, 3f), Array.Empty())); MaxBlockSkillSpeedScale = config.Bind("Physics", "BlockSkillSpeedScaleMax", 1.7f, new ConfigDescription("Blocking skill speed scale at skill 100. Lerps from BlockSkillSpeedScaleMin at Blocking 0.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 3f), Array.Empty())); GravityMultiplier = config.Bind("Physics", "GravityMultiplier", 1f, new ConfigDescription("Multiplier applied to downhill gravity acceleration.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 5f), Array.Empty())); FrictionMultiplier = config.Bind("Physics", "FrictionMultiplier", 1f, new ConfigDescription("Global friction multiplier. Always applied (including downhill). Free-coast uses a lighter fraction so glide stays long; braking uses full strength. Biome/shield frictions still scale with this.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 5f), Array.Empty())); AirControl = config.Bind("Physics", "AirControl", 0.15f, new ConfigDescription("Fraction of ground steering applied while airborne.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); SteeringStrength = config.Bind("Physics", "SteeringStrength", 4.75f, new ConfigDescription("How quickly velocity direction can change while sledding.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 10f), Array.Empty())); InvertSteering = config.Bind("Physics", "InvertSteering", false, "Swap A/D while sledding. Leave false for natural left/right; enable if steering feels backwards."); CameraRelativeSteering = config.Bind("Physics", "CameraRelativeSteering", true, "When true, A/D lean uses screen left/right when the camera has a clear lateral view of the slide; sideways freelook and slope-align keep sled/body left/right. Looking against travel stays sled-natural (no lean swap). When false, A/D always turn relative to slide direction."); BrakeStrength = config.Bind("Physics", "BrakeStrength", 1.5f, new ConfigDescription("Extra friction multiplier when holding S.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 10f), Array.Empty())); ForwardLeanBonus = config.Bind("Physics", "ForwardLeanBonus", 1.5f, new ConfigDescription("Extra acceleration when holding W on real downhill slopes. No effect on flat / near-flat ground (cannot sustain sledding forever with Shift+W).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 30f), Array.Empty())); SteeringSpeedFalloff = config.Bind("Physics", "SteeringSpeedFalloff", 0.035f, new ConfigDescription("Higher values reduce steering responsiveness at speed.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); UphillPenalty = config.Bind("Physics", "UphillPenalty", 0.75f, new ConfigDescription("Uphill deceleration relative to downhill slope pull (1 = mirror gravity × grade). Scaled by slope steepness. Lower = more climb carry from downhill runs.", (AcceptableValueBase)(object)new AcceptableValueRange(0.25f, 10f), Array.Empty())); SlopeTransitionRetention = config.Bind("Physics", "SlopeTransitionRetention", 0.9f, new ConfigDescription("How much speed to keep when the ground normal changes (valleys / downhill→uphill). 1 = full retain, 0 = raw ProjectOnPlane bleed.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); FlatDeceleration = config.Bind("Physics", "FlatDeceleration", 8f, new ConfigDescription("Deceleration on flat ground (m/s² scale). Free-coast applies a lighter fraction; braking uses full strength.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 30f), Array.Empty())); AbsorbDamageToShield = config.Bind("Damage", "AbsorbDamageToShield", true, "When true, fall and impact damage go to shield durability instead of player HP while sledding."); EndSledOnCombatHit = config.Bind("Damage", "EndSledOnCombatHit", true, "When true, creature or player attacks knock you off the sled while sledding."); StaggerOnCombatHit = config.Bind("Damage", "StaggerOnCombatHit", true, "Apply a stagger when knocked off the sled by a creature or player attack."); CombatHitMinDamage = config.Bind("Damage", "CombatHitMinDamage", 1f, new ConfigDescription("Minimum damage before a combat hit can knock you off the sled.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 50f), Array.Empty())); DamageToDurabilityMultiplier = config.Bind("Damage", "DamageToDurabilityMultiplier", 0.15f, new ConfigDescription("Shield durability lost per point of HP damage absorbed while sledding.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); EnableDurabilityLoss = config.Bind("Durability", "EnableDurabilityLoss", true, "Whether sledding wears down the equipped shield."); DurabilityPerMeter = config.Bind("Durability", "DurabilityPerMeter", 0.02f, FloatRange(0f, 5f)); DurabilityPerSecond = config.Bind("Durability", "DurabilityPerSecond", 0.05f, FloatRange(0f, 5f)); LandingDamageMultiplier = config.Bind("Durability", "LandingDamageMultiplier", 1.5f, FloatRange(0f, 10f)); StumbleOnShieldBreak = config.Bind("Durability", "StumbleOnShieldBreak", true, "Apply a stagger when the shield breaks from sledding."); SnowFriction = config.Bind("Terrain", "SnowFriction", 0.55f, FloatRange(0.1f, 3f, "Snow-surface friction blended with MountainFriction / DeepNorthFriction.")); GrassFriction = config.Bind("Terrain", "GrassFriction", 0.85f, FloatRange(0.1f, 3f)); BlackForestFriction = config.Bind("Terrain", "BlackForestFriction", 0.95f, FloatRange(0.1f, 3f)); SwampFriction = config.Bind("Terrain", "SwampFriction", 1.45f, FloatRange(0.1f, 3f)); AshlandsFriction = config.Bind("Terrain", "AshlandsFriction", 0.75f, FloatRange(0.1f, 3f)); MountainFriction = config.Bind("Terrain", "MountainFriction", 0.5f, FloatRange(0.1f, 3f)); MeadowsFriction = config.Bind("Terrain", "MeadowsFriction", 1f, FloatRange(0.1f, 3f)); MistlandsFriction = config.Bind("Terrain", "MistlandsFriction", 0.9f, FloatRange(0.1f, 3f)); OceanFriction = config.Bind("Terrain", "OceanFriction", 1.2f, FloatRange(0.1f, 3f)); DeepNorthFriction = config.Bind("Terrain", "DeepNorthFriction", 0.5f, FloatRange(0.1f, 3f)); AshlandsDurabilityWearMultiplier = config.Bind("Terrain", "AshlandsDurabilityWearMultiplier", 1.35f, FloatRange(1f, 5f)); EnableShieldSurf = config.Bind("Terrain", "EnableShieldSurf", true, "Reduced friction when sledding on player-built pieces / wood ramps (piece layer, wood WearNTear, ramp-like names)."); ShieldSurfFriction = config.Bind("Terrain", "ShieldSurfFriction", 0.4f, FloatRange(0.1f, 3f, "Friction multiplier on built wood/piece surfaces. Lower = faster (0.4 default).")); CollisionSpeedThreshold = config.Bind("Impacts", "CollisionSpeedThreshold", 6f, new ConfigDescription("Minimum speed (m/s) before impact camera/audio effects trigger.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 30f), Array.Empty())); CollisionSpeedDamageScale = config.Bind("Impacts", "CollisionSpeedDamageScale", 1.25f, new ConfigDescription("Impact intensity scale for camera shake and sound.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); EnableWildlifeImpactKill = config.Bind("Impacts", "EnableWildlifeImpactKill", true, "Instantly kill small wildlife when sledding into them at or above CollisionSpeedThreshold (Boar, Deer, Greyling, Neck, Crow, Gull, Hare, Ash crow)."); StaminaMode = config.Bind("Stamina", "StaminaMode", SledStaminaMode.None, "Stamina drain behavior while sledding."); StaminaActivationCost = config.Bind("Stamina", "StaminaActivationCost", 10f, FloatRange(0f, 100f)); StaminaPerSecond = config.Bind("Stamina", "StaminaPerSecond", 2f, FloatRange(0f, 50f)); StaminaJumpCost = config.Bind("Stamina", "StaminaJumpCost", 8f, FloatRange(0f, 100f)); EnableParticles = config.Bind("Effects", "EnableParticles", true, (ConfigDescription)null); EnableCameraEffects = config.Bind("Effects", "EnableCameraEffects", true, "Master switch for sled camera FOV boost, tilt, and shake."); EnableSoundEffects = config.Bind("Effects", "EnableSoundEffects", true, "Slide / wind / impact audio while sledding."); EnableSpeedometer = config.Bind("Effects", "EnableSpeedometer", false, (ConfigDescription)null); CameraShakeStrength = config.Bind("Effects", "CameraShakeStrength", 0.35f, FloatRange(0f, 2f, "Impact camera shake scale. Requires EnableCameraEffects=true.")); SpeedFovIncrease = config.Bind("Effects", "SpeedFovIncrease", 8f, FloatRange(0f, 30f, "Extra FOV (degrees) at full sled speed. Requires EnableCameraEffects=true. Restores when you exit the sled.")); CameraTiltStrength = config.Bind("Effects", "CameraTiltStrength", 4f, FloatRange(0f, 20f, "Steer roll (degrees) while sledding. Requires EnableCameraEffects=true.")); EnableShieldSparks = config.Bind("Effects", "EnableShieldSparks", true, "Spawn brief spark bursts on collisions / wildlife impacts. Also requires EnableParticles."); ShieldWearConfig.Init(config); MigrateLegacyConfig(config); } private static void MigrateLegacyConfig(ConfigFile config) { if (ConfigSchemaVersion.Value < 27) { MigrateRenamedFloat(config, "Physics", "MinBlockSkillSpeedScale", MinBlockSkillSpeedScale); MigrateRenamedFloat(config, "Physics", "MaxBlockSkillSpeedScale", MaxBlockSkillSpeedScale); } if (ConfigSchemaVersion.Value < 2) { if (ActivationWindow.Value <= 0.6f) { ActivationWindow.Value = 2.5f; Plugin.Log.LogInfo((object)"Shield Sledding: raised ActivationWindow to 2.5s (was too short)."); } if (MinimumSlope.Value >= 10f) { MinimumSlope.Value = 2f; Plugin.Log.LogInfo((object)"Shield Sledding: lowered MinimumSlope to 2° (was too steep)."); } } if (ConfigSchemaVersion.Value < 3) { if (MinimumSlope.Value > 0f) { MinimumSlope.Value = 0f; Plugin.Log.LogInfo((object)"Shield Sledding: lowered MinimumSlope to 0° so flat ground works."); } ConfigSchemaVersion.Value = 3; } if (ConfigSchemaVersion.Value < 4) { ConfigSchemaVersion.Value = 4; } if (ConfigSchemaVersion.Value < 5) { if (SledGroundClearance.Value > 0.1f) { SledGroundClearance.Value = 0.06f; Plugin.Log.LogInfo((object)"Shield Sledding: lowered SledGroundClearance to 0.06m for slope contact."); } ConfigSchemaVersion.Value = 5; } if (ConfigSchemaVersion.Value < 6) { SledGroundClearance.Value = 0f; Plugin.Log.LogInfo((object)"Shield Sledding: set SledGroundClearance to 0m for full slope contact."); ConfigSchemaVersion.Value = 6; } if (ConfigSchemaVersion.Value < 7) { if (DamageToDurabilityMultiplier.Value >= 0.99f) { DamageToDurabilityMultiplier.Value = 0.15f; Plugin.Log.LogInfo((object)"Shield Sledding: lowered DamageToDurabilityMultiplier to 0.15 (was melting shields)."); } ConfigSchemaVersion.Value = 7; } if (ConfigSchemaVersion.Value < 8) { ConfigSchemaVersion.Value = 8; } if (ConfigSchemaVersion.Value < 9) { Plugin.Log.LogInfo((object)"Shield Sledding: config v9 — removed legacy collision/ghost options."); ConfigSchemaVersion.Value = 9; } if (ConfigSchemaVersion.Value < 10) { Plugin.Log.LogInfo((object)"Shield Sledding: config v10 — simplified damage toggle and per-shield speed entries in [ShieldSpeeds]."); ConfigSchemaVersion.Value = 10; } if (ConfigSchemaVersion.Value < 11) { if (MaximumSpeed.Value >= 20f) { MaximumSpeed.Value = 13f; } if (BaseAcceleration.Value >= 16f) { BaseAcceleration.Value = 10f; } if (ForwardLeanBonus.Value >= 3f) { ForwardLeanBonus.Value = 1.5f; } Plugin.Log.LogInfo((object)"Shield Sledding: config v11 — lowered default speeds and removed stats section."); ConfigSchemaVersion.Value = 11; } if (ConfigSchemaVersion.Value < 12) { if (MaximumSpeed.Value <= 13.5f) { MaximumSpeed.Value = 10f; } Plugin.Log.LogInfo((object)"Shield Sledding: config v12 — ShieldBanded baseline 10 m/s, tier scaling, Blocking skill affects speed."); ConfigSchemaVersion.Value = 12; } if (ConfigSchemaVersion.Value < 13) { Plugin.Log.LogInfo((object)"Shield Sledding: config v13 — Blocking skill scales 80% to 100% of max speed (10 m/s on banded at skill 100)."); ConfigSchemaVersion.Value = 13; } if (ConfigSchemaVersion.Value < 14) { Plugin.Log.LogInfo((object)"Shield Sledding: config v14 — uniform sled speed; shield tier affects durability wear ([ShieldWear])."); ConfigSchemaVersion.Value = 14; } if (ConfigSchemaVersion.Value < 15) { ResetObsoleteSpeedConfig(config); Plugin.Log.LogInfo((object)"Shield Sledding: config v15 — cleared obsolete [ShieldSpeeds] values. Speed is uniform; edit [ShieldWear] only."); ConfigSchemaVersion.Value = 15; } if (ConfigSchemaVersion.Value < 16) { MaximumSpeed.Value = 0f; Plugin.Log.LogInfo((object)"Shield Sledding: config v16 — slope-natural speed (MaximumSpeed 0 = no cap; speed follows hill steepness)."); ConfigSchemaVersion.Value = 16; } if (ConfigSchemaVersion.Value < 17) { ResetObsoleteSpeedConfig(config); ShieldWearConfig.MigrateLegacyWearDefaults(config); Plugin.Log.LogInfo((object)"Shield Sledding: config v17 — updated [ShieldWear] defaults; use ModdedWolf.ShieldSledding.cfg only."); ConfigSchemaVersion.Value = 17; } if (ConfigSchemaVersion.Value < 18) { if (MinimumSlope.Value < 12f) { MinimumSlope.Value = 12f; Plugin.Log.LogInfo((object)"Shield Sledding: restored MinimumSlope to 12° — flat ground cannot start sledding."); } ConfigSchemaVersion.Value = 18; } if (ConfigSchemaVersion.Value < 19) { if (MinimumSlope.Value < 12f) { MinimumSlope.Value = 12f; Plugin.Log.LogInfo((object)"Shield Sledding: set MinimumSlope to 12° (flat ground cannot start sledding)."); } ConfigSchemaVersion.Value = 19; } if (ConfigSchemaVersion.Value < 20) { if (UphillPenalty.Value >= 2.9f) { UphillPenalty.Value = 1f; Plugin.Log.LogInfo((object)"Shield Sledding: lowered UphillPenalty to 1 (was stopping hard on climbs; now grade-scaled)."); } ConfigSchemaVersion.Value = 20; } if (ConfigSchemaVersion.Value < 21) { ShieldWearConfig.MigrateWoodWearDefault(config); Plugin.Log.LogInfo((object)"Shield Sledding: config v21 — ShieldWood wear default 6.00 (2× prior); [ShieldWear] range max 10."); ConfigSchemaVersion.Value = 21; } if (ConfigSchemaVersion.Value < 22) { ShieldWearConfig.MigrateEarlyShieldWearDoubling(config); Plugin.Log.LogInfo((object)"Shield Sledding: config v22 — early shield wear (Wood→Banded) defaults doubled."); ConfigSchemaVersion.Value = 22; } if (ConfigSchemaVersion.Value < 23) { ShieldWearConfig.MigrateTowerWearAdvantage(config); Plugin.Log.LogInfo((object)"Shield Sledding: config v23 — tower shields wear slower than matching non-tower boards."); ConfigSchemaVersion.Value = 23; } if (ConfigSchemaVersion.Value < 24) { if (Mathf.Approximately(MinimumSlope.Value, 12f)) { MinimumSlope.Value = 8f; Plugin.Log.LogInfo((object)"Shield Sledding: config v24 — MinimumSlope default 8° (was 12°)."); } else { Plugin.Log.LogInfo((object)"Shield Sledding: config v24 — MinimumSledSpeed added (default 2 m/s to stay sledding)."); } ConfigSchemaVersion.Value = 24; } if (ConfigSchemaVersion.Value < 25) { if (Mathf.Approximately(MinBlockSkillSpeedScale.Value, 0.8f)) { MinBlockSkillSpeedScale.Value = 1f; } Plugin.Log.LogInfo((object)"Shield Sledding: config v25 — Blocking skill speed scale 1.0 at skill 0 → 1.7 at skill 100."); ConfigSchemaVersion.Value = 25; } if (ConfigSchemaVersion.Value < 26) { if (Mathf.Approximately(MinBlockSkillSpeedScale.Value, 1f)) { MinBlockSkillSpeedScale.Value = 0.8f; } Plugin.Log.LogInfo((object)"Shield Sledding: config v26 — Blocking skill speed scale 0.80 at skill 0 → 1.7 at skill 100."); ConfigSchemaVersion.Value = 26; } if (ConfigSchemaVersion.Value < 27) { Plugin.Log.LogInfo((object)"Shield Sledding: config v27 — renamed Blocking skill scales to BlockSkillSpeedScaleMin / BlockSkillSpeedScaleMax (kept adjacent in config UI)."); ConfigSchemaVersion.Value = 27; } if (ConfigSchemaVersion.Value < 28) { if (Mathf.Approximately(SteeringStrength.Value, 2.5f)) { SteeringStrength.Value = 4.75f; } if (Mathf.Approximately(SteeringSpeedFalloff.Value, 0.08f)) { SteeringSpeedFalloff.Value = 0.035f; } Plugin.Log.LogInfo((object)"Shield Sledding: config v28 — stronger default steering; softer rock/obstacle sled collisions."); ConfigSchemaVersion.Value = 28; } if (ConfigSchemaVersion.Value < 29) { Plugin.Log.LogInfo((object)"Shield Sledding: config v29 — aggressive rock skim (pass-through low obstacles; heightmap ride plane)."); ConfigSchemaVersion.Value = 29; } if (ConfigSchemaVersion.Value < 30) { Plugin.Log.LogInfo((object)"Shield Sledding: config v30 — fixed canopy/roof upward snaps; restored water skim ground."); ConfigSchemaVersion.Value = 30; } if (ConfigSchemaVersion.Value < 31) { if (Mathf.Approximately(WaterSledMinSpeed.Value, 6f)) { WaterSledMinSpeed.Value = 3.5f; } if (Mathf.Approximately(WaterSledFriction.Value, 0.35f)) { WaterSledFriction.Value = 0.22f; } Plugin.Log.LogInfo((object)"Shield Sledding: config v31 — water skim latch/hysteresis; lower engage speed; fixed water friction."); ConfigSchemaVersion.Value = 31; } if (ConfigSchemaVersion.Value < 32) { if (Mathf.Approximately(ShieldSurfFriction.Value, 0.65f)) { ShieldSurfFriction.Value = 0.4f; } Plugin.Log.LogInfo((object)"Shield Sledding: config v32 — water skim blocks shore terrain; faster wood/piece ramp friction."); ConfigSchemaVersion.Value = 32; } if (ConfigSchemaVersion.Value < 33) { Plugin.Log.LogInfo((object)"Shield Sledding: config v33 — wood ramp lock (no micro-bounce); solid collision inside dungeons."); ConfigSchemaVersion.Value = 33; } if (ConfigSchemaVersion.Value < 34) { if (Mathf.Approximately(WaterSledFriction.Value, 0.22f)) { WaterSledFriction.Value = 0.48f; } Plugin.Log.LogInfo((object)"Shield Sledding: config v34 — water skim rides live wave height; higher water friction + sustain speed."); ConfigSchemaVersion.Value = 34; } if (ConfigSchemaVersion.Value < 35) { if (Mathf.Approximately(WaterSledMinSpeed.Value, 3.5f)) { WaterSledMinSpeed.Value = 5.5f; } if (Mathf.Approximately(WaterSledSustainSpeed.Value, 5f)) { WaterSledSustainSpeed.Value = 6.5f; } if (Mathf.Approximately(WaterSledFriction.Value, 0.48f) || Mathf.Approximately(WaterSledFriction.Value, 0.22f)) { WaterSledFriction.Value = 0.55f; } Plugin.Log.LogInfo((object)"Shield Sledding: config v35 — no water W-propulsion; harder skim engage/decay; soft particle spray."); ConfigSchemaVersion.Value = 35; } if (ConfigSchemaVersion.Value < 36) { if (Mathf.Approximately(WaterSledMinSpeed.Value, 5.5f)) { WaterSledMinSpeed.Value = 4.5f; } if (Mathf.Approximately(WaterSledSustainSpeed.Value, 6.5f)) { WaterSledSustainSpeed.Value = 5f; } if (Mathf.Approximately(WaterSledFriction.Value, 0.55f)) { WaterSledFriction.Value = 0.4f; } if (Mathf.Approximately(MinimumSledSpeed.Value, 2f)) { MinimumSledSpeed.Value = 0.75f; } Plugin.Log.LogInfo((object)"Shield Sledding: config v36 — softer water coast/exit; end sled when submerged; gentler ground min speed."); ConfigSchemaVersion.Value = 36; } if (ConfigSchemaVersion.Value < 37) { if (Mathf.Approximately(WaterSledSustainSpeed.Value, 5f)) { WaterSledSustainSpeed.Value = 6f; } Plugin.Log.LogInfo((object)"Shield Sledding: config v37 — water skim sustain/exit near ~6 m/s (no longer cancels around ~4)."); ConfigSchemaVersion.Value = 37; } if (ConfigSchemaVersion.Value < 38) { WaterSledSustainSpeed.Value = 6f; if (WaterSledMinSpeed.Value < 6f) { WaterSledMinSpeed.Value = 6f; } Plugin.Log.LogInfo((object)"Shield Sledding: config v38 — water skim cancel hard-forced to 6 m/s (sole water speed restriction)."); ConfigSchemaVersion.Value = 38; } if (ConfigSchemaVersion.Value < 39) { if (Mathf.Approximately(MinimumSledSpeed.Value, 0.75f)) { MinimumSledSpeed.Value = 2f; } Plugin.Log.LogInfo((object)"Shield Sledding: config v39 — ground min speed default 2 m/s (water cancel stays at 6)."); ConfigSchemaVersion.Value = 39; } if (ConfigSchemaVersion.Value < 40) { if (Mathf.Approximately(UphillPenalty.Value, 1f)) { UphillPenalty.Value = 0.75f; } Plugin.Log.LogInfo((object)"Shield Sledding: config v40 — better downhill→uphill momentum (UphillPenalty 0.75 + SlopeTransitionRetention)."); ConfigSchemaVersion.Value = 40; } if (ConfigSchemaVersion.Value < 41) { if (Mathf.Approximately(MinimumSledSpeed.Value, 2f)) { MinimumSledSpeed.Value = 4f; } Plugin.Log.LogInfo((object)"Shield Sledding: config v41 — ground min speed default 4 m/s (water cancel stays at 6)."); ConfigSchemaVersion.Value = 41; } if (ConfigSchemaVersion.Value < 42) { Plugin.Log.LogInfo((object)"Shield Sledding: config v42 — InvertSteering + CameraRelativeSteering (natural A/D default)."); ConfigSchemaVersion.Value = 42; } if (ConfigSchemaVersion.Value < 43) { Plugin.Log.LogInfo((object)"Shield Sledding: config v43 — travel-based steer frame (stable A/D while freelook / slope-align)."); ConfigSchemaVersion.Value = 43; } } private static void MigrateRenamedFloat(ConfigFile config, string section, string oldKey, ConfigEntry newEntry) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ConfigDefinition val = new ConfigDefinition(section, oldKey); bool saveOnConfigSet = config.SaveOnConfigSet; config.SaveOnConfigSet = false; try { ConfigEntry val2 = config.Bind(section, oldKey, float.NegativeInfinity, (ConfigDescription)null); if (!float.IsNegativeInfinity(val2.Value)) { newEntry.Value = val2.Value; } config.Remove(val); } finally { config.SaveOnConfigSet = saveOnConfigSet; } } private static void ResetObsoleteSpeedConfig(ConfigFile config) { for (int i = 0; i < ShieldSpeedRegistry.VanillaShieldPrefabs.Length; i++) { string text = ShieldSpeedRegistry.VanillaShieldPrefabs[i]; ConfigEntry val = config.Bind("ShieldSpeeds", text, 1f, (ConfigDescription)null); if (!Mathf.Approximately(val.Value, 1f)) { val.Value = 1f; Plugin.Log.LogInfo((object)("Shield Sledding: reset obsolete ShieldSpeeds." + text + " to 1.0 (unused).")); } } ConfigEntry val2 = config.Bind("ShieldSpeeds", "DefaultModdedSpeed", 1f, (ConfigDescription)null); if (!Mathf.Approximately(val2.Value, 1f)) { val2.Value = 1f; } ConfigEntry val3 = config.Bind("ShieldSpeeds", "CustomModdedSpeeds", string.Empty, (ConfigDescription)null); if (!string.IsNullOrEmpty(val3.Value)) { val3.Value = string.Empty; } } } internal static class DamageAbsorption { internal static bool ShouldAbsorb(Player player) { if (!Utility.IsLocalPlayer(player)) { return false; } ShieldSledController instance = ShieldSledController.Instance; if (instance != null) { if (!instance.IsSledding) { return instance.IsArmed; } return true; } return false; } internal static bool TryAbsorb(Character character, HitData hit) { if (!ConfigManager.AbsorbDamageToShield.Value) { return false; } Player player = (Player)(object)((character is Player) ? character : null); if (!ShouldAbsorb(player) || hit == null) { return false; } float totalDamage = ((DamageTypes)(ref hit.m_damage)).GetTotalDamage(); if (totalDamage <= 0.001f) { return false; } ShieldSledController instance = ShieldSledController.Instance; bool isSledding = instance.IsSledding; Character attacker = null; if (isSledding && ConfigManager.EndSledOnCombatHit.Value && totalDamage >= ConfigManager.CombatHitMinDamage.Value && TryGetCombatAttacker(hit, character, out attacker)) { if (totalDamage > 1f) { EffectController.Instance?.ShakeCamera(totalDamage * 0.02f * ConfigManager.CameraShakeStrength.Value); } instance.EndSledding(player, SledEndReason.CombatHit); if (ConfigManager.StaggerOnCombatHit.Value) { ApplyCombatStagger(player, hit, attacker); } ClearHitDamage(hit); return true; } if (isSledding) { ItemData handShield = Utility.GetHandShield(player); if (handShield != null) { instance.ReportDamageAsShieldWear(player, handShield, totalDamage); } } if (totalDamage > 1f) { EffectController.Instance?.ShakeCamera(totalDamage * 0.01f * ConfigManager.CameraShakeStrength.Value); } ClearHitDamage(hit); return true; } internal static bool TryGetCombatAttacker(HitData hit, Character victim, out Character attacker) { attacker = hit.GetAttacker(); if ((Object)(object)attacker == (Object)null || (Object)(object)attacker == (Object)(object)victim || attacker.IsDead()) { return false; } return true; } private static void ApplyCombatStagger(Player player, HitData hit, Character attacker) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_002f: 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_0039: Unknown result type (might be due to invalid IL or missing references) Vector3 val = hit.m_dir; if (((Vector3)(ref val)).sqrMagnitude < 0.01f && (Object)(object)attacker != (Object)null) { val = ((Component)player).transform.position - ((Component)attacker).transform.position; } if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = -((Component)player).transform.forward; } ((Character)player).Stagger(((Vector3)(ref val)).normalized); } internal static void ApplyLandingDamage(Player player, float impact) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || impact <= 0.5f) { return; } float num = impact * ConfigManager.LandingDamageMultiplier.Value; if (!(num <= 0.001f)) { HitData val = new HitData(); val.m_damage.m_blunt = num; val.m_point = ((Component)player).transform.position; val.m_dir = Vector3.down; ((Character)player).Damage(val); if (num > 1f) { EffectController.Instance?.ShakeCamera(num * 0.01f * ConfigManager.CameraShakeStrength.Value); } } } internal static void ClearHitDamage(HitData hit) { if (hit != null) { hit.m_damage.m_blunt = 0f; hit.m_damage.m_slash = 0f; hit.m_damage.m_pierce = 0f; hit.m_damage.m_fire = 0f; hit.m_damage.m_frost = 0f; hit.m_damage.m_lightning = 0f; hit.m_damage.m_poison = 0f; hit.m_damage.m_spirit = 0f; hit.m_damage.m_chop = 0f; hit.m_damage.m_pickaxe = 0f; hit.m_staggerMultiplier = 0f; hit.m_pushForce = 0f; } } } internal sealed class DurabilityController { private Vector3 _lastPosition; private float _sessionTime; internal void Begin(Player player) { //IL_0017: 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_001c: Unknown result type (might be due to invalid IL or missing references) _lastPosition = (((Object)(object)player != (Object)null) ? ((Component)player).transform.position : Vector3.zero); _sessionTime = 0f; } internal void Tick(Player player, ItemData shield, PhysicsResult result) { //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_0025: 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_0041: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (ConfigManager.EnableDurabilityLoss.Value && !((Object)(object)player == (Object)null) && shield != null) { Vector3 position = ((Component)player).transform.position; float num = Vector3.Distance(position, _lastPosition); if (num > 3f) { num = 3f; } _lastPosition = position; _sessionTime += Time.fixedDeltaTime; float num2 = 1f; if ((int)result.Ground.Biome != 0) { num2 = Utility.GetDurabilityWearBiomeMultiplier(result.Ground.Biome); } float num3 = 0f; num3 += num * ConfigManager.DurabilityPerMeter.Value; num3 += Time.fixedDeltaTime * ConfigManager.DurabilityPerSecond.Value; num3 += result.HorizontalSpeed * 0.001f * ConfigManager.DurabilityPerMeter.Value; num3 *= num2; num3 *= ShieldSpeedRegistry.GetWearMultiplier(shield); ApplyWear(player, shield, num3); } } internal void OnLanding(Player player, ItemData shield, float impact) { if (ConfigManager.EnableDurabilityLoss.Value && shield != null && !(impact <= 0.5f)) { float num = impact * ConfigManager.LandingDamageMultiplier.Value * 0.15f; num *= ShieldSpeedRegistry.GetWearMultiplier(shield); ApplyWear(player, shield, num); } } internal void OnCollision(Player player, ItemData shield, float impactForce) { } internal void OnDamage(Player player, ItemData shield, float damage) { if (ConfigManager.EnableDurabilityLoss.Value && shield != null && !(damage <= 0f)) { float num = damage * ConfigManager.DamageToDurabilityMultiplier.Value; num *= ShieldSpeedRegistry.GetWearMultiplier(shield); num = Mathf.Min(num, shield.GetMaxDurability() * 0.08f); ApplyWear(player, shield, num); } } private void ApplyWear(Player player, ItemData shield, float wear) { if (!(wear <= 0f)) { float num = shield.GetMaxDurability() * 0.05f; if (num > 0f) { wear = Mathf.Min(wear, num); } shield.m_durability -= wear; if (shield.m_durability <= 0f) { shield.m_durability = 0f; ((Humanoid)player).UnequipItem(shield, true); ShieldSledController.Instance?.EndSledding(player, SledEndReason.ShieldBroken); } } } } internal sealed class EffectController { private readonly Dictionary _remoteParticles = new Dictionary(); private ParticleSystem _localParticles; private float _shakeTimer; private float _shakeStrength; private Vector3 _shakeOffset; private float _fovOffset; private float _fovSpeedRatio; private float _tilt; private static Material _sharedParticleMaterial; private static Texture2D _sharedParticleTexture; internal static EffectController Instance { get; private set; } internal float CurrentFovOffset => _fovOffset; internal EffectController() { Instance = this; } internal static void Prewarm() { if (!Utility.IsDedicatedServer()) { EnsureSharedParticleMaterial(); } } internal void Begin(Player player) { EnsureLocalParticles(player); if ((Object)(object)_localParticles != (Object)null && !_localParticles.isPlaying) { _localParticles.Stop(true, (ParticleSystemStopBehavior)0); } } internal void End(Player player) { CleanupForPlayer(player); ClearCameraEffects(); } internal void CleanupOrphans() { if ((Object)(object)_localParticles != (Object)null) { Object.Destroy((Object)(object)((Component)_localParticles).gameObject); _localParticles = null; } } internal void CleanupForPlayer(Player player) { if (!((Object)(object)player == (Object)null)) { if ((Object)(object)_localParticles != (Object)null) { _localParticles.Stop(true, (ParticleSystemStopBehavior)0); } ClearCameraEffects(); } } internal void Update(Player player, float speed, float steerX) { if (!((Object)(object)player == (Object)null) && !Utility.IsDedicatedServer()) { UpdateParticles(player, speed); if (!ConfigManager.EnableCameraEffects.Value) { ClearCameraEffects(); UpdateRemoteEffects(); } else { UpdateCamera(player, speed, steerX); UpdateRemoteEffects(); } } } private void UpdateParticles(Player player, float speed) { if (!ConfigManager.EnableParticles.Value) { if ((Object)(object)_localParticles != (Object)null) { _localParticles.Stop(true, (ParticleSystemStopBehavior)1); } } else if (speed > 1f) { EnsureLocalParticles(player); if ((Object)(object)_localParticles != (Object)null && !_localParticles.isPlaying) { _localParticles.Play(); } } else if ((Object)(object)_localParticles != (Object)null) { _localParticles.Stop(true, (ParticleSystemStopBehavior)1); } } internal void OnLanding(Player player, float impact) { if (Utility.IsLocalPlayer(player)) { ShakeCamera(impact * ConfigManager.CameraShakeStrength.Value * 0.02f); } } internal void OnCollision(Player player, Vector3 point, Vector3 normal, float impact) { //IL_0039: 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_004a: Unknown result type (might be due to invalid IL or missing references) if (Utility.IsLocalPlayer(player)) { ShakeCamera(impact * ConfigManager.CameraShakeStrength.Value * 0.03f); } if (ConfigManager.EnableShieldSparks.Value && ConfigManager.EnableParticles.Value) { SpawnBurst(point, normal, new Color(1f, 0.7f, 0.2f), 12); } } internal void OnRemoteCollision(Vector3 point, Vector3 normal, float impact) { //IL_0028: 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_0039: Unknown result type (might be due to invalid IL or missing references) if (!(impact < 1f) && !Utility.IsDedicatedServer() && ConfigManager.EnableShieldSparks.Value && ConfigManager.EnableParticles.Value) { SpawnBurst(point, normal, new Color(1f, 0.7f, 0.2f), 12); } } internal void OnWildlifeImpact(Player player, Vector3 point, Vector3 direction, float impact) { //IL_0039: 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_004a: Unknown result type (might be due to invalid IL or missing references) if (Utility.IsLocalPlayer(player)) { ShakeCamera(impact * ConfigManager.CameraShakeStrength.Value * 0.04f); } if (ConfigManager.EnableShieldSparks.Value && ConfigManager.EnableParticles.Value) { SpawnBurst(point, direction, new Color(1f, 0.7f, 0.2f), 18); } } internal void ShakeCamera(float strength) { if (ConfigManager.EnableCameraEffects.Value && !(strength <= 0f) && !Utility.IsDedicatedServer() && !((Object)(object)Player.m_localPlayer == (Object)null)) { _shakeStrength = Mathf.Max(_shakeStrength, strength); _shakeTimer = 0.25f; } } private void EnsureLocalParticles(Player player) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0177: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: 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_01c6: 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: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0215: 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_0224: 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_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0264: 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_007f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_localParticles != (Object)null) { Transform feetAttach = ShieldSledVisual.GetFeetAttach(player); Transform val = (((Object)(object)feetAttach != (Object)null) ? feetAttach : ((Component)player).transform); if ((Object)(object)((Component)_localParticles).transform.parent != (Object)(object)val) { ((Component)_localParticles).transform.SetParent(val, false); ((Component)_localParticles).transform.localPosition = (Vector3)(((Object)(object)feetAttach != (Object)null) ? Vector3.zero : new Vector3(0f, 0.1f, 0.4f)); } return; } Transform feetAttach2 = ShieldSledVisual.GetFeetAttach(player); GameObject val2 = new GameObject("ShieldSledding_LocalParticles"); val2.transform.SetParent(((Object)(object)feetAttach2 != (Object)null) ? feetAttach2 : ((Component)player).transform, false); val2.transform.localPosition = (Vector3)(((Object)(object)feetAttach2 != (Object)null) ? Vector3.zero : new Vector3(0f, 0.1f, 0.4f)); _localParticles = val2.AddComponent(); MainModule main = _localParticles.main; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.45f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(1.5f); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.08f); ((MainModule)(ref main)).maxParticles = 48; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.92f, 0.96f, 1f, 0.65f)); EmissionModule emission = _localParticles.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(18f); ShapeModule shape = _localParticles.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4; ((ShapeModule)(ref shape)).angle = 14f; ((ShapeModule)(ref shape)).radius = 0.15f; ColorOverLifetimeModule colorOverLifetime = _localParticles.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val3 = new Gradient(); val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(new Color(0.95f, 0.98f, 1f), 0f), new GradientColorKey(new Color(0.75f, 0.88f, 1f), 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(0.65f, 0f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3); ApplyParticleMaterial(_localParticles); _localParticles.Stop(true, (ParticleSystemStopBehavior)0); } private static Shader FindParticleShader() { string[] array = new string[7] { "Legacy Shaders/Particles/Alpha Blended", "Particles/Standard Unlit", "Mobile/Particles/Alpha Blended", "Particles/Additive", "Mobile/Particles/Additive", "Sprites/Default", "Unlit/Transparent" }; for (int i = 0; i < array.Length; i++) { Shader val = Shader.Find(array[i]); if ((Object)(object)val != (Object)null) { return val; } } return null; } private static Texture2D CreateSoftParticleTexture() { //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_0016: 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_0025: Expected O, but got Unknown //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) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false) { name = "ShieldSledding_SoftParticle", wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; float num = 31.5f; float num2 = num; Color[] array = (Color[])(object)new Color[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num3 = ((float)j - num) / num2; float num4 = ((float)i - num) / num2; float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4); float num6 = ((num5 >= 1f) ? 0f : Mathf.Pow(1f - num5, 1.65f)); array[i * 64 + j] = new Color(1f, 1f, 1f, num6); } } val.SetPixels(array); val.Apply(false, true); return val; } private static Material EnsureSharedParticleMaterial() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_00a3: 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_00bc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_sharedParticleMaterial != (Object)null) { return _sharedParticleMaterial; } Shader val = FindParticleShader(); if ((Object)(object)val == (Object)null) { return null; } if ((Object)(object)_sharedParticleTexture == (Object)null) { _sharedParticleTexture = CreateSoftParticleTexture(); } Color val2 = default(Color); ((Color)(ref val2))..ctor(0.92f, 0.96f, 1f, 0.55f); Material val3 = new Material(val); ((Object)val3).name = "ShieldSledding_ParticleMat"; val3.mainTexture = (Texture)(object)_sharedParticleTexture; if (val3.HasProperty("_MainTex")) { val3.SetTexture("_MainTex", (Texture)(object)_sharedParticleTexture); } if (val3.HasProperty("_Color")) { val3.SetColor("_Color", val2); } if (val3.HasProperty("_TintColor")) { val3.SetColor("_TintColor", val2); } val3.color = val2; if (val3.HasProperty("_Mode")) { val3.SetFloat("_Mode", 2f); } val3.SetInt("_SrcBlend", 5); val3.SetInt("_DstBlend", 10); val3.SetInt("_ZWrite", 0); val3.DisableKeyword("_ALPHATEST_ON"); val3.EnableKeyword("_ALPHABLEND_ON"); val3.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val3.renderQueue = 3000; _sharedParticleMaterial = val3; return _sharedParticleMaterial; } private static void ApplyParticleMaterial(ParticleSystem particles) { if ((Object)(object)particles == (Object)null) { return; } ParticleSystemRenderer component = ((Component)particles).GetComponent(); if (!((Object)(object)component == (Object)null)) { Material val = EnsureSharedParticleMaterial(); if (!((Object)(object)val == (Object)null)) { component.renderMode = (ParticleSystemRenderMode)0; ((Renderer)component).sharedMaterial = val; } } } private void UpdateCamera(Player player, float speed, float steerX) { //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)GameCamera.instance?.m_camera == (Object)null) { ClearCameraEffects(); return; } float num = 12f; if (Utility.TrySampleGround(player, out var sample)) { num = Mathf.Max(6f, ShieldSpeedRegistry.EstimateNaturalSpeed(in sample)); } float num2 = Mathf.Clamp01(speed / Mathf.Max(0.01f, num)); float deltaTime = Time.deltaTime; float num3 = ((num2 >= _fovSpeedRatio) ? 12f : 2.2f); _fovSpeedRatio = Mathf.Lerp(_fovSpeedRatio, num2, 1f - Mathf.Exp((0f - num3) * deltaTime)); _fovOffset = _fovSpeedRatio * ConfigManager.SpeedFovIncrease.Value; float num4 = (0f - steerX) * ConfigManager.CameraTiltStrength.Value; _tilt = Mathf.Lerp(_tilt, num4, Time.deltaTime * 6f); if (_shakeTimer > 0f) { _shakeTimer -= Time.deltaTime; _shakeOffset = Random.insideUnitSphere * _shakeStrength; if (_shakeTimer <= 0f) { _shakeStrength = 0f; _shakeOffset = Vector3.zero; } } else { _shakeOffset = Vector3.zero; } } internal static void ApplyCameraAfterGameCamera(GameCamera gameCamera) { //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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) EffectController instance = Instance; if (instance == null || (Object)(object)gameCamera == (Object)null || !ConfigManager.EnableCameraEffects.Value) { return; } float fovOffset = instance._fovOffset; if (fovOffset > 0.001f) { if ((Object)(object)gameCamera.m_camera != (Object)null) { Camera camera = gameCamera.m_camera; camera.fieldOfView += fovOffset; } if ((Object)(object)gameCamera.m_skyCamera != (Object)null) { Camera skyCamera = gameCamera.m_skyCamera; skyCamera.fieldOfView += fovOffset; } } float tilt = instance._tilt; Vector3 shakeOffset = instance._shakeOffset; bool flag = Mathf.Abs(tilt) > 0.001f; bool flag2 = ((Vector3)(ref shakeOffset)).sqrMagnitude > 1E-07f; if (flag || flag2) { ApplyTiltAndShake(((Component)gameCamera).transform, tilt, shakeOffset, flag, flag2); if ((Object)(object)gameCamera.m_camera != (Object)null && (Object)(object)((Component)gameCamera.m_camera).transform != (Object)(object)((Component)gameCamera).transform) { ApplyTiltAndShake(((Component)gameCamera.m_camera).transform, tilt, shakeOffset, flag, flag2); } if ((Object)(object)gameCamera.m_skyCamera != (Object)null) { ApplyTiltAndShake(((Component)gameCamera.m_skyCamera).transform, tilt, shakeOffset, flag, flag2); } } } private static void ApplyTiltAndShake(Transform transform, float tilt, Vector3 shake, bool hasTilt, bool hasShake) { //IL_000f: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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) if (!((Object)(object)transform == (Object)null)) { if (hasTilt) { transform.rotation *= Quaternion.Euler(0f, 0f, tilt); } if (hasShake) { transform.position += shake; } } } private void ClearCameraEffects() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) _fovOffset = 0f; _fovSpeedRatio = 0f; _tilt = 0f; _shakeTimer = 0f; _shakeStrength = 0f; _shakeOffset = Vector3.zero; } private void UpdateRemoteEffects() { List allPlayers = Player.GetAllPlayers(); if (allPlayers == null) { return; } for (int i = 0; i < allPlayers.Count; i++) { Player val = allPlayers[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)Player.m_localPlayer)) { if (!MultiplayerSync.Instance.TryReadRemoteState(val, out var active, out var speed, out var _)) { StopRemote(val); } else if (!active || speed < 1f || !ConfigManager.EnableParticles.Value) { StopRemote(val); } else { EnsureRemoteParticles(val); } } } } private void EnsureRemoteParticles(Player player) { //IL_001b: 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_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_0058: 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_0065: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) int instanceID = ((Object)player).GetInstanceID(); if (!_remoteParticles.ContainsKey(instanceID)) { GameObject val = new GameObject("ShieldSledding_RemoteParticles"); val.transform.SetParent(((Component)player).transform, false); val.transform.localPosition = new Vector3(0f, 0.1f, 0.4f); ParticleSystem val2 = val.AddComponent(); MainModule main = val2.main; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.4f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(1.2f); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.08f); ((MainModule)(ref main)).maxParticles = 24; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.95f, 0.98f, 1f, 0.5f)); ApplyParticleMaterial(val2); val2.Play(); _remoteParticles[instanceID] = val2; } } private void StopRemote(Player player) { int instanceID = ((Object)player).GetInstanceID(); if (_remoteParticles.TryGetValue(instanceID, out var value) && (Object)(object)value != (Object)null) { value.Stop(true, (ParticleSystemStopBehavior)1); } } private static void SpawnBurst(Vector3 point, Vector3 normal, Color color, int count) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0019: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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) if (!Utility.IsDedicatedServer()) { GameObject val = new GameObject("ShieldSledding_SparkBurst"); val.transform.position = point; if (((Vector3)(ref normal)).sqrMagnitude > 0.01f) { val.transform.rotation = Quaternion.LookRotation(((Vector3)(ref normal)).normalized); } ParticleSystem val2 = val.AddComponent(); MainModule main = val2.main; ((MainModule)(ref main)).duration = 0.2f; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.35f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(2.5f); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.06f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(color); ((MainModule)(ref main)).maxParticles = count; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1] { new Burst(0f, (short)count) }); ShapeModule shape = val2.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4; ((ShapeModule)(ref shape)).angle = 35f; ((ShapeModule)(ref shape)).radius = 0.05f; ApplyParticleMaterial(val2); val2.Play(); Object.Destroy((Object)(object)val, 1.25f); } } } internal sealed class MultiplayerSync { private struct RemoteSledState { internal bool Active; internal float Speed; internal string ShieldPrefab; } internal const string ImpactRpc = "ShieldSledding_Impact"; internal const string StateRpc = "ShieldSledding_State"; private static readonly int ZdoActive = StringExtensionMethods.GetStableHashCode("SS_Active"); private static readonly int ZdoShieldPrefab = StringExtensionMethods.GetStableHashCode("SS_ShieldPrefab"); private static readonly int ZdoSpeed = StringExtensionMethods.GetStableHashCode("SS_Speed"); private readonly HashSet _registeredViews = new HashSet(); private readonly Dictionary _remoteStates = new Dictionary(); private float _lastWriteTime; private bool _lastActive; private float _lastSpeed; private string _lastShield = string.Empty; internal static MultiplayerSync Instance { get; private set; } internal MultiplayerSync() { Instance = this; } internal static void EnsureRegistered(ZNetView nview) { if ((Object)(object)nview == (Object)null || !nview.IsValid()) { return; } MultiplayerSync sync = Instance; if (sync == null) { return; } int id = ((Object)nview).GetInstanceID(); if (!sync._registeredViews.Add(id)) { return; } nview.Register("ShieldSledding_Impact", (Action)delegate(long sender, Vector3 point, float impact) { //IL_001d: 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) if (!(impact < 1f) && sender != ZNet.GetUID()) { EffectController.Instance?.OnRemoteCollision(point, Vector3.up, impact); AudioController.Instance?.PlayImpact(Player.m_localPlayer, impact); } }); nview.Register("ShieldSledding_State", (Action)delegate(long sender, bool active, float speed, string shieldPrefab) { if (sender != ZNet.GetUID()) { sync._remoteStates[id] = new RemoteSledState { Active = active, Speed = speed, ShieldPrefab = (shieldPrefab ?? string.Empty) }; } }); } internal void WriteLocalState(Player player, bool active, float speed) { if ((Object)(object)player == (Object)null || !Utility.IsLocalPlayer(player)) { return; } ZDO playerZdo = Utility.GetPlayerZdo(player); if (playerZdo == null) { return; } string text = string.Empty; ItemData val = Utility.GetEquippedShield(player); if (val == null) { val = ShieldSledController.Instance?.LockedShield; } if (val != null) { text = Utility.GetShieldPrefabName(val); } if ((active && Time.time - _lastWriteTime >= 1f) || active != _lastActive || !Mathf.Approximately(speed, _lastSpeed) || !(text == _lastShield) || !(Time.time - _lastWriteTime < 0.1f)) { playerZdo.Set(ZdoActive, active ? 1 : 0, false); playerZdo.Set(ZdoSpeed, speed); if (!string.IsNullOrEmpty(text)) { playerZdo.Set(ZdoShieldPrefab, text); } else if (!active) { playerZdo.Set(ZdoShieldPrefab, string.Empty); } _lastActive = active; _lastSpeed = speed; _lastShield = text; _lastWriteTime = Time.time; BroadcastLocalState(player, active, speed, text); } } private static void BroadcastLocalState(Player player, bool active, float speed, string shield) { ZNetView component = ((Component)player).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { EnsureRegistered(component); component.InvokeRPC(ZNetView.Everybody, "ShieldSledding_State", new object[3] { active, speed, shield ?? string.Empty }); } } internal bool TryReadRemoteState(Player player, out bool active, out float speed, out string shieldPrefab) { active = false; speed = 0f; shieldPrefab = string.Empty; if ((Object)(object)player == (Object)null) { return false; } ZNetView component = ((Component)player).GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid()) { EnsureRegistered(component); if (_remoteStates.TryGetValue(((Object)component).GetInstanceID(), out var value)) { active = value.Active; speed = value.Speed; shieldPrefab = value.ShieldPrefab ?? string.Empty; return true; } } ZDO playerZdo = Utility.GetPlayerZdo(player); if (playerZdo == null) { return false; } active = playerZdo.GetInt(ZdoActive, 0) != 0; speed = playerZdo.GetFloat(ZdoSpeed, 0f); shieldPrefab = playerZdo.GetString(ZdoShieldPrefab, string.Empty); return true; } internal void ClearRemoteState(ZNetView nview) { if (!((Object)(object)nview == (Object)null)) { int instanceID = ((Object)nview).GetInstanceID(); _remoteStates.Remove(instanceID); _registeredViews.Remove(instanceID); } } internal void UpdateRemotePlayers() { List allPlayers = Player.GetAllPlayers(); if (allPlayers == null) { return; } for (int i = 0; i < allPlayers.Count; i++) { Player val = allPlayers[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)Player.m_localPlayer)) { EnsureRegistered(((Component)val).GetComponent()); } } ShieldSledVisual.UpdateRemotePlayers(); } internal void SendImpactEvent(Player player, Vector3 point, float impact) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null)) { ZNetView component = ((Component)player).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { EnsureRegistered(component); component.InvokeRPC(ZNetView.Everybody, "ShieldSledding_Impact", new object[2] { point, impact }); } } } } internal struct SledRunRecord { public float Distance; public float MaxSpeed; public float LongestJump; public string TimestampUtc; } internal struct GhostFrame { public Vector3 Position; public Quaternion Rotation; public float Time; } internal static class GhostReplaySystem { private static readonly List Frames = new List(); private static GameObject _ghost; private static float _sessionStart; internal static void BeginSession() { Frames.Clear(); _sessionStart = Time.time; DestroyGhost(); } internal static void RecordFrame(Player player) { } internal static void EndSession() { Frames.Clear(); DestroyGhost(); } private static void SpawnGhostPlayback() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown DestroyGhost(); _ghost = new GameObject("ShieldSledding_Ghost"); _ghost.AddComponent().Initialize(Frames.ToArray()); } private static void DestroyGhost() { if ((Object)(object)_ghost != (Object)null) { Object.Destroy((Object)(object)_ghost); _ghost = null; } } } internal sealed class GhostPlayback : MonoBehaviour { private GhostFrame[] _frames; private int _index; private float _startTime; internal void Initialize(GhostFrame[] frames) { _frames = frames; _index = 0; _startTime = Time.time; TryCreateGhostVisual(((Component)this).transform); } private static void TryCreateGhostVisual(Transform parent) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_00b3: 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) Shader val = FindGhostShader(); if ((Object)(object)val == (Object)null) { return; } GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)1); val2.transform.SetParent(parent, false); val2.transform.localScale = new Vector3(0.5f, 0.9f, 0.5f); Collider component = val2.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Renderer component2 = val2.GetComponent(); if ((Object)(object)component2 == (Object)null) { Object.Destroy((Object)(object)val2); return; } Material val3 = new Material(val); Color val4 = default(Color); ((Color)(ref val4))..ctor(0.4f, 0.8f, 1f, 0.35f); if (val3.HasProperty("_Color")) { val3.SetColor("_Color", val4); } else { val3.color = val4; } component2.material = val3; } private static Shader FindGhostShader() { string[] array = new string[4] { "Custom/StandardClear", "Custom/StandardDoubleSided", "Unlit/Color", "Sprites/Default" }; for (int i = 0; i < array.Length; i++) { Shader val = Shader.Find(array[i]); if ((Object)(object)val != (Object)null) { return val; } } return null; } private void Update() { //IL_0080: 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) if (_frames == null || _frames.Length == 0) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } float num = Time.time - _startTime; while (_index < _frames.Length - 1 && _frames[_index + 1].Time <= num) { _index++; } GhostFrame ghostFrame = _frames[_index]; ((Component)this).transform.SetPositionAndRotation(ghostFrame.Position, ghostFrame.Rotation); if (_index >= _frames.Length - 1 && num > _frames[_frames.Length - 1].Time + 1f) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } internal static class RecordsManager { private static string FilePath => Path.Combine(Paths.ConfigPath, "ShieldSledding_Records.json"); internal static void SaveRun(SledRunRecord record) { List list = new List(); if (File.Exists(FilePath)) { list.AddRange(File.ReadAllLines(FilePath)); } list.Add($"{record.TimestampUtc}|{record.Distance:F2}|{record.MaxSpeed:F2}|{record.LongestJump:F2}"); if (list.Count > 200) { list.RemoveAt(0); } File.WriteAllLines(FilePath, list); } } internal static class LeaderboardManager { private static readonly List Entries = new List(); private static string FilePath => Path.Combine(Paths.ConfigPath, "ShieldSledding_Leaderboard.json"); internal static void Submit(SledRunRecord record) { Entries.Add(record); Entries.Sort((SledRunRecord a, SledRunRecord b) => b.MaxSpeed.CompareTo(a.MaxSpeed)); if (Entries.Count > 25) { Entries.RemoveAt(Entries.Count - 1); } List list = new List(Entries.Count); for (int num = 0; num < Entries.Count; num++) { SledRunRecord sledRunRecord = Entries[num]; list.Add($"{sledRunRecord.TimestampUtc}|{sledRunRecord.Distance:F2}|{sledRunRecord.MaxSpeed:F2}|{sledRunRecord.LongestJump:F2}"); } File.WriteAllLines(FilePath, list); } } internal static class TimeTrialManager { private static float _startTime; private static bool _active; internal static void BeginSession() { } internal static void EndSession() { } } internal static class SledPatches { internal static bool UpdateMotionPatched; internal static void Apply(Harmony harmony) { PatchMethod(harmony, typeof(Character), "Jump", "CharacterJumpPrefix", "CharacterJumpPostfix"); PatchMethod(harmony, typeof(Player), "SetControls", "PlayerSetControlsPrefix"); PatchMethod(harmony, typeof(Humanoid), "UpdateBlock", "HumanoidUpdateBlockPrefix"); PatchMethod(harmony, typeof(Humanoid), "EquipItem", "HumanoidEquipItemPrefix"); PatchMethod(harmony, typeof(Humanoid), "UnequipItem", "HumanoidUnequipItemPrefix"); PatchMethod(harmony, typeof(Character), "UpdateMotion", "CharacterUpdateMotionPrefix", null, new Type[1] { typeof(float) }); PatchDeclaredMethod(harmony, typeof(Character), "Damage", "CharacterDamagePrefix", null, new Type[1] { typeof(HitData) }); PatchAllDeclaredMethods(harmony, typeof(Character), "RPC_Damage", "CharacterRpcDamagePrefix"); PatchMethod(harmony, typeof(Character), "UpdateGroundContact", "CharacterUpdateGroundContactPrefix", "CharacterUpdateGroundContactPostfix"); PatchMethod(harmony, typeof(Character), "UpdateWater", "CharacterUpdateWaterPrefix"); PatchMethod(harmony, typeof(Character), "UnderWorldCheck", "CharacterUnderWorldCheckPrefix", null, new Type[1] { typeof(float) }); PatchMethod(harmony, typeof(VisEquipment), "UpdateEquipmentVisuals", "VisEquipmentUpdateEquipmentVisualsPrefix", "VisEquipmentUpdateEquipmentPostfix"); PatchMethod(harmony, typeof(ZNetView), "OnDestroy", "ZNetViewOnDestroyPrefix"); PatchMethod(harmony, typeof(GameCamera), "UpdateCamera", null, "GameCameraUpdateCameraPostfix", new Type[1] { typeof(float) }); } private static void GameCameraUpdateCameraPostfix(GameCamera __instance) { EffectController.ApplyCameraAfterGameCamera(__instance); } private static void PatchMethod(Harmony harmony, Type type, string methodName, string prefix = null, string postfix = null, Type[] argTypes = null) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) MethodInfo methodInfo = ((argTypes == null) ? AccessTools.Method(type, methodName, (Type[])null, (Type[])null) : AccessTools.Method(type, methodName, argTypes, (Type[])null)); if (methodInfo == null) { Plugin.Log.LogError((object)("Shield Sledding: could not patch " + type.Name + "." + methodName)); return; } if (type == typeof(Character) && methodName == "UpdateMotion") { UpdateMotionPatched = true; } harmony.Patch((MethodBase)methodInfo, (prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(SledPatches), prefix, (Type[])null), (postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(SledPatches), postfix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Plugin.Log.LogInfo((object)("Shield Sledding: patched " + type.Name + "." + methodName)); } private static void PatchDeclaredMethod(Harmony harmony, Type type, string methodName, string prefix = null, string postfix = null, Type[] argTypes = null) { //IL_0058: 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) MethodInfo methodInfo = ((argTypes == null) ? AccessTools.DeclaredMethod(type, methodName, (Type[])null, (Type[])null) : AccessTools.DeclaredMethod(type, methodName, argTypes, (Type[])null)); if (methodInfo == null) { Plugin.Log.LogError((object)("Shield Sledding: could not patch declared " + type.Name + "." + methodName)); return; } harmony.Patch((MethodBase)methodInfo, (prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(SledPatches), prefix, (Type[])null), (postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(SledPatches), postfix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Plugin.Log.LogInfo((object)("Shield Sledding: patched declared " + type.Name + "." + methodName)); } private static void PatchAllDeclaredMethods(Harmony harmony, Type type, string methodName, string prefix = null) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) int num = 0; foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(type)) { if (!(declaredMethod.Name != methodName)) { harmony.Patch((MethodBase)declaredMethod, (prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(SledPatches), prefix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ParameterInfo[] parameters = declaredMethod.GetParameters(); string text = ((parameters.Length == 0) ? string.Empty : string.Join(", ", Array.ConvertAll(parameters, (ParameterInfo p) => p.ParameterType.Name))); Plugin.Log.LogInfo((object)("Shield Sledding: patched declared " + type.Name + "." + methodName + "(" + text + ")")); num++; } } if (num == 0) { Plugin.Log.LogInfo((object)("Shield Sledding: skipped optional patch " + type.Name + "." + methodName + " (no matching methods).")); } } private static bool CharacterJumpPrefix(Character __instance) { if (!Utility.IsLocalPlayer((Player)(object)((__instance is Player) ? __instance : null))) { return true; } ShieldSledController instance = ShieldSledController.Instance; if (instance == null || !instance.IsSledding) { return true; } return false; } private static void CharacterJumpPostfix(Character __instance) { if (Utility.IsLocalPlayer((Player)(object)((__instance is Player) ? __instance : null))) { ShieldSledController.Instance?.NotifyJump(); } } private static void PlayerSetControlsPrefix(Player __instance, ref Vector3 movedir, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, ref bool block, ref bool blockHold, ref bool jump, ref bool crouch, ref bool run, ref bool autoRun, ref bool dodge, ref Vector3 ___m_moveDir) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (Utility.IsLocalPlayer(__instance)) { ShieldSledController instance = ShieldSledController.Instance; if (((instance != null) & jump) && !instance.IsSledding) { instance.NotifyJumpIntentFromInput(); } if (instance != null && instance.TryOverrideControls(__instance, ref movedir, ref block, ref jump, ref run)) { ___m_moveDir = Vector3.zero; movedir = Vector3.zero; attack = false; attackHold = false; secondaryAttack = false; secondaryAttackHold = false; blockHold = false; dodge = false; autoRun = false; crouch = false; } } } private static bool HumanoidUpdateBlockPrefix(Humanoid __instance) { if (!Utility.IsLocalPlayer((Player)(object)((__instance is Player) ? __instance : null))) { return true; } if (ShieldSledController.Instance != null) { return !ShieldSledController.Instance.IsSledding; } return true; } private static bool HumanoidEquipItemPrefix(Humanoid __instance, ItemData item) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 if (!Utility.IsLocalPlayer((Player)(object)((__instance is Player) ? __instance : null))) { return true; } ShieldSledController instance = ShieldSledController.Instance; if (instance == null || !instance.IsSledding) { return true; } ItemData lockedShield = instance.LockedShield; if (lockedShield == null || item == null) { return true; } SharedData shared = item.m_shared; if (shared != null && (int)shared.m_itemType == 5 && item != lockedShield) { return false; } return true; } private static bool HumanoidUnequipItemPrefix(Humanoid __instance, ItemData item) { if (!Utility.IsLocalPlayer((Player)(object)((__instance is Player) ? __instance : null))) { return true; } ShieldSledController instance = ShieldSledController.Instance; if (instance == null || !instance.IsSledding) { return true; } if (item != null && item == instance.LockedShield) { return false; } return true; } private static bool CharacterUpdateMotionPrefix(Character __instance, float dt) { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_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) Player val = (Player)(object)((__instance is Player) ? __instance : null); if (!Utility.IsLocalPlayer(val)) { return true; } ShieldSledController instance = ShieldSledController.Instance; if (instance == null) { return true; } if (instance.IsArmed && !instance.IsSledding) { instance.TrackArmedMomentum(val); if (!instance.TryActivateOnLanding(val)) { return true; } } if (instance.IsSledding) { instance.ApplySledPhysics(val, dt); GroundSample ground; bool flag = Utility.TryGetSledGround(val, out ground); if (flag && ((Vector3)(ref ((Character)val).m_lastGroundNormal)).sqrMagnitude > 0.01f) { ground.Normal = ((Character)val).m_lastGroundNormal; ground.Point = ((Character)val).m_lastGroundPoint; ground.Collider = ((Character)val).m_lastGroundCollider; ground.SlopeAngle = Vector3.Angle(ground.Normal, Vector3.up); ground.SlopeDown = Vector3.ProjectOnPlane(Vector3.down, ground.Normal); if (((Vector3)(ref ground.SlopeDown)).sqrMagnitude > 0.0001f) { ((Vector3)(ref ground.SlopeDown)).Normalize(); } } if (!ground.IsWaterSurface) { SledGroundSolver.FixGroundClip(val); } SledGroundSolver.SyncCharacterMotionState(__instance, instance.SimulatedVelocity, flag); return false; } return true; } private static bool VisEquipmentUpdateEquipmentVisualsPrefix(VisEquipment __instance) { if (!Utility.IsLocalPlayer(((Component)__instance).GetComponent())) { return true; } ShieldSledController instance = ShieldSledController.Instance; if (instance != null) { return !instance.IsShieldSledActive; } return true; } private static void VisEquipmentUpdateEquipmentPostfix(VisEquipment __instance) { Player component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null) { return; } bool active = default(bool); float speed; string shieldPrefab; if (Utility.IsLocalPlayer(component)) { ShieldSledController instance = ShieldSledController.Instance; if (instance != null && instance.IsShieldSledActive) { ShieldSledVisual.LateUpdate(component); } } else if (MultiplayerSync.Instance != null && MultiplayerSync.Instance.TryReadRemoteState(component, out active, out speed, out shieldPrefab) && active) { ShieldSledVisual.LateUpdate(component); } } private static bool CharacterUpdateGroundContactPrefix(Character __instance, ref float ___m_maxAirAltitude) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00d3: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_0119: 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) Player player = (Player)(object)((__instance is Player) ? __instance : null); if (!Utility.IsLocalPlayer(player)) { return true; } ShieldSledController instance = ShieldSledController.Instance; if (instance == null || !instance.IsSledding) { if (instance != null && instance.IsShieldSledActive && ConfigManager.AbsorbDamageToShield.Value) { ___m_maxAirAltitude = ((Component)__instance).transform.position.y; } return true; } if (ConfigManager.AbsorbDamageToShield.Value) { ___m_maxAirAltitude = ((Component)__instance).transform.position.y; } if (Utility.TryGetSledGround(player, out var ground)) { if (ground.IsWaterSurface) { __instance.m_groundContact = true; __instance.m_lastGroundPoint = ground.Point; __instance.m_lastGroundNormal = Vector3.up; __instance.m_lastGroundCollider = null; } else { bool groundContact = !Utility.IsSeparatingFromGround(instance.SimulatedVelocity, in ground); __instance.m_groundContact = groundContact; __instance.m_lastGroundPoint = ground.Point; Vector3 lastGroundNormal = __instance.m_lastGroundNormal; if (((Vector3)(ref lastGroundNormal)).sqrMagnitude > 0.01f && Vector3.Angle(lastGroundNormal, ground.Normal) < 28f) { Vector3 val = Vector3.Slerp(lastGroundNormal, ground.Normal, 0.35f); __instance.m_lastGroundNormal = ((Vector3)(ref val)).normalized; } else { __instance.m_lastGroundNormal = ground.Normal; } __instance.m_lastGroundCollider = ground.Collider; } } return false; } private static void CharacterUpdateGroundContactPostfix(Character __instance) { Player player = (Player)(object)((__instance is Player) ? __instance : null); if (Utility.IsLocalPlayer(player)) { ShieldSledController instance = ShieldSledController.Instance; if (instance != null && !instance.IsSledding && instance.IsArmed && __instance.m_groundContact) { instance.TrackArmedMomentum(player); instance.TryActivateOnLanding(player); } } } private static bool CharacterUpdateWaterPrefix(Character __instance) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (!Utility.IsLocalPlayer(val)) { return true; } ShieldSledController instance = ShieldSledController.Instance; if (instance == null || !instance.IsSledding) { return true; } if (WaterSledHelper.IsWaterSledding(val, instance.CurrentSpeed)) { ((Character)val).m_swimTimer = 1f; return false; } return true; } private static bool CharacterUnderWorldCheckPrefix(Character __instance) { Player player = (Player)(object)((__instance is Player) ? __instance : null); if (!Utility.IsLocalPlayer(player)) { return true; } ShieldSledController instance = ShieldSledController.Instance; if (instance != null && instance.IsSledding) { SledGroundSolver.RescueUnderWorld(player); return false; } return true; } private static bool CharacterDamagePrefix(Character __instance, HitData hit) { if (DamageAbsorption.TryAbsorb(__instance, hit)) { return false; } return true; } private static bool CharacterRpcDamagePrefix(Character __instance, object[] __args) { HitData val = FindHitData(__args); if (val == null) { return true; } if (DamageAbsorption.TryAbsorb(__instance, val)) { return false; } return true; } private static HitData FindHitData(object[] args) { if (args == null) { return null; } foreach (object obj in args) { HitData val = (HitData)((obj is HitData) ? obj : null); if (val != null) { return val; } } return null; } private static void ZNetViewOnDestroyPrefix(ZNetView __instance) { Player component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null)) { MultiplayerSync.Instance?.ClearRemoteState(__instance); ShieldSledVisual.OnPlayerDestroyed(component); EffectController.Instance?.CleanupForPlayer(component); if (__instance.IsOwner()) { ShieldSledController.Instance?.EndSledding(component, SledEndReason.Manual); } } } } internal struct PhysicsResult { public float HorizontalSpeed; public float LandingImpact; public bool OnGround; public GroundSample Ground; public Vector3 Velocity; } internal sealed class PhysicsController { private const float ReferenceGravity = 9.81f; private static PhysicsMaterial _frictionlessMaterial; private Vector3 _lastVelocity; private bool _wasAirborne; private bool _bodyTuned; private bool _savedUseGravity; private bool _savedIsKinematic; private float _savedDrag; private float _savedAngularDrag; private bool _savedDetectCollisions; private float _jumpCooldownUntil; private float _airborneGraceUntil; private float _sledStartGraceUntil; private float _sledStartDuration = 0.65f; private float _entrySpeedFloor; private float _entrySpeedFloorUntil; private bool _dynamicStartup; private bool _preferDynamicBody; private int _kinematicDeferFrames; private Vector3 _smoothedGroundNormal = Vector3.up; private bool _hasSmoothedGround; private Vector3 _smoothedSteerDir; private bool _hasSmoothedSteer; private float _postDownhillCarryUntil; private readonly List<(Collider Collider, PhysicsMaterial Material)> _savedColliderMaterials = new List<(Collider, PhysicsMaterial)>(); internal Vector3 SimulatedVelocity => _lastVelocity; internal bool IsInStartupGrace => Time.time < _sledStartGraceUntil; internal float StartupBlend { get { if (_sledStartDuration <= 0f) { return 0f; } return Mathf.Clamp01((_sledStartGraceUntil - Time.time) / _sledStartDuration); } } static PhysicsController() { //IL_0005: 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_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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown _frictionlessMaterial = new PhysicsMaterial("ShieldSledFrictionless") { dynamicFriction = 0f, staticFriction = 0f, frictionCombine = (PhysicsMaterialCombine)2, bounceCombine = (PhysicsMaterialCombine)2, bounciness = 0f }; } internal void CaptureBodyVelocity(Player player) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) Rigidbody body = Utility.GetBody(player); if ((Object)(object)body == (Object)null) { _lastVelocity = Vector3.zero; return; } _lastVelocity = body.linearVelocity; if (((Vector3)(ref _lastVelocity)).sqrMagnitude < 0.0001f) { _lastVelocity = ((Character)player).GetVelocity(); } } internal void SetSimulatedVelocity(Player player, Vector3 velocity) { //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_000d: Unknown result type (might be due to invalid IL or missing references) _lastVelocity = velocity; Utility.TrySetLinearVelocity(Utility.GetBody(player), velocity); } internal bool TryJump(Player player) { //IL_002c: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: 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_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: 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_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0263: 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_027a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || Time.time < _jumpCooldownUntil) { return false; } if (((Character)player).InTar()) { return false; } ShieldSledController instance = ShieldSledController.Instance; float speed = instance?.CurrentSpeed ?? Utility.HorizontalSpeed(_lastVelocity); bool flag = instance != null && instance.IsSledding && WaterSledHelper.IsWaterSledding(player, speed); if (((Character)player).InWater() && !flag) { return false; } if (IsAirborneForPhysics(player)) { return false; } if (!Utility.TryGetSledGround(player, out var ground) && !Utility.TryProbeGroundBelow(player, 1.5f, out ground)) { return false; } if (Utility.GetFeetHeightAboveGround(player, ground) > 0.34f) { return false; } if (!ground.IsWaterSurface && Utility.IsSeparatingFromGround(_lastVelocity, in ground, 0.35f)) { return false; } float jumpStaminaUsage = ((Character)player).m_jumpStaminaUsage; if (jumpStaminaUsage > 0f && player.GetStamina() < jumpStaminaUsage) { return false; } if (jumpStaminaUsage > 0f) { ((Character)player).UseStamina(jumpStaminaUsage); } Vector3 val = Vector3.ProjectOnPlane(_lastVelocity, ground.Normal); Vector3 val2; if (((Vector3)(ref val)).sqrMagnitude > 0.25f) { val2 = val + ground.Normal * ((Character)player).m_jumpForce; } else { Vector3 val3 = Vector3.ProjectOnPlane(((Component)player).transform.forward, ground.Normal); if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f && ((Vector3)(ref ground.SlopeDown)).sqrMagnitude > 0.0001f) { val3 = ground.SlopeDown; } else if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { val3 = Utility.Flatten(((Component)player).transform.forward); } ((Vector3)(ref val3)).Normalize(); val2 = val3 * Mathf.Max(((Character)player).m_jumpForceForward, 1f) + ground.Normal * ((Character)player).m_jumpForce; } _lastVelocity = val2; ((Character)player).m_groundContact = false; ((Character)player).m_sliding = false; ((Character)player).m_maxAirAltitude = ((Component)player).transform.position.y; _wasAirborne = true; _airborneGraceUntil = Time.time + 0.22f; _jumpCooldownUntil = Time.time + 0.35f; if (ground.IsWaterSurface) { WaterSledHelper.ResetSurfaceSmoothing(); } SetSimulatedVelocity(player, val2); Rigidbody body = Utility.GetBody(player); if ((Object)(object)body != (Object)null && _bodyTuned && body.isKinematic) { body.MovePosition(body.position + Vector3.up * 0.12f); ((Component)player).transform.position = body.position; } return true; } internal bool IsAirborneForPhysics(Player player) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return false; } if (Time.time < _airborneGraceUntil) { return true; } if (Time.time < _sledStartGraceUntil && ((Character)player).m_groundContact) { return false; } ShieldSledController instance = ShieldSledController.Instance; if (instance != null && instance.IsSledding && WaterSledHelper.TryGetWaterSledGround(player, instance.CurrentSpeed, out var ground) && Utility.GetFeetPosition(player).y <= ground.WaterSurfaceY + 0.38f + 0.35f) { return false; } if (!Utility.TryProbeGroundBelow(player, 1.5f, out var sample)) { return true; } if (Utility.GetFeetHeightAboveGround(player, sample) > 0.38f) { return true; } return Utility.IsSeparatingFromGround(_lastVelocity, in sample); } internal void Reset(Player player) { CaptureBodyVelocity(player); _wasAirborne = false; _airborneGraceUntil = 0f; _hasSmoothedGround = false; _hasSmoothedSteer = false; _postDownhillCarryUntil = 0f; } internal void ConfigureBodyForSled(Player player) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ConfigureBodyForSled(player, Vector3.zero); } internal void ConfigureBodyForSled(Player player, Vector3 seedVelocity) { //IL_0079: 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_009d: Unknown result type (might be due to invalid IL or missing references) Rigidbody body = Utility.GetBody(player); if (!((Object)(object)body == (Object)null)) { _savedUseGravity = body.useGravity; _savedIsKinematic = body.isKinematic; _savedDrag = body.linearDamping; _savedAngularDrag = body.angularDamping; _savedDetectCollisions = body.detectCollisions; body.useGravity = false; body.linearDamping = 0f; body.angularDamping = 0f; body.detectCollisions = false; ApplyFrictionlessColliders(player); _lastVelocity = seedVelocity; if (!body.isKinematic) { _dynamicStartup = true; _preferDynamicBody = false; _kinematicDeferFrames = 1; Utility.TrySetLinearVelocity(body, seedVelocity); } else { body.isKinematic = true; _dynamicStartup = false; _preferDynamicBody = false; _kinematicDeferFrames = 0; } _bodyTuned = true; } } internal void PrewarmBodyTune(Player player) { if (!((Object)(object)player == (Object)null) && !((Object)(object)_frictionlessMaterial == (Object)null)) { CapsuleCollider collider = ((Character)player).m_collider; if (!((Object)(object)collider == (Object)null)) { PhysicsMaterial sharedMaterial = ((Collider)collider).sharedMaterial; ((Collider)collider).sharedMaterial = _frictionlessMaterial; ((Collider)collider).sharedMaterial = sharedMaterial; } } } internal Vector3 ResolveLandingSeed(Player player, in GroundSample ground, ItemData shield, Vector3 armedMomentum, float armedPeakHorizontal, bool armedLanding = false) { //IL_001f: 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_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_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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_007e: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_018b: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: 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_023d: 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_0344: 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_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) Vector3 groundNormal; Vector3 slopeDown; Vector3 best; float bestSpeed; if (!((Object)(object)player == (Object)null)) { Vector3 val = ground.Normal; if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f)) { groundNormal = ground.Normal; slopeDown = ground.SlopeDown; best = Vector3.zero; bestSpeed = 0f; Vector3 val2 = armedMomentum; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = ((Character)player).m_currentVel; } if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = ((Character)player).GetVelocity(); } Rigidbody body = Utility.GetBody(player); if ((Object)(object)body != (Object)null) { val = body.linearVelocity; if (((Vector3)(ref val)).sqrMagnitude > ((Vector3)(ref val2)).sqrMagnitude) { val2 = body.linearVelocity; } } if (((Vector3)(ref val2)).sqrMagnitude < 0.01f && (Object)(object)player != (Object)null) { Vector3 sledLookOnPlane = Utility.GetSledLookOnPlane(player, groundNormal); val2 = ((((Vector3)(ref sledLookOnPlane)).sqrMagnitude > 0.01f) ? sledLookOnPlane : ((Component)player).transform.forward); } Consider(armedMomentum); Consider(((Character)player).GetVelocity()); if ((Object)(object)body != (Object)null) { Consider(body.linearVelocity); } Consider(((Character)player).m_currentVel); ConsiderCarriedHorizontal(armedPeakHorizontal, val2); if (armedPeakHorizontal > bestSpeed + 0.05f) { Vector3 val3 = ((((Vector3)(ref best)).sqrMagnitude > 0.0001f) ? best : ((((Vector3)(ref val2)).sqrMagnitude > 0.01f) ? val2 : slopeDown)); if (((Vector3)(ref val3)).sqrMagnitude > 0.0001f) { Vector3 val4 = Vector3.ProjectOnPlane(val3, groundNormal); if (((Vector3)(ref val4)).sqrMagnitude > 0.0001f) { Consider(((Vector3)(ref val4)).normalized * armedPeakHorizontal); } } } float num = ShieldSpeedRegistry.EstimateNaturalSpeed(in ground, player, shield); if (bestSpeed < 0.12f) { if (armedLanding && (armedPeakHorizontal > 0.25f || ground.SlopeAngle >= Utility.GetActivationMinimumSlope())) { float num2 = Mathf.Max(0.75f, armedPeakHorizontal * 0.35f); if (num > 0.5f) { num2 = Mathf.Min(num2, num); } Vector3 val5 = ((((Vector3)(ref val2)).sqrMagnitude > 0.01f) ? Vector3.ProjectOnPlane(val2, groundNormal) : Vector3.zero); if (((Vector3)(ref val5)).sqrMagnitude < 0.0001f && ((Vector3)(ref slopeDown)).sqrMagnitude > 0.0001f) { val5 = slopeDown; } if (((Vector3)(ref val5)).sqrMagnitude > 0.0001f) { return ((Vector3)(ref val5)).normalized * num2; } } return Vector3.zero; } if (((Vector3)(ref slopeDown)).sqrMagnitude > 0.0001f) { float num3 = Vector3.Dot(((Vector3)(ref best)).normalized, ((Vector3)(ref slopeDown)).normalized); if (num3 < -0.35f) { if (armedLanding && armedPeakHorizontal > 0.25f) { float num4 = Mathf.InverseLerp(-0.35f, -0.95f, num3); Vector3 val6 = Vector3.Slerp(((Vector3)(ref best)).normalized, ((Vector3)(ref slopeDown)).normalized, num4 * 0.55f); float num5 = Mathf.Min(bestSpeed, (num > 0.5f) ? num : bestSpeed); return ((Vector3)(ref val6)).normalized * Mathf.Max(num5, 0.75f); } return Vector3.zero; } } float num6 = ((num > 0.5f) ? Mathf.Min(bestSpeed, num) : bestSpeed); if (num6 < 0.12f) { return Vector3.zero; } return ((Vector3)(ref best)).normalized * num6; } } return Vector3.zero; void Consider(Vector3 worldVel) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0036: Unknown result type (might be due to invalid IL or missing references) if (!(((Vector3)(ref worldVel)).sqrMagnitude < 0.01f)) { Vector3 val7 = Vector3.ProjectOnPlane(worldVel, groundNormal); float magnitude = ((Vector3)(ref val7)).magnitude; if (magnitude > bestSpeed) { bestSpeed = magnitude; best = val7; } } } void ConsiderCarriedHorizontal(float horizontalSpeed, Vector3 hint) { //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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (!(horizontalSpeed < 0.12f)) { Vector3 val7 = Utility.Flatten(hint); if (((Vector3)(ref val7)).sqrMagnitude < 0.01f && ((Vector3)(ref slopeDown)).sqrMagnitude > 0.0001f) { val7 = Utility.Flatten(slopeDown); } if (!(((Vector3)(ref val7)).sqrMagnitude < 0.01f)) { Consider(((Vector3)(ref val7)).normalized * horizontalSpeed); } } } } internal Vector3 ComputeLandingSeed(Player player, in GroundSample ground, ItemData shield, Vector3 armedMomentum) { //IL_001f: 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_0025: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_0177: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null)) { Vector3 val = ground.Normal; if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f)) { Vector3 val2 = armedMomentum; if (((Vector3)(ref val2)).sqrMagnitude < 0.12f) { val2 = ((Character)player).GetVelocity(); Rigidbody body = Utility.GetBody(player); if ((Object)(object)body != (Object)null && !body.isKinematic) { val = body.linearVelocity; if (((Vector3)(ref val)).sqrMagnitude > ((Vector3)(ref val2)).sqrMagnitude) { val2 = body.linearVelocity; } } } if (((Vector3)(ref val2)).sqrMagnitude < 0.12f && ((Vector3)(ref ((Character)player).m_currentVel)).sqrMagnitude > 0.12f) { val2 = ((Character)player).m_currentVel; } Vector3 val3 = Vector3.ProjectOnPlane(val2, ground.Normal); float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude < 0.12f && ((Vector3)(ref armedMomentum)).sqrMagnitude > 0.12f) { val3 = Vector3.ProjectOnPlane(armedMomentum, ground.Normal); magnitude = ((Vector3)(ref val3)).magnitude; } if (magnitude < 0.12f) { return Vector3.zero; } float num = ShieldSpeedRegistry.EstimateNaturalSpeed(in ground, player, shield); Vector3 slopeDown = ground.SlopeDown; if (((Vector3)(ref slopeDown)).sqrMagnitude > 0.0001f) { float num2 = Vector3.Dot(((Vector3)(ref val3)).normalized, ((Vector3)(ref slopeDown)).normalized); if (num2 < -0.35f) { return Vector3.zero; } if (num2 < 0.45f) { val3 = Vector3.Lerp(val3, ((Vector3)(ref slopeDown)).normalized * magnitude, 0.35f); } } float num3 = ((num > 0.5f) ? Mathf.Min(magnitude, num * 0.98f) : magnitude); if (num3 < 0.12f) { return Vector3.zero; } return ((Vector3)(ref val3)).normalized * num3; } } return Vector3.zero; } internal void PrepareSledStart(Player player, Vector3 seedVelocity, in GroundSample ground, ItemData shield) { //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_002c: 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_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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) _lastVelocity = seedVelocity; _wasAirborne = false; _airborneGraceUntil = 0f; _hasSmoothedSteer = false; _postDownhillCarryUntil = 0f; Vector3 normal = ground.Normal; if (((Vector3)(ref normal)).sqrMagnitude > 0.01f) { normal = ground.Normal; _smoothedGroundNormal = ((Vector3)(ref normal)).normalized; _hasSmoothedGround = true; } else { _hasSmoothedGround = false; } float magnitude = ((Vector3)(ref seedVelocity)).magnitude; float num = ShieldSpeedRegistry.EstimateNaturalSpeed(in ground, player, shield); float num2 = ((num > 0.5f) ? Mathf.Clamp01(magnitude / num) : 0f); if (magnitude > 0.4f || num2 >= 0.2f) { _sledStartDuration = 0f; } else if (num2 >= 0.15f) { _sledStartDuration = 0.12f; } else { _sledStartDuration = Mathf.Lerp(0.5f, 0.18f, num2 * num2); } _sledStartGraceUntil = Time.time + _sledStartDuration; if (magnitude > 0.4f) { _entrySpeedFloor = magnitude; _entrySpeedFloorUntil = Time.time + 1.25f; } else { _entrySpeedFloor = 0f; _entrySpeedFloorUntil = 0f; } if ((Object)(object)player != (Object)null) { ((Character)player).m_running = false; ((Character)player).m_walk = false; ((Character)player).m_sliding = magnitude > 0.25f; SledGroundSolver.SyncCharacterMotionState((Character)(object)player, seedVelocity, grounded: true); } } internal void ApplySledStartMotion(Player player) { } internal void PrepareSledStart(Player player) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) PrepareSledStart(player, Vector3.zero, default(GroundSample), null); } internal void RestoreBody(Player player) { if (_bodyTuned) { RestoreColliderMaterials(); Rigidbody body = Utility.GetBody(player); if ((Object)(object)body != (Object)null) { body.useGravity = _savedUseGravity; body.isKinematic = _savedIsKinematic; body.linearDamping = _savedDrag; body.angularDamping = _savedAngularDrag; body.detectCollisions = _savedDetectCollisions; } _bodyTuned = false; _dynamicStartup = false; _preferDynamicBody = false; _kinematicDeferFrames = 0; _entrySpeedFloor = 0f; _entrySpeedFloorUntil = 0f; _hasSmoothedGround = false; _hasSmoothedSteer = false; _postDownhillCarryUntil = 0f; } } private void FinalizeDynamicStartup(Player player, Rigidbody body) { //IL_002e: 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_0064: 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_0051: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null) && !((Object)(object)body == (Object)null) && !body.isKinematic && _dynamicStartup && !_preferDynamicBody) { _lastVelocity = body.linearVelocity; if (((Vector3)(ref _lastVelocity)).sqrMagnitude < 0.01f) { _lastVelocity = ((Character)player).m_currentVel; } body.isKinematic = true; body.position = ((Component)player).transform.position; _dynamicStartup = false; _kinematicDeferFrames = 0; } } private void ApplyFrictionlessColliders(Player player) { _savedColliderMaterials.Clear(); if (!((Object)(object)player == (Object)null)) { CapsuleCollider collider = ((Character)player).m_collider; if ((Object)(object)collider != (Object)null) { _savedColliderMaterials.Add(((Collider)(object)collider, ((Collider)collider).sharedMaterial)); ((Collider)collider).sharedMaterial = _frictionlessMaterial; } } } private void RestoreColliderMaterials() { for (int i = 0; i < _savedColliderMaterials.Count; i++) { var (val, sharedMaterial) = _savedColliderMaterials[i]; if ((Object)(object)val != (Object)null) { val.sharedMaterial = sharedMaterial; } } _savedColliderMaterials.Clear(); } internal PhysicsResult Simulate(Player player, ItemData shield, Vector3 steerInput, bool brake, bool leanForward, float dt) { //IL_0054: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0940: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0961: Unknown result type (might be due to invalid IL or missing references) //IL_0962: Unknown result type (might be due to invalid IL or missing references) //IL_0969: Unknown result type (might be due to invalid IL or missing references) //IL_0970: Unknown result type (might be due to invalid IL or missing references) //IL_0975: Unknown result type (might be due to invalid IL or missing references) //IL_097a: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: 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_098c: Unknown result type (might be due to invalid IL or missing references) //IL_098d: Unknown result type (might be due to invalid IL or missing references) //IL_0992: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: 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_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_0a51: Unknown result type (might be due to invalid IL or missing references) //IL_09ad: Unknown result type (might be due to invalid IL or missing references) //IL_09a4: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0a42: Unknown result type (might be due to invalid IL or missing references) //IL_0a49: Unknown result type (might be due to invalid IL or missing references) //IL_0a4e: Unknown result type (might be due to invalid IL or missing references) //IL_09cf: Unknown result type (might be due to invalid IL or missing references) //IL_09d4: Unknown result type (might be due to invalid IL or missing references) //IL_09db: Unknown result type (might be due to invalid IL or missing references) //IL_09e0: Unknown result type (might be due to invalid IL or missing references) //IL_09e2: Unknown result type (might be due to invalid IL or missing references) //IL_09ee: Unknown result type (might be due to invalid IL or missing references) //IL_09fe: Unknown result type (might be due to invalid IL or missing references) //IL_0a03: Unknown result type (might be due to invalid IL or missing references) //IL_0a08: Unknown result type (might be due to invalid IL or missing references) //IL_0a0e: Unknown result type (might be due to invalid IL or missing references) //IL_0a13: Unknown result type (might be due to invalid IL or missing references) //IL_0a18: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0380: 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_0241: 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_0a89: Unknown result type (might be due to invalid IL or missing references) //IL_0a8b: Unknown result type (might be due to invalid IL or missing references) //IL_0a90: Unknown result type (might be due to invalid IL or missing references) //IL_0a95: Unknown result type (might be due to invalid IL or missing references) //IL_0a9b: Unknown result type (might be due to invalid IL or missing references) //IL_0a9d: Unknown result type (might be due to invalid IL or missing references) //IL_0aa2: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_0272: 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_0287: 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_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: 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_02cc: 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_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0b6d: Unknown result type (might be due to invalid IL or missing references) //IL_0b6e: Unknown result type (might be due to invalid IL or missing references) //IL_0b87: Unknown result type (might be due to invalid IL or missing references) //IL_0b88: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0568: 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_0712: Unknown result type (might be due to invalid IL or missing references) //IL_0719: Unknown result type (might be due to invalid IL or missing references) //IL_071e: Unknown result type (might be due to invalid IL or missing references) //IL_0723: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_05f8: 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_0736: Unknown result type (might be due to invalid IL or missing references) //IL_073d: Unknown result type (might be due to invalid IL or missing references) //IL_0742: Unknown result type (might be due to invalid IL or missing references) //IL_0744: Unknown result type (might be due to invalid IL or missing references) //IL_0746: Unknown result type (might be due to invalid IL or missing references) //IL_0752: Unknown result type (might be due to invalid IL or missing references) //IL_0762: Unknown result type (might be due to invalid IL or missing references) //IL_0767: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_0646: 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_0659: Unknown result type (might be due to invalid IL or missing references) //IL_065e: Unknown result type (might be due to invalid IL or missing references) //IL_0663: Unknown result type (might be due to invalid IL or missing references) //IL_06b1: Unknown result type (might be due to invalid IL or missing references) //IL_06b2: Unknown result type (might be due to invalid IL or missing references) //IL_06c4: Unknown result type (might be due to invalid IL or missing references) //IL_06c9: Unknown result type (might be due to invalid IL or missing references) //IL_06ce: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_08f2: Unknown result type (might be due to invalid IL or missing references) //IL_08ec: Unknown result type (might be due to invalid IL or missing references) //IL_08f7: Unknown result type (might be due to invalid IL or missing references) //IL_0907: Unknown result type (might be due to invalid IL or missing references) //IL_090f: Unknown result type (might be due to invalid IL or missing references) //IL_0914: Unknown result type (might be due to invalid IL or missing references) //IL_08b8: Unknown result type (might be due to invalid IL or missing references) //IL_08bf: Unknown result type (might be due to invalid IL or missing references) //IL_08c4: Unknown result type (might be due to invalid IL or missing references) PhysicsResult result = default(PhysicsResult); Rigidbody body = Utility.GetBody(player); if ((Object)(object)body == (Object)null) { return result; } if (_dynamicStartup) { if (_kinematicDeferFrames > 0) { _kinematicDeferFrames--; } else { FinalizeDynamicStartup(player, body); } } Vector3 velocity = (_bodyTuned ? _lastVelocity : body.linearVelocity); GroundSample ground; bool flag = Utility.TryGetSledGround(player, out ground); bool flag2 = flag && !ground.IsWaterSurface && Utility.IsBuiltSledSurface(ground.Collider); if (flag && !ground.IsWaterSurface) { ground = SmoothGroundSample(in ground, dt, flag2); } else if (!flag) { _hasSmoothedGround = false; } bool flag3 = (result.OnGround = flag && !IsAirborneForPhysics(player)); result.Velocity = velocity; result.Ground = ground; float steeringMultiplier = ShieldSpeedRegistry.GetSteeringMultiplier(shield); float blockSkillMultiplier = ShieldSpeedRegistry.GetBlockSkillMultiplier(player, shield); float num = GetSlopePullStrength() * blockSkillMultiplier; float num2 = ConfigManager.FrictionMultiplier.Value; if (flag) { num2 *= Utility.GetBiomeFriction(ground.Biome); if (Utility.TryGetShieldSurfFriction(ground.Collider, out var friction)) { num2 *= friction; } } if (brake) { num2 *= 1f + ConfigManager.BrakeStrength.Value; } bool flag4 = Time.time < _sledStartGraceUntil; float startupBlend = StartupBlend; bool flag5 = _entrySpeedFloor > 0.12f && Time.time < _entrySpeedFloorUntil; Vector3 val2; if (flag3 && flag) { Vector3 val = ground.Normal; if (!flag2 && val.y < 0.78f) { float num3 = Mathf.InverseLerp(0.78f, 0.45f, val.y); val2 = Vector3.Slerp(val, Vector3.up, num3 * 0.85f); val = ((Vector3)(ref val2)).normalized; } float magnitude = ((Vector3)(ref velocity)).magnitude; Vector3 val3 = Vector3.ProjectOnPlane(velocity, val); if (((Vector3)(ref val3)).sqrMagnitude > 0.0001f && magnitude > 0.25f) { float num4 = Mathf.Clamp01(ConfigManager.SlopeTransitionRetention.Value); float num5 = Mathf.Lerp(((Vector3)(ref val3)).magnitude, magnitude, num4); velocity = ((Vector3)(ref val3)).normalized * num5; } else { velocity = val3; } if (ground.IsWaterSurface) { velocity = Utility.Flatten(velocity); float magnitude2 = ((Vector3)(ref velocity)).magnitude; Vector3 val4 = ((magnitude2 > 0.01f) ? ((Vector3)(ref velocity)).normalized : Utility.Flatten(((Component)player).transform.forward)); if (((Vector3)(ref val4)).sqrMagnitude < 0.0001f) { val4 = Vector3.forward; } if (((Vector3)(ref steerInput)).sqrMagnitude > 0.0001f) { float num6 = ConfigManager.SteeringStrength.Value * steeringMultiplier * 0.85f; num6 /= 1f + magnitude2 * ConfigManager.SteeringSpeedFalloff.Value; Vector3 val5 = SmoothSteerDirection(Utility.Flatten(((Vector3)(ref steerInput)).normalized), dt); Vector3 val6 = Vector3.RotateTowards(val4, val5, num6 * dt, 0f); velocity = ((Vector3)(ref val6)).normalized * magnitude2; val4 = ((Vector3)(ref val6)).normalized; } else { _hasSmoothedSteer = false; } float value = ConfigManager.WaterSledFriction.Value; if ((brake || value > 0f) && magnitude2 > 0.01f) { float num7 = value * (brake ? 2.4f : 1f) * magnitude2 * dt; float num8 = Mathf.Max(0f, magnitude2 - num7); velocity = val4 * num8; } WaterSledHelper.ApplySoftWaterFollow(player, in ground, ref velocity, dt); } else { Vector3 slopeDown = ground.SlopeDown; float num9 = Mathf.Sin(ground.SlopeAngle * ((float)Math.PI / 180f)); Vector3 val7 = ((((Vector3)(ref velocity)).sqrMagnitude > 0.01f) ? ((Vector3)(ref velocity)).normalized : slopeDown); if (((Vector3)(ref val7)).sqrMagnitude < 0.0001f && ((Vector3)(ref slopeDown)).sqrMagnitude > 0.0001f) { val7 = slopeDown; } float num10 = ((((Vector3)(ref velocity)).sqrMagnitude > 0.01f) ? Vector3.Dot(((Vector3)(ref velocity)).normalized, -slopeDown) : 0f); float magnitude3 = ((Vector3)(ref velocity)).magnitude; float num11 = ShieldSpeedRegistry.EstimateNaturalSpeed(in ground, player, shield); float num12 = ((Time.time < _postDownhillCarryUntil) ? Mathf.Clamp01((_postDownhillCarryUntil - Time.time) / 0.45f) : 0f); bool flag6 = ground.SlopeAngle < ConfigManager.MinimumSlope.Value + 2f && num9 < 0.08f; if (flag4 && !flag5 && num9 > 0.01f && num10 < 0.4f && !flag6 && ((Vector3)(ref slopeDown)).sqrMagnitude > 0.0001f && magnitude3 < num11 * 0.88f) { float num13 = 1f - startupBlend; num13 = num13 * num13 * (3f - 2f * num13); float num14 = Mathf.Max(num11 * num13 * 0.92f, magnitude3); Vector3 val8 = ((Vector3)(ref slopeDown)).normalized * num14; float num15 = Mathf.Max(num * num9 * 2.5f, num11 * 1.8f); velocity = Vector3.MoveTowards(velocity, val8, num15 * dt); magnitude3 = ((Vector3)(ref velocity)).magnitude; val7 = ((magnitude3 > 0.01f) ? ((Vector3)(ref velocity)).normalized : slopeDown); } else if (!flag6 && num9 > 0.01f && num10 < 0.4f) { velocity += slopeDown * (num * num9 * dt); _postDownhillCarryUntil = Time.time + 0.45f; } else if (!flag6 && !flag5 && !flag4 && num10 > 0.15f && num9 > 0.01f) { float num16 = Mathf.Clamp01((num10 - 0.15f) / 0.85f); float num17 = ConfigManager.UphillPenalty.Value * num * num9 * num16; if (num12 > 0.001f) { num17 *= Mathf.Lerp(1f, 0.45f, num12); } velocity -= val7 * (num17 * dt); } else if (!flag5 && !flag4 && flag6) { float num18 = (brake ? 1f : 0.35f); if (!brake && num12 > 0.001f) { num18 *= Mathf.Lerp(1f, 0.25f, num12); } velocity -= val7 * (ConfigManager.FlatDeceleration.Value * num18 * dt); } if (leanForward && ((Vector3)(ref val7)).sqrMagnitude > 0.0001f) { float num19 = 0f; if (!flag6 && num10 < 0.35f && num9 > 0.04f) { num19 = Mathf.Clamp01((num9 - 0.04f) / 0.12f); } if (num19 > 0.001f) { velocity += val7 * (ConfigManager.ForwardLeanBonus.Value * num19 * dt); } } if (((Vector3)(ref steerInput)).sqrMagnitude > 0.0001f) { float num20 = ConfigManager.SteeringStrength.Value * steeringMultiplier; float magnitude4 = ((Vector3)(ref velocity)).magnitude; num20 /= 1f + magnitude4 * ConfigManager.SteeringSpeedFalloff.Value; Vector3 val9 = Vector3.ProjectOnPlane(((Vector3)(ref steerInput)).normalized, ground.Normal); if (((Vector3)(ref val9)).sqrMagnitude > 0.0001f) { Vector3 val10 = SmoothSteerDirection(((Vector3)(ref val9)).normalized, dt); Vector3 val11 = Vector3.RotateTowards(val7, val10, num20 * dt, 0f); float magnitude5 = ((Vector3)(ref velocity)).magnitude; velocity = val11 * magnitude5; } } else { _hasSmoothedSteer = false; } bool flag7 = num9 > 0.02f && num10 < 0.4f; float num21 = ((startupBlend > 0.001f) ? Mathf.Lerp(1f, 0.08f, startupBlend) : 1f); magnitude3 = ((Vector3)(ref velocity)).magnitude; if (!flag5 && num2 > 0f && magnitude3 > 0.01f && !(flag4 && !brake && flag7)) { float num22 = (brake ? 1f : 0.28f); if (!brake && num10 > 0.15f && num9 > 0.01f) { float num23 = Mathf.Clamp01((num10 - 0.15f) / 0.85f); float num24 = Mathf.Lerp(1f, 0.38f, num23); if (num12 > 0.001f) { num24 *= Mathf.Lerp(1f, 0.55f, num12); } num22 *= num24; } if (!brake && magnitude3 > 8f) { float num25 = Mathf.Clamp01((magnitude3 - 8f) / 22f); num22 *= Mathf.Lerp(1f, 0.72f, num25); } float num26 = num2 * num22 * num21 * magnitude3 * dt; float num27 = Mathf.Max(0f, magnitude3 - num26); velocity = ((Vector3)(ref velocity)).normalized * num27; } if (flag5 && ((Vector3)(ref velocity)).magnitude + 0.02f < _entrySpeedFloor) { Vector3 val12 = ((((Vector3)(ref velocity)).sqrMagnitude > 0.01f) ? ((Vector3)(ref velocity)).normalized : val7); if (((Vector3)(ref val12)).sqrMagnitude > 0.0001f) { velocity = val12 * _entrySpeedFloor; } } ApplyGroundClearance(player, ground, ref velocity, dt); if (!flag2) { ApplySoftGroundFollow(player, in ground, ref velocity, dt); } } } else { _hasSmoothedSteer = false; float num28 = Mathf.Abs(Physics.gravity.y); if (num28 < 0.01f) { num28 = 9.81f; } velocity += Vector3.down * num28 * dt; if (((Vector3)(ref steerInput)).sqrMagnitude > 0.0001f) { Vector3 val13 = Utility.Flatten(velocity); Vector3 val14 = ((((Vector3)(ref val13)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val13)).normalized : ((Vector3)(ref steerInput)).normalized); float num29 = ConfigManager.SteeringStrength.Value * ConfigManager.AirControl.Value * steeringMultiplier; Vector3 val15 = SmoothSteerDirection(Utility.Flatten(((Vector3)(ref steerInput)).normalized), dt); Vector3 val16 = Vector3.RotateTowards(val14, val15, num29 * dt, 0f); float magnitude6 = ((Vector3)(ref val13)).magnitude; velocity = val16 * magnitude6 + Vector3.up * velocity.y; } } float value2 = ConfigManager.MaximumSpeed.Value; if (value2 > 0f) { value2 *= blockSkillMultiplier; if (((Vector3)(ref velocity)).magnitude > value2) { velocity = ((Vector3)(ref velocity)).normalized * value2; } } result.HorizontalSpeed = Utility.HorizontalSpeed(velocity); if (_wasAirborne && flag3 && flag && !ground.IsWaterSurface) { float num30 = Mathf.Max(0f, _lastVelocity.y); Vector3 v = velocity - _lastVelocity; val2 = Utility.Flatten(v); result.LandingImpact = num30 + ((Vector3)(ref val2)).magnitude * 0.25f; } bool flag8 = flag && ground.IsWaterSurface; bool flag9 = flag8 || (WaterSledHelper.IsSkimCommitted && WaterSledHelper.IsLiquidNearPlayer(player)); ApplySimulatedMotion(player, body, ref velocity, dt, lockVertical: false, flag3 && !flag9, flag9, flag8 ? ground.WaterSurfaceY : float.NaN, flag2 && flag3); DepenetrateBlockingSolids(player, body, ref velocity); if (flag9) { if (!ConstrainWaterSkimAgainstLand(player, body, ref velocity, dt) && WaterSledHelper.IsSkimCommitted && flag && ground.IsWaterSurface) { WaterSledHelper.ApplySoftWaterFollow(player, in ground, ref velocity, dt); } } else { ConstrainFeetToGround(player, body, ref velocity, dt, startupBlend, flag3, flag2 && flag3); } SledGroundSolver.RescueTerrainPenetration(player, ref velocity); result.Velocity = velocity; result.Ground = ground; ApplyStaminaDrain(player, flag3, dt); _lastVelocity = velocity; _wasAirborne = !flag3; return result; } private GroundSample SmoothGroundSample(in GroundSample raw, float dt, bool onBuiltPiece = false) { //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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_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_01b6: 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_01c6: 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_01f7: 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_00aa: 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_006f: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) GroundSample result = raw; Vector3 val; if (!_hasSmoothedGround || ((Vector3)(ref _smoothedGroundNormal)).sqrMagnitude < 0.01f) { val = raw.Normal; _smoothedGroundNormal = ((Vector3)(ref val)).normalized; _hasSmoothedGround = true; } else if (onBuiltPiece) { float num = 1f - Mathf.Exp(-36f * Mathf.Max(dt, 0.001f)); val = Vector3.Slerp(_smoothedGroundNormal, raw.Normal, num); _smoothedGroundNormal = ((Vector3)(ref val)).normalized; } else { float num2 = 1f - Mathf.Exp(-12f * Mathf.Max(dt, 0.001f)); float num3 = Vector3.Angle(_smoothedGroundNormal, raw.Normal); if (num3 > 25f) { float num4 = ((num3 > 50f) ? 0.48f : ((num3 > 35f) ? 0.72f : 0.88f)); num2 = Mathf.Clamp01(num2 * num4); Vector3 val2 = Vector3.ProjectOnPlane(Vector3.down, _smoothedGroundNormal); Vector3 val3 = Vector3.ProjectOnPlane(Vector3.down, raw.Normal); if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f && ((Vector3)(ref val3)).sqrMagnitude > 0.0001f && Vector3.Dot(((Vector3)(ref val2)).normalized, ((Vector3)(ref val3)).normalized) < 0.25f) { num2 = Mathf.Max(num2, 1f - Mathf.Exp(-18f * Mathf.Max(dt, 0.001f))); } } val = Vector3.Slerp(_smoothedGroundNormal, raw.Normal, num2); _smoothedGroundNormal = ((Vector3)(ref val)).normalized; } result.Normal = _smoothedGroundNormal; result.SlopeAngle = Vector3.Angle(result.Normal, Vector3.up); result.SlopeDown = Vector3.ProjectOnPlane(Vector3.down, result.Normal); if (((Vector3)(ref result.SlopeDown)).sqrMagnitude > 0.0001f) { ((Vector3)(ref result.SlopeDown)).Normalize(); } result.Downhill = Utility.Flatten(result.SlopeDown); if (((Vector3)(ref result.Downhill)).sqrMagnitude > 0.0001f) { ((Vector3)(ref result.Downhill)).Normalize(); } return result; } private Vector3 SmoothSteerDirection(Vector3 desired, float dt) { //IL_000e: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_007a: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref desired)).sqrMagnitude < 0.0001f) { return desired; } ((Vector3)(ref desired)).Normalize(); if (!_hasSmoothedSteer || ((Vector3)(ref _smoothedSteerDir)).sqrMagnitude < 0.0001f) { _smoothedSteerDir = desired; _hasSmoothedSteer = true; return desired; } float num = 1f - Mathf.Exp(-22f * Mathf.Max(dt, 0.001f)); Vector3 val = Vector3.Slerp(_smoothedSteerDir, desired, num); _smoothedSteerDir = ((Vector3)(ref val)).normalized; return _smoothedSteerDir; } private static void ApplySoftGroundFollow(Player player, in GroundSample ground, ref Vector3 velocity, float dt) { //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_003a: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return; } Vector3 normal = ground.Normal; if (!(((Vector3)(ref normal)).sqrMagnitude < 0.01f)) { Vector3 val = ((ground.Normal.y >= 0.72f) ? ground.Normal : Vector3.up); float num = Mathf.Clamp(ConfigManager.SledGroundClearance.Value, 0f, 0.6f); float num2 = Utility.GetFeetHeightAboveGround(player, ground) - num; float num3 = Vector3.Dot(velocity, val); float num4 = ((num2 < 0f) ? 32f : 9f); float num5 = (0f - num2) * num4; if (num2 < -0.05f) { num5 = Mathf.Max(num5, (0f - num2) * 48f); } else if (num2 > 0.18f && num3 > -0.5f) { num5 = Mathf.Min(num5, -2.5f); } float num6 = ((num2 < 0f) ? 110f : 28f) * Mathf.Max(dt, 0.001f); float num7 = Mathf.MoveTowards(num3, num5, num6); velocity += val * (num7 - num3); } } private static void ConstrainFeetToGround(Player player, Rigidbody body, ref Vector3 velocity, float dt, float startupBlend, bool allowDownwardSettle = true, bool preferBuiltPieceLock = false) { //IL_004e: 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_0089: 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_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0233: 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_023f: 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_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0227: 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_0271: 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_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)body == (Object)null) { return; } if (WaterSledHelper.IsSkimCommitted) { ConstrainWaterSkimAgainstLand(player, body, ref velocity, dt); return; } if (!Utility.TryProbeGroundBelow(player, 3f, out var sample) || sample.IsWaterSurface) { RescueDeepPenetration(player, body, ref velocity); SledGroundSolver.RescueTerrainPenetration(player, ref velocity); return; } float y = Utility.GetFeetPosition(player).y; bool flag = Utility.IsInInterior(player); float num = (flag ? 0.22f : 0.4f); if (sample.Point.y > y + num) { if (flag || !Utility.TryGetTerrainHeightPublic(((Component)player).transform.position, out var height) || y >= height - 0.05f) { return; } if (Mathf.Abs(sample.Point.y - height) > 0.85f) { SledGroundSolver.RescueTerrainPenetration(player, ref velocity); return; } } bool flag2 = preferBuiltPieceLock || Utility.IsBuiltSledSurface(sample.Collider); float num2 = Mathf.Clamp(ConfigManager.SledGroundClearance.Value, 0f, 0.6f); float feetHeightAboveGround = Utility.GetFeetHeightAboveGround(player, sample); float num3 = feetHeightAboveGround - num2; float num4 = (flag2 ? (-0.02f) : (-0.008f)); float num5 = (flag2 ? 0.16f : 0.1f); if (num3 >= num4 && num3 <= num5) { return; } float num7; if (num3 < 0f) { float num6 = (flag ? 0.22f : (flag2 ? 0.28f : 3.5f)); num7 = Mathf.Min(0f - num3, num6); if (num7 < 0.1f && startupBlend > 0.001f) { num7 *= Mathf.Lerp(0.7f, 1f, 1f - startupBlend); } } else { if (!allowDownwardSettle || feetHeightAboveGround > 0.38f) { return; } float num8 = 1f - Mathf.Exp((0f - (flag2 ? 22f : 14f)) * Mathf.Max(dt, 0.001f)); float num9 = (flag2 ? (10f * dt) : (18f * dt)); num7 = 0f - Mathf.Min(num3, Mathf.Max(num3 * num8, num9)); } if (Mathf.Abs(num7) < 0.001f) { return; } Vector3 val = ((flag2 || sample.Normal.y < 0.7f) ? Vector3.up : sample.Normal); Vector3 position = (body.position += val * num7); ((Component)player).transform.position = position; if (num3 < 0f) { float num10 = Vector3.Dot(velocity, -val); if (num10 > 0f) { velocity += val * num10; } } } private static void RescueDeepPenetration(Player player, Rigidbody body, ref Vector3 velocity) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00a7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)body == (Object)null || !Utility.TryProbeGroundBelow(player, 6f, out var sample) || sample.IsWaterSurface) { return; } float feetClearance = Mathf.Clamp(ConfigManager.SledGroundClearance.Value, 0f, 0.6f); if (!(Utility.GetFeetHeightAboveGround(player, sample) >= -0.02f)) { Vector3 position = (body.position = Utility.GetRootPositionForFeetOnGround(player, sample, feetClearance)); ((Component)player).transform.position = position; float num = Vector3.Dot(velocity, -sample.Normal); if (num > 0f) { velocity += sample.Normal * num; } } } private void ApplySimulatedMotion(Player player, Rigidbody body, ref Vector3 velocity, float dt, bool lockVertical = false, bool allowDownwardSettle = true, bool waterSkimming = false, float waterSurfaceY = float.NaN, bool onBuiltPiece = false) { //IL_0001: 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_0046: 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_0077: 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_0082: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Vector3 val = velocity * dt; if (lockVertical) { val.y = 0f; } float magnitude = ((Vector3)(ref val)).magnitude; int num = ((!(magnitude > 0.28f)) ? 1 : Mathf.Clamp(Mathf.CeilToInt(magnitude / 0.28f), 1, 10)); Vector3 delta = val / (float)num; float dt2 = dt / (float)num; if (waterSkimming && float.IsNaN(waterSurfaceY) && WaterSledHelper.TryGetWaterSurface(player, out var surfaceY)) { waterSurfaceY = surfaceY; } for (int i = 0; i < num; i++) { Vector3 val2 = ResolveObstacleMovement(player, delta, ref velocity, waterSkimming, waterSurfaceY); Vector3 position = (body.position += val2); ((Component)player).transform.position = position; if (i >= num - 1) { continue; } if (waterSkimming) { if (ConstrainWaterSkimAgainstLand(player, body, ref velocity, dt2)) { waterSkimming = false; } } else if (!onBuiltPiece) { ConstrainFeetToGround(player, body, ref velocity, dt2, 0f, allowDownwardSettle); } SledGroundSolver.RescueTerrainPenetration(player, ref velocity); } } private static Vector3 ResolveObstacleMovement(Player player, Vector3 delta, ref Vector3 velocity, bool waterSkimming = false, float waterSurfaceY = float.NaN) { //IL_0017: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_064d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0168: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0466: 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_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0590: 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_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05aa: Unknown result type (might be due to invalid IL or missing references) //IL_05ac: Unknown result type (might be due to invalid IL or missing references) //IL_05b1: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: 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_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_05c4: Unknown result type (might be due to invalid IL or missing references) //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_060c: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Unknown result type (might be due to invalid IL or missing references) //IL_062b: 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_0648: 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_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: 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_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0377: 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_033f: 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_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0400: 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_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: 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_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03de: 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_03e0: 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_03e7: 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_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || ((Vector3)(ref delta)).sqrMagnitude < 1E-06f) { return delta; } if (!TryGetPlayerCapsule(player, out var point, out var point2, out var radius)) { return delta; } bool flag = !waterSkimming && Utility.IsInInterior(player); Vector3 val = point - point2; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude > 0.05f) { float num = (waterSkimming ? Mathf.Min(0.22f, magnitude * 0.18f) : (flag ? Mathf.Min(0.06f, magnitude * 0.06f) : Mathf.Min(0.22f, magnitude * 0.2f))); point2 += val / magnitude * num; } float num2 = Mathf.Max(0.08f, radius * (waterSkimming ? 0.85f : (flag ? 0.95f : 0.88f))); int num3 = (flag ? 4 : 3); int groundLayerMask = Utility.GetGroundLayerMask(); float y = Utility.GetFeetPosition(player).y; float terrainY = y; if (Utility.TryGetTerrainHeightPublic(((Component)player).transform.position, out var height)) { terrainY = height; } Vector3 val2 = Vector3.zero; Vector3 val3 = delta; Vector3 val4 = Vector3.zero; bool flag2 = false; float magnitude2 = ((Vector3)(ref velocity)).magnitude; Vector3 normalized = ((Vector3)(ref delta)).normalized; int num4 = 0; RaycastHit hit = default(RaycastHit); for (int i = 0; i < num3 && ((Vector3)(ref val3)).sqrMagnitude > 1E-06f; i++) { float magnitude3 = ((Vector3)(ref val3)).magnitude; Vector3 val5 = val3 / magnitude3; if (!Physics.CapsuleCast(point, point2, num2, val5, ref hit, magnitude3 + 0.03f, groundLayerMask, (QueryTriggerInteraction)1)) { val2 += val3; break; } if (!((waterSkimming && !float.IsNaN(waterSurfaceY)) ? IsWaterSkimBlockingSolid(in hit, waterSurfaceY, y) : (flag ? IsInteriorBlockingSolid(in hit, y) : IsHardBlockingWall(in hit, val5, y, terrainY)))) { bool flag3 = Utility.IsTerrainCollider(((RaycastHit)(ref hit)).collider); bool num5 = waterSkimming && !float.IsNaN(waterSurfaceY) && ((RaycastHit)(ref hit)).point.y < waterSurfaceY - 0.15f && ((RaycastHit)(ref hit)).point.y < y - 0.35f; bool flag4 = Utility.IsBuiltStructureObstacle(((RaycastHit)(ref hit)).collider); bool flag5 = Utility.IsWallLikeObstacle(((RaycastHit)(ref hit)).collider); bool flag6 = Utility.IsBeeswaxSealedObstacle(((RaycastHit)(ref hit)).collider); Bounds bounds = ((RaycastHit)(ref hit)).collider.bounds; bool flag7 = ((Bounds)(ref bounds)).max.y - y >= 1.15f && ((RaycastHit)(ref hit)).normal.y < 0.4f; if (!num5 && !flag5 && ((RaycastHit)(ref hit)).normal.y >= 0.2f && (flag || flag3 || flag4 || (waterSkimming && !float.IsNaN(waterSurfaceY) && ((RaycastHit)(ref hit)).point.y >= waterSurfaceY - 0.55f))) { float num6 = Mathf.Max(0f, ((RaycastHit)(ref hit)).distance - 0.03f); Vector3 val6 = val5 * num6; val2 += val6; point += val6; point2 += val6; val3 -= val6; val3 = Vector3.ProjectOnPlane(val3, ((RaycastHit)(ref hit)).normal); float num7 = Vector3.Dot(velocity, -((RaycastHit)(ref hit)).normal); if (num7 > 0f) { velocity += ((RaycastHit)(ref hit)).normal * num7; } continue; } if ((!(flag4 || flag5 || flag6 || flag7) && !Utility.IsTreeLikeObstacle(((RaycastHit)(ref hit)).collider)) || !(((RaycastHit)(ref hit)).normal.y < 0.55f)) { if (!flag && !waterSkimming && !flag3 && num4 < 6) { num4++; float num8 = Mathf.Min(magnitude3, Mathf.Max(((RaycastHit)(ref hit)).distance + 0.06f, 0.06f)); Vector3 val7 = val5 * num8; val2 += val7; point += val7; point2 += val7; val3 -= val7; i--; continue; } val2 += val3; break; } } flag2 = true; val4 = ((RaycastHit)(ref hit)).normal; float num9 = Mathf.Max(0f, ((RaycastHit)(ref hit)).distance - 0.03f); Vector3 val8 = val5 * num9; val2 += val8; point += val8; point2 += val8; val3 -= val8; Vector3 val9 = Vector3.ProjectOnPlane(val3, ((RaycastHit)(ref hit)).normal); if (num9 <= 0.001f && ((Vector3)(ref val9)).sqrMagnitude < 1E-06f) { break; } val3 = val9; } if (flag2 && ((Vector3)(ref val4)).sqrMagnitude > 0.0001f && ((Vector3)(ref velocity)).sqrMagnitude > 0.0001f) { float num10 = Vector3.Dot(velocity, val4); if (num10 < 0f) { velocity -= val4 * num10; } if (flag && ((Vector3)(ref velocity)).sqrMagnitude > 0.0001f) { float num11 = Vector3.Dot(velocity, val4); if (num11 < 0f) { velocity -= val4 * num11; } } if (magnitude2 > 0.25f) { Vector3 val10 = Utility.Flatten(normalized); Vector3 val11 = Utility.Flatten(velocity); if (((Vector3)(ref val10)).sqrMagnitude > 0.0001f && ((Vector3)(ref val11)).sqrMagnitude > 0.0001f) { if (Vector3.Dot(((Vector3)(ref val10)).normalized, ((Vector3)(ref val11)).normalized) < 0.05f) { Vector3 val12 = Vector3.ProjectOnPlane(normalized, val4); if (((Vector3)(ref val12)).sqrMagnitude > 0.0001f) { velocity = ((Vector3)(ref val12)).normalized * magnitude2; } else { velocity = normalized * (magnitude2 * 0.85f); } } else { float num12 = Vector3.Angle(val10, val11); float num13 = (flag ? 25f : 40f); if (num12 > num13) { Vector3 val13 = Vector3.RotateTowards(normalized, ((Vector3)(ref velocity)).normalized, num13 * ((float)Math.PI / 180f), 0f); velocity = ((Vector3)(ref val13)).normalized * Mathf.Max(((Vector3)(ref velocity)).magnitude, magnitude2 * 0.7f); } } } } } return val2; } private static void DepenetrateBlockingSolids(Player player, Rigidbody body, ref Vector3 velocity) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: 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_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00cc: 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_012c: 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_0115: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: 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_01b4: 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_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)body == (Object)null || !TryGetPlayerCapsule(player, out var point, out var point2, out var radius)) { return; } float num = Mathf.Max(0.08f, radius * 0.85f); int groundLayerMask = Utility.GetGroundLayerMask(); Collider[] array = Physics.OverlapCapsule(point, point2, num, groundLayerMask, (QueryTriggerInteraction)1); if (array == null || array.Length == 0) { return; } CapsuleCollider collider = ((Character)player).m_collider; float y = Utility.GetFeetPosition(player).y; Vector3 val = Vector3.zero; Vector3 val3 = default(Vector3); float num2 = default(float); foreach (Collider val2 in array) { if ((Object)(object)val2 == (Object)null || (Object)(object)val2 == (Object)(object)collider || Utility.IsTerrainCollider(val2) || !Physics.ComputePenetration((Collider)(object)collider, body.position, ((Component)player).transform.rotation, val2, ((Component)val2).transform.position, ((Component)val2).transform.rotation, ref val3, ref num2) || num2 < 0.001f || ((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { continue; } if (val3.y > 0.55f) { Bounds bounds = val2.bounds; if (((Bounds)(ref bounds)).max.y <= y + 0.55f) { continue; } } bool num3 = val3.y < 0.45f; bool flag = Utility.IsBuiltStructureObstacle(val2); bool flag2 = Utility.IsWallLikeObstacle(val2); bool flag3 = Utility.IsBeeswaxSealedObstacle(val2); bool flag4 = Utility.IsTreeLikeObstacle(val2); bool flag5 = Utility.IsInInterior(player); if (num3 || flag || flag2 || flag3 || flag4 || flag5) { Vector3 val4 = val3 * (num2 + 0.02f); if (val3.y < 0.35f) { val4.y *= 0.15f; } val += val4; float num4 = Vector3.Dot(velocity, -val3); if (num4 > 0f) { velocity += val3 * num4; } } } if (!(((Vector3)(ref val)).sqrMagnitude < 1E-06f)) { if (((Vector3)(ref val)).magnitude > 0.45f) { val = ((Vector3)(ref val)).normalized * 0.45f; } Vector3 position = (body.position += val); ((Component)player).transform.position = position; } } private static bool IsWaterSkimBlockingSolid(in RaycastHit hit, float waterSurfaceY, float feetY) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0077: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = hit; if ((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) { return false; } val = hit; if (((RaycastHit)(ref val)).point.y < waterSurfaceY - 0.15f) { val = hit; if (((RaycastHit)(ref val)).point.y < feetY - 0.35f) { return false; } } val = hit; if (((RaycastHit)(ref val)).normal.y >= 0.35f) { return false; } val = hit; return ((RaycastHit)(ref val)).point.y >= waterSurfaceY - 0.35f; } private static bool IsInteriorBlockingSolid(in RaycastHit hit, float feetY) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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) RaycastHit val = hit; if ((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) { return false; } val = hit; if (((RaycastHit)(ref val)).normal.y >= 0.45f) { val = hit; if (((RaycastHit)(ref val)).point.y <= feetY + 0.35f) { val = hit; if (((RaycastHit)(ref val)).point.y >= feetY - 2.5f) { return false; } } } val = hit; if (!(((RaycastHit)(ref val)).normal.y < 0.15f)) { val = hit; if (!(((RaycastHit)(ref val)).point.y > feetY + 0.55f)) { val = hit; return ((RaycastHit)(ref val)).normal.y < 0.45f; } } return true; } private static bool IsHardBlockingWall(in RaycastHit hit, Vector3 travelDir, float feetY, float terrainY) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_00a3: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0199: 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) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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_01d4: 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_01ee: 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_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0208: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = hit; if ((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) { return false; } float num; if (!(((Vector3)(ref travelDir)).sqrMagnitude > 0.0001f)) { num = 1f; } else { Vector3 normalized = ((Vector3)(ref travelDir)).normalized; val = hit; num = 0f - Vector3.Dot(normalized, ((RaycastHit)(ref val)).normal); } float num2 = num; val = hit; bool num3 = Utility.IsWallLikeObstacle(((RaycastHit)(ref val)).collider); val = hit; bool flag = Utility.IsBeeswaxSealedObstacle(((RaycastHit)(ref val)).collider); if (num3) { val = hit; if (((RaycastHit)(ref val)).normal.y >= 0.55f) { return false; } return num2 >= 0.12f; } if (flag) { val = hit; if (((RaycastHit)(ref val)).normal.y >= 0.45f) { return false; } return num2 >= 0.18f; } val = hit; if (Utility.IsBuiltStructureObstacle(((RaycastHit)(ref val)).collider)) { val = hit; if (((RaycastHit)(ref val)).normal.y >= 0.45f) { return false; } return num2 >= 0.22f; } val = hit; if (Utility.IsTreeLikeObstacle(((RaycastHit)(ref val)).collider)) { val = hit; if (((RaycastHit)(ref val)).normal.y >= 0.55f) { return false; } if (num2 >= 0.28f) { val = hit; return ((RaycastHit)(ref val)).normal.y < 0.55f; } return false; } val = hit; if (((RaycastHit)(ref val)).normal.y >= 0.35f) { return false; } if (num2 < 0.5f) { return false; } val = hit; Bounds bounds = ((RaycastHit)(ref val)).collider.bounds; float y = ((Bounds)(ref bounds)).max.y; val = hit; float num4 = Mathf.Max(((RaycastHit)(ref val)).point.y, y) - feetY; val = hit; float num5 = Mathf.Max(((RaycastHit)(ref val)).point.y, y) - terrainY; val = hit; float num6 = ((RaycastHit)(ref val)).point.y - feetY; val = hit; float num7 = ((RaycastHit)(ref val)).point.y - terrainY; bool num8 = num6 >= 0.9f && num7 >= 1.05f; bool flag2 = num4 >= 1.15f && num5 >= 1.15f; if (!num8 && !flag2) { return false; } val = hit; if (((RaycastHit)(ref val)).normal.y < 0.28f) { return num2 >= 0.45f; } return false; } private static bool ConstrainWaterSkimAgainstLand(Player player, Rigidbody body, ref Vector3 velocity, float dt) { //IL_002d: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00ea: 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_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_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: 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_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0209: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)body == (Object)null) { return false; } if (SledGroundSolver.RescueTerrainPenetration(player, ref velocity) && WaterSledHelper.TryGetWaterSurface(player, out var surfaceY) && Utility.TryGetTerrainHeightPublic(((Component)player).transform.position, out var height) && height >= surfaceY + 0.05f) { WaterSledHelper.ClearSkimForLandTransition(); return true; } if (!WaterSledHelper.TryGetWaterSurface(player, out var surfaceY2)) { return false; } if (!Utility.TryProbeSolidLandNearFeet(player, surfaceY2, out var land)) { return false; } float num = Mathf.Clamp(ConfigManager.SledGroundClearance.Value, 0f, 0.6f); float feetHeightAboveGround = Utility.GetFeetHeightAboveGround(player, land); Vector3 val = ((land.Normal.y >= 0.45f) ? land.Normal : Vector3.up); if (feetHeightAboveGround < num - 0.01f) { float num2 = Mathf.Min(3.5f, num - feetHeightAboveGround); Vector3 position = (body.position += val * num2); ((Component)player).transform.position = position; float magnitude = ((Vector3)(ref velocity)).magnitude; float num3 = Vector3.Dot(velocity, -val); if (num3 > 0f) { velocity += val * num3; } Vector3 val3 = Vector3.ProjectOnPlane(velocity, val); if (((Vector3)(ref val3)).sqrMagnitude > 0.0001f && magnitude > 0.25f) { velocity = ((Vector3)(ref val3)).normalized * Mathf.Max(((Vector3)(ref val3)).magnitude, magnitude * 0.92f); } WaterSledHelper.ClearSkimForLandTransition(); return true; } if (feetHeightAboveGround < 0.22f && land.Point.y >= surfaceY2 + 0.08f) { float num4 = 1f - Mathf.Exp(-16f * Mathf.Max(dt, 0.001f)); float num5 = Mathf.Min(feetHeightAboveGround - num, Mathf.Max((feetHeightAboveGround - num) * num4, 14f * dt)); if (num5 > 0.001f) { Vector3 position2 = (body.position -= val * num5); ((Component)player).transform.position = position2; WaterSledHelper.ClearSkimForLandTransition(); return true; } } return false; } private static bool TryGetPlayerCapsule(Player player, out Vector3 point1, out Vector3 point2, out float radius) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0062: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00ea: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) point1 = Vector3.zero; point2 = Vector3.zero; radius = 0f; CapsuleCollider val = ((Character)(player?)).m_collider; if ((Object)(object)val == (Object)null) { return false; } Transform transform = ((Component)val).transform; Vector3 val2 = transform.TransformPoint(val.center); Vector3 val3 = (Vector3)(val.direction switch { 0 => transform.right, 2 => transform.forward, _ => transform.up, }); float num = Mathf.Abs((val.direction == 1) ? transform.lossyScale.y : transform.lossyScale.x); float num2 = Mathf.Max(transform.lossyScale.x, transform.lossyScale.z); radius = val.radius * num2; float num3 = Mathf.Max(0f, val.height * num * 0.5f - radius); point1 = val2 + val3 * num3; point2 = val2 - val3 * num3; return true; } private static float GetSlopePullStrength() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Abs(Physics.gravity.y); if (num < 0.01f) { num = 9.81f; } return num * ConfigManager.GravityMultiplier.Value * (ConfigManager.BaseAcceleration.Value / 9.81f); } private static void ApplyGroundClearance(Player player, GroundSample ground, ref Vector3 velocity, float dt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_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_0037: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Dot(velocity, -ground.Normal); if (num > 0f) { velocity += ground.Normal * num; } } private static void ApplyStaminaDrain(Player player, bool onGround, float dt) { if (ConfigManager.StaminaMode.Value != SledStaminaMode.Constant) { return; } float num = ConfigManager.StaminaPerSecond.Value * dt; if (!(num <= 0f)) { if (player.GetStamina() < num) { ShieldSledController.Instance?.EndSledding(player, SledEndReason.Manual); } else { ((Character)player).UseStamina(num); } } } } public enum SledStaminaMode { None, Constant, ActivationOnly, JumpBurst } public enum SledState { Idle, Armed, Sledding } [BepInPlugin("ModdedWolf.ShieldSledding", "Shield Sledding", "1.0.9")] public class Plugin : BaseUnityPlugin { public const string GUID = "ModdedWolf.ShieldSledding"; internal const string LegacyGuid = "dev.modded.shieldsledding"; public const string NAME = "Shield Sledding"; public const string VERSION = "1.0.9"; internal static Plugin Instance; internal static ManualLogSource Log; private GameObject _manager; private Harmony _harmony; private void Awake() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; MigrateLegacyConfigFile(); ConfigManager.Init(((BaseUnityPlugin)this).Config); ShieldSpeedRegistry.Init(); _harmony = new Harmony("ModdedWolf.ShieldSledding"); SledPatches.Apply(_harmony); _harmony.PatchAll(typeof(Plugin).Assembly); _manager = new GameObject("ShieldSledding_Manager"); _manager.AddComponent(); Object.DontDestroyOnLoad((Object)(object)_manager); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Shield Sledding v1.0.9 loaded."); } private static void MigrateLegacyConfigFile() { string configPath = Paths.ConfigPath; string text = Path.Combine(configPath, "dev.modded.shieldsledding.cfg"); string text2 = Path.Combine(configPath, "ModdedWolf.ShieldSledding.cfg"); if (!File.Exists(text)) { return; } if (!File.Exists(text2)) { File.Copy(text, text2); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)"Shield Sledding: migrated config from dev.modded.shieldsledding.cfg to ModdedWolf.ShieldSledding.cfg"); } } else { ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)"Shield Sledding: ignoring obsolete dev.modded.shieldsledding.cfg (ModdedWolf.ShieldSledding.cfg already exists)."); } } try { File.Delete(text); ManualLogSource log3 = Log; if (log3 != null) { log3.LogInfo((object)"Shield Sledding: removed obsolete dev.modded.shieldsledding.cfg"); } } catch (IOException ex) { ManualLogSource log4 = Log; if (log4 != null) { log4.LogWarning((object)("Shield Sledding: could not remove legacy config: " + ex.Message)); } } } private void OnDestroy() { if ((Object)(object)_manager != (Object)null) { Object.Destroy((Object)(object)_manager); _manager = null; } Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } _harmony = null; } } internal sealed class ShieldSledController { private float _jumpIntentUntil; private float _armedUntil; private float _lastArmPressTime; private float _activationBufferedUntil; private float _lastActivationFailLogTime; private float _exitInputBlockedUntil; private float _minSpeedCheckUntil; private float _activationBlockedUntil; private float _belowMinSpeedSince = -1f; private bool _wasOnGround = true; private bool _exitRequested; private bool _activationStaminaPaid; private bool _sessionCleaned; private int _warmupStep; private Vector3 _armedMomentumSnapshot; private float _armedPeakHorizontal; private float _armedAirPeakHorizontal; private float _jumpCarryHorizontal; private bool _armedLeftGround; private bool _jumpSequenceActive; private bool _gIntentAfterJump; private float _armedLandGraceUntil; private readonly PhysicsController _physics = new PhysicsController(); private readonly DurabilityController _durability = new DurabilityController(); private readonly CollisionController _collision = new CollisionController(); private readonly EffectController _effects = new EffectController(); private readonly AudioController _audio = new AudioController(); private readonly MultiplayerSync _sync = new MultiplayerSync(); private readonly StatsTracker _stats = new StatsTracker(); internal static ShieldSledController Instance { get; private set; } internal SledState State { get; private set; } internal bool IsSledding => State == SledState.Sledding; internal bool IsArmed => State == SledState.Armed; internal bool IsShieldSledActive { get { if (!IsSledding) { return IsArmed; } return true; } } internal float CurrentSpeed { get; private set; } internal Vector3 SimulatedVelocity => _physics.SimulatedVelocity; internal ItemData LockedShield { get; private set; } internal bool IsInStartupGrace => _physics.IsInStartupGrace; internal float StartupBlend => _physics.StartupBlend; internal Vector3 MoveInput { get; private set; } internal float SteerAxis { get; private set; } internal bool BrakeInput { get; private set; } internal bool LeanForwardInput { get; private set; } internal bool IsAirborneForSledJump(Player player) { return _physics.IsAirborneForPhysics(player); } internal void SetSimulatedVelocity(Player player, Vector3 velocity) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) _physics.SetSimulatedVelocity(player, velocity); } internal ShieldSledController() { Instance = this; } internal void NotifyJump() { if (_jumpSequenceActive) { _jumpIntentUntil = Time.time + ConfigManager.ActivationWindow.Value; } } internal void NotifyJumpIntentFromInput() { _jumpSequenceActive = true; _gIntentAfterJump = false; _jumpIntentUntil = Mathf.Max(_jumpIntentUntil, Time.time + ConfigManager.ActivationWindow.Value); } internal void NotifyLeftGround() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && Time.time <= _jumpIntentUntil + 0.25f) { float num = SampleBestHorizontalSpeed(localPlayer); if (num > _jumpCarryHorizontal) { _jumpCarryHorizontal = num; } } if (IsArmed) { _armedLeftGround = true; _armedLandGraceUntil = Time.time + 0.35f; } if (_jumpSequenceActive && Time.time <= _jumpIntentUntil + 0.15f) { _jumpIntentUntil = Time.time + ConfigManager.ActivationWindow.Value; } } internal void Update() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { _sessionCleaned = false; _warmupStep = 0; ResetLocalState(); return; } if (!_sessionCleaned) { ShieldSledVisual.DestroyTrackedOrphans(); _effects.CleanupOrphans(); _sessionCleaned = true; _warmupStep = 1; } if (_warmupStep > 0 && _warmupStep <= 4) { RunSessionWarmup(localPlayer); } if (((Character)localPlayer).IsDead()) { if (IsSledding || IsArmed) { EndSledding(localPlayer, SledEndReason.Death); } } else { if (!ConfigManager.EnableShieldSledding.Value) { return; } if (!Utility.IsUiBlockingInput() && Utility.WasJumpPressed()) { if (IsSledding) { TryPerformSledJump(localPlayer); } else { NotifyJumpIntentFromInput(); } } ReadInput(localPlayer); HandleActivationInput(localPlayer); HandleExitInput(localPlayer); UpdateArmedState(localPlayer); CheckEnvironmentalExits(localPlayer); ValidateHandShield(localPlayer); if (IsArmed || IsSledding) { ShieldSledVisual.Update(localPlayer, active: true, IsSledding); } if (IsSledding) { _stats.Update(localPlayer, CurrentSpeed); _effects.Update(localPlayer, CurrentSpeed, SteerAxis); _audio.Update(localPlayer, CurrentSpeed); _sync.WriteLocalState(localPlayer, active: true, CurrentSpeed); } else { _effects.Update(localPlayer, 0f, 0f); _audio.Update(localPlayer, 0f); _sync.WriteLocalState(localPlayer, active: false, 0f); } _sync.UpdateRemotePlayers(); } } internal void ApplySledPhysics(Player player, float dt) { if ((Object)(object)player == (Object)null || !IsSledding) { return; } try { ApplySledPhysicsInternal(player, dt); } catch (Exception arg) { Plugin.Log.LogError((object)$"Shield Sledding: physics tick failed — ending sled. {arg}"); try { EndSledding(player, SledEndReason.Manual); } catch (Exception arg2) { Plugin.Log.LogError((object)$"Shield Sledding: failed to end sled after physics error. {arg2}"); State = SledState.Idle; } } } private void ApplySledPhysicsInternal(Player player, float dt) { //IL_0045: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) dt = Mathf.Clamp(dt, 0.001f, 0.05f); ItemData val = LockedShield ?? Utility.GetHandShield(player); if (val == null || val.m_durability <= 0f) { EndSledding(player, SledEndReason.ShieldBroken); return; } PhysicsResult result = _physics.Simulate(player, val, MoveInput, BrakeInput, LeanForwardInput, dt); CurrentSpeed = result.HorizontalSpeed; if (result.OnGround && !result.Ground.IsWaterSurface) { ((Character)player).m_lastGroundPoint = result.Ground.Point; ((Character)player).m_lastGroundNormal = result.Ground.Normal; ((Character)player).m_lastGroundCollider = result.Ground.Collider; ((Character)player).m_groundContact = true; SledGroundSolver.UpdateSledFacing((Character)(object)player, in result.Ground, dt); } _durability.Tick(player, val, result); _collision.Tick(player, val, result); _sync.WriteLocalState(player, active: true, CurrentSpeed); bool flag = ((Character)player).IsOnGround(); if (!_wasOnGround && flag) { if (ConfigManager.AbsorbDamageToShield.Value) { _durability.OnLanding(player, val, result.LandingImpact); } else { DamageAbsorption.ApplyLandingDamage(player, result.LandingImpact); } _collision.OnLanding(player, result.LandingImpact); _effects.OnLanding(player, result.LandingImpact); _audio.OnLanding(player, result.LandingImpact); _stats.OnLanding(player, result.LandingImpact); } _wasOnGround = flag; } internal bool TryOverrideControls(Player player, ref Vector3 moveDir, ref bool block, ref bool jump, ref bool run) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (IsSledding) { block = false; if (jump) { TryPerformSledJump(player); jump = false; } moveDir = Vector3.zero; run = false; return true; } if (IsArmed && Utility.IsAirborne(player)) { block = false; jump = false; Vector3 val = ((Character)player).GetVelocity(); Rigidbody body = Utility.GetBody(player); if ((Object)(object)body != (Object)null && !body.isKinematic && Utility.HorizontalSpeed(body.linearVelocity) > Utility.HorizontalSpeed(val)) { val = body.linearVelocity; } if (Utility.HorizontalSpeed(((Character)player).m_currentVel) > Utility.HorizontalSpeed(val)) { val = ((Character)player).m_currentVel; } Vector3 val2 = Utility.Flatten(val); if (((Vector3)(ref val2)).sqrMagnitude > 0.35f) { moveDir = ((Vector3)(ref val2)).normalized; run = true; } return true; } _ = IsArmed; return false; } private void RunSessionWarmup(Player player) { switch (_warmupStep) { case 1: AudioController.Prewarm(); _audio.Begin(player); _audio.End(player); break; case 2: EffectController.Prewarm(); _effects.Begin(player); break; case 3: Utility.PrewarmPhysicsQueries(player); _physics.PrewarmBodyTune(player); break; case 4: ShieldSledVisual.DestroySceneOrphans(); break; } _warmupStep++; } private void ReadInput(Player player) { //IL_0001: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_0149: 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_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) MoveInput = Vector3.zero; SteerAxis = 0f; BrakeInput = false; LeanForwardInput = false; if (Utility.IsUiBlockingInput()) { return; } Vector3 val = Utility.Flatten(((Component)player).transform.forward); Vector3 val2 = ((Component)player).transform.right; if (IsSledding && Utility.TryGetSledSteerAxes(player, SimulatedVelocity, out var forward, out var right)) { val = forward; val2 = right; } else { Utility.ResetSledSteerFrame(); if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { ((Vector3)(ref val)).Normalize(); } } if (ZInput.GetKey((KeyCode)97, true) || ZInput.GetKey((KeyCode)276, true)) { SteerAxis -= 1f; } if (ZInput.GetKey((KeyCode)100, true) || ZInput.GetKey((KeyCode)275, true)) { SteerAxis += 1f; } if (ConfigManager.InvertSteering != null && ConfigManager.InvertSteering.Value) { SteerAxis = 0f - SteerAxis; } Vector3 val4; if (Mathf.Abs(SteerAxis) > 0.01f) { Vector3 val3 = val + val2 * SteerAxis; if (((Vector3)(ref val3)).sqrMagnitude > 0.0001f) { MoveInput = ((Vector3)(ref val3)).normalized; } else { val4 = val2 * SteerAxis; MoveInput = ((Vector3)(ref val4)).normalized; } } if (ZInput.GetKey((KeyCode)119, true) || ZInput.GetKey((KeyCode)273, true)) { LeanForwardInput = true; } if (ZInput.GetKey((KeyCode)115, true) || ZInput.GetKey((KeyCode)274, true)) { BrakeInput = true; } SteerAxis = Mathf.Clamp(SteerAxis, -1f, 1f); val4 = MoveInput; if (((Vector3)(ref val4)).sqrMagnitude > 1f) { val4 = MoveInput; ((Vector3)(ref val4)).Normalize(); } } private void UpdateArmedState(Player player) { bool flag = ((Character)player).IsOnGround() || ((Character)player).m_groundContact; if (_wasOnGround && !flag) { NotifyLeftGround(); } else if (flag && !_wasOnGround) { _jumpSequenceActive = false; _jumpIntentUntil = 0f; _activationBufferedUntil = 0f; _gIntentAfterJump = false; if (IsArmed && !IsSledding) { _armedLandGraceUntil = Mathf.Max(_armedLandGraceUntil, Time.time + 0.3f); } } if (IsArmed && !IsSledding) { UpdateArmedMomentum(player); if (Time.time > _armedUntil) { State = SledState.Idle; _armedLeftGround = false; _armedLandGraceUntil = 0f; _jumpCarryHorizontal = 0f; _jumpSequenceActive = false; _jumpIntentUntil = 0f; ShieldSledVisual.Hide(player); Plugin.Log.LogInfo((object)"Shield sled arm expired before sledding started."); } } else if (!IsSledding && !IsArmed) { TryArm(player); } _wasOnGround = flag; } internal void TrackArmedMomentum(Player player) { if (!((Object)(object)player == (Object)null) && IsArmed && !IsSledding) { UpdateArmedMomentum(player); } } internal bool TryActivateOnLanding(Player player) { if ((Object)(object)player == (Object)null || !IsArmed || IsSledding) { return false; } if (!_armedLeftGround) { return false; } if (!((Character)player).IsOnGround() && !((Character)player).m_groundContact) { return false; } if (!Utility.TryGetActivationGround(player, out var ground)) { return false; } float feetHeightAboveGround = Utility.GetFeetHeightAboveGround(player, ground); bool num = !_wasOnGround; bool flag = Time.time <= _armedLandGraceUntil; if (!num && !flag) { return false; } CaptureLandingMomentum(player); if (!TryActivateSled(player, fromArmed: true, in ground, feetHeightAboveGround)) { if (Utility.GetActivationSlopeAngle(player, in ground) < Utility.GetActivationMinimumSlope()) { CancelArm(player, "Landing too flat to start sledding."); } return false; } _armedLeftGround = false; _armedLandGraceUntil = 0f; return true; } private void CaptureLandingMomentum(Player player) { //IL_002b: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) UpdateArmedMomentum(player); if (!Utility.TryProbeGroundBelow(player, 2f, out var sample) || ((Vector3)(ref sample.Normal)).sqrMagnitude < 0.01f) { return; } Vector3 armedMomentumSnapshot = Vector3.ProjectOnPlane(((Character)player).m_currentVel, sample.Normal); if (((Vector3)(ref armedMomentumSnapshot)).sqrMagnitude > ((Vector3)(ref _armedMomentumSnapshot)).sqrMagnitude) { _armedMomentumSnapshot = armedMomentumSnapshot; } Rigidbody body = Utility.GetBody(player); if ((Object)(object)body != (Object)null && !body.isKinematic) { Vector3 armedMomentumSnapshot2 = Vector3.ProjectOnPlane(body.linearVelocity, sample.Normal); if (((Vector3)(ref armedMomentumSnapshot2)).sqrMagnitude > ((Vector3)(ref _armedMomentumSnapshot)).sqrMagnitude) { _armedMomentumSnapshot = armedMomentumSnapshot2; } } PromoteSnapshotToPeakHorizontal(player, in sample); } private void PromoteSnapshotToPeakHorizontal(Player player, in GroundSample ground) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00a4: 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_00f5: 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_00b7: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(new float[3] { _armedPeakHorizontal, _armedAirPeakHorizontal, _jumpCarryHorizontal }); if (num <= ((Vector3)(ref _armedMomentumSnapshot)).magnitude + 0.05f) { return; } Vector3 v = _armedMomentumSnapshot; if (((Vector3)(ref v)).sqrMagnitude < 0.01f) { v = ((Character)player).m_currentVel; } if (((Vector3)(ref v)).sqrMagnitude < 0.01f) { v = ((Character)player).GetVelocity(); } Vector3 val = Utility.Flatten(v); if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { Vector3 sledLookOnPlane = Utility.GetSledLookOnPlane(player, ground.Normal); val = ((((Vector3)(ref sledLookOnPlane)).sqrMagnitude > 0.01f) ? Utility.Flatten(sledLookOnPlane) : Utility.Flatten(((Component)player).transform.forward)); } if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f)) { Vector3 armedMomentumSnapshot = Vector3.ProjectOnPlane(((Vector3)(ref val)).normalized * num, ground.Normal); if (((Vector3)(ref armedMomentumSnapshot)).sqrMagnitude > ((Vector3)(ref _armedMomentumSnapshot)).sqrMagnitude) { _armedMomentumSnapshot = armedMomentumSnapshot; } } } internal void UpdateArmedMomentumFixed(Player player) { if (!((Object)(object)player == (Object)null) && IsArmed && !IsSledding) { UpdateArmedMomentum(player); } } private void UpdateArmedMomentum(Player player) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00a7: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Character)player).GetVelocity(); Rigidbody body = Utility.GetBody(player); if ((Object)(object)body != (Object)null && !body.isKinematic) { Vector3 linearVelocity = body.linearVelocity; if (((Vector3)(ref linearVelocity)).sqrMagnitude > ((Vector3)(ref val)).sqrMagnitude) { val = body.linearVelocity; } } if (((Vector3)(ref ((Character)player).m_currentVel)).sqrMagnitude > ((Vector3)(ref val)).sqrMagnitude) { val = ((Character)player).m_currentVel; } GroundSample sample; Vector3 armedMomentumSnapshot = ((!Utility.TryProbeGroundBelow(player, 2f, out sample) || !(((Vector3)(ref sample.Normal)).sqrMagnitude > 0.01f)) ? Utility.Flatten(val) : Vector3.ProjectOnPlane(val, sample.Normal)); if (((Vector3)(ref armedMomentumSnapshot)).sqrMagnitude > ((Vector3)(ref _armedMomentumSnapshot)).sqrMagnitude) { _armedMomentumSnapshot = armedMomentumSnapshot; } float num = Utility.HorizontalSpeed(val); if (num > _armedPeakHorizontal) { _armedPeakHorizontal = num; } if (Utility.IsAirborne(player) && num > _armedAirPeakHorizontal) { _armedAirPeakHorizontal = num; } } private static float SampleBestHorizontalSpeed(Player player) { //IL_0010: 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_0035: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return 0f; } float num = Utility.HorizontalSpeed(((Character)player).GetVelocity()); Rigidbody body = Utility.GetBody(player); if ((Object)(object)body != (Object)null && !body.isKinematic) { num = Mathf.Max(num, Utility.HorizontalSpeed(body.linearVelocity)); } return Mathf.Max(num, Utility.HorizontalSpeed(((Character)player).m_currentVel)); } private void HandleActivationInput(Player player) { if ((Object)(object)player == (Object)null || IsSledding || IsArmed || Utility.IsUiBlockingInput() || !Utility.WasActivationPressed()) { return; } if (!Utility.HasUsableShield(player)) { _gIntentAfterJump = false; _activationBufferedUntil = 0f; LogArmFailureThrottled("Equip a shield to sled."); return; } _activationBufferedUntil = Time.time + 0.35f; if (_jumpSequenceActive) { _gIntentAfterJump = true; } else { LogArmFailureThrottled("Press jump, then " + Utility.GetActivationKeyLabel() + " while in the air."); } } internal void TryArm(Player player) { //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) if ((Object)(object)player == (Object)null || IsSledding || IsArmed || Time.time < _activationBlockedUntil || Utility.IsUiBlockingInput() || !WithinJumpWindow() || !_jumpSequenceActive || !_gIntentAfterJump || !Utility.CanArmInAir(player)) { return; } ItemData handShield = Utility.GetHandShield(player); if (handShield == null || handShield.m_durability <= 0f) { _gIntentAfterJump = false; _activationBufferedUntil = 0f; LogArmFailureThrottled("Equip a shield to sled."); return; } _activationBufferedUntil = 0f; _lastArmPressTime = Time.time; _gIntentAfterJump = false; State = SledState.Armed; _armedUntil = Time.time + ConfigManager.ArmedWindow.Value; _armedMomentumSnapshot = Vector3.zero; _armedLeftGround = true; UpdateArmedMomentum(player); float armedAirPeakHorizontal = (_armedPeakHorizontal = Mathf.Max(new float[4] { SampleBestHorizontalSpeed(player), _jumpCarryHorizontal, _armedPeakHorizontal, _armedAirPeakHorizontal })); if (Utility.IsAirborne(player)) { _armedAirPeakHorizontal = armedAirPeakHorizontal; } ShieldSledVisual.Show(player, handShield); Utility.ShowHint("Shield sled armed — land on a slope."); Plugin.Log.LogInfo((object)("Shield sled armed with " + Utility.GetShieldPrefabName(handShield) + ".")); } private bool TryActivateSled(Player player, bool fromArmed, in GroundSample ground, float feetGap = 0f) { if ((Object)(object)player == (Object)null || IsSledding) { return false; } if (Time.time < _activationBlockedUntil) { return false; } if (!((Character)player).IsOnGround() && !((Character)player).m_groundContact && !Utility.IsSledGrounded(player)) { return false; } GroundSample ground2 = ground; if (!Utility.TryGetActivationGround(player, out ground2)) { LogActivationFailureThrottled("no ground under player"); return false; } if (!CanActivateOnGround(player, ground2, fromArmed)) { if (!fromArmed) { LogActivationFailureThrottled($"Need a {Utility.GetActivationMinimumSlope():F0}° slope to start (ground is {ground2.SlopeAngle:F0}°)."); } return false; } ItemData handShield = Utility.GetHandShield(player); if (handShield == null || handShield.m_durability <= 0f) { LogActivationFailureThrottled("Equip a shield to sled."); if (fromArmed) { CancelArm(player, "Equip a shield to sled."); } return false; } BeginSledding(player, handShield, fromArmed, in ground2); return true; } private bool TryActivateSled(Player player, bool fromArmed) { Utility.TryGetActivationGround(player, out var ground); float feetGap = ((((Vector3)(ref ground.Normal)).sqrMagnitude > 0.01f) ? Utility.GetFeetHeightAboveGround(player, ground) : 0f); return TryActivateSled(player, fromArmed, in ground, feetGap); } private bool CanActivateOnGround(Player player, GroundSample ground, bool fromArmed) { float activationMinimumSlope = Utility.GetActivationMinimumSlope(); return Utility.GetActivationSlopeAngle(player, in ground) >= activationMinimumSlope; } private void CancelArm(Player player, string userHint = null) { if (IsArmed && !IsSledding) { State = SledState.Idle; _armedUntil = 0f; _armedLeftGround = false; _armedLandGraceUntil = 0f; _jumpSequenceActive = false; _jumpIntentUntil = 0f; _activationBufferedUntil = 0f; _gIntentAfterJump = false; ShieldSledVisual.Hide(player); Plugin.Log.LogInfo((object)"Shield sled disarmed."); if (!string.IsNullOrEmpty(userHint)) { Utility.ShowHint(userHint); } } } private void LogArmFailureThrottled(string message) { if (!(Time.time - _lastActivationFailLogTime < 1.5f)) { _lastActivationFailLogTime = Time.time; Plugin.Log.LogInfo((object)("Shield sled: " + message)); Utility.ShowHint(message); } } private void LogActivationFailureThrottled(string reason) { if (!(Time.time - _lastActivationFailLogTime < 1f)) { _lastActivationFailLogTime = Time.time; Plugin.Log.LogInfo((object)("Shield sled not ready: " + reason + ".")); Utility.ShowHint(reason); } } private void BeginSledding(Player player, ItemData shield, bool fromArmedLanding, in GroundSample activationGroundIn) { //IL_0155: 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_0143: 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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_0221: Unknown result type (might be due to invalid IL or missing references) if (shield == null || shield.m_durability <= 0f || !shield.m_equipped) { Plugin.Log.LogInfo((object)"Shield sled not ready: no equipped shield."); if (fromArmedLanding && IsArmed) { CancelArm(player, "Equip a shield to sled."); } return; } if (!PayActivationStamina(player)) { State = SledState.Idle; ShieldSledVisual.Hide(player); return; } GroundSample ground = activationGroundIn; if (!Utility.TryGetActivationGround(player, out ground)) { Utility.TrySampleGround(player, out ground); } float activationMinimumSlope = Utility.GetActivationMinimumSlope(); float activationSlopeAngle = Utility.GetActivationSlopeAngle(player, in ground); if (activationSlopeAngle < activationMinimumSlope) { Plugin.Log.LogInfo((object)$"Shield sled not ready: landing slope {activationSlopeAngle:F1}° (need {activationMinimumSlope:F0}°)."); if (fromArmedLanding && IsArmed) { CancelArm(player, "Landing too flat to start sledding."); } return; } State = SledState.Sledding; LockedShield = shield; _armedUntil = 0f; _exitInputBlockedUntil = Time.time + 0.08f; _minSpeedCheckUntil = Time.time + 0.25f; _belowMinSpeedSince = -1f; _wasOnGround = ((Character)player).IsOnGround() || ((Character)player).m_groundContact; float num = Mathf.Max(new float[3] { _armedAirPeakHorizontal, _armedPeakHorizontal, _jumpCarryHorizontal }); Vector3 seedVelocity = (fromArmedLanding ? _physics.ResolveLandingSeed(player, in ground, shield, _armedMomentumSnapshot, num, armedLanding: true) : Vector3.zero); _armedMomentumSnapshot = Vector3.zero; _armedPeakHorizontal = 0f; _armedAirPeakHorizontal = 0f; _jumpCarryHorizontal = 0f; _armedLeftGround = false; _armedLandGraceUntil = 0f; _physics.ConfigureBodyForSled(player, seedVelocity); _physics.PrepareSledStart(player, seedVelocity, in ground, shield); SledGroundSolver.SnapToGroundOnSledStart(player, ((Vector3)(ref seedVelocity)).magnitude); ShieldSledVisual.EnsureReadyForSledding(player, shield); _durability.Begin(player); _collision.Begin(player); _effects.Begin(player); _audio.Begin(player); _stats.Begin(player); GhostReplaySystem.BeginSession(); TimeTrialManager.BeginSession(); CurrentSpeed = Utility.HorizontalSpeed(_physics.SimulatedVelocity); float num2 = ShieldSpeedRegistry.EstimateNaturalSpeed(in ground, player, shield); Plugin.Log.LogInfo((object)($"Shield sledding activated on {Utility.GetShieldPrefabName(shield)} at {CurrentSpeed:F1} m/s " + $"(carry {num:F1} m/s, slope {ground.SlopeAngle:F0}°, coast ~{num2:F1} m/s).")); } private bool PayActivationStamina(Player player) { if (_activationStaminaPaid) { return true; } if (ConfigManager.StaminaMode.Value != SledStaminaMode.ActivationOnly && ConfigManager.StaminaMode.Value != SledStaminaMode.Constant && ConfigManager.StaminaMode.Value != SledStaminaMode.JumpBurst) { _activationStaminaPaid = true; return true; } float value = ConfigManager.StaminaActivationCost.Value; if (value <= 0f) { _activationStaminaPaid = true; return true; } if (player.GetStamina() < value) { return false; } ((Character)player).UseStamina(value); _activationStaminaPaid = true; return true; } private void HandleExitInput(Player player) { if (!Utility.IsUiBlockingInput()) { if (IsSledding && Time.time >= _exitInputBlockedUntil && Utility.WasActivationPressed()) { EndSledding(player, SledEndReason.Manual); } else if (IsArmed && !IsSledding && Utility.WasDismountPressed()) { CancelArm(player); } else if (IsSledding && Utility.WasDismountPressed()) { EndSledding(player, SledEndReason.Manual); _exitRequested = true; } } } private void CheckEnvironmentalExits(Player player) { if (IsSledding) { if (WaterSledHelper.ShouldEndSledForWater(player, CurrentSpeed)) { WaterSledHelper.ResetSurfaceSmoothing(); EndSledding(player, SledEndReason.Water); } else if (!WaterSledHelper.IsWaterSledding(player, CurrentSpeed)) { CheckMinimumSledSpeed(player); } } } private void CheckMinimumSledSpeed(Player player) { float num = ConfigManager.MinimumSledSpeed?.Value ?? 0f; if (num <= 0f) { _belowMinSpeedSince = -1f; return; } if (Time.time < _minSpeedCheckUntil || _physics.IsInStartupGrace) { _belowMinSpeedSince = -1f; return; } if (!((Character)player).IsOnGround() && !((Character)player).m_groundContact) { _belowMinSpeedSince = -1f; return; } if (CurrentSpeed + 0.01f >= num) { _belowMinSpeedSince = -1f; return; } if (_belowMinSpeedSince < 0f) { _belowMinSpeedSince = Time.time; } if (!(Time.time - _belowMinSpeedSince < 0.2f)) { EndSledding(player, SledEndReason.TooSlow); } } private void ValidateHandShield(Player player) { if (!IsShieldSledActive || (Object)(object)player == (Object)null) { return; } if (IsSledding) { ItemData handShield = Utility.GetHandShield(player); if (handShield != LockedShield || handShield == null || handShield.m_durability <= 0f) { EndSledding(player, SledEndReason.ShieldBroken); Plugin.Log.LogInfo((object)"Shield sledding ended: shield changed or removed."); } } else if (!Utility.HasUsableShield(player)) { State = SledState.Idle; _armedUntil = 0f; ShieldSledVisual.Hide(player); Plugin.Log.LogInfo((object)"Shield sled arm cancelled: shield not in hand."); } } internal bool TryPerformSledJump(Player player) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || !IsSledding || !_physics.TryJump(player)) { return false; } NotifyJump(); NotifyLeftGround(); if (ConfigManager.StaminaMode.Value == SledStaminaMode.JumpBurst) { float value = ConfigManager.StaminaJumpCost.Value; if (value > 0f && player.GetStamina() >= value) { ((Character)player).UseStamina(value); } } _stats.OnJump(player); ApplySledPhysics(player, Time.fixedDeltaTime); SledGroundSolver.SyncCharacterMotionState((Character)(object)player, SimulatedVelocity, grounded: false); return true; } internal void EndSledding(Player player, SledEndReason reason) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) if (!IsSledding && !IsArmed) { return; } bool isSledding = IsSledding; bool isArmed = IsArmed; if (isSledding && (reason == SledEndReason.Manual || reason == SledEndReason.CombatHit)) { _activationBlockedUntil = Time.time + 0.6f; } State = SledState.Idle; LockedShield = null; Utility.ResetSledSteerFrame(); _activationStaminaPaid = false; _armedUntil = 0f; _exitInputBlockedUntil = 0f; _minSpeedCheckUntil = 0f; _belowMinSpeedSince = -1f; CurrentSpeed = 0f; _armedMomentumSnapshot = Vector3.zero; _armedPeakHorizontal = 0f; _armedAirPeakHorizontal = 0f; _jumpCarryHorizontal = 0f; _armedLeftGround = false; _armedLandGraceUntil = 0f; _jumpSequenceActive = false; _jumpIntentUntil = 0f; _activationBufferedUntil = 0f; _gIntentAfterJump = false; Rigidbody body = Utility.GetBody(player); Vector3 simulatedVelocity = _physics.SimulatedVelocity; if ((Object)(object)body != (Object)null) { _physics.RestoreBody(player); if (isSledding) { Vector3 val = simulatedVelocity; Vector3 val2 = Utility.Flatten(val); val = ((reason != SledEndReason.Manual) ? (val2 * 0.5f + Vector3.up * val.y) : (val2 * 0.2f + Vector3.up * Mathf.Min(val.y, 0.5f))); Utility.TrySetLinearVelocity(body, val); ((Character)player).m_sliding = false; SledGroundSolver.SyncCharacterMotionState((Character)(object)player, val, ((Character)player).IsOnGround()); } } if (isSledding || isArmed) { ShieldSledVisual.Hide(player); } if (isSledding) { if (reason == SledEndReason.ShieldBroken && ConfigManager.StumbleOnShieldBreak.Value) { ((Character)player).Stagger(Vector3.zero); Utility.TrySetLinearVelocity(body, Vector3.zero); } _stats.End(player); _effects.End(player); _audio.End(player); WaterSledHelper.ResetSurfaceSmoothing(); GhostReplaySystem.EndSession(); TimeTrialManager.EndSession(); Plugin.Log.LogInfo((object)$"Shield sledding ended: {reason}."); } _sync.WriteLocalState(player, active: false, 0f); } private bool WithinJumpWindow() { return Time.time <= _jumpIntentUntil; } private void ResetLocalState() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) State = SledState.Idle; CurrentSpeed = 0f; _activationStaminaPaid = false; _armedUntil = 0f; _armedMomentumSnapshot = Vector3.zero; _armedPeakHorizontal = 0f; _armedAirPeakHorizontal = 0f; _jumpCarryHorizontal = 0f; _armedLeftGround = false; _jumpSequenceActive = false; _gIntentAfterJump = false; _armedLandGraceUntil = 0f; _activationBufferedUntil = 0f; ShieldSledVisual.Hide(null); } internal bool ConsumeExitRequest() { if (!_exitRequested) { return false; } _exitRequested = false; return true; } internal void ReportCollisionWear(Player player, ItemData shield, float impact) { _durability.OnCollision(player, shield, impact); } internal void ReportDamageAsShieldWear(Player player, ItemData shield, float damage) { _durability.OnDamage(player, shield, damage); } } internal enum SledEndReason { Manual, Water, Death, ShieldBroken, CombatHit, TooSlow } [DefaultExecutionOrder(32000)] internal sealed class ShieldSledManager : MonoBehaviour { private ShieldSledController _controller; internal static ShieldSledManager Instance { get; private set; } private void Awake() { Instance = this; _controller = new ShieldSledController(); ((Component)this).gameObject.AddComponent(); } private void Update() { if (ConfigManager.EnableShieldSledding.Value && !Utility.IsDedicatedServer()) { _controller.Update(); } } private void LateUpdate() { if (!ConfigManager.EnableShieldSledding.Value || Utility.IsDedicatedServer()) { return; } Player localPlayer = Player.m_localPlayer; ShieldSledController instance = ShieldSledController.Instance; if (!((Object)(object)localPlayer == (Object)null) && instance != null) { if (instance.IsArmed || instance.IsSledding) { ShieldSledVisual.LateUpdate(localPlayer); } ShieldSledVisual.UpdateRemotePlayers(); } } private void FixedUpdate() { if (!ConfigManager.EnableShieldSledding.Value || Utility.IsDedicatedServer()) { return; } Player localPlayer = Player.m_localPlayer; ShieldSledController instance = ShieldSledController.Instance; if (!((Object)(object)localPlayer == (Object)null) && instance != null) { if (instance.IsArmed && !instance.IsSledding) { instance.UpdateArmedMomentumFixed(localPlayer); } else if (instance.IsSledding && !instance.IsInStartupGrace) { SledGroundSolver.FixGroundClip(localPlayer); } } } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } internal static class ShieldSledVisual { private struct ShieldTransformBackup { internal Transform Parent; internal Vector3 LocalPosition; internal Quaternion LocalRotation; internal Vector3 LocalScale; } private struct TransformBackup { internal Transform Transform; internal Vector3 LocalPosition; internal Quaternion LocalRotation; internal Vector3 LocalScale; } private struct ColliderBackup { internal Collider Collider; internal bool Enabled; } private struct RigidbodyBackup { internal Rigidbody Body; internal bool DetectCollisions; } private sealed class VisualState { internal Transform FeetAttach; internal Transform ShieldTransform; internal string ActiveShieldPrefab; internal ShieldTransformBackup ShieldBackup; internal Player OwnerPlayer; internal bool BackupValid; internal bool VisualUpdateInProgress; internal Transform PhysicsStrippedFor; internal readonly List ColliderBackups = new List(); internal readonly List RigidbodyBackups = new List(); internal readonly List HierarchyBackups = new List(); } private const string FeetAttachName = "ShieldSledding_FeetAttach"; private const string LocalParticlesName = "ShieldSledding_LocalParticles"; private static readonly Dictionary States = new Dictionary(); private static readonly List ScratchIds = new List(); private static string _lastLoggedFeetPoseKey; private static int KeyOf(Player player) { if (!((Object)(object)player != (Object)null)) { return 0; } return ((Object)player).GetInstanceID(); } private static bool TryGetState(Player player, out VisualState state) { state = null; if ((Object)(object)player == (Object)null) { return false; } if (States.TryGetValue(KeyOf(player), out state)) { return state != null; } return false; } private static VisualState GetOrCreateState(Player player) { int key = KeyOf(player); if (States.TryGetValue(key, out var value) && value != null) { return value; } VisualState visualState = new VisualState(); States[key] = visualState; return visualState; } private static void RemoveState(Player player) { if (!((Object)(object)player == (Object)null)) { States.Remove(KeyOf(player)); } } internal static void DestroyAllOrphans() { DestroyTrackedOrphans(); DestroySceneOrphans(); } internal static void DestroyTrackedOrphans() { ScratchIds.Clear(); foreach (KeyValuePair state in States) { ScratchIds.Add(state.Key); } for (int i = 0; i < ScratchIds.Count; i++) { if (States.TryGetValue(ScratchIds[i], out var value) && value != null) { TearDownState(value, refreshEquipment: false); } } States.Clear(); } internal static void DestroySceneOrphans() { GameObject[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (GameObject val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.GetComponent() != (Object)null)) { string name = ((Object)val).name; if (name == "ShieldSledding_FeetAttach" || name == "ShieldSledding_LocalParticles") { Object.Destroy((Object)(object)val); } else if (name.StartsWith("ShieldSledding_")) { Object.Destroy((Object)(object)val); } } } } internal static void EnsureReadyForSledding(Player player, ItemData shield) { if (!((Object)(object)player == (Object)null) && shield != null && !Utility.IsDedicatedServer()) { if (TryGetState(player, out var state) && (Object)(object)state.OwnerPlayer == (Object)(object)player && (Object)(object)state.FeetAttach != (Object)null && (Object)(object)state.ShieldTransform != (Object)null) { RefreshFeetShieldTransform(player, state); ApplyFeetShieldPose(player, state); } else { Show(player, shield); } } } internal static void Show(Player player, ItemData shield) { if (!((Object)(object)player == (Object)null) && shield != null && !Utility.IsDedicatedServer()) { Hide(player); Transform equippedShieldTransform = GetEquippedShieldTransform(player); if ((Object)(object)equippedShieldTransform == (Object)null) { Plugin.Log.LogWarning((object)("Shield Sledding: no equipped shield mesh for " + Utility.GetShieldPrefabName(shield) + ".")); } else { BeginShow(player, equippedShieldTransform, Utility.GetShieldPrefabName(shield)); } } } internal static void ShowRemote(Player player, string shieldPrefabHint) { if ((Object)(object)player == (Object)null || Utility.IsDedicatedServer() || Utility.IsLocalPlayer(player)) { return; } if (TryGetState(player, out var state) && (Object)(object)state.FeetAttach != (Object)null && (Object)(object)state.ShieldTransform != (Object)null) { if (!string.IsNullOrEmpty(shieldPrefabHint)) { state.ActiveShieldPrefab = shieldPrefabHint; } return; } Hide(player); Transform val = GetEquippedShieldTransform(player); if ((Object)(object)val == (Object)null) { val = FindRemoteShieldMesh(player); } if (!((Object)(object)val == (Object)null)) { string prefab = ((!string.IsNullOrEmpty(shieldPrefabHint)) ? shieldPrefabHint : ResolvePrefabFromTransform(val)); BeginShow(player, val, prefab); } } private static void BeginShow(Player player, Transform equipped, string prefab) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) VisualState orCreateState = GetOrCreateState(player); orCreateState.OwnerPlayer = player; orCreateState.ActiveShieldPrefab = prefab ?? string.Empty; orCreateState.BackupValid = true; orCreateState.ShieldBackup = CaptureTransform(equipped); orCreateState.ShieldTransform = equipped; CaptureHierarchyBackup(orCreateState, equipped); orCreateState.FeetAttach = new GameObject("ShieldSledding_FeetAttach").transform; orCreateState.FeetAttach.SetParent(((Component)player).transform, false); RefreshFeetShieldTransform(player, orCreateState); ReparentShieldToFeet(player, orCreateState); Plugin.Log.LogInfo((object)("Shield Sledding: moved " + ((Object)equipped).name + " visual to feet.")); } internal static Transform GetFeetAttach(Player player) { if (!TryGetState(player, out var state) || (Object)(object)state.OwnerPlayer != (Object)(object)player) { return null; } return state.FeetAttach; } internal static void Hide(Player player) { VisualState state; if ((Object)(object)player == (Object)null) { ScratchIds.Clear(); foreach (KeyValuePair state2 in States) { VisualState value = state2.Value; if ((Object)(object)value?.OwnerPlayer == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)value.OwnerPlayer == (Object)(object)Player.m_localPlayer) { ScratchIds.Add(state2.Key); } } for (int i = 0; i < ScratchIds.Count; i++) { if (!States.TryGetValue(ScratchIds[i], out var value2) || value2 == null) { States.Remove(ScratchIds[i]); continue; } Player ownerPlayer = value2.OwnerPlayer; TearDownState(value2, (Object)(object)ownerPlayer != (Object)null); States.Remove(ScratchIds[i]); } } else if (TryGetState(player, out state)) { TearDownState(state, refreshEquipment: true); RemoveState(player); } } private static void TearDownState(VisualState state, bool refreshEquipment) { if (state != null) { Player ownerPlayer = state.OwnerPlayer; RestoreShieldTransform(state); if (refreshEquipment) { RefreshEquipmentVisuals(ownerPlayer); } if ((Object)(object)state.FeetAttach != (Object)null) { Object.Destroy((Object)(object)((Component)state.FeetAttach).gameObject); state.FeetAttach = null; } state.OwnerPlayer = null; } } internal static void OnPlayerDestroyed(Player player) { if (!((Object)(object)player == (Object)null) && TryGetState(player, out var state)) { state.FeetAttach = null; state.ShieldTransform = null; state.ActiveShieldPrefab = null; state.OwnerPlayer = null; state.BackupValid = false; RestoreShieldPhysics(state); state.HierarchyBackups.Clear(); RemoveState(player); } } internal static void Update(Player player, bool active, bool sledding) { if (active && TryGetState(player, out var state) && !((Object)(object)state.FeetAttach == (Object)null) && !((Object)(object)state.OwnerPlayer != (Object)(object)player)) { RunVisualUpdate(player, state); } } internal static void LateUpdate(Player player) { if (TryGetState(player, out var state) && !((Object)(object)state.FeetAttach == (Object)null) && !((Object)(object)state.OwnerPlayer != (Object)(object)player)) { RunVisualUpdate(player, state); } } internal static void UpdateRemotePlayers() { if (Utility.IsDedicatedServer() || MultiplayerSync.Instance == null) { return; } List allPlayers = Player.GetAllPlayers(); if (allPlayers == null) { return; } ScratchIds.Clear(); for (int i = 0; i < allPlayers.Count; i++) { Player val = allPlayers[i]; if ((Object)(object)val == (Object)null || Utility.IsLocalPlayer(val)) { continue; } VisualState state; if (!MultiplayerSync.Instance.TryReadRemoteState(val, out var active, out var _, out var shieldPrefab)) { if (TryGetState(val, out state)) { Hide(val); } continue; } if (!active) { if (TryGetState(val, out state)) { Hide(val); } continue; } ShowRemote(val, shieldPrefab); if (TryGetState(val, out var state2) && (Object)(object)state2.FeetAttach != (Object)null) { RunVisualUpdate(val, state2); ScratchIds.Add(KeyOf(val)); } } List list = null; foreach (KeyValuePair state3 in States) { VisualState value = state3.Value; if (!((Object)(object)value?.OwnerPlayer == (Object)null) && !Utility.IsLocalPlayer(value.OwnerPlayer) && !ScratchIds.Contains(state3.Key)) { if (list == null) { list = new List(); } list.Add(state3.Key); } } if (list == null) { return; } for (int j = 0; j < list.Count; j++) { if (States.TryGetValue(list[j], out var value2) && (Object)(object)value2?.OwnerPlayer != (Object)null) { Hide(value2.OwnerPlayer); } } } private static void RunVisualUpdate(Player player, VisualState state) { if (state.VisualUpdateInProgress) { return; } state.VisualUpdateInProgress = true; try { if (RefreshShieldReference(player, state)) { RefreshFeetShieldTransform(player, state); EnsureShieldOnFeet(player, state); ApplyFeetShieldPose(player, state); } } finally { state.VisualUpdateInProgress = false; } } private static bool RefreshShieldReference(Player player, VisualState state) { if (Utility.IsLocalPlayer(player)) { ShieldSledController instance = ShieldSledController.Instance; if (instance != null && instance.IsSledding) { return (Object)(object)state.ShieldTransform != (Object)null; } } Transform val = GetEquippedShieldTransform(player); if ((Object)(object)val == (Object)null && !Utility.IsLocalPlayer(player)) { val = FindRemoteShieldMesh(player); } if ((Object)(object)val == (Object)null) { return false; } if ((Object)(object)val != (Object)(object)state.ShieldTransform) { RestoreShieldPhysics(state); state.ShieldTransform = val; } return (Object)(object)state.ShieldTransform != (Object)null; } private static void ReparentShieldToFeet(Player player, VisualState state) { if (!((Object)(object)state.ShieldTransform == (Object)null) && !((Object)(object)state.FeetAttach == (Object)null)) { state.ShieldTransform.SetParent(state.FeetAttach, true); DisableShieldPhysics(state, state.ShieldTransform); ApplyFeetShieldPose(player, state); } } private static void EnsureShieldOnFeet(Player player, VisualState state) { if (!((Object)(object)state.ShieldTransform == (Object)null) && !((Object)(object)state.FeetAttach == (Object)null) && (Object)(object)state.ShieldTransform.parent != (Object)(object)state.FeetAttach) { state.ShieldTransform.SetParent(state.FeetAttach, true); DisableShieldPhysics(state, state.ShieldTransform); } } private static void ApplyFeetShieldPose(Player player, VisualState state) { //IL_004e: 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_0053: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_0113: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)state.ShieldTransform == (Object)null || (Object)(object)state.FeetAttach == (Object)null) { return; } ItemData activeShieldItem = GetActiveShieldItem(player); string text = (state.ActiveShieldPrefab = ResolveShieldPrefabName(activeShieldItem, state)); Vector3 localScale = (state.BackupValid ? state.ShieldBackup.LocalScale : state.ShieldTransform.localScale); state.ShieldTransform.localScale = localScale; if (IsBucklerShield(text, activeShieldItem) && !IsCarapaceBuckler(text)) { ApplyBucklerFeetPose(state.ShieldTransform); LogFeetPoseOnce(text, Vector3.zero, new Vector3(180f, 0f, 0f), buckler: true); return; } Vector3 feetLocalEuler = GetFeetLocalEuler(text); state.ShieldTransform.localRotation = Quaternion.Euler(feetLocalEuler); ResetAttachChildOffsets(state.ShieldTransform); state.ShieldTransform.localPosition = Vector3.zero; CenterBoardHorizontallyOnFeet(state); Vector3 feetLocalPosition = GetFeetLocalPosition(text); if (((Vector3)(ref feetLocalPosition)).sqrMagnitude > 0.0001f) { Transform shieldTransform = state.ShieldTransform; shieldTransform.localPosition += feetLocalPosition; } bool buckler = IsCarapaceBuckler(text); LogFeetPoseOnce(text, state.ShieldTransform.localPosition, feetLocalEuler, buckler); } private static ItemData GetActiveShieldItem(Player player) { if (Utility.IsLocalPlayer(player)) { return ShieldSledController.Instance?.LockedShield ?? Utility.GetHandShield(player); } return Utility.GetHandShield(player); } private static string ResolveShieldPrefabName(ItemData shield, VisualState state) { if (shield != null) { string shieldPrefabName = Utility.GetShieldPrefabName(shield); if (!string.IsNullOrEmpty(shieldPrefabName)) { return shieldPrefabName; } if ((Object)(object)shield.m_dropPrefab != (Object)null) { string text = ((Object)shield.m_dropPrefab).name; if (!string.IsNullOrEmpty(text) && text.EndsWith("(Clone)", StringComparison.Ordinal)) { text = text.Substring(0, text.Length - "(Clone)".Length).TrimEnd(Array.Empty()); } return text; } if (!string.IsNullOrEmpty(shield.m_shared?.m_name)) { return shield.m_shared.m_name; } } return state.ActiveShieldPrefab ?? string.Empty; } private static void ApplyBucklerFeetPose(Transform shield) { //IL_0001: 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) shield.localPosition = Vector3.zero; ResetAttachChildOffsets(shield); shield.localRotation = Quaternion.Euler(180f, 0f, 0f); } private static void LogFeetPoseOnce(string prefab, Vector3 localPos, Vector3 euler, bool buckler) { //IL_0011: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_00a6: 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) string text = $"{prefab}|{localPos}|{euler}|{buckler}"; if (!(_lastLoggedFeetPoseKey == text)) { _lastLoggedFeetPoseKey = text; string text2 = (buckler ? "buckler" : "attach local"); Plugin.Log.LogInfo((object)$"Shield Sledding: feet pose ({text2}) for '{prefab}' -> pos ({localPos.x:F2}, {localPos.y:F2}, {localPos.z:F2}) rot ({euler.x:F0}, {euler.y:F0}, {euler.z:F0})."); } } private static bool IsBucklerShield(string prefab, ItemData shield) { if (!ContainsShieldKey(prefab, "buckler") && !ContainsShieldKey(shield?.m_shared?.m_name, "buckler")) { object value; if (shield == null) { value = null; } else { GameObject dropPrefab = shield.m_dropPrefab; value = ((dropPrefab != null) ? ((Object)dropPrefab).name : null); } return ContainsShieldKey((string)value, "buckler"); } return true; } private static bool ContainsShieldKey(string value, string key) { if (string.IsNullOrEmpty(value)) { return false; } return value.Replace("_", string.Empty).Replace("$", string.Empty).IndexOf(key, StringComparison.OrdinalIgnoreCase) >= 0; } private static bool IsFlametalShield(string prefab) { return ContainsShieldKey(prefab, "flametal"); } private static bool IsBandedShield(string prefab) { return ContainsShieldKey(prefab, "banded"); } private static bool IsTowerShield(string prefab) { return ContainsShieldKey(prefab, "tower"); } private static bool IsCarapaceBuckler(string prefab) { return ContainsShieldKey(prefab, "carapacebuckler"); } private static Vector3 GetFeetLocalPosition(string shieldPrefab) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_006f: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(shieldPrefab)) { return Vector3.zero; } if (IsTowerShield(shieldPrefab)) { return Vector3.zero; } switch (shieldPrefab) { case "ShieldSerpentscale": return new Vector3(0f, 0f, -0.15f); case "ShieldSilver": case "ShieldBlackmetal": return new Vector3(0f, 0f, -0.1f); default: return Vector3.zero; } } private static Vector3 GetFeetLocalEuler(string shieldPrefab) { //IL_001f: 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) if (IsFlametalShield(shieldPrefab) || IsBandedShield(shieldPrefab)) { return new Vector3(-90f, 0f, 0f); } return new Vector3(90f, 0f, 0f); } private static void CenterBoardHorizontallyOnFeet(VisualState state) { //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) //IL_004b: 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_0051: 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_006a: 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) if (!((Object)(object)state.ShieldTransform == (Object)null) && !((Object)(object)state.FeetAttach == (Object)null) && TryGetShieldRenderBounds(state.ShieldTransform, out var bounds)) { Vector3 val = state.FeetAttach.position - ((Bounds)(ref bounds)).center; Vector3 val2 = state.FeetAttach.InverseTransformVector(val); val2.y = 0f; Transform shieldTransform = state.ShieldTransform; shieldTransform.localPosition += val2; } } private static bool TryGetShieldRenderBounds(Transform root, out Bounds bounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_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) bounds = default(Bounds); Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); bool flag = false; foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && val.enabled && (val is MeshRenderer || val is SkinnedMeshRenderer)) { if (!flag) { bounds = val.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } } } return flag; } private static void ResetAttachChildOffsets(Transform root) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null) { return; } Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)root)) { val.localPosition = Vector3.zero; val.localRotation = Quaternion.identity; } } } private static void DisableShieldPhysics(VisualState state, Transform root) { if ((Object)(object)root == (Object)null || (Object)(object)root == (Object)(object)state.PhysicsStrippedFor) { return; } RestoreShieldPhysics(state); Collider[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Collider val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { state.ColliderBackups.Add(new ColliderBackup { Collider = val, Enabled = val.enabled }); val.enabled = false; } } Rigidbody[] componentsInChildren2 = ((Component)root).GetComponentsInChildren(true); foreach (Rigidbody val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)null)) { state.RigidbodyBackups.Add(new RigidbodyBackup { Body = val2, DetectCollisions = val2.detectCollisions }); val2.detectCollisions = false; } } state.PhysicsStrippedFor = root; } private static void RestoreShieldPhysics(VisualState state) { for (int i = 0; i < state.ColliderBackups.Count; i++) { ColliderBackup colliderBackup = state.ColliderBackups[i]; if ((Object)(object)colliderBackup.Collider != (Object)null) { colliderBackup.Collider.enabled = colliderBackup.Enabled; } } for (int j = 0; j < state.RigidbodyBackups.Count; j++) { RigidbodyBackup rigidbodyBackup = state.RigidbodyBackups[j]; if ((Object)(object)rigidbodyBackup.Body != (Object)null) { rigidbodyBackup.Body.detectCollisions = rigidbodyBackup.DetectCollisions; } } state.ColliderBackups.Clear(); state.RigidbodyBackups.Clear(); state.PhysicsStrippedFor = null; } private static void RestoreShieldTransform(VisualState state) { //IL_0067: 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_0093: Unknown result type (might be due to invalid IL or missing references) RestoreShieldPhysics(state); if ((Object)(object)state.ShieldTransform == (Object)null) { state.HierarchyBackups.Clear(); return; } if (state.BackupValid && (Object)(object)state.ShieldBackup.Parent != (Object)null) { try { RestoreHierarchyBackup(state); state.ShieldTransform.SetParent(state.ShieldBackup.Parent, false); state.ShieldTransform.localPosition = state.ShieldBackup.LocalPosition; state.ShieldTransform.localRotation = state.ShieldBackup.LocalRotation; state.ShieldTransform.localScale = state.ShieldBackup.LocalScale; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Shield Sledding: could not restore shield parent after sled — " + ex.Message)); } } state.ShieldTransform = null; state.ActiveShieldPrefab = null; state.BackupValid = false; state.HierarchyBackups.Clear(); } private static void CaptureHierarchyBackup(VisualState state, Transform root) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) state.HierarchyBackups.Clear(); if ((Object)(object)root == (Object)null) { return; } Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)root)) { state.HierarchyBackups.Add(new TransformBackup { Transform = val, LocalPosition = val.localPosition, LocalRotation = val.localRotation, LocalScale = val.localScale }); } } } private static void RestoreHierarchyBackup(VisualState state) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < state.HierarchyBackups.Count; i++) { TransformBackup transformBackup = state.HierarchyBackups[i]; if (!((Object)(object)transformBackup.Transform == (Object)null)) { transformBackup.Transform.localPosition = transformBackup.LocalPosition; transformBackup.Transform.localRotation = transformBackup.LocalRotation; transformBackup.Transform.localScale = transformBackup.LocalScale; } } } private static void RefreshEquipmentVisuals(Player player) { if (!((Object)(object)player == (Object)null)) { VisEquipment visEquipment = ((Humanoid)player).m_visEquipment; if (!((Object)(object)visEquipment == (Object)null)) { visEquipment.UpdateEquipmentVisuals(); } } } private static ShieldTransformBackup CaptureTransform(Transform transform) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) return new ShieldTransformBackup { Parent = transform.parent, LocalPosition = transform.localPosition, LocalRotation = transform.localRotation, LocalScale = transform.localScale }; } private static void RefreshFeetShieldTransform(Player player, VisualState state) { //IL_0035: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0078: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_0109: 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_010b: 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_00a0: 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) if ((Object)(object)state.FeetAttach == (Object)null) { return; } float rootToFeetOffset = Utility.GetRootToFeetOffset(player); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, 0f - rootToFeetOffset + 0.02f, 0.15f); state.FeetAttach.localPosition = val; Vector3 val2 = Utility.Flatten(((Component)player).transform.forward); Vector3 val3 = Vector3.up; if (Utility.TryProbeGroundBelow(player, 1.5f, out var sample)) { val2 = Vector3.ProjectOnPlane(((Component)player).transform.forward, sample.Normal); if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = ((((Vector3)(ref sample.Downhill)).sqrMagnitude > 0.0001f) ? sample.Downhill : ((Component)player).transform.forward); } ((Vector3)(ref val2)).Normalize(); val3 = sample.Normal; } else { if (!(((Vector3)(ref val2)).sqrMagnitude > 0.0001f)) { state.FeetAttach.localRotation = Quaternion.identity; return; } ((Vector3)(ref val2)).Normalize(); } Vector3 position = ((Component)player).transform.TransformPoint(val); state.FeetAttach.position = position; state.FeetAttach.rotation = Quaternion.LookRotation(val2, val3); } private static Transform GetEquippedShieldTransform(Player player) { GameObject equippedShieldObject = GetEquippedShieldObject(player); if (!((Object)(object)equippedShieldObject != (Object)null)) { return null; } return equippedShieldObject.transform; } private static GameObject GetEquippedShieldObject(Player player) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Invalid comparison between Unknown and I4 VisEquipment visEquipment = ((Humanoid)player).m_visEquipment; if ((Object)(object)visEquipment == (Object)null) { return null; } if (((Humanoid)player).m_leftItem != null) { SharedData shared = ((Humanoid)player).m_leftItem.m_shared; if (shared != null && (int)shared.m_itemType == 5 && ((Humanoid)player).m_leftItem.m_equipped && (Object)(object)visEquipment.m_leftItemInstance != (Object)null) { return visEquipment.m_leftItemInstance; } } if (((Humanoid)player).m_rightItem != null) { SharedData shared2 = ((Humanoid)player).m_rightItem.m_shared; if (shared2 != null && (int)shared2.m_itemType == 5 && ((Humanoid)player).m_rightItem.m_equipped && (Object)(object)visEquipment.m_rightItemInstance != (Object)null) { return visEquipment.m_rightItemInstance; } } return null; } private static Transform FindRemoteShieldMesh(Player player) { VisEquipment val = ((Humanoid)(player?)).m_visEquipment; if ((Object)(object)val == (Object)null) { return null; } if ((Object)(object)val.m_leftItemInstance != (Object)null) { return val.m_leftItemInstance.transform; } if ((Object)(object)val.m_rightItemInstance != (Object)null) { return val.m_rightItemInstance.transform; } return null; } private static string ResolvePrefabFromTransform(Transform transform) { if ((Object)(object)transform == (Object)null) { return string.Empty; } string text = ((Object)transform).name; if (string.IsNullOrEmpty(text)) { return string.Empty; } if (ContainsShieldKey(text, "attach") && !ContainsShieldKey(text, "shield")) { return string.Empty; } if (text.EndsWith("(Clone)", StringComparison.Ordinal)) { text = text.Substring(0, text.Length - "(Clone)".Length).TrimEnd(Array.Empty()); } return text; } } internal static class ShieldSpeedRegistry { internal static readonly string[] VanillaShieldPrefabs = new string[16] { "ShieldWood", "ShieldWoodTower", "ShieldBronzeBuckler", "ShieldBoneTower", "ShieldIronBuckler", "ShieldBanded", "ShieldIronSquare", "ShieldIronTower", "ShieldSerpentscale", "ShieldSilver", "ShieldBlackmetal", "ShieldBlackmetalTower", "ShieldCarapace", "ShieldCarapaceBuckler", "ShieldFlametal", "ShieldFlametalTower" }; private static readonly Dictionary WearByPrefab = new Dictionary(); private static readonly Dictionary TokenToPrefab = new Dictionary(); private static bool _initialized; internal static void Init() { if (!_initialized) { _initialized = true; Rebuild(); } } internal static void Rebuild() { WearByPrefab.Clear(); for (int i = 0; i < VanillaShieldPrefabs.Length; i++) { string text = VanillaShieldPrefabs[i]; WearByPrefab[text] = ShieldWearConfig.GetWear(text); } ShieldWearConfig.ApplyCustomWear(WearByPrefab); BuildTokenCache(); Plugin.Log.LogInfo((object)$"Shield Sledding: registered {VanillaShieldPrefabs.Length} vanilla shields (uniform speed, tier wear)."); } internal static string ResolveShieldPrefab(ItemData shield) { if (shield?.m_shared == null) { return string.Empty; } if ((Object)(object)shield.m_dropPrefab != (Object)null) { return StripCloneSuffix(((Object)shield.m_dropPrefab).name); } string name = shield.m_shared.m_name; if (!string.IsNullOrEmpty(name) && TokenToPrefab.TryGetValue(name, out var value)) { return value; } if ((Object)(object)ObjectDB.instance != (Object)null && !string.IsNullOrEmpty(name)) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(name); if ((Object)(object)itemPrefab != (Object)null) { return StripCloneSuffix(((Object)itemPrefab).name); } } return string.Empty; } private static string StripCloneSuffix(string name) { if (string.IsNullOrEmpty(name)) { return string.Empty; } if (name.EndsWith("(Clone)", StringComparison.Ordinal)) { return name.Substring(0, name.Length - "(Clone)".Length).TrimEnd(Array.Empty()); } return name; } internal static float EstimateNaturalSpeed(in GroundSample ground, Player player = null, ItemData shield = null) { //IL_0031: 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_003a: Unknown result type (might be due to invalid IL or missing references) if (ground.SlopeAngle < 0.5f) { return 0f; } float num = Mathf.Sin(ground.SlopeAngle * ((float)Math.PI / 180f)); float num2 = ConfigManager.FrictionMultiplier.Value; if ((int)ground.Biome != 0) { num2 *= Utility.GetBiomeFriction(ground.Biome); } num2 *= 0.28f; num2 = Mathf.Max(0.05f, num2); float num3 = Mathf.Abs(Physics.gravity.y) * ConfigManager.GravityMultiplier.Value * (ConfigManager.BaseAcceleration.Value / 9.81f); float blockSkillMultiplier = GetBlockSkillMultiplier(player ?? Player.m_localPlayer, shield); return num3 * num / num2 * blockSkillMultiplier; } internal static float GetMaxSpeed(Player player, ItemData shield) { Player val = player ?? Player.m_localPlayer; if ((Object)(object)val != (Object)null && Utility.TrySampleGround(val, out var sample)) { return EstimateNaturalSpeed(in sample, val, shield); } return ((ConfigManager.MaximumSpeed.Value > 0f) ? ConfigManager.MaximumSpeed.Value : 12f) * GetBlockSkillMultiplier(val, shield); } internal static float GetWearMultiplier(ItemData shield) { string text = ResolveShieldPrefab(shield); if (string.IsNullOrEmpty(text)) { Plugin.Log.LogWarning((object)"Shield Sledding: could not resolve shield prefab for wear lookup — using DefaultModdedWear."); return ShieldWearConfig.DefaultModdedWear?.Value ?? 1f; } return ShieldWearConfig.GetWear(text); } internal static float GetSpeedMultiplier(Player player, ItemData shield) { return GetBlockSkillMultiplier(player, shield); } internal static float GetBlockSkillMultiplier(Player player, ItemData shield) { if ((Object)(object)player == (Object)null) { return 1f; } float num = Mathf.Clamp01(((Character)player).GetSkillFactor((SkillType)6)); float num2 = ConfigManager.MinBlockSkillSpeedScale?.Value ?? 0.8f; float num3 = ConfigManager.MaxBlockSkillSpeedScale?.Value ?? 1.7f; num2 = Mathf.Clamp(num2, 0.35f, 3f); num3 = Mathf.Clamp(num3, num2, 3f); return Mathf.Lerp(num2, num3, num); } internal static float GetSteeringMultiplier(ItemData shield) { if (shield?.m_shared == null) { return 1f; } string text = ResolveShieldPrefab(shield); if (!string.IsNullOrEmpty(text) && text.IndexOf("Tower", StringComparison.OrdinalIgnoreCase) >= 0) { return 0.85f; } string name = shield.m_shared.m_name; if (!string.IsNullOrEmpty(name) && name.IndexOf("tower", StringComparison.OrdinalIgnoreCase) >= 0) { return 0.85f; } return 1f; } internal static float GetEffectiveBlockPower(Player player, ItemData shield) { if (shield == null || (Object)(object)player == (Object)null) { return 0f; } return shield.GetBlockPower(((Character)player).GetSkillFactor((SkillType)6)); } internal static void RegisterUnknownShields() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Invalid comparison between Unknown and I4 if ((Object)(object)ObjectDB.instance == (Object)null) { return; } List items = ObjectDB.instance.m_items; if (items == null || items.Count == 0) { return; } int num = 0; int num2 = 0; float value = ShieldWearConfig.DefaultModdedWear?.Value ?? 1f; for (int i = 0; i < items.Count; i++) { GameObject val = items[i]; if ((Object)(object)val == (Object)null) { continue; } ItemDrop component = val.GetComponent(); if (component?.m_itemData?.m_shared != null && (int)component.m_itemData.m_shared.m_itemType == 5) { num++; string name = ((Object)val).name; if (!WearByPrefab.ContainsKey(name)) { WearByPrefab[name] = value; num2++; Plugin.Log.LogInfo((object)("Shield Sledding: auto-registered modded shield '" + name + "' at default wear.")); } } } BuildTokenCache(); Plugin.Log.LogInfo((object)$"Shield Sledding: ObjectDB has {num} shields ({num2} modded auto-registered)."); } private static void BuildTokenCache() { TokenToPrefab.Clear(); if ((Object)(object)ObjectDB.instance == (Object)null) { return; } for (int i = 0; i < VanillaShieldPrefabs.Length; i++) { string text = VanillaShieldPrefabs[i]; TokenToPrefab[text] = text; GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text); if (!((Object)(object)itemPrefab == (Object)null)) { string text2 = itemPrefab.GetComponent()?.m_itemData?.m_shared?.m_name; if (!string.IsNullOrEmpty(text2)) { TokenToPrefab[text2] = text; } } } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] internal static class ObjectDbShieldRegistryPatch { private static void Postfix() { ShieldSpeedRegistry.Rebuild(); ShieldSpeedRegistry.RegisterUnknownShields(); } } internal static class ShieldWearConfig { private static readonly Dictionary> Entries = new Dictionary>(); internal static ConfigEntry DefaultModdedWear; internal static ConfigEntry CustomModdedWear; 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown Entries.Clear(); for (int i = 0; i < ShieldSpeedRegistry.VanillaShieldPrefabs.Length; i++) { string text = ShieldSpeedRegistry.VanillaShieldPrefabs[i]; float defaultWear = GetDefaultWear(text); Entries[text] = config.Bind("ShieldWear", text, defaultWear, new ConfigDescription("Durability wear multiplier while sledding. Higher = wears faster. Speed is the same for all shields.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 10f), Array.Empty())); } DefaultModdedWear = config.Bind("ShieldWear", "DefaultModdedWear", 1f, new ConfigDescription("Wear multiplier for modded shields not listed above.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 10f), Array.Empty())); CustomModdedWear = config.Bind("ShieldWear", "CustomModdedWear", string.Empty, "Extra modded shields as PrefabName:Wear pairs. Example: MyShield:1.2,OtherShield:0.8"); } internal static float GetWear(string prefabName) { if (!string.IsNullOrEmpty(prefabName) && Entries.TryGetValue(prefabName, out var value)) { return value.Value; } if (!string.IsNullOrEmpty(prefabName) && TryGetCustomWear(prefabName, out var wear)) { return wear; } if (DefaultModdedWear == null) { return 1f; } return DefaultModdedWear.Value; } internal static void ApplyCustomWear(Dictionary target) { Utility.ParseCustomShieldSpeeds(CustomModdedWear?.Value ?? string.Empty, target); } private static bool TryGetCustomWear(string prefabName, out float wear) { wear = 1f; string text = CustomModdedWear?.Value; if (string.IsNullOrWhiteSpace(text) || string.IsNullOrEmpty(prefabName)) { return false; } string[] array = text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ':' }); if (array2.Length == 2 && string.Equals(array2[0].Trim(), prefabName, StringComparison.OrdinalIgnoreCase) && float.TryParse(array2[1].Trim(), out wear)) { return true; } } return false; } internal static void MigrateLegacyWearDefaults(ConfigFile config) { for (int i = 0; i < ShieldSpeedRegistry.VanillaShieldPrefabs.Length; i++) { string text = ShieldSpeedRegistry.VanillaShieldPrefabs[i]; float defaultWear = GetDefaultWear(text); float legacyDefaultWear = GetLegacyDefaultWear(text); ConfigEntry val = config.Bind("ShieldWear", text, defaultWear, (ConfigDescription)null); if (Mathf.Approximately(val.Value, legacyDefaultWear)) { val.Value = defaultWear; } } } internal static void MigrateWoodWearDefault(ConfigFile config) { MigrateWearIfPreviousDefault(config, "ShieldWood", 3f); } internal static void MigrateEarlyShieldWearDoubling(ConfigFile config) { MigrateWearIfPreviousDefault(config, "ShieldWood", 3f); MigrateWearIfPreviousDefault(config, "ShieldWoodTower", 3.2f); MigrateWearIfPreviousDefault(config, "ShieldBoneTower", 2.25f); MigrateWearIfPreviousDefault(config, "ShieldBronzeBuckler", 1.75f); MigrateWearIfPreviousDefault(config, "ShieldBanded", 1f); } internal static void MigrateTowerWearAdvantage(ConfigFile config) { MigrateWearIfPreviousDefault(config, "ShieldWoodTower", 6.4f); MigrateWearIfPreviousDefault(config, "ShieldBoneTower", 4.5f); MigrateWearIfPreviousDefault(config, "ShieldIronTower", 0.9f); MigrateWearIfPreviousDefault(config, "ShieldBlackmetalTower", 0.58f); MigrateWearIfPreviousDefault(config, "ShieldFlametalTower", 0.38f); } private static void MigrateWearIfPreviousDefault(ConfigFile config, string prefab, float previousDefault) { float defaultWear = GetDefaultWear(prefab); ConfigEntry val = config.Bind("ShieldWear", prefab, defaultWear, (ConfigDescription)null); if (Mathf.Approximately(val.Value, previousDefault)) { val.Value = defaultWear; } } private static float GetLegacyDefaultWear(string prefab) { return prefab switch { "ShieldWood" => 2.25f, "ShieldWoodTower" => 2.4f, "ShieldBoneTower" => 1.85f, "ShieldKnight" => 1.55f, "ShieldBronzeBuckler" => 1.55f, "ShieldBanded" => 1f, "ShieldIronBuckler" => 0.85f, "ShieldIronSquare" => 0.9f, "ShieldIronTower" => 0.95f, "ShieldSerpentscale" => 0.75f, "ShieldSilver" => 0.7f, "ShieldBlackmetal" => 0.6f, "ShieldBlackmetalTower" => 0.65f, "ShieldCarapace" => 0.5f, "ShieldCarapaceBuckler" => 0.45f, "ShieldFlametal" => 0.4f, "ShieldFlametalTower" => 0.45f, _ => 1f, }; } private static float GetDefaultWear(string prefab) { return prefab switch { "ShieldWood" => 6f, "ShieldWoodTower" => 5.6f, "ShieldBoneTower" => 4.2f, "ShieldKnight" => 3.7f, "ShieldBronzeBuckler" => 3.5f, "ShieldBanded" => 2f, "ShieldIronBuckler" => 0.8f, "ShieldIronSquare" => 0.85f, "ShieldIronTower" => 0.75f, "ShieldSerpentscale" => 0.7f, "ShieldSilver" => 0.65f, "ShieldBlackmetal" => 0.55f, "ShieldBlackmetalTower" => 0.52f, "ShieldCarapace" => 0.45f, "ShieldCarapaceBuckler" => 0.4f, "ShieldFlametal" => 0.35f, "ShieldFlametalTower" => 0.32f, _ => 1f, }; } } internal static class SledGroundSolver { internal static void SeparateFromGround(Player player) { FixGroundClip(player); } internal static bool FixGroundClip(Player player) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0179: 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_00df: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00fd: 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_0202: 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_0213: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0273: 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_0251: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return false; } Vector3 velocity = Vector3.zero; if (RescueTerrainPenetration(player, ref velocity)) { return true; } ShieldSledController instance = ShieldSledController.Instance; float speed = instance?.CurrentSpeed ?? 0f; if (WaterSledHelper.IsWaterSledding(player, speed) || WaterSledHelper.IsSkimCommitted) { if (WaterSledHelper.TryGetWaterSurface(player, out var surfaceY) && Utility.TryProbeSolidLandNearFeet(player, surfaceY, out var land)) { float targetFeetClearance = GetTargetFeetClearance(); float feetHeightAboveGround = Utility.GetFeetHeightAboveGround(player, land); if (feetHeightAboveGround < targetFeetClearance - 0.01f) { float num = Mathf.Min(3.5f, targetFeetClearance - feetHeightAboveGround); Rigidbody body = Utility.GetBody(player); Vector3 val = (((Object)(object)body != (Object)null) ? body.position : ((Component)player).transform.position); Vector3 val2 = ((land.Normal.y >= 0.45f) ? land.Normal : Vector3.up); val += val2 * num; if ((Object)(object)body != (Object)null) { body.position = val; } ((Component)player).transform.position = val; WaterSledHelper.ClearSkimForLandTransition(); return true; } } return false; } if (!Utility.TryProbeGroundBelow(player, 3f, out var sample)) { return false; } if (sample.IsWaterSurface) { return false; } float targetFeetClearance2 = GetTargetFeetClearance(); float feetHeightAboveGround2 = Utility.GetFeetHeightAboveGround(player, sample); if (feetHeightAboveGround2 >= targetFeetClearance2 - 0.01f) { return true; } bool flag = Utility.IsInInterior(player); float num2 = (flag ? 0.22f : 0.45f); if (sample.Point.y > Utility.GetFeetPosition(player).y + num2) { return false; } float num3 = Mathf.Min(flag ? 0.22f : 3.5f, targetFeetClearance2 - feetHeightAboveGround2); if (num3 < 0.12f && instance != null && instance.StartupBlend > 0.001f) { num3 *= Mathf.Lerp(0.55f, 1f, 1f - instance.StartupBlend); } if (num3 <= 0.001f) { return true; } Rigidbody body2 = Utility.GetBody(player); Vector3 val3 = (((Object)(object)body2 != (Object)null) ? body2.position : ((Component)player).transform.position); Vector3 val4 = ((sample.Normal.y >= 0.7f) ? sample.Normal : Vector3.up); val3 += val4 * num3; if ((Object)(object)body2 != (Object)null) { body2.position = val3; } ((Component)player).transform.position = val3; ((Character)player).m_lastGroundPoint = sample.Point; ((Character)player).m_lastGroundNormal = sample.Normal; ((Character)player).m_lastGroundCollider = sample.Collider; ((Character)player).m_groundContact = true; return true; } internal static bool RescueTerrainPenetration(Player player, ref Vector3 velocity) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_018e: 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_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) if ((Object)(object)player == (Object)null || Utility.IsInInterior(player)) { return false; } ZoneSystem instance = ZoneSystem.instance; float num = default(float); if ((Object)(object)instance == (Object)null || !instance.GetGroundHeight(((Component)player).transform.position, ref num)) { return false; } float targetFeetClearance = GetTargetFeetClearance(); float y = Utility.GetFeetPosition(player).y; float num2 = num + targetFeetClearance; if (y >= num - 0.02f) { return false; } bool flag = WaterSledHelper.IsSkimCommitted || WaterSledHelper.IsWaterSledding(player, (ShieldSledController.Instance != null) ? ShieldSledController.Instance.CurrentSpeed : 0f); if (flag && WaterSledHelper.TryGetWaterSurface(player, out var surfaceY)) { if (num <= surfaceY + 0.08f && y >= surfaceY - 0.55f) { return false; } num2 = Mathf.Max(num2, num + targetFeetClearance); } float num3 = num2 - y; if (num3 <= 0.01f) { return false; } Vector3 position = ((Component)player).transform.position; position.y += num3; Rigidbody body = Utility.GetBody(player); if ((Object)(object)body != (Object)null) { body.position = position; } ((Component)player).transform.position = position; if (velocity.y < 0f) { velocity.y = 0f; } float num4 = Vector3.Dot(velocity, Vector3.down); if (num4 > 0f) { velocity += Vector3.up * num4; } bool flag2 = false; if (flag && WaterSledHelper.TryGetWaterSurface(player, out var surfaceY2)) { flag2 = num >= surfaceY2 + 0.05f; } if (flag2) { WaterSledHelper.ClearSkimForLandTransition(); } ((Character)player).m_lastGroundPoint = new Vector3(position.x, num, position.z); ((Character)player).m_lastGroundNormal = Vector3.up; ((Character)player).m_groundContact = true; return true; } internal static void RescueUnderWorld(Player player) { //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) if (!((Object)(object)player == (Object)null)) { Vector3 velocity = Vector3.zero; if (!RescueTerrainPenetration(player, ref velocity)) { FixGroundClip(player); } } } internal static void SnapToGroundOnSledStart(Player player, float seedSpeed = 0f) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_00c5: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (!Utility.TrySampleGround(player, out var sample) && !Utility.TryProbeGroundBelow(player, 2f, out sample))) { return; } ((Character)player).m_lastGroundPoint = sample.Point; ((Character)player).m_lastGroundNormal = sample.Normal; ((Character)player).m_lastGroundCollider = sample.Collider; ((Character)player).m_groundContact = true; if (seedSpeed > 1.25f) { Vector3 velocity = ((ShieldSledController.Instance != null) ? ShieldSledController.Instance.SimulatedVelocity : Vector3.zero); SyncCharacterMotionState((Character)(object)player, velocity, grounded: true); return; } float targetFeetClearance = GetTargetFeetClearance(); float feetHeightAboveGround = Utility.GetFeetHeightAboveGround(player, sample); Rigidbody body = Utility.GetBody(player); if (Mathf.Abs(feetHeightAboveGround - targetFeetClearance) > 0.08f) { Vector3 rootPositionForFeetOnGround = Utility.GetRootPositionForFeetOnGround(player, sample, targetFeetClearance); Vector3 position = Vector3.Lerp(((Object)(object)body != (Object)null) ? body.position : ((Component)player).transform.position, rootPositionForFeetOnGround, 0.35f); if ((Object)(object)body != (Object)null) { body.position = position; } ((Component)player).transform.position = position; } else if (Mathf.Abs(feetHeightAboveGround - targetFeetClearance) > 0.025f) { Vector3 rootPositionForFeetOnGround2 = Utility.GetRootPositionForFeetOnGround(player, sample, targetFeetClearance); Vector3 position2 = Vector3.Lerp(((Object)(object)body != (Object)null) ? body.position : ((Component)player).transform.position, rootPositionForFeetOnGround2, 0.22f); if ((Object)(object)body != (Object)null) { body.position = position2; } ((Component)player).transform.position = position2; } Vector3 velocity2 = ((ShieldSledController.Instance != null) ? ShieldSledController.Instance.SimulatedVelocity : Vector3.zero); SyncCharacterMotionState((Character)(object)player, velocity2, grounded: true); } private static float GetTargetFeetClearance() { return Mathf.Clamp(ConfigManager.SledGroundClearance.Value, 0f, 0.6f); } internal static void SyncCharacterMotionState(Character character, Vector3 velocity, bool grounded) { //IL_0024: 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_0029: 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_002c: 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_0046: 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) if (!((Object)(object)character == (Object)null)) { Vector3 val = ((((Vector3)(ref character.m_lastGroundNormal)).sqrMagnitude > 0.01f) ? character.m_lastGroundNormal : Vector3.up); Vector3 currentVel = Vector3.ProjectOnPlane(velocity, val); bool flag = ShieldSledController.Instance?.IsSledding ?? false; character.m_currentVel = currentVel; character.m_running = false; character.m_walk = false; character.m_sliding = ((!flag) ? (grounded && ((Vector3)(ref currentVel)).magnitude > 0.5f) : (grounded && ((Vector3)(ref currentVel)).magnitude > 0.25f)); if (flag && grounded) { character.m_groundContact = true; } } } internal static void UpdateSledFacing(Character character, in GroundSample ground, float dt) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_011f: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || dt <= 0f) { return; } Vector3 val = ground.Normal; if (((Vector3)(ref val)).sqrMagnitude < 0.01f || ground.IsWaterSurface) { return; } ShieldSledController instance = ShieldSledController.Instance; Vector3 normal = ground.Normal; Vector3 val2 = Vector3.zero; if (instance != null) { val2 = Vector3.ProjectOnPlane(instance.SimulatedVelocity, normal); } if (((Vector3)(ref val2)).sqrMagnitude < 0.08f) { if (instance == null || !instance.IsInStartupGrace) { return; } val = ground.SlopeDown; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { return; } val2 = ground.SlopeDown; } Vector3 val3 = Vector3.ProjectOnPlane(((Component)character).transform.forward, normal); if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { return; } ((Vector3)(ref val3)).Normalize(); ((Vector3)(ref val2)).Normalize(); float num = Vector3.Angle(val3, val2); if (!(num < 4f)) { float num2 = instance?.CurrentSpeed ?? 0f; float num3 = Mathf.Lerp(100f, 210f, Mathf.Clamp01(num2 / 10f)); if (instance != null && instance.IsInStartupGrace && num > 40f) { num3 = Mathf.Max(num3, 160f); } Quaternion val4 = Quaternion.LookRotation(val2, normal); ((Component)character).transform.rotation = Quaternion.RotateTowards(((Component)character).transform.rotation, val4, num3 * dt); Rigidbody body = Utility.GetBody((Player)(object)((character is Player) ? character : null)); if ((Object)(object)body != (Object)null) { body.rotation = ((Component)character).transform.rotation; } } } } internal sealed class SpeedometerHud : MonoBehaviour { private GUIStyle _style; private void OnGUI() { //IL_00a1: 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_0037: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (!ConfigManager.EnableSpeedometer.Value) { return; } ShieldSledController instance = ShieldSledController.Instance; if (instance != null && instance.IsSledding) { if (_style == null) { _style = new GUIStyle(GUI.skin.label) { fontSize = 18, fontStyle = (FontStyle)1, alignment = (TextAnchor)8 }; _style.normal.textColor = Color.white; } float currentSpeed = instance.CurrentSpeed; string text = $"{currentSpeed:F1} m/s"; GUI.Label(new Rect((float)Screen.width - 180f, (float)Screen.height - 80f, 160f, 60f), text, _style); } } } internal sealed class StatsTracker { private Vector3 _lastPos; private bool _trackingAir; internal void Begin(Player player) { //IL_0017: 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_001c: Unknown result type (might be due to invalid IL or missing references) _lastPos = (((Object)(object)player != (Object)null) ? ((Component)player).transform.position : Vector3.zero); _trackingAir = false; } internal void Update(Player player, float speed) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return; } _lastPos = ((Component)player).transform.position; if (!((Character)player).IsOnGround()) { if (!_trackingAir) { _trackingAir = true; } } else if (_trackingAir) { _trackingAir = false; } GhostReplaySystem.RecordFrame(player); } internal void OnJump(Player player) { if (!((Object)(object)player == (Object)null)) { _trackingAir = true; } } internal void OnLanding(Player player, float impact) { if (!((Object)(object)player == (Object)null) && _trackingAir) { _trackingAir = false; } } internal void End(Player player) { } } internal static class Utility { internal const int GroundLayerMask = 224495617; private static int _resolvedGroundMask; internal const float SledGroundContactMax = 0.38f; internal const float SledJumpFeetMax = 0.34f; internal const float SledAirborneSeparation = 0.45f; internal const float FeetBelowRoot = 0.92f; private static bool _steerAntiTravelFlipped; private static RaycastHit[] _groundHitBuffer = (RaycastHit[])(object)new RaycastHit[32]; internal static int GetGroundLayerMask() { if (_resolvedGroundMask != 0) { return _resolvedGroundMask; } _resolvedGroundMask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "blocker" }); if (_resolvedGroundMask == 0) { _resolvedGroundMask = 224495617; } return _resolvedGroundMask; } internal static bool IsSeparatingFromGround(Vector3 velocity, in GroundSample ground, float threshold = 0.45f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0015: Unknown result type (might be due to invalid IL or missing references) Vector3 normal = ground.Normal; if (((Vector3)(ref normal)).sqrMagnitude < 0.01f) { return velocity.y > threshold; } return Vector3.Dot(velocity, ground.Normal) > threshold; } internal static bool IsSledGrounded(Player player) { if ((Object)(object)player == (Object)null) { return false; } ShieldSledController instance = ShieldSledController.Instance; GroundSample sample; if (instance != null && instance.IsSledding) { return TryGetSledGround(player, out sample); } if (!((Character)player).IsOnGround()) { return false; } if (GetVerticalSpeed(player) > 0.5f) { return false; } return TrySampleGround(player, out sample); } internal static float GetVerticalSpeed(Player player) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return 0f; } ShieldSledController instance = ShieldSledController.Instance; if (instance != null && instance.IsSledding) { return instance.SimulatedVelocity.y; } Rigidbody body = GetBody(player); if ((Object)(object)body != (Object)null) { return body.linearVelocity.y; } return ((Character)player).GetVelocity().y; } internal static bool IsDedicatedServer() { if ((Object)(object)ZNet.instance != (Object)null) { return ZNet.instance.IsDedicated(); } return false; } internal static bool IsLocalPlayer(Player player) { if ((Object)(object)player != (Object)null) { return (Object)(object)player == (Object)(object)Player.m_localPlayer; } return false; } internal static Rigidbody GetBody(Player player) { if ((Object)(object)player == (Object)null) { return null; } return ((Character)player).m_body; } internal static Rigidbody GetBody(Character character) { if ((Object)(object)character == (Object)null) { return null; } return character.m_body; } internal static bool TrySetLinearVelocity(Rigidbody body, Vector3 velocity) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)body == (Object)null || body.isKinematic) { return false; } body.linearVelocity = velocity; return true; } internal static ZDO GetPlayerZdo(Player player) { if ((Object)(object)player == (Object)null) { return null; } ZNetView component = ((Component)player).GetComponent(); if (!((Object)(object)component != (Object)null) || !component.IsValid()) { return null; } return component.GetZDO(); } internal static string GetCharacterPrefabToken(Character character) { if ((Object)(object)character == (Object)null) { return string.Empty; } ZNetView component = ((Component)character).GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid()) { ZDO zDO = component.GetZDO(); if (zDO != null && (Object)(object)ZNetScene.instance != (Object)null) { GameObject prefab = ZNetScene.instance.GetPrefab(zDO.GetPrefab()); if ((Object)(object)prefab != (Object)null) { return ((Object)prefab).name; } } } return ((Object)((Component)character).gameObject).name.Replace("(Clone)", string.Empty).Trim(); } internal static ItemData GetHandShield(Player player) { if ((Object)(object)player == (Object)null) { return null; } if (IsEquippedHandShield(((Humanoid)player).m_leftItem)) { return ((Humanoid)player).m_leftItem; } if (IsEquippedHandShield(((Humanoid)player).m_rightItem)) { return ((Humanoid)player).m_rightItem; } return null; } internal static ItemData GetEquippedShield(Player player) { return GetHandShield(player); } private static bool IsShieldItem(ItemData item) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if (item?.m_shared != null) { return (int)item.m_shared.m_itemType == 5; } return false; } private static bool IsEquippedHandShield(ItemData item) { if (IsShieldItem(item)) { return item.m_equipped; } return false; } internal static bool HasUsableShield(Player player) { ItemData handShield = GetHandShield(player); if (handShield != null) { return handShield.m_durability > 0f; } return false; } internal static string GetShieldPrefabName(ItemData shield) { return ShieldSpeedRegistry.ResolveShieldPrefab(shield); } internal static bool IsAirborne(Player player) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return false; } if (!((Character)player).IsOnGround()) { return true; } ShieldSledController instance = ShieldSledController.Instance; GroundSample ground; if (instance != null && instance.IsSledding) { return !TryGetSledGround(player, out ground); } Rigidbody body = GetBody(player); if ((Object)(object)body != (Object)null) { return body.linearVelocity.y > 0.75f; } return false; } internal static Vector3 GetFeetPosition(Player player) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_00a1: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return Vector3.zero; } CapsuleCollider collider = ((Character)player).m_collider; if ((Object)(object)collider != (Object)null) { Transform transform = ((Component)collider).transform; Vector3 val = transform.TransformPoint(collider.center); Vector3 val2 = (Vector3)(collider.direction switch { 0 => transform.right, 2 => transform.forward, _ => transform.up, }); float num = Mathf.Abs((collider.direction == 1) ? transform.lossyScale.y : transform.lossyScale.x); float num2 = collider.height * num * 0.5f; return val - val2 * num2; } return ((Component)player).transform.position - Vector3.up * 0.92f; } internal static float GetRootToFeetOffset(Player player) { //IL_001a: 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) if ((Object)(object)player == (Object)null) { return 0.92f; } return Mathf.Max(0.35f, ((Component)player).transform.position.y - GetFeetPosition(player).y); } internal static Vector3 GetRootPositionForFeetOnGround(Player player, GroundSample ground, float feetClearance) { //IL_0017: 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_001c: 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_0023: 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) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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) Vector3 val = (((Object)(object)player != (Object)null) ? ((Component)player).transform.position : ground.Point); Vector3 val2 = GetFeetPosition(player) - val; return ground.Point + ground.Normal * feetClearance - val2; } internal static float GetFeetHeightAboveGround(Player player, GroundSample ground) { //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_0027: 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_0009: Unknown result type (might be due to invalid IL or missing references) if (ground.IsWaterSurface) { return GetFeetPosition(player).y - ground.WaterSurfaceY; } return Vector3.Dot(GetFeetPosition(player) - ground.Point, ground.Normal); } internal static bool IsPhysicallyGrounded(Player player) { return IsSledGrounded(player); } internal static bool WasActivationPressed() { //IL_0005: 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_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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = ConfigManager.ActivationKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { return true; } KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey; if ((int)mainKey == 0) { return false; } if (!ZInput.GetKeyDown(mainKey, true)) { return Input.GetKeyDown(mainKey); } return true; } internal unsafe static string GetActivationKeyLabel() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = ConfigManager.ActivationKey.Value; if ((int)((KeyboardShortcut)(ref value)).MainKey == 0) { return "None"; } return ((object)(*(KeyboardShortcut*)(&value))/*cast due to .constrained prefix*/).ToString(); } internal static bool WasDismountPressed() { if (!ZInput.GetKeyDown((KeyCode)27, true)) { return Input.GetKeyDown((KeyCode)27); } return true; } internal static bool WasJumpPressed() { if (!ZInput.GetButtonDown("Jump") && !Input.GetKeyDown((KeyCode)32)) { return ZInput.GetKeyDown((KeyCode)32, true); } return true; } internal static bool IsInDeepWater(Player player) { if ((Object)(object)player == (Object)null) { return false; } if (((Character)player).InWater()) { return ((Character)player).IsSwimming(); } return false; } internal static bool IsInInterior(Player player) { if ((Object)(object)player != (Object)null) { return ((Character)player).InInterior(); } return false; } internal static bool IsUiBlockingInput() { if ((Object)(object)Console.instance != (Object)null && Console.IsVisible()) { return true; } if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) { return true; } if (TextInput.IsVisible()) { return true; } if (Minimap.InTextInput()) { return true; } if (Menu.IsVisible()) { return true; } if (InventoryGui.IsVisible()) { return true; } return false; } internal static void ShowHint(string message) { if (!string.IsNullOrEmpty(message) && ConfigManager.ShowActivationHints.Value) { MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)2, message, 0, (Sprite)null, false); } } } internal static float GetActivationMinimumSlope() { return Mathf.Max(0f, ConfigManager.MinimumSlope.Value); } internal static float GetActivationSlopeAngle(Player player, in GroundSample ground) { //IL_002c: 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) if ((Object)(object)player != (Object)null && (((Character)player).IsOnGround() || ((Character)player).m_groundContact) && ((Vector3)(ref ((Character)player).m_lastGroundNormal)).sqrMagnitude > 0.01f) { return Vector3.Angle(((Character)player).m_lastGroundNormal, Vector3.up); } return ground.SlopeAngle; } internal static bool CanArmInAir(Player player) { if ((Object)(object)player == (Object)null) { return false; } if (((Character)player).IsOnGround() || ((Character)player).m_groundContact) { return false; } return GetVerticalSpeed(player) > -1.5f; } internal static bool TryGetActivationGround(Player player, out GroundSample ground) { //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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) ground = default(GroundSample); if ((Object)(object)player == (Object)null) { return false; } if ((((Character)player).IsOnGround() || ((Character)player).m_groundContact) && ((Vector3)(ref ((Character)player).m_lastGroundNormal)).sqrMagnitude > 0.01f) { ground.Point = ((Character)player).m_lastGroundPoint; ground.Normal = ((Character)player).m_lastGroundNormal; ground.Collider = ((Character)player).m_lastGroundCollider; PopulateSlopeFields(ref ground); ground.Biome = ResolveBiome(ground.Point); return true; } if (TryProbeGroundBelow(player, 2.5f, out ground)) { return true; } return TrySampleGround(player, out ground); } private static void PopulateSlopeFields(ref GroundSample sample) { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) sample.SlopeAngle = Vector3.Angle(sample.Normal, Vector3.up); sample.SlopeDown = Vector3.ProjectOnPlane(Vector3.down, sample.Normal); if (((Vector3)(ref sample.SlopeDown)).sqrMagnitude > 0.0001f) { ((Vector3)(ref sample.SlopeDown)).Normalize(); } sample.Downhill = Flatten(sample.SlopeDown); if (((Vector3)(ref sample.Downhill)).sqrMagnitude > 0.0001f) { ((Vector3)(ref sample.Downhill)).Normalize(); } } internal static bool IsSlopeValidForSledding(GroundSample ground, Vector3 velocity) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) float activationMinimumSlope = GetActivationMinimumSlope(); if (ground.SlopeAngle >= activationMinimumSlope) { return true; } if (ground.SlopeAngle >= activationMinimumSlope * 0.5f && HorizontalSpeed(velocity) >= 2f) { return true; } return false; } internal static float HorizontalSpeed(Vector3 velocity) { //IL_0000: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) Vector3 val = new Vector3(velocity.x, 0f, velocity.z); return ((Vector3)(ref val)).magnitude; } internal static Vector3 Flatten(Vector3 v) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) v.y = 0f; return v; } internal static Vector3 GetSledLookOnPlane(Player player, Vector3 up) { //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_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_0060: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; if ((Object)(object)GameCamera.instance != (Object)null) { Transform transform = ((Component)GameCamera.instance).transform; if ((Object)(object)transform != (Object)null) { val = transform.forward; } } if (((Vector3)(ref val)).sqrMagnitude < 0.01f && (Object)(object)player != (Object)null) { val = ((Character)player).GetLookDir(); } if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return Vector3.zero; } Vector3 val2 = Vector3.ProjectOnPlane(val, (((Vector3)(ref up)).sqrMagnitude > 0.01f) ? up : Vector3.up); if (!(((Vector3)(ref val2)).sqrMagnitude > 0.01f)) { return Vector3.zero; } return ((Vector3)(ref val2)).normalized; } private static bool UpdateSteerAntiTravelFlip(float facingDot) { if (_steerAntiTravelFlipped) { if (facingDot > -0.12f) { _steerAntiTravelFlipped = false; } } else if (facingDot < -0.42f) { _steerAntiTravelFlipped = true; } return _steerAntiTravelFlipped; } internal static void ResetSledSteerFrame() { _steerAntiTravelFlipped = false; } internal static bool TryGetSledSteerAxes(Player player, Vector3 velocity, out Vector3 forward, out Vector3 right) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_005a: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_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_0089: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_0131: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: 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_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_017b: 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_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_018b: 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_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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) forward = Vector3.zero; right = Vector3.zero; if ((Object)(object)player == (Object)null) { return false; } Vector3 val = Vector3.up; GroundSample ground = default(GroundSample); bool flag = TryGetSledGround(player, out ground); if (flag && ((Vector3)(ref ground.Normal)).sqrMagnitude > 0.01f) { val = ground.Normal; } Vector3 val2 = Vector3.ProjectOnPlane(velocity, val); bool flag2 = ((Vector3)(ref val2)).sqrMagnitude > 0.12f; if (flag2) { ((Vector3)(ref val2)).Normalize(); } Vector3 val3 = Vector3.ProjectOnPlane(((Component)player).transform.forward, val); if (flag2) { forward = val2; } else if (((Vector3)(ref val3)).sqrMagnitude > 0.01f) { forward = ((Vector3)(ref val3)).normalized; } else if (flag && ((Vector3)(ref ground.SlopeDown)).sqrMagnitude > 0.0001f) { forward = ground.SlopeDown; } else { forward = Flatten(((Component)player).transform.forward); if (((Vector3)(ref forward)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref forward)).Normalize(); } Vector3 val4 = Vector3.Cross(val, forward); if (((Vector3)(ref val4)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref val4)).Normalize(); right = val4; bool num = ConfigManager.CameraRelativeSteering == null || ConfigManager.CameraRelativeSteering.Value; Vector3 sledLookOnPlane = GetSledLookOnPlane(player, val); if (num && (Object)(object)GameCamera.instance != (Object)null) { Transform transform = ((Component)GameCamera.instance).transform; if ((Object)(object)transform != (Object)null) { Vector3 val5 = Vector3.ProjectOnPlane(transform.right, val); val5 = Vector3.ProjectOnPlane(val5, forward); if (((Vector3)(ref val5)).sqrMagnitude > 0.04f) { right = ((Vector3)(ref val5)).normalized; } } } if (num && flag2 && ((Vector3)(ref sledLookOnPlane)).sqrMagnitude > 0.01f) { if (UpdateSteerAntiTravelFlip(Vector3.Dot(sledLookOnPlane, forward))) { right = -right; } } else { _steerAntiTravelFlipped = false; } right = Vector3.ProjectOnPlane(right, forward); right = Vector3.ProjectOnPlane(right, val); if (((Vector3)(ref right)).sqrMagnitude < 0.01f) { right = val4; } if (((Vector3)(ref right)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref right)).Normalize(); return true; } internal static bool TryProbeGroundBelow(Player player, float maxDistance, out GroundSample sample) { //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_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_002a: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_0096: 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_00a1: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: 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_010b: 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_0209: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) sample = default(GroundSample); if ((Object)(object)player == (Object)null) { return false; } Vector3 position = ((Component)player).transform.position; Vector3 feetPosition = GetFeetPosition(player); float num = Mathf.Max(0.35f, position.y - feetPosition.y); float num2 = Mathf.Clamp(num + 0.35f, 0.85f, 1.35f); Vector3 origin = position + Vector3.up * num2; float distance = num2 + num + Mathf.Max(0.25f, maxDistance) + 0.85f; int groundLayerMask = GetGroundLayerMask(); if (!TryPickGroundHit(origin, distance, groundLayerMask, feetPosition.y, out var best) && !TryPickGroundHit(position + Vector3.up * 2.2f, num + maxDistance + 3f, groundLayerMask, feetPosition.y, out best)) { return TrySampleZoneGroundNearFeet(feetPosition, out sample); } Vector3 point = ((RaycastHit)(ref best)).point; Vector3 val = ((RaycastHit)(ref best)).normal; Collider collider = ((RaycastHit)(ref best)).collider; if (!IsBuiltSledSurface(collider) && TryGetSolidHeight(feetPosition, out var height, out var normal) && IsSolidHeightUsableAsGround(height, feetPosition.y, point.y)) { float num3 = point.y - height; bool num4 = feetPosition.y < height - 0.02f && height - feetPosition.y <= 1.15f; bool num5 = Mathf.Abs(feetPosition.y - height) <= 0.68f; bool flag = num5 && num3 > 0.02f && num3 < 1.2f && !IsTerrainCollider(collider); bool flag2 = num5 && num3 > 0.02f && num3 < 1.2f && val.y < 0.75f; if (num4 || flag || flag2) { ((Vector3)(ref point))..ctor(feetPosition.x, height, feetPosition.z); val = ((((Vector3)(ref normal)).sqrMagnitude > 0.01f) ? normal : Vector3.up); collider = null; } } if (point.y > feetPosition.y + 0.4f) { if (!TryGetTerrainHeightPublic(feetPosition, out var height2) || !(feetPosition.y < height2 - 0.05f)) { if (TrySampleZoneGroundNearFeet(feetPosition, out sample)) { return true; } return false; } ((Vector3)(ref point))..ctor(feetPosition.x, height2, feetPosition.z); val = Vector3.up; collider = null; } PopulateGroundSample(ref sample, point, val, collider); return true; } private static bool IsSolidHeightUsableAsGround(float solidY, float feetY, float hitY) { if (solidY > feetY + 0.45f) { return false; } if (solidY < feetY - 2.75f) { return false; } if (!(Mathf.Abs(solidY - hitY) <= 1.35f)) { return Mathf.Abs(solidY - feetY) <= 1.35f; } return true; } private static bool TrySampleZoneGround(Vector3 nearFeet, out GroundSample sample) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return TrySampleZoneGroundNearFeet(nearFeet, out sample); } private static bool TrySampleZoneGroundNearFeet(Vector3 nearFeet, out GroundSample sample) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0054: 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_009f: 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_00a7: 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_00aa: 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_007c: Unknown result type (might be due to invalid IL or missing references) sample = default(GroundSample); if (!TryGetSolidHeight(nearFeet, out var height, out var normal)) { return false; } if (height > nearFeet.y + 0.45f || height < nearFeet.y - 2.75f) { ZoneSystem instance = ZoneSystem.instance; float num = default(float); if ((Object)(object)instance == (Object)null || !instance.GetGroundHeight(nearFeet, ref num)) { return false; } if (num > nearFeet.y + 0.45f || num < nearFeet.y - 2.75f) { return false; } height = num; normal = Vector3.up; } Vector3 point = default(Vector3); ((Vector3)(ref point))..ctor(nearFeet.x, height, nearFeet.z); Vector3 normal2 = ((((Vector3)(ref normal)).sqrMagnitude > 0.01f) ? normal : Vector3.up); PopulateGroundSample(ref sample, point, normal2, null); return true; } private static bool TryGetSolidHeight(Vector3 worldPos, out float height, out Vector3 normal) { //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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) height = 0f; normal = Vector3.up; ZoneSystem instance = ZoneSystem.instance; if ((Object)(object)instance == (Object)null) { return false; } GameObject val = default(GameObject); if (instance.GetSolidHeight(worldPos, ref height, ref normal, ref val)) { return true; } if (instance.GetGroundHeight(worldPos, ref height)) { normal = Vector3.up; return true; } return false; } internal static bool TryGetSolidHeightPublic(Vector3 worldPos, out float height, out Vector3 normal) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return TryGetSolidHeight(worldPos, out height, out normal); } internal static bool TryGetTerrainHeightPublic(Vector3 worldPos, out float height) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) height = 0f; ZoneSystem instance = ZoneSystem.instance; if ((Object)(object)instance != (Object)null) { return instance.GetGroundHeight(worldPos, ref height); } return false; } internal static bool IsTreeLikeObstacle(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) { return true; } if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) { return true; } Transform root = ((Component)collider).transform.root; string text = (((Object)(object)root != (Object)null) ? ((Object)root).name : ((Object)((Component)collider).gameObject).name); if (string.IsNullOrEmpty(text)) { text = ((Object)((Component)collider).gameObject).name; } if (NameLooksLikeBush(text)) { return false; } return NameLooksLikeTree(text); } internal static bool IsBuiltStructureObstacle(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } int num = LayerMask.NameToLayer("piece"); if (num >= 0 && ((Component)collider).gameObject.layer == num) { return true; } if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) { return true; } if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) { return true; } if (IsWallLikeObstacle(collider)) { return true; } return IsBeeswaxSealedObstacle(collider); } internal static bool IsWallLikeObstacle(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } Piece componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { string name = componentInParent.m_name ?? string.Empty; string name2 = (((Object)(object)((Component)componentInParent).gameObject != (Object)null) ? ((Object)((Component)componentInParent).gameObject).name : string.Empty); if (NameLooksLikeWall(name) || NameLooksLikeWall(name2)) { return true; } } Transform root = ((Component)collider).transform.root; if (!NameLooksLikeWall(((Object)(object)root != (Object)null) ? ((Object)root).name : string.Empty)) { return NameLooksLikeWall(((Object)((Component)collider).gameObject).name); } return true; } internal static bool IsBeeswaxSealedObstacle(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } WearNTear componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { return false; } ZNetView component = ((Component)componentInParent).GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid()) { return component.GetZDO().GetInt("beeswax_sealed", 0) == 1; } return false; } private static bool NameLooksLikeWall(string name) { if (string.IsNullOrEmpty(name)) { return false; } if (name.IndexOf("wall", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("fence", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("gate", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("door", StringComparison.OrdinalIgnoreCase) < 0) { return name.IndexOf("stakewall", StringComparison.OrdinalIgnoreCase) >= 0; } return true; } private static bool NameLooksLikeBush(string name) { if (name.IndexOf("bush", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("shrub", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("berry", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("thistle", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("cloudberry", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("raspberry", StringComparison.OrdinalIgnoreCase) < 0) { return name.IndexOf("blueberry", StringComparison.OrdinalIgnoreCase) >= 0; } return true; } private static bool NameLooksLikeTree(string name) { if (name.IndexOf("tree", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("beech", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("oak", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("birch", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("pine", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("spruce", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("yggdrasil", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("stubbe", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("trunk", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("FirTree", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("TreeLog", StringComparison.OrdinalIgnoreCase) < 0 && !name.StartsWith("Fir", StringComparison.OrdinalIgnoreCase) && !name.EndsWith("Log", StringComparison.OrdinalIgnoreCase)) { return name.EndsWith("Log(Clone)", StringComparison.OrdinalIgnoreCase); } return true; } internal static void PrewarmPhysicsQueries(Player player) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00c3: 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_00e1: Unknown result type (might be due to invalid IL or missing references) int groundLayerMask = GetGroundLayerMask(); RaycastHit val = default(RaycastHit); Physics.Raycast(((Object)(object)player != (Object)null) ? (((Component)player).transform.position + Vector3.up * 1.2f) : (Vector3.up * 50f), Vector3.down, ref val, 8f, groundLayerMask, (QueryTriggerInteraction)1); if (!((Object)(object)((Character)(player?)).m_collider == (Object)null)) { CapsuleCollider collider = ((Character)player).m_collider; Bounds bounds = ((Collider)collider).bounds; Vector3 val2 = ((Bounds)(ref bounds)).center + Vector3.up * (collider.height * 0.25f); bounds = ((Collider)collider).bounds; Vector3 val3 = ((Bounds)(ref bounds)).center - Vector3.up * (collider.height * 0.25f); Physics.CapsuleCast(val2, val3, Mathf.Max(0.05f, collider.radius * 0.5f), ((Component)player).transform.forward, ref val, 0.35f, groundLayerMask, (QueryTriggerInteraction)1); } } private static void PopulateGroundSample(ref GroundSample sample, Vector3 point, Vector3 normal, Collider collider) { //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_0016: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_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) sample.Point = point; sample.Normal = ((((Vector3)(ref normal)).sqrMagnitude > 0.01f) ? ((Vector3)(ref normal)).normalized : Vector3.up); sample.Collider = collider; sample.SlopeAngle = Vector3.Angle(sample.Normal, Vector3.up); sample.SlopeDown = Vector3.ProjectOnPlane(Vector3.down, sample.Normal); if (((Vector3)(ref sample.SlopeDown)).sqrMagnitude > 0.0001f) { ((Vector3)(ref sample.SlopeDown)).Normalize(); } sample.Downhill = Flatten(sample.SlopeDown); if (((Vector3)(ref sample.Downhill)).sqrMagnitude > 0.0001f) { ((Vector3)(ref sample.Downhill)).Normalize(); } sample.Biome = ResolveBiome(point); } private static bool TryPickGroundHit(Vector3 origin, float distance, int mask, float feetY, out RaycastHit best) { //IL_0002: 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_005f: 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_0047: 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_00a3: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) best = default(RaycastHit); int num = Physics.RaycastNonAlloc(origin, Vector3.down, _groundHitBuffer, distance, mask, (QueryTriggerInteraction)1); if (num == _groundHitBuffer.Length && _groundHitBuffer.Length < 128) { Array.Resize(ref _groundHitBuffer, _groundHitBuffer.Length * 2); num = Physics.RaycastNonAlloc(origin, Vector3.down, _groundHitBuffer, distance, mask, (QueryTriggerInteraction)1); } if (num <= 0) { RaycastHit hit = default(RaycastHit); if (Physics.SphereCast(origin, 0.18f, Vector3.down, ref hit, distance, mask, (QueryTriggerInteraction)1) && IsAcceptableGroundHit(in hit, feetY)) { best = hit; return true; } return false; } float num2 = float.MaxValue; bool flag = false; for (int i = 0; i < num; i++) { RaycastHit hit2 = _groundHitBuffer[i]; if (IsAcceptableGroundHit(in hit2, feetY)) { float num3 = feetY - ((RaycastHit)(ref hit2)).point.y; float num4 = (1f - Mathf.Clamp01(((RaycastHit)(ref hit2)).normal.y)) * 2.5f; if (IsBuiltSledSurface(((RaycastHit)(ref hit2)).collider)) { num4 -= 1.1f; } else if (!IsTerrainCollider(((RaycastHit)(ref hit2)).collider)) { num4 += 0.55f; } float num5 = Mathf.Abs(num3) + num4; if (num3 < -0.02f) { num5 += 2.5f + (0f - num3); } if (!flag || num5 < num2) { num2 = num5; best = hit2; flag = true; } } } return flag; } private static bool IsAcceptableGroundHit(in RaycastHit hit, float feetY) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_001f: 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_0064: 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_006c: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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) RaycastHit val = hit; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null)) { val = hit; if (!(((RaycastHit)(ref val)).normal.y < 0.4f)) { val = hit; if (IsWallLikeObstacle(((RaycastHit)(ref val)).collider)) { val = hit; if (((RaycastHit)(ref val)).normal.y < 0.72f) { return false; } } val = hit; if (((RaycastHit)(ref val)).point.y > feetY + 0.28f) { val = hit; if (IsTerrainCollider(((RaycastHit)(ref val)).collider)) { val = hit; if (TryGetTerrainHeightPublic(((RaycastHit)(ref val)).point, out var height) && feetY < height - 0.05f) { val = hit; if (Mathf.Abs(((RaycastHit)(ref val)).point.y - height) <= 0.75f) { return true; } } } return false; } return true; } } return false; } internal static bool IsTerrainCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } int num = LayerMask.NameToLayer("terrain"); if (num >= 0 && ((Component)collider).gameObject.layer == num) { return true; } string name = ((Object)((Component)collider).gameObject).name; if (!string.IsNullOrEmpty(name)) { if (name.IndexOf("Terrain", StringComparison.OrdinalIgnoreCase) < 0) { return name.IndexOf("Heightmap", StringComparison.OrdinalIgnoreCase) >= 0; } return true; } return false; } internal static bool TryGetSledGround(Player player, out GroundSample ground, float contactThreshold = 0.38f) { //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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00d3: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_021b: 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) ground = default(GroundSample); if ((Object)(object)player == (Object)null) { return false; } Rigidbody body = GetBody(player); ShieldSledController instance = ShieldSledController.Instance; Vector3 velocity = Vector3.zero; float num = 0f; if (instance != null && instance.IsSledding) { velocity = instance.SimulatedVelocity; num = instance.CurrentSpeed; } else if ((Object)(object)body != (Object)null) { velocity = body.linearVelocity; num = HorizontalSpeed(velocity); } if (instance != null && instance.IsSledding && WaterSledHelper.TryGetWaterSledGround(player, num, out ground) && (!TryGetTerrainHeightPublic(GetFeetPosition(player), out var height) || !(height > ground.WaterSurfaceY + 0.12f) || !(GetFeetPosition(player).y >= height - 0.35f))) { return true; } if (instance != null && instance.IsSledding && WaterSledHelper.CanWaterSled(Mathf.Max(num, HorizontalSpeed(velocity))) && WaterSledHelper.TryBuildWaterGround(player, out ground)) { float num2 = GetFeetPosition(player).y - ground.WaterSurfaceY; if (num2 <= 1.35f && num2 >= -2.35f && (!TryGetTerrainHeightPublic(GetFeetPosition(player), out var height2) || !(height2 > ground.WaterSurfaceY + 0.12f) || !(GetFeetPosition(player).y >= height2 - 0.35f))) { return true; } } if (TryProbeGroundBelow(player, 1.5f, out ground)) { if (instance != null && instance.IsSledding && WaterSledHelper.IsLiquidNearPlayer(player) && (WaterSledHelper.CanWaterSled(Mathf.Max(num, HorizontalSpeed(velocity))) || WaterSledHelper.IsSkimCommitted) && WaterSledHelper.TryBuildWaterGround(player, out var ground2)) { float feetHeightAboveGround = GetFeetHeightAboveGround(player, ground); bool flag = !ground.IsWaterSurface && ground.Point.y <= ground2.WaterSurfaceY + 0.12f; bool flag2 = !ground.IsWaterSurface && ground.Point.y > ground2.WaterSurfaceY + 0.12f; if ((feetHeightAboveGround > 0.2f || flag) && !flag2) { ground = ground2; return true; } } if (GetFeetHeightAboveGround(player, ground) <= contactThreshold && (instance == null || !instance.IsSledding || instance.IsInStartupGrace || !IsSeparatingFromGround(velocity, in ground))) { return true; } } return false; } internal static bool TrySampleGround(Player player, out GroundSample sample) { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0199: 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) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_01c7: 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_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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) sample = default(GroundSample); if ((Object)(object)player == (Object)null) { return false; } if (((Character)player).IsOnGround() && ((Vector3)(ref ((Character)player).m_lastGroundNormal)).sqrMagnitude > 0.01f) { sample.Point = ((Character)player).m_lastGroundPoint; sample.Normal = ((Character)player).m_lastGroundNormal; sample.Collider = ((Character)player).m_lastGroundCollider; sample.SlopeAngle = Vector3.Angle(sample.Normal, Vector3.up); sample.SlopeDown = Vector3.ProjectOnPlane(Vector3.down, sample.Normal); if (((Vector3)(ref sample.SlopeDown)).sqrMagnitude > 0.0001f) { ((Vector3)(ref sample.SlopeDown)).Normalize(); } sample.Downhill = Flatten(sample.SlopeDown); if (((Vector3)(ref sample.Downhill)).sqrMagnitude > 0.0001f) { ((Vector3)(ref sample.Downhill)).Normalize(); } sample.Biome = ResolveBiome(sample.Point); return true; } Vector3 val = GetFeetPosition(player) + Vector3.up * 0.35f; int groundLayerMask = GetGroundLayerMask(); RaycastHit val2 = default(RaycastHit); if (!Physics.SphereCast(val, 0.28f, Vector3.down, ref val2, 2.5f, groundLayerMask) && !Physics.SphereCast(((Component)player).transform.position + Vector3.up * 0.5f, 0.28f, Vector3.down, ref val2, 3.5f, groundLayerMask)) { return false; } sample.Point = ((RaycastHit)(ref val2)).point; sample.Normal = ((RaycastHit)(ref val2)).normal; sample.Collider = ((RaycastHit)(ref val2)).collider; sample.SlopeAngle = Vector3.Angle(((RaycastHit)(ref val2)).normal, Vector3.up); sample.SlopeDown = Vector3.ProjectOnPlane(Vector3.down, ((RaycastHit)(ref val2)).normal); if (((Vector3)(ref sample.SlopeDown)).sqrMagnitude > 0.0001f) { ((Vector3)(ref sample.SlopeDown)).Normalize(); } sample.Downhill = Flatten(sample.SlopeDown); if (((Vector3)(ref sample.Downhill)).sqrMagnitude > 0.0001f) { ((Vector3)(ref sample.Downhill)).Normalize(); } sample.Biome = ResolveBiome(((RaycastHit)(ref val2)).point); return true; } internal static bool TryRaycastGround(Player player, out GroundSample sample) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) sample = default(GroundSample); if ((Object)(object)player == (Object)null) { return false; } Vector3 val = GetFeetPosition(player) + Vector3.up * 0.35f; int groundLayerMask = GetGroundLayerMask(); RaycastHit val2 = default(RaycastHit); if (!Physics.SphereCast(val, 0.28f, Vector3.down, ref val2, 3f, groundLayerMask) && !Physics.SphereCast(((Component)player).transform.position + Vector3.up * 0.5f, 0.28f, Vector3.down, ref val2, 4f, groundLayerMask)) { return false; } sample.Point = ((RaycastHit)(ref val2)).point; sample.Normal = ((RaycastHit)(ref val2)).normal; sample.Collider = ((RaycastHit)(ref val2)).collider; sample.SlopeAngle = Vector3.Angle(((RaycastHit)(ref val2)).normal, Vector3.up); sample.SlopeDown = Vector3.ProjectOnPlane(Vector3.down, ((RaycastHit)(ref val2)).normal); if (((Vector3)(ref sample.SlopeDown)).sqrMagnitude > 0.0001f) { ((Vector3)(ref sample.SlopeDown)).Normalize(); } sample.Downhill = Flatten(sample.SlopeDown); if (((Vector3)(ref sample.Downhill)).sqrMagnitude > 0.0001f) { ((Vector3)(ref sample.Downhill)).Normalize(); } sample.Biome = ResolveBiome(((RaycastHit)(ref val2)).point); return true; } internal static Biome ResolveBiome(Vector3 worldPos) { //IL_000e: 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_0020: Unknown result type (might be due to invalid IL or missing references) if (WorldGenerator.instance == null) { return (Biome)1; } return WorldGenerator.instance.GetBiome(worldPos.x, worldPos.z, 0.02f, false); } internal static float GetBiomeFriction(Biome biome) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0005: 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_001d: Expected I4, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I4 //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 if ((int)biome <= 16) { switch (biome - 1) { default: if ((int)biome != 8) { if ((int)biome != 16) { break; } return ConfigManager.GrassFriction.Value; } return ConfigManager.BlackForestFriction.Value; case 0: return ConfigManager.MeadowsFriction.Value; case 1: return ConfigManager.SwampFriction.Value; case 3: return BlendSnowFriction(ConfigManager.MountainFriction.Value); case 2: break; } } else if ((int)biome <= 64) { if ((int)biome == 32) { return ConfigManager.AshlandsFriction.Value; } if ((int)biome == 64) { return BlendSnowFriction(ConfigManager.DeepNorthFriction.Value); } } else { if ((int)biome == 256) { return ConfigManager.OceanFriction.Value; } if ((int)biome == 512) { return ConfigManager.MistlandsFriction.Value; } } return ConfigManager.GrassFriction.Value; } private static float BlendSnowFriction(float biomeFriction) { return (biomeFriction + ConfigManager.SnowFriction.Value) * 0.5f; } internal static bool IsSnowBiome(Biome biome) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)biome != 4) { return (int)biome == 64; } return true; } internal static bool TryGetShieldSurfFriction(Collider collider, out float friction) { friction = ConfigManager.ShieldSurfFriction.Value; if (!ConfigManager.EnableShieldSurf.Value || (Object)(object)collider == (Object)null) { return false; } if (IsBuiltSledSurface(collider)) { return true; } return false; } internal static bool IsBuiltSledSurface(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } if (IsWallLikeObstacle(collider)) { return false; } int num = LayerMask.NameToLayer("piece"); if (num >= 0 && ((Component)collider).gameObject.layer == num) { return true; } WearNTear componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && ((object)Unsafe.As(ref componentInParent.m_materialType)/*cast due to .constrained prefix*/).ToString().IndexOf("wood", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } Piece componentInParent2 = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null) { string name = componentInParent2.m_name ?? string.Empty; string name2 = (((Object)(object)((Component)componentInParent2).gameObject != (Object)null) ? ((Object)((Component)componentInParent2).gameObject).name : string.Empty); if (NameLooksLikeWoodRamp(name) || NameLooksLikeWoodRamp(name2)) { return true; } } return NameLooksLikeWoodRamp(((Object)((Component)collider).gameObject).name); } private static bool NameLooksLikeWoodRamp(string name) { if (string.IsNullOrEmpty(name)) { return false; } if (NameLooksLikeWall(name)) { return false; } if (name.IndexOf("wood", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("ramp", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("floor", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("stair", StringComparison.OrdinalIgnoreCase) < 0) { return name.IndexOf("bridge", StringComparison.OrdinalIgnoreCase) >= 0; } return true; } internal static bool TryProbeSolidLandNearFeet(Player player, float waterSurfaceY, out GroundSample land) { //IL_002c: 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_004e: Unknown result type (might be due to invalid IL or missing references) land = default(GroundSample); if ((Object)(object)player == (Object)null) { return false; } if (!TryProbeGroundBelow(player, 3f, out var sample) || sample.IsWaterSurface) { return false; } if (sample.Point.y < waterSurfaceY + 0.08f) { return false; } float y = GetFeetPosition(player).y; if (sample.Point.y > y + 0.45f) { return false; } land = sample; return true; } internal static float GetDurabilityWearBiomeMultiplier(Biome biome) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)biome != 32) { return 1f; } return ConfigManager.AshlandsDurabilityWearMultiplier.Value; } internal static void ParseCustomShieldSpeeds(string raw, Dictionary target) { if (string.IsNullOrWhiteSpace(raw)) { return; } string[] array = raw.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ':' }); if (array2.Length == 2) { string key = array2[0].Trim(); if (float.TryParse(array2[1].Trim(), out var result)) { target[key] = result; } } } } } internal struct GroundSample { public Vector3 Point; public Vector3 Normal; public Collider Collider; public float SlopeAngle; public Vector3 Downhill; public Vector3 SlopeDown; public Biome Biome; public bool IsWaterSurface; public float WaterSurfaceY; } internal static class WaterSledHelper { private static float _smoothedSurfaceY; private static bool _hasSmoothedSurface; private static float _waterLatchUntil; private static bool _skimCommitted; private static float _skimExitGraceUntil; private static float _belowCancelSpeedSince = -1f; private const float WaterLatchSeconds = 1.35f; private const float CancelGraceSeconds = 0.18f; private const float SoftDeadzone = 0.04f; private const float HardSettleAbove = 0.08f; private const float HardSettleBelow = 0.1f; private const float RideInset = 0.18f; private const float InvalidLiquidSentinel = -5000f; internal static bool IsSkimCommitted { get { if (_skimCommitted) { return Time.time <= _waterLatchUntil; } return false; } } internal static bool CanWaterSled(float speed) { if (ConfigManager.EnableWaterSledding.Value) { return speed >= GetEngageMinSpeed(); } return false; } internal static bool CanKeepWaterSled(float speed) { if (ConfigManager.EnableWaterSledding.Value) { return speed >= GetCancelMinSpeed(); } return false; } private static float GetEngageMinSpeed() { return Mathf.Max(GetCancelMinSpeed(), ConfigManager.WaterSledMinSpeed.Value); } private static float GetCancelMinSpeed() { return Mathf.Max(0.5f, ConfigManager.WaterSledSustainSpeed.Value); } internal static bool IsWaterSledding(Player player, float speed) { if ((Object)(object)player == (Object)null || !ConfigManager.EnableWaterSledding.Value) { return false; } if (_skimCommitted) { if (CanKeepWaterSled(speed) && IsNearWaterBody(player)) { RefreshWaterLatch(); _belowCancelSpeedSince = -1f; return true; } if (Time.time <= _skimExitGraceUntil && IsNearWaterBody(player) && !IsTrulySubmerged(player)) { return true; } ClearSkimCommit(); return false; } if (!CanWaterSled(speed)) { return false; } if (!TryGetAnyWaterSurface(player, out var surfaceY)) { return false; } if (!IsFeetNearSurface(player, surfaceY) && !IsOverDeepWaterColumn(player, surfaceY)) { return false; } CommitSkim(surfaceY); return true; } internal static bool IsOverWater(Player player) { if ((Object)(object)player == (Object)null) { return false; } if (IsSkimCommitted) { return true; } return IsNearWaterBody(player); } internal static bool IsLiquidNearPlayer(Player player) { if ((Object)(object)player != (Object)null) { return IsNearWaterBody(player); } return false; } internal static void ResetSurfaceSmoothing() { _hasSmoothedSurface = false; _waterLatchUntil = 0f; ClearSkimCommit(); } internal static bool TryGetWaterSurface(Player player, out float surfaceY) { return TryGetAnyWaterSurface(player, out surfaceY); } internal static bool TryBuildWaterGround(Player player, out GroundSample ground) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0082: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) ground = default(GroundSample); if ((Object)(object)player == (Object)null || !TryGetAnyWaterSurface(player, out var surfaceY)) { return false; } Vector3 feetPosition = Utility.GetFeetPosition(player); if (Mathf.Abs(feetPosition.y - surfaceY) > 4.5f && !IsSkimCommitted) { return false; } float num = Mathf.Clamp(ConfigManager.SledGroundClearance.Value, 0f, 0.6f); float num2 = surfaceY - 0.18f + num; ground.Point = new Vector3(feetPosition.x, num2, feetPosition.z); ground.Normal = Vector3.up; ground.Collider = null; ground.SlopeAngle = 0f; ground.SlopeDown = Vector3.zero; ground.Downhill = Vector3.zero; ground.Biome = (Biome)256; ground.IsWaterSurface = true; ground.WaterSurfaceY = num2; return true; } internal static bool TryGetWaterSledGround(Player player, float speed, out GroundSample ground) { ground = default(GroundSample); if (!IsWaterSledding(player, speed)) { return false; } return TryBuildWaterGround(player, out ground); } internal static bool ShouldEndSledForWater(Player player, float speed) { //IL_00f4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || !ConfigManager.EnableWaterSledding.Value) { if (!Utility.IsInDeepWater(player)) { if ((Object)(object)player != (Object)null) { return ((Character)player).InWater(); } return false; } return true; } if (IsTrulySubmerged(player)) { ClearSkimCommit(); return true; } if (IsWaterSledding(player, speed)) { if (!CanKeepWaterSled(speed)) { if (_belowCancelSpeedSince < 0f) { _belowCancelSpeedSince = Time.time; } if (Time.time - _belowCancelSpeedSince > 0.18f) { ClearSkimCommit(); return true; } _skimExitGraceUntil = Time.time + 0.18f; return false; } _belowCancelSpeedSince = -1f; return false; } if (CanWaterSled(speed) && TryGetAnyWaterSurface(player, out var surfaceY) && (IsFeetNearSurface(player, surfaceY) || IsOverDeepWaterColumn(player, surfaceY)) && !IsTrulySubmerged(player)) { CommitSkim(surfaceY); return false; } if (Utility.IsInDeepWater(player) || ((Character)player).InWater()) { ClearSkimCommit(); return true; } if (TryGetAnyWaterSurface(player, out var surfaceY2) && Utility.GetFeetPosition(player).y < surfaceY2 - 0.35f) { ClearSkimCommit(); return true; } return false; } private static bool IsTrulySubmerged(Player player) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return false; } if (Utility.IsInDeepWater(player) || ((Character)player).IsSwimming()) { return true; } float submersionDepth = GetSubmersionDepth(player); if (submersionDepth > 0.75f) { return true; } if (TryGetAnyWaterSurface(player, out var surfaceY) && Utility.GetFeetPosition(player).y < surfaceY - 1.15f && submersionDepth > 0.35f) { return true; } return false; } internal static void ApplySoftWaterFollow(Player player, in GroundSample waterGround, ref Vector3 velocity, float dt) { //IL_0021: 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_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || !waterGround.IsWaterSurface) { return; } float num = waterGround.WaterSurfaceY; bool flag = false; if (Utility.TryGetTerrainHeightPublic(((Component)player).transform.position, out var height) && height > num + 0.05f) { num = height; flag = true; ClearSkimForLandTransition(); } float y = Utility.GetFeetPosition(player).y; float num2 = y - num; if (Mathf.Abs(num2) > 0.04f) { float num3; if (num2 > 0.08f || num2 < -0.1f) { num3 = 0f - num2; } else { float num4 = Mathf.Max(0.06f, 8f * Mathf.Max(dt, 0.001f)); num3 = Mathf.Clamp(0f - num2, 0f - num4, num4); } Rigidbody body = Utility.GetBody(player); Vector3 val = (((Object)(object)body != (Object)null) ? body.position : ((Component)player).transform.position); val.y += num3; if (Utility.TryGetTerrainHeightPublic(val, out var height2)) { float num5 = ((Component)player).transform.position.y - y; float num6 = height2 + num5; if (val.y < num6) { val.y = num6; flag = true; ClearSkimForLandTransition(); } } if ((Object)(object)body != (Object)null) { body.position = val; } ((Component)player).transform.position = val; } velocity.y = 0f; ((Character)player).m_lastGroundPoint = new Vector3(((Component)player).transform.position.x, num, ((Component)player).transform.position.z); ((Character)player).m_lastGroundNormal = Vector3.up; ((Character)player).m_groundContact = true; ((Character)player).m_swimTimer = 1f; if (!flag) { _skimCommitted = true; if (((ShieldSledController.Instance != null) ? ShieldSledController.Instance.CurrentSpeed : Utility.HorizontalSpeed(velocity)) >= GetCancelMinSpeed()) { RefreshWaterLatch(); } } } internal static void MaintainWaterSurface(Player player, in GroundSample waterGround, float dt) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null) && waterGround.IsWaterSurface) { Vector3 velocity = Vector3.zero; ApplySoftWaterFollow(player, in waterGround, ref velocity, dt); } } private static void CommitSkim(float surfaceY) { _skimCommitted = true; _belowCancelSpeedSince = -1f; _skimExitGraceUntil = Time.time + 0.18f; _smoothedSurfaceY = surfaceY; _hasSmoothedSurface = true; RefreshWaterLatch(); Plugin.Log.LogInfo((object)$"Shield Sledding: water skim engaged at Y={surfaceY:F1}."); } private static void ClearSkimCommit() { _skimCommitted = false; _belowCancelSpeedSince = -1f; _skimExitGraceUntil = 0f; } internal static void ClearSkimForLandTransition() { ClearSkimCommit(); _waterLatchUntil = 0f; } private static void RefreshWaterLatch() { _waterLatchUntil = Time.time + 1.35f; } private static bool IsNearWaterBody(Player player) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return false; } if (((Character)player).InWater()) { return true; } if (TryGetAnyWaterSurface(player, out var surfaceY) && (IsFeetNearSurface(player, surfaceY) || IsOverDeepWaterColumn(player, surfaceY))) { return true; } if (IsSkimCommitted && _hasSmoothedSurface && Mathf.Abs(Utility.GetFeetPosition(player).y - _smoothedSurfaceY) < 1.6f) { return true; } return false; } private static bool IsFeetNearSurface(Player player, float surfaceY) { //IL_0001: 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) float y = Utility.GetFeetPosition(player).y; float y2 = ((Component)player).transform.position.y; bool num = y <= surfaceY + 1.1f && y >= surfaceY - 2.1f; bool flag = y2 <= surfaceY + 1.85f && y2 >= surfaceY - 1.1f; return num || flag; } private static bool IsOverDeepWaterColumn(Player player, float surfaceY) { //IL_0001: 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) float y = Utility.GetFeetPosition(player).y; if (y > surfaceY + 1.35f || y < surfaceY - 2.5f) { return false; } if (!Utility.TryProbeGroundBelow(player, 6f, out var sample) || sample.IsWaterSurface) { return true; } if (Utility.GetFeetHeightAboveGround(player, sample) > 0.2f) { return true; } return sample.Point.y <= surfaceY + 0.05f; } private static float GetSubmersionDepth(Player player) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (!TryGetAnyWaterSurface(player, out var surfaceY)) { return 0f; } return Mathf.Max(0f, surfaceY - ((Component)player).transform.position.y); } private static bool TryGetAnyWaterSurface(Player player, out float surfaceY) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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) surfaceY = 0f; if ((Object)(object)player == (Object)null) { return false; } float num = float.NaN; Vector3 feetPosition = Utility.GetFeetPosition(player); float y = feetPosition.y; float y2 = ((Component)player).transform.position.y; float num2 = ReadLiveWaveSurface(feetPosition); float num3 = ReadOceanSurfaceY(((Component)player).transform.position); if (IsPlausibleSurface(num2, y2, y)) { num = num2; } else { float num4 = ReadCharacterLiquidLevel(player); if (IsPlausibleSurface(num4, y2, y)) { num = (IsPlausibleSurface(num3, y2, y) ? Mathf.Min(num4, num3 + 0.45f) : num4); } else if (IsPlausibleSurface(num3, y2, y)) { num = num3; } } if (float.IsNaN(num) && _hasSmoothedSurface && Time.time <= _waterLatchUntil && Mathf.Abs(y - _smoothedSurfaceY) < 2f) { if (!IsPlausibleSurface(num3, y2, y)) { surfaceY = _smoothedSurfaceY; return true; } num = Mathf.Lerp(_smoothedSurfaceY, num3, 0.4f); } if (float.IsNaN(num)) { return false; } if (!_hasSmoothedSurface) { _smoothedSurfaceY = num; _hasSmoothedSurface = true; } else { float num5 = Mathf.Max(Time.deltaTime, 0.001f); float num6 = num - _smoothedSurfaceY; float num7 = 1f - Mathf.Exp(-14f * num5); if (Mathf.Abs(num6) > 0.4f) { num7 = Mathf.Clamp01(num7 * 3f); } _smoothedSurfaceY = Mathf.Lerp(_smoothedSurfaceY, num, num7); } surfaceY = _smoothedSurfaceY; return true; } private static float ReadLiveWaveSurface(Vector3 worldPos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) try { float liquidLevel = Floating.GetLiquidLevel(worldPos, 1f, (LiquidType)0); if (liquidLevel > -5000f) { return liquidLevel; } } catch { } return -5000f; } private static float ReadCharacterLiquidLevel(Player player) { try { float liquidLevel = ((Character)player).GetLiquidLevel(); if (liquidLevel > -5000f) { return liquidLevel; } } catch { } float liquidLevel2 = ((Character)player).m_liquidLevel; if (!(liquidLevel2 > -5000f)) { return -5000f; } return liquidLevel2; } private static float ReadOceanSurfaceY(Vector3 worldPos) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) ZoneSystem instance = ZoneSystem.instance; if ((Object)(object)instance == (Object)null) { return -5000f; } float waterLevel = instance.m_waterLevel; if (waterLevel <= -5000f) { return -5000f; } float num = default(float); if (instance.GetGroundHeight(worldPos, ref num) && num > waterLevel - 0.15f) { return -5000f; } return waterLevel; } private static bool IsPlausibleSurface(float surfaceY, float rootY, float feetY) { if (float.IsNaN(surfaceY) || surfaceY <= -5000f) { return false; } if (surfaceY > feetY - 8f && surfaceY < feetY + 6f && surfaceY > rootY - 9f) { return surfaceY < rootY + 6f; } return false; } } internal static class WildlifeImpact { private static readonly string[] KillPrefabTokens = new string[9] { "Boar", "Deer", "Greyling", "Neck", "Crow", "Gull", "Seagull", "Hare", "AshCrow" }; private static readonly Dictionary RecentHits = new Dictionary(); internal static void TryRam(Player player, ItemData shield, PhysicsResult result) { //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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_017c: 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) if ((Object)(object)player == (Object)null || !ConfigManager.EnableWildlifeImpactKill.Value) { return; } float horizontalSpeed = result.HorizontalSpeed; if (horizontalSpeed < ConfigManager.CollisionSpeedThreshold.Value) { return; } CleanupRecent(); Vector3 val = Utility.Flatten(result.Velocity); if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = Utility.Flatten(((Component)player).transform.forward); } if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { return; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = ((Component)player).transform.position + Vector3.up * 0.75f; float num = 0.72f; float num2 = Mathf.Clamp(horizontalSpeed * 0.14f, 1f, 2.4f); RaycastHit[] array = Physics.SphereCastAll(val2, num, val, num2, -1); for (int i = 0; i < array.Length; i++) { TryHitCollider(player, shield, ((RaycastHit)(ref array[i])).collider, ((RaycastHit)(ref array[i])).point, val, horizontalSpeed); } Collider[] array2 = Physics.OverlapSphere(val2 + val * (num * 0.5f), num, -1); foreach (Collider val3 in array2) { if (!((Object)(object)val3 == (Object)null)) { Bounds bounds = val3.bounds; Vector3 v = ((Bounds)(ref bounds)).center - val2; Vector3 val4 = Utility.Flatten(v); if (!(Vector3.Dot(((Vector3)(ref val4)).normalized, val) < 0.25f) && !(((Vector3)(ref v)).sqrMagnitude > (num2 + num) * (num2 + num))) { bounds = val3.bounds; TryHitCollider(player, shield, val3, ((Bounds)(ref bounds)).center, val, horizontalSpeed); } } } } private static void TryHitCollider(Player player, ItemData shield, Collider collider, Vector3 point, Vector3 dir, float speed) { //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) if ((Object)(object)collider == (Object)null) { return; } Character componentInParent = ((Component)collider).GetComponentInParent(); if (IsKillTarget(componentInParent)) { int instanceID = ((Object)componentInParent).GetInstanceID(); if (!RecentHits.ContainsKey(instanceID)) { RecentHits[instanceID] = Time.time + 1.5f; ApplyKill(player, shield, componentInParent, point, dir, speed); } } } private static bool IsKillTarget(Character character) { if ((Object)(object)character == (Object)null || character.IsDead() || character is Player) { return false; } if (character.m_tamed) { return false; } string characterPrefabToken = Utility.GetCharacterPrefabToken(character); if (string.IsNullOrEmpty(characterPrefabToken)) { return false; } for (int i = 0; i < KillPrefabTokens.Length; i++) { if (characterPrefabToken.IndexOf(KillPrefabTokens[i], StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } private static void ApplyKill(Player player, ItemData shield, Character character, Vector3 point, Vector3 dir, float speed) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0028: 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_002f: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) HitData val = new HitData(); val.m_damage.m_blunt = Mathf.Max(character.GetMaxHealth() * 2f, 200f); val.m_point = point; val.m_dir = dir; val.m_pushForce = speed * 0.75f; ZNetView component = ((Component)player).GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid()) { val.m_attacker = component.GetZDO().m_uid; } val.m_skill = (SkillType)3; val.m_skillLevel = ((Character)player).GetSkillLevel((SkillType)3); character.Damage(val); float impact = speed * ConfigManager.CollisionSpeedDamageScale.Value; ShieldSledController.Instance?.ReportCollisionWear(player, shield, impact); EffectController.Instance?.OnWildlifeImpact(player, point, dir, impact); AudioController.Instance?.PlayImpact(player, impact); MultiplayerSync.Instance?.SendImpactEvent(player, point, impact); } private static void CleanupRecent() { if (RecentHits.Count == 0) { return; } float time = Time.time; List list = null; foreach (KeyValuePair recentHit in RecentHits) { if (!(recentHit.Value > time)) { if (list == null) { list = new List(); } list.Add(recentHit.Key); } } if (list != null) { for (int i = 0; i < list.Count; i++) { RecentHits.Remove(list[i]); } } } } } namespace ShieldSledding.Patches { [HarmonyPatch(typeof(ZNetView), "Awake")] internal static class ZNetViewAwakePatch { private static void Postfix(ZNetView __instance) { if ((Object)(object)((Component)__instance).GetComponent() != (Object)null) { MultiplayerSync.EnsureRegistered(__instance); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }