Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ShieldSledding v1.0.0
ShieldSledding.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.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.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ShieldSledding")] [assembly: AssemblyTitle("ShieldSledding")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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; internal static AudioController Instance { get; private set; } internal AudioController() { Instance = this; } 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()) { return; } EnsureSources(player); Utility.GetHandShield(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.2f + num2 * 0.6f; _slideSource.pitch = 0.8f + num2 * 0.5f; } else { _slideSource.Stop(); } } if (!((Object)(object)_windSource != (Object)null)) { return; } if (speed > 6f) { if (!_windSource.isPlaying) { _windSource.Play(); } _windSource.volume = num2 * 0.5f; _windSource.pitch = 0.9f + num2 * 0.8f; } 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) { _slideSource.PlayOneShot(_slideSource.clip, Mathf.Clamp01(impact / 20f)); } } } private void EnsureSources(Player player) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (!((Object)(object)_slideSource != (Object)null)) { GameObject val = new GameObject("ShieldSledding_Audio"); val.transform.SetParent(((Component)player).transform, false); _slideSource = val.AddComponent<AudioSource>(); _slideSource.loop = true; _slideSource.spatialBlend = 0f; _slideSource.volume = 0.4f; _windSource = val.AddComponent<AudioSource>(); _windSource.loop = true; _windSource.spatialBlend = 0f; _windSource.volume = 0.25f; _windSource.pitch = 1.1f; } } } 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)) { EffectController.Instance?.ShakeCamera(impact * 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<bool> EnableShieldSledding; internal static ConfigEntry<KeyboardShortcut> ActivationKey; internal static ConfigEntry<float> ActivationWindow; internal static ConfigEntry<float> ArmedWindow; internal static ConfigEntry<float> MinimumSlope; internal static ConfigEntry<float> SledGroundClearance; internal static ConfigEntry<bool> EnableWaterSledding; internal static ConfigEntry<float> WaterSledMinSpeed; internal static ConfigEntry<float> WaterSledFriction; internal static ConfigEntry<float> BaseAcceleration; internal static ConfigEntry<float> MaximumSpeed; internal static ConfigEntry<float> MinBlockSkillSpeedScale; internal static ConfigEntry<float> GravityMultiplier; internal static ConfigEntry<float> FrictionMultiplier; internal static ConfigEntry<float> AirControl; internal static ConfigEntry<float> SteeringStrength; internal static ConfigEntry<float> BrakeStrength; internal static ConfigEntry<float> ForwardLeanBonus; internal static ConfigEntry<float> SteeringSpeedFalloff; internal static ConfigEntry<float> UphillPenalty; internal static ConfigEntry<float> FlatDeceleration; internal static ConfigEntry<bool> AbsorbDamageToShield; internal static ConfigEntry<bool> EndSledOnCombatHit; internal static ConfigEntry<bool> StaggerOnCombatHit; internal static ConfigEntry<float> CombatHitMinDamage; internal static ConfigEntry<bool> EnableDurabilityLoss; internal static ConfigEntry<float> DurabilityPerMeter; internal static ConfigEntry<float> DurabilityPerSecond; internal static ConfigEntry<float> LandingDamageMultiplier; internal static ConfigEntry<float> DamageToDurabilityMultiplier; internal static ConfigEntry<bool> StumbleOnShieldBreak; internal static ConfigEntry<float> SnowFriction; internal static ConfigEntry<float> GrassFriction; internal static ConfigEntry<float> BlackForestFriction; internal static ConfigEntry<float> SwampFriction; internal static ConfigEntry<float> AshlandsFriction; internal static ConfigEntry<float> MountainFriction; internal static ConfigEntry<float> MeadowsFriction; internal static ConfigEntry<float> MistlandsFriction; internal static ConfigEntry<float> OceanFriction; internal static ConfigEntry<float> DeepNorthFriction; internal static ConfigEntry<float> AshlandsDurabilityWearMultiplier; internal static ConfigEntry<bool> EnableShieldSurf; internal static ConfigEntry<float> ShieldSurfFriction; internal static ConfigEntry<float> CollisionSpeedThreshold; internal static ConfigEntry<float> CollisionSpeedDamageScale; internal static ConfigEntry<bool> EnableWildlifeImpactKill; internal static ConfigEntry<SledStaminaMode> StaminaMode; internal static ConfigEntry<float> StaminaActivationCost; internal static ConfigEntry<float> StaminaPerSecond; internal static ConfigEntry<float> StaminaJumpCost; internal static ConfigEntry<bool> EnableParticles; internal static ConfigEntry<bool> EnableCameraEffects; internal static ConfigEntry<bool> EnableSoundEffects; internal static ConfigEntry<bool> EnableSpeedometer; internal static ConfigEntry<float> CameraShakeStrength; internal static ConfigEntry<float> SpeedFovIncrease; internal static ConfigEntry<float> CameraTiltStrength; internal static ConfigEntry<bool> EnableShieldSparks; internal static ConfigEntry<int> 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<float>(min, max), Array.Empty<object>()); } 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<int>(min, max), Array.Empty<object>()); } 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Expected O, but got Unknown //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Expected O, but got Unknown //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Expected O, but got Unknown //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Expected O, but got Unknown //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Expected O, but got Unknown //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Expected O, but got Unknown //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Expected O, but got Unknown //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Expected O, but got Unknown //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Expected O, but got Unknown //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Expected O, but got Unknown //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Expected O, but got Unknown //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_0462: 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_0854: Unknown result type (might be due to invalid IL or missing references) //IL_085e: Expected O, but got Unknown //IL_088c: Unknown result type (might be due to invalid IL or missing references) //IL_0896: Expected O, but got Unknown ConfigSchemaVersion = config.Bind<int>("General", "ConfigSchemaVersion", 1, "Internal config migration version. Do not edit unless you know what you are doing."); EnableShieldSledding = config.Bind<bool>("General", "EnableShieldSledding", true, "Master toggle for shield sledding."); ActivationKey = config.Bind<KeyboardShortcut>("General", "ActivationKey", new KeyboardShortcut((KeyCode)103, Array.Empty<KeyCode>()), "Press while airborne after a jump to arm shield sled mode."); ActivationWindow = config.Bind<float>("General", "ActivationWindow", 2.5f, new ConfigDescription("Seconds after jumping during which G can arm sled mode.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); ArmedWindow = config.Bind<float>("General", "ArmedWindow", 6f, new ConfigDescription("Seconds after arming to land and start sledding before the arm expires.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 15f), Array.Empty<object>())); MinimumSlope = config.Bind<float>("General", "MinimumSlope", 0f, new ConfigDescription("Minimum ground slope in degrees required to start sledding on landing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 45f), Array.Empty<object>())); SledGroundClearance = config.Bind<float>("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<float>(0f, 0.6f), Array.Empty<object>())); EnableWaterSledding = config.Bind<bool>("Physics", "EnableWaterSledding", true, "Allow sledding across water when moving fast enough."); WaterSledMinSpeed = config.Bind<float>("Physics", "WaterSledMinSpeed", 6f, new ConfigDescription("Minimum speed (m/s) required to skim across water instead of swimming.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 20f), Array.Empty<object>())); WaterSledFriction = config.Bind<float>("Physics", "WaterSledFriction", 0.35f, new ConfigDescription("Extra friction while skimming water. Lower = faster skim.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 2f), Array.Empty<object>())); BaseAcceleration = config.Bind<float>("Physics", "BaseAcceleration", 10f, new ConfigDescription("Slope pull strength (~10 ≈ gravity). Higher = faster coast on the same hill.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>())); MaximumSpeed = config.Bind<float>("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<float>(0f, 80f), Array.Empty<object>())); MinBlockSkillSpeedScale = config.Bind<float>("Physics", "MinBlockSkillSpeedScale", 0.8f, new ConfigDescription("Unused — speed is slope-based. Blocking skill no longer limits sled speed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.35f, 1f), Array.Empty<object>())); GravityMultiplier = config.Bind<float>("Physics", "GravityMultiplier", 1f, new ConfigDescription("Multiplier applied to downhill gravity acceleration.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); FrictionMultiplier = config.Bind<float>("Physics", "FrictionMultiplier", 1f, new ConfigDescription("Global friction multiplier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); AirControl = config.Bind<float>("Physics", "AirControl", 0.15f, new ConfigDescription("Fraction of ground steering applied while airborne.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); SteeringStrength = config.Bind<float>("Physics", "SteeringStrength", 2.5f, new ConfigDescription("How quickly velocity direction can change while sledding.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); BrakeStrength = config.Bind<float>("Physics", "BrakeStrength", 1.5f, new ConfigDescription("Extra friction multiplier when holding S.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); ForwardLeanBonus = config.Bind<float>("Physics", "ForwardLeanBonus", 1.5f, new ConfigDescription("Extra acceleration when holding W.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>())); SteeringSpeedFalloff = config.Bind<float>("Physics", "SteeringSpeedFalloff", 0.08f, new ConfigDescription("Higher values reduce steering responsiveness at speed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); UphillPenalty = config.Bind<float>("Physics", "UphillPenalty", 3f, new ConfigDescription("Deceleration multiplier when moving uphill.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>())); FlatDeceleration = config.Bind<float>("Physics", "FlatDeceleration", 8f, new ConfigDescription("Deceleration on flat ground.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>())); AbsorbDamageToShield = config.Bind<bool>("Damage", "AbsorbDamageToShield", true, "When true, fall and impact damage go to shield durability instead of player HP while sledding."); EndSledOnCombatHit = config.Bind<bool>("Damage", "EndSledOnCombatHit", true, "When true, creature or player attacks knock you off the sled while sledding."); StaggerOnCombatHit = config.Bind<bool>("Damage", "StaggerOnCombatHit", true, "Apply a stagger when knocked off the sled by a creature or player attack."); CombatHitMinDamage = config.Bind<float>("Damage", "CombatHitMinDamage", 1f, new ConfigDescription("Minimum damage before a combat hit can knock you off the sled.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>())); DamageToDurabilityMultiplier = config.Bind<float>("Damage", "DamageToDurabilityMultiplier", 0.15f, new ConfigDescription("Shield durability lost per point of HP damage absorbed while sledding.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); EnableDurabilityLoss = config.Bind<bool>("Durability", "EnableDurabilityLoss", true, "Whether sledding wears down the equipped shield."); DurabilityPerMeter = config.Bind<float>("Durability", "DurabilityPerMeter", 0.02f, FloatRange(0f, 5f)); DurabilityPerSecond = config.Bind<float>("Durability", "DurabilityPerSecond", 0.05f, FloatRange(0f, 5f)); LandingDamageMultiplier = config.Bind<float>("Durability", "LandingDamageMultiplier", 1.5f, FloatRange(0f, 10f)); StumbleOnShieldBreak = config.Bind<bool>("Durability", "StumbleOnShieldBreak", true, "Apply a stagger when the shield breaks from sledding."); SnowFriction = config.Bind<float>("Terrain", "SnowFriction", 0.55f, FloatRange(0.1f, 3f)); GrassFriction = config.Bind<float>("Terrain", "GrassFriction", 0.85f, FloatRange(0.1f, 3f)); BlackForestFriction = config.Bind<float>("Terrain", "BlackForestFriction", 0.95f, FloatRange(0.1f, 3f)); SwampFriction = config.Bind<float>("Terrain", "SwampFriction", 1.45f, FloatRange(0.1f, 3f)); AshlandsFriction = config.Bind<float>("Terrain", "AshlandsFriction", 0.75f, FloatRange(0.1f, 3f)); MountainFriction = config.Bind<float>("Terrain", "MountainFriction", 0.5f, FloatRange(0.1f, 3f)); MeadowsFriction = config.Bind<float>("Terrain", "MeadowsFriction", 1f, FloatRange(0.1f, 3f)); MistlandsFriction = config.Bind<float>("Terrain", "MistlandsFriction", 0.9f, FloatRange(0.1f, 3f)); OceanFriction = config.Bind<float>("Terrain", "OceanFriction", 1.2f, FloatRange(0.1f, 3f)); DeepNorthFriction = config.Bind<float>("Terrain", "DeepNorthFriction", 0.5f, FloatRange(0.1f, 3f)); AshlandsDurabilityWearMultiplier = config.Bind<float>("Terrain", "AshlandsDurabilityWearMultiplier", 1.35f, FloatRange(1f, 5f)); EnableShieldSurf = config.Bind<bool>("Terrain", "EnableShieldSurf", true, "Allow reduced friction when sledding on player-built wood pieces."); ShieldSurfFriction = config.Bind<float>("Terrain", "ShieldSurfFriction", 0.65f, FloatRange(0.1f, 3f)); CollisionSpeedThreshold = config.Bind<float>("Impacts", "CollisionSpeedThreshold", 6f, new ConfigDescription("Minimum speed (m/s) before impact camera/audio effects trigger.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f), Array.Empty<object>())); CollisionSpeedDamageScale = config.Bind<float>("Impacts", "CollisionSpeedDamageScale", 1.25f, new ConfigDescription("Impact intensity scale for camera shake and sound.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); EnableWildlifeImpactKill = config.Bind<bool>("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<SledStaminaMode>("Stamina", "StaminaMode", SledStaminaMode.None, "Stamina drain behavior while sledding."); StaminaActivationCost = config.Bind<float>("Stamina", "StaminaActivationCost", 10f, FloatRange(0f, 100f)); StaminaPerSecond = config.Bind<float>("Stamina", "StaminaPerSecond", 2f, FloatRange(0f, 50f)); StaminaJumpCost = config.Bind<float>("Stamina", "StaminaJumpCost", 8f, FloatRange(0f, 100f)); EnableParticles = config.Bind<bool>("Effects", "EnableParticles", true, (ConfigDescription)null); EnableCameraEffects = config.Bind<bool>("Effects", "EnableCameraEffects", true, (ConfigDescription)null); EnableSoundEffects = config.Bind<bool>("Effects", "EnableSoundEffects", true, (ConfigDescription)null); EnableSpeedometer = config.Bind<bool>("Effects", "EnableSpeedometer", false, (ConfigDescription)null); CameraShakeStrength = config.Bind<float>("Effects", "CameraShakeStrength", 0.35f, FloatRange(0f, 2f)); SpeedFovIncrease = config.Bind<float>("Effects", "SpeedFovIncrease", 8f, FloatRange(0f, 30f)); CameraTiltStrength = config.Bind<float>("Effects", "CameraTiltStrength", 4f, FloatRange(0f, 20f)); EnableShieldSparks = config.Bind<bool>("Effects", "EnableShieldSparks", true, (ConfigDescription)null); ShieldWearConfig.Init(config); MigrateLegacyConfig(config); } private static void MigrateLegacyConfig(ConfigFile config) { 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; } } private static void ResetObsoleteSpeedConfig(ConfigFile config) { for (int i = 0; i < ShieldSpeedRegistry.VanillaShieldPrefabs.Length; i++) { string text = ShieldSpeedRegistry.VanillaShieldPrefabs[i]; ConfigEntry<float> val = config.Bind<float>("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<float> val2 = config.Bind<float>("ShieldSpeeds", "DefaultModdedSpeed", 1f, (ConfigDescription)null); if (!Mathf.Approximately(val2.Value, 1f)) { val2.Value = 1f; } ConfigEntry<string> val3 = config.Bind<string>("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); } 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); } 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 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<int, ParticleSystem> _remoteParticles = new Dictionary<int, ParticleSystem>(); private ParticleSystem _localParticles; private float _shakeTimer; private float _shakeStrength; private float _baseFov = -1f; private float _tilt; internal static EffectController Instance { get; private set; } internal EffectController() { Instance = this; } internal void Begin(Player player) { if ((Object)(object)_localParticles != (Object)null) { Object.Destroy((Object)(object)((Component)_localParticles).gameObject); _localParticles = null; } EnsureLocalParticles(player); } internal void End(Player player) { CleanupForPlayer(player); RestoreFov(); _tilt = 0f; } internal void CleanupOrphans() { GameObject[] array = Object.FindObjectsByType<GameObject>((FindObjectsSortMode)0); foreach (GameObject val in array) { if ((Object)(object)val != (Object)null && ((Object)val).name == "ShieldSledding_LocalParticles") { Object.Destroy((Object)(object)val); } } _localParticles = null; } internal void CleanupForPlayer(Player player) { if (!((Object)(object)player == (Object)null)) { if ((Object)(object)_localParticles != (Object)null) { Object.Destroy((Object)(object)((Component)_localParticles).gameObject); _localParticles = null; } RestoreFov(); _tilt = 0f; } } internal void Update(Player player, float speed, float steerX) { if (!((Object)(object)player == (Object)null) && !Utility.IsDedicatedServer()) { UpdateParticles(player, speed); if (!ConfigManager.EnableCameraEffects.Value) { UpdateRemoteEffects(); return; } 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) { ShakeCamera(impact * ConfigManager.CameraShakeStrength.Value * 0.02f); } internal void OnCollision(Player player, Vector3 point, Vector3 normal, float impact) { //IL_0031: 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_0042: Unknown result type (might be due to invalid IL or missing references) 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 OnWildlifeImpact(Player player, Vector3 point, Vector3 direction, float impact) { //IL_0031: 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_0042: Unknown result type (might be due to invalid IL or missing references) 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) { _shakeStrength = Mathf.Max(_shakeStrength, strength); _shakeTimer = 0.2f; } private void EnsureLocalParticles(Player player) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0064: 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_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_008d: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_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_0102: 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_0117: 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_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_0155: Expected O, but got Unknown //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: 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_01cf: 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_01e2: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_localParticles != (Object)null)) { Transform feetAttach = ShieldSledVisual.GetFeetAttach(player); GameObject val = new GameObject("ShieldSledding_LocalParticles"); val.transform.SetParent(((Object)(object)feetAttach != (Object)null) ? feetAttach : ((Component)player).transform, false); val.transform.localPosition = (Vector3)(((Object)(object)feetAttach != (Object)null) ? Vector3.zero : new Vector3(0f, 0.1f, 0.4f)); _localParticles = val.AddComponent<ParticleSystem>(); 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 val2 = new Gradient(); val2.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(val2); ApplyParticleMaterial(_localParticles); } } private static Shader FindParticleShader() { string[] array = new string[7] { "Particles/Standard Unlit", "Legacy Shaders/Particles/Alpha Blended", "Mobile/Particles/Additive", "Universal Render Pipeline/Particles/Unlit", "Sprites/Default", "Unlit/Color", "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 CreateWhiteParticleTexture() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_001f: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false); val.SetPixel(0, 0, Color.white); val.Apply(false, true); return val; } private static void ApplyParticleMaterial(ParticleSystem particles) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_006b: 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_0084: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)particles == (Object)null) { return; } ParticleSystemRenderer component = ((Component)particles).GetComponent<ParticleSystemRenderer>(); if ((Object)(object)component == (Object)null) { return; } Shader val = FindParticleShader(); if (!((Object)(object)val == (Object)null)) { Color val2 = default(Color); ((Color)(ref val2))..ctor(0.92f, 0.96f, 1f, 0.65f); Material val3 = new Material(val); val3.mainTexture = (Texture)(object)CreateWhiteParticleTexture(); if (val3.HasProperty("_Color")) { val3.SetColor("_Color", val2); } if (val3.HasProperty("_TintColor")) { val3.SetColor("_TintColor", val2); } val3.color = val2; ((Renderer)component).material = val3; } } private void UpdateCamera(Player player, float speed, float steerX) { //IL_00c1: 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_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_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) Camera val = GameCamera.instance?.m_camera; if (!((Object)(object)val == (Object)null)) { if (_baseFov < 0f) { _baseFov = val.fieldOfView; } float num = 12f; if (Utility.TrySampleGround(player, out var sample)) { num = Mathf.Max(6f, ShieldSpeedRegistry.EstimateNaturalSpeed(in sample)); } float num2 = Mathf.Clamp01(speed / num); val.fieldOfView = _baseFov + num2 * ConfigManager.SpeedFovIncrease.Value; _tilt = Mathf.Lerp(_tilt, (0f - steerX) * ConfigManager.CameraTiltStrength.Value, Time.deltaTime * 6f); if (_shakeTimer > 0f) { _shakeTimer -= Time.deltaTime; Vector3 val2 = Random.insideUnitSphere * _shakeStrength; Transform transform = ((Component)val).transform; transform.localPosition += val2 * Time.deltaTime * 10f; } } } private void RestoreFov() { Camera val = GameCamera.instance?.m_camera; if ((Object)(object)val != (Object)null && _baseFov > 0f) { val.fieldOfView = _baseFov; } _baseFov = -1f; } private void UpdateRemoteEffects() { List<Player> 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<ParticleSystem>(); 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_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_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) for (int i = 0; i < count; i++) { Vector3 val = Random.insideUnitSphere * 0.2f; Debug.DrawRay(point + val, normal * 0.5f, color, 0.25f); } } } internal sealed class MultiplayerSync { internal const string ImpactRpc = "ShieldSledding_Impact"; 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<int> _registeredViews = new HashSet<int>(); 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 instance = Instance; if (instance == null) { return; } int instanceID = ((Object)nview).GetInstanceID(); if (!instance._registeredViews.Add(instanceID)) { return; } nview.Register<Vector3, float>("ShieldSledding_Impact", (Action<long, Vector3, float>)delegate(long sender, Vector3 point, float impact) { //IL_0015: 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 (!(impact < 1f)) { EffectController.Instance?.OnCollision(null, point, Vector3.up, impact); AudioController.Instance?.PlayImpact(Player.m_localPlayer, impact); } }); } 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 equippedShield = Utility.GetEquippedShield(player); if (equippedShield != null) { text = Utility.GetShieldPrefabName(equippedShield); } if (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); } _lastActive = active; _lastSpeed = speed; _lastShield = text; _lastWriteTime = Time.time; } } internal bool TryReadRemoteState(Player player, out bool active, out float speed, out string shieldPrefab) { active = false; speed = 0f; shieldPrefab = string.Empty; 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 UpdateRemotePlayers() { List<Player> 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<ZNetView>()); } } } 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<ZNetView>(); 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<GhostFrame> Frames = new List<GhostFrame>(); 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<GhostPlayback>().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<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Renderer component2 = val2.GetComponent<Renderer>(); 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<string> list = new List<string>(); 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<SledRunRecord> Entries = new List<SledRunRecord>(); 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<string> list = new List<string>(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(VisEquipment), "UpdateEquipmentVisuals", "VisEquipmentUpdateEquipmentVisualsPrefix", "VisEquipmentUpdateEquipmentPostfix"); PatchMethod(harmony, typeof(ZNetView), "OnDestroy", "ZNetViewOnDestroyPrefix"); } 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_0078: 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) { return true; } if (instance.IsArmed && !instance.IsSledding) { instance.TrackArmedMomentum(player); if (!instance.TryActivateOnLanding(player)) { return true; } } if (instance.IsSledding) { instance.ApplySledPhysics(player, dt); GroundSample ground; bool flag = Utility.TryGetSledGround(player, out ground); if (flag && !instance.IsInStartupGrace && !ground.IsWaterSurface) { SledGroundSolver.FixGroundClip(player); } SledGroundSolver.SyncCharacterMotionState(__instance, instance.SimulatedVelocity, flag); return false; } return true; } private static bool VisEquipmentUpdateEquipmentVisualsPrefix(VisEquipment __instance) { if (!Utility.IsLocalPlayer(((Component)__instance).GetComponent<Player>())) { return true; } ShieldSledController instance = ShieldSledController.Instance; if (instance != null) { return !instance.IsSledding; } return true; } private static void VisEquipmentUpdateEquipmentPostfix(VisEquipment __instance) { Player component = ((Component)__instance).GetComponent<Player>(); if (Utility.IsLocalPlayer(component)) { ShieldSledController instance = ShieldSledController.Instance; if (instance != null && instance.IsShieldSledActive) { ShieldSledVisual.LateUpdate(component); } } } private static bool CharacterUpdateGroundContactPrefix(Character __instance, ref float ___m_maxAirAltitude) { //IL_0048: 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_0092: 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) //IL_00bc: 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_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_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) 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) { ___m_maxAirAltitude = ((Component)__instance).transform.position.y; } return true; } ___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; __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 player = (Player)(object)((__instance is Player) ? __instance : null); if (!Utility.IsLocalPlayer(player)) { return true; } ShieldSledController instance = ShieldSledController.Instance; if (instance == null || !instance.IsSledding) { return true; } if (WaterSledHelper.CanWaterSled(instance.CurrentSpeed) && WaterSledHelper.IsOverWater(player) && !instance.IsAirborneForSledJump(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<Player>(); if (!((Object)(object)component == (Object)null) && __instance.IsOwner()) { ShieldSledVisual.OnPlayerDestroyed(component); EffectController.Instance?.CleanupForPlayer(component); 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 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 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_0029: Unknown result type (might be due to invalid IL or missing references) _lastVelocity = velocity; Rigidbody body = Utility.GetBody(player); if (!((Object)(object)body == (Object)null) && (!_bodyTuned || !body.isKinematic)) { body.linearVelocity = 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; } 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_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) Rigidbody body = Utility.GetBody(player); if (!((Object)(object)body == (Object)null)) { _savedUseGravity = body.useGravity; _savedIsKinematic = body.isKinematic; _savedDrag = body.linearDamping; _savedAngularDrag = body.angularDamping; body.useGravity = false; body.linearDamping = 0f; body.angularDamping = 0f; body.isKinematic = true; ApplyFrictionlessColliders(player); _lastVelocity = seedVelocity; _dynamicStartup = false; _preferDynamicBody = false; _bodyTuned = true; } } 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_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_0103: 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_00f6: 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_0173: 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_01a6: 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_015a: 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_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: 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 hint = armedMomentum; if (((Vector3)(ref hint)).sqrMagnitude < 0.01f) { hint = ((Character)player).m_currentVel; } if (((Vector3)(ref hint)).sqrMagnitude < 0.01f) { hint = ((Character)player).GetVelocity(); } Rigidbody body = Utility.GetBody(player); if ((Object)(object)body != (Object)null) { val = body.linearVelocity; if (((Vector3)(ref val)).sqrMagnitude > ((Vector3)(ref hint)).sqrMagnitude) { hint = body.linearVelocity; } } if (((Vector3)(ref hint)).sqrMagnitude < 0.01f && (Object)(object)player != (Object)null) { hint = ((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, hint); if (armedPeakHorizontal > bestSpeed + 0.05f && ((Vector3)(ref slopeDown)).sqrMagnitude > 0.0001f && bestSpeed < armedPeakHorizontal * 0.9f) { Consider(((Vector3)(ref slopeDown)).normalized * armedPeakHorizontal); } if (bestSpeed < 0.12f) { return Vector3.zero; } float num = ShieldSpeedRegistry.EstimateNaturalSpeed(in ground); if (((Vector3)(ref slopeDown)).sqrMagnitude > 0.0001f && Vector3.Dot(((Vector3)(ref best)).normalized, ((Vector3)(ref slopeDown)).normalized) < -0.35f) { return Vector3.zero; } float num2 = ((num > 0.5f) ? Mathf.Min(bestSpeed, num) : bestSpeed); if (num2 < 0.12f) { return Vector3.zero; } return ((Vector3)(ref best)).normalized * num2; } } 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 val2 = Vector3.ProjectOnPlane(worldVel, groundNormal); float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude > bestSpeed) { bestSpeed = magnitude; best = val2; } } } void ConsiderCarriedHorizontal(float horizontalSpeed, Vector3 v) { //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 val2 = Utility.Flatten(v); if (((Vector3)(ref val2)).sqrMagnitude < 0.01f && ((Vector3)(ref slopeDown)).sqrMagnitude > 0.0001f) { val2 = Utility.Flatten(slopeDown); } if (!(((Vector3)(ref val2)).sqrMagnitude < 0.01f)) { Consider(((Vector3)(ref val2)).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_00f7: 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_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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_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_017d: 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_0175: Unknown resul