Decompiled source of KCCDownpatcher v1.1.0
patchers/KCCDownpatcher.dll
Decompiled a month agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using Mono.Cecil; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("KCCDownpatcher")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0.0+b308ded7e289cd4e5145d2f62c5cc4db9dba7d59")] [assembly: AssemblyProduct("KCCDownpatcher")] [assembly: AssemblyTitle("KCCDownpatcher")] [assembly: AssemblyVersion("1.1.0.0")] public static class KCCDownpatcher { private static readonly ManualLogSource Log = Logger.CreateLogSource("KCCDownpatcher"); public static IEnumerable<string> TargetDLLs { get; } = new string[1] { "KinematicCharacterController.dll" }; public static void Patch(AssemblyDefinition assembly) { ModuleDefinition mainModule = assembly.MainModule; TypeDefinition type = mainModule.GetType("KinematicCharacterController.KinematicCharacterMotor"); ModuleDefinition mainModule2 = AssemblyDefinition.ReadAssembly(Path.Combine(Paths.ManagedPath, "UnityEngine.PhysicsModule.dll")).MainModule; TypeReference fieldType = mainModule.ImportReference((TypeReference)(object)mainModule2.GetType("UnityEngine.Rigidbody")); ModuleDefinition mainModule3 = AssemblyDefinition.ReadAssembly(Path.Combine(Paths.ManagedPath, "UnityEngine.CoreModule.dll")).MainModule; TypeReference fieldType2 = mainModule.ImportReference((TypeReference)(object)mainModule3.GetType("UnityEngine.Vector3")); AddField(type, fieldType, "Rigidbody"); AddField(type, mainModule.TypeSystem.Boolean, "usingOldKCC"); AddField(type, mainModule.TypeSystem.Boolean, "SafeMovement"); AddField(type, mainModule.TypeSystem.Int32, "_rigidbodiesPushedCount"); AddField(type, mainModule.TypeSystem.Single, "_internalResultingMovementMagnitude"); AddField(type, fieldType2, "_internalResultingMovementDirection"); } private static void AddField(TypeDefinition target, TypeReference fieldType, string fieldName) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown if (target == null || fieldType == null) { Log.LogError((object)("Null types in AddField: " + fieldName)); return; } if (((IEnumerable<FieldDefinition>)target.Fields).FirstOrDefault((Func<FieldDefinition, bool>)((FieldDefinition a) => ((MemberReference)a).Name == fieldName)) != null) { Log.LogWarning((object)(((MemberReference)target).Name + "." + fieldName + " already exists")); return; } FieldDefinition val = new FieldDefinition(fieldName, (FieldAttributes)6, fieldType); target.Fields.Add(val); } }
plugins/KCCDownplugin.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Dolso; using Dolso.RiskofOptions; using HG.Reflection; using KinematicCharacterController; using MonoMod.Cil; using MonoMod.RuntimeDetour; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace Dolso { internal static class log { private static ManualLogSource logger; internal static void start(ManualLogSource logSource) { logger = logSource; } internal static void start(string name) { logger = Logger.CreateLogSource(name); } internal static void debug(object data) { logger.LogDebug(data); } internal static void info(object data) { logger.LogInfo(data); } internal static void message(object data) { logger.LogMessage(data); } internal static void warning(object data) { logger.LogWarning(data); } internal static void error(object data) { logger.LogError(data); } internal static void fatal(object data) { logger.LogFatal(data); } internal static void LogError(this ILCursor c, object data) { logger.LogError((object)string.Format($"ILCursor failure, skipping: {data}\n{c}")); } internal static void LogErrorCaller(this ILCursor c, object data, [CallerMemberName] string callerName = "") { logger.LogError((object)string.Format($"ILCursor failure in {callerName}, skipping: {data}\n{c}")); } } internal static class HookManager { internal delegate bool ConfigEnabled<T>(ConfigEntry<T> configEntry); internal const BindingFlags allFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static ILHookConfig ilHookConfig = new ILHookConfig { ManualApply = true }; private static HookConfig onHookConfig = new HookConfig { ManualApply = true }; private static readonly ConfigEnabled<bool> boolConfigEnabled = (ConfigEntry<bool> configEntry) => configEntry.Value; internal static void Hook(Type typeFrom, string methodFrom, Manipulator ilHook) { HookInternal(GetMethod(typeFrom, methodFrom), ilHook); } internal static void Hook(MethodBase methodFrom, Manipulator ilHook) { HookInternal(methodFrom, ilHook); } internal static void Hook(Delegate from, Manipulator ilHook) { HookInternal(from.Method, ilHook); } internal static void Hook<T>(Expression<Action<T>> from, Manipulator ilHook) { HookInternal(((MethodCallExpression)from.Body).Method, ilHook); } internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook) { HookInternal(GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target); } internal static void Hook(MethodBase methodFrom, MethodInfo onHook) { HookInternal(methodFrom, onHook, null); } internal static void Hook(MethodBase methodFrom, Delegate onHook) { HookInternal(methodFrom, onHook.Method, onHook.Target); } internal static void Hook(Delegate from, Delegate onHook) { HookInternal(from.Method, onHook.Method, onHook.Target); } internal static void Hook<T>(Expression<Action<T>> from, Delegate onHook) { HookInternal(((MethodCallExpression)from.Body).Method, onHook.Method, onHook.Target); } internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook, object instance) { HookInternal(GetMethod(typeFrom, methodFrom), onHook.Method, instance); } internal static void Hook(MethodBase methodFrom, MethodInfo onHook, object target) { HookInternal(methodFrom, onHook, target); } private static void HookInternal(MethodBase methodFrom, Manipulator ilHook) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (methodFrom == null) { log.error("null MethodFrom for hook: " + ((Delegate)(object)ilHook).Method.Name); return; } try { new ILHook(methodFrom, ilHook, ref ilHookConfig).Apply(); } catch (Exception ex) { log.error($"Failed to apply ILHook: {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}"); } } private static void HookInternal(MethodBase methodFrom, MethodInfo onHook, object target) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (methodFrom == null) { log.error("null methodFrom for hook: " + onHook.Name); return; } try { new Hook(methodFrom, onHook, target, ref onHookConfig).Apply(); } catch (Exception ex) { log.error($"Failed to apply onHook: {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Name}\n{ex}"); } } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Manipulator ilHook) { configEntry.AddHookConfig(enabled, GetMethod(typeFrom, methodFrom), ilHook); } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Manipulator ilHook) { configEntry.AddHookConfig(enabled, methodFrom, ilHook); } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Delegate onHook) { configEntry.AddHookConfig(enabled, GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target); } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Delegate onHook) { configEntry.AddHookConfig(enabled, methodFrom, onHook.Method, onHook.Target); } internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Manipulator ilHook) { configEntry.AddHookConfig(boolConfigEnabled, GetMethod(typeFrom, methodFrom), ilHook); } internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Manipulator ilHook) { configEntry.AddHookConfig(boolConfigEnabled, methodFrom, ilHook); } internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Delegate onHook) { configEntry.AddHookConfig(boolConfigEnabled, GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target); } internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Delegate onHook) { configEntry.AddHookConfig(boolConfigEnabled, methodFrom, onHook.Method, onHook.Target); } private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Manipulator ilHook) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown if (methodFrom == null) { log.error("null MethodFrom for hook: " + ((Delegate)(object)ilHook).Method.Name); return; } try { configEntry.AddHookConfig(enabled, (IDetour)new ILHook(methodFrom, ilHook, ref ilHookConfig)); } catch (Exception ex) { log.error($"Failed to ilHook {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}"); } } private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, MethodInfo onHook, object target) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if (methodFrom == null) { log.error("null MethodFrom for hook: " + onHook.Name); return; } try { configEntry.AddHookConfig(enabled, (IDetour)new Hook(methodFrom, onHook, target, ref onHookConfig)); } catch (Exception ex) { log.error($"Failed to onHook {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Name}\n{ex}"); } } private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, IDetour detour) { configEntry.SettingChanged += delegate(object sender, EventArgs args) { UpdateHook(detour, enabled(sender as ConfigEntry<T>)); }; if (enabled(configEntry)) { detour.Apply(); } } private static void UpdateHook(IDetour hook, bool enabled) { if (enabled) { if (!hook.IsApplied) { hook.Apply(); } } else if (hook.IsApplied) { hook.Undo(); } } internal static void PriorityFirst() { ilHookConfig.Before = new string[1] { "*" }; onHookConfig.Before = new string[1] { "*" }; } internal static void PriorityLast() { ilHookConfig.After = new string[1] { "*" }; onHookConfig.After = new string[1] { "*" }; } internal static void PriorityNormal() { ilHookConfig.Before = null; onHookConfig.Before = null; ilHookConfig.After = null; onHookConfig.After = null; } internal static IDetour ManualDetour(Type typeFrom, string methodFrom, Delegate onHook) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown try { return (IDetour)new Hook((MethodBase)GetMethod(typeFrom, methodFrom), onHook, ref onHookConfig); } catch (Exception ex) { log.error($"Failed to make onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex}"); } return null; } internal static MethodInfo GetMethod(Type typeFrom, string methodFrom) { if (typeFrom == null || methodFrom == null) { return null; } IEnumerable<MethodInfo> enumerable = from predicate in typeFrom.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where predicate.Name == methodFrom select predicate; if (enumerable.Count() == 1) { return enumerable.First(); } if (enumerable.Count() == 0) { log.error($"Failed to find method: {typeFrom}.{methodFrom}"); } else { log.error($"{enumerable.Count()} ambiguous matches found for: {typeFrom}.{methodFrom}"); foreach (MethodInfo item in enumerable) { log.error(item); } } return null; } internal static MethodInfo GetMethod(Type typeFrom, string methodFrom, params Type[] parameters) { if (typeFrom == null || methodFrom == null) { return null; } MethodInfo? method = typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, parameters, null); if (method == null) { log.error($"Failed to find method: {typeFrom}.{methodFrom}_{parameters.Length}"); } return method; } } } namespace Dolso.RiskofOptions { internal static class RiskofOptions { internal const string rooGuid = "com.rune580.riskofoptions"; internal static bool enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); internal static void SetSprite(Sprite sprite) { ModSettingsManager.SetModIcon(sprite); } internal static void SetSpriteDefaultIcon() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_007e: 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) DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); string path = ((!(directoryInfo.Name == "plugins")) ? directoryInfo.FullName : directoryInfo.Parent.FullName); try { Texture2D val = new Texture2D(256, 256); if (ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(path, "icon.png")))) { ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f))); } else { log.error("Failed to load icon.png"); } } catch (Exception ex) { log.error("Failed to load icon.png\n" + ex); } } internal static void AddBool(ConfigEntry<bool> entry) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig { description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddBool(ConfigEntry<bool> entry, string categoryName, string name) { //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_000d: 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_0025: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig { category = categoryName, name = name, description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddBool(ConfigEntry<bool> entry, string categoryName) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig { category = categoryName, description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddEnum<T>(ConfigEntry<T> entry) where T : Enum { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)entry, new ChoiceConfig { description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddColor(ConfigEntry<Color> entry) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new ColorOption(entry, new ColorOptionConfig { description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddKey(ConfigEntry<KeyboardShortcut> entry) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry, new KeyBindConfig { description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddFloat(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}") { //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_000d: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig { min = min, max = max, FormatString = format, description = ((ConfigEntryBase)(object)entry).DescWithDefault(format) })); } internal static void AddFloat(ConfigEntry<float> entry, string categoryName, float min, float max, string format = "{0:f2}") { //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_000d: 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_001c: 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_0036: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig { min = min, max = max, FormatString = format, category = categoryName, description = ((ConfigEntryBase)(object)entry).DescWithDefault(format) })); } internal static void AddFloatField(ConfigEntry<float> entry, float min = float.MinValue, float max = float.MaxValue, string format = "{0:f2}") { //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_000d: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown FloatFieldConfig val = new FloatFieldConfig(); ((NumericFieldConfig<float>)val).Min = min; ((NumericFieldConfig<float>)val).Max = max; ((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault(format); ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(entry, val)); } internal static void AddInt(ConfigEntry<int> entry, int min = int.MinValue, int max = int.MaxValue) { //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_000d: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown IntFieldConfig val = new IntFieldConfig(); ((NumericFieldConfig<int>)val).Min = min; ((NumericFieldConfig<int>)val).Max = max; ((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault(); ModSettingsManager.AddOption((BaseOption)new IntFieldOption(entry, val)); } internal static void AddIntSlider(ConfigEntry<int> entry, int min, int max) { //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_000d: 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_0025: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig { min = min, max = max, description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddIntSlider(ConfigEntry<int> entry, string categoryName, int min, int max) { //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_000d: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig { min = min, max = max, category = categoryName, description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddString(ConfigEntry<string> entry, bool restartRequired = false) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(entry, new InputFieldConfig { submitOn = (SubmitEnum)6, lineType = (LineType)0, description = ((ConfigEntryBase)(object)entry).DescWithDefault(), restartRequired = restartRequired })); } internal static void AddString(ConfigEntry<string> entry, string categoryName, bool restartRequired = false) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_001b: 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_0033: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(entry, new InputFieldConfig { submitOn = (SubmitEnum)6, lineType = (LineType)0, category = categoryName, description = ((ConfigEntryBase)(object)entry).DescWithDefault(), restartRequired = restartRequired })); } internal static void AddOption(ConfigEntry<bool> entry) { AddBool(entry); } internal static void AddOption(ConfigEntry<bool> entry, string categoryName, string name) { AddBool(entry, categoryName, name); } internal static void AddOption(ConfigEntry<bool> entry, string categoryName) { AddBool(entry, categoryName); } internal static void AddOption<T>(ConfigEntry<T> entry) where T : Enum { AddEnum<T>(entry); } internal static void AddOption(ConfigEntry<Color> entry) { AddColor(entry); } internal static void AddOption(ConfigEntry<KeyboardShortcut> entry) { AddKey(entry); } internal static void AddOption(ConfigEntry<int> entry) { AddInt(entry); } internal static void AddOption(ConfigEntry<string> entry) { AddString(entry); } private static string DescWithDefault(this ConfigEntryBase entry) { return $"{entry.Description.Description}\n[Default: {entry.DefaultValue}]"; } private static string DescWithDefault(this ConfigEntryBase entry, string format) { return string.Format("{1}\n[Default: " + format + "]", entry.DefaultValue, entry.Description.Description); } } } namespace KCCDownplugin { internal class Config { private static ConfigFile configFile; internal static ConfigEntry<string> expensiveBodiesConfig; internal static ConfigEntry<string> oldKccBlacklistConfig; internal static ConfigEntry<bool> enableOldPotRolling; internal static void DoConfig(ConfigFile bepConfigFile) { configFile = bepConfigFile; expensiveBodiesConfig = bepConfigFile.Bind<string>("Kinematic Settings", "Disable Cheap KCM", "AcidLarvaBody, BeetleBody, EngiWalkerTurretBody, LemurianBody, DevotedLemurianBody, ImpBody, VerminBody, VoidInfestorBody", "Disables the cheaper KinematicCharacterMotor that Gearbox made non-survivor bodies have, as it causes issues with certain bodies\nSeperated by ', ' or ',', and names must match exactly, use the body_list command to view them.\nIf an entry is 'all' then expensive kcm will be enabled for all bodies.\n"); oldKccBlacklistConfig = bepConfigFile.Bind<string>("Kinematic Settings", "Old KCC blacklist", "", "Prevent using old KCC on players for the listed bodies\nSeperated by ', ' or ',', and names must match exactly, use the body_list command to view them.\nIf an entry is 'all' then will be disabled for all bodies.\n"); enableOldPotRolling = bepConfigFile.Bind<bool>("Kinematic Settings", "Old Pot Rolling", true, "Changes pot physics to how it was pre-sots, as the old kcc is not compatible with the new pot physics"); if (RiskofOptions.enabled) { DoRiskOfOptions(); } } internal static void DoRiskOfOptions() { RiskofOptions.SetSpriteDefaultIcon(); RiskofOptions.AddString(expensiveBodiesConfig, restartRequired: true); RiskofOptions.AddString(oldKccBlacklistConfig); RiskofOptions.AddOption(enableOldPotRolling); } [ConCommand(/*Could not decode attribute arguments.*/)] private static void ReloadConfig(ConCommandArgs args) { configFile.Reload(); Debug.Log((object)"KCCDownpatcher config reloaded"); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("dolso.KCCDownplugin", "KCCDownplugin", "1.1.0")] public class KCCDownplugin : BaseUnityPlugin { private static BodyIndex[] oldKccBlacklist; private void Awake() { log.start(((BaseUnityPlugin)this).Logger); Config.DoConfig(((BaseUnityPlugin)this).Config); Config.oldKccBlacklistConfig.SettingChanged += delegate { RefreshOldKCCBlacklist(); }; Config.enableOldPotRolling.SettingChanged += delegate { ChangePotPhysics(); }; if (Config.enableOldPotRolling.Value) { ChangePotPhysics(); } HookManager.Hook(typeof(CharacterMotor), "BeforeCharacterUpdate", (Delegate)new Action<Action<CharacterMotor, float>, CharacterMotor, float>(AddSafeMovementCheck_On_BeforeCharacterUpdate_CharacterMotor)); HookManager.Hook(typeof(PlayerCharacterMasterController), "Awake", (Delegate)new Action<Action<PlayerCharacterMasterController>, PlayerCharacterMasterController>(SubscribePlayerBodyStart_On_Awake_PlayerCharacterMasterController)); HookManager.Hook(typeof(KinematicCharacterSystem), "RegisterCharacterMotor", (Delegate)new Action<Action<KinematicCharacterMotor>, KinematicCharacterMotor>(CheckIfUsingOld_On_Register_KinematicCharacterSystem)); HookManager.Hook(typeof(KinematicCharacterSystem), "UnregisterCharacterMotor", (Delegate)new Action<Action<KinematicCharacterMotor>, KinematicCharacterMotor>(CheckIfUsingOld_On_Unregister_KinematicCharacterSystem)); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ApplyConfig)); } private static void ChangePotPhysics() { //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) AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/ExplosivePotDestructible/ExplosivePotDestructibleBody.prefab"); val.Completed += delegate(AsyncOperationHandle<GameObject> potHandle) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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) AsyncOperationHandle<PhysicMaterial> val2 = Addressables.LoadAssetAsync<PhysicMaterial>((object)("RoR2/Base/Common/" + (Config.enableOldPotRolling.Value ? "physmatDestructibles" : "physmatBouncy") + ".physicMaterial")); val2.Completed += delegate(AsyncOperationHandle<PhysicMaterial> matHandle) { ((Collider)potHandle.Result.GetComponent<MeshCollider>()).material = matHandle.Result; }; }; } private static void ApplyConfig() { try { foreach (KinematicCharacterMotor item in FindBodies(Config.expensiveBodiesConfig, gatherAll: true)) { item.playerCharacter = true; } RefreshOldKCCBlacklist(); } catch (Exception data) { log.error(data); oldKccBlacklist = (BodyIndex[])(object)new BodyIndex[0]; } } private static void RefreshOldKCCBlacklist() { List<KinematicCharacterMotor> list = FindBodies(Config.oldKccBlacklistConfig, gatherAll: false); if (list == null) { oldKccBlacklist = (BodyIndex[])(object)new BodyIndex[1] { (BodyIndex)(-1) }; } else { oldKccBlacklist = list.Select((KinematicCharacterMotor a) => BodyCatalog.FindBodyIndex(((Component)a).gameObject)).ToArray(); } } private static List<KinematicCharacterMotor> FindBodies(ConfigEntry<string> configEntry, bool gatherAll) { List<KinematicCharacterMotor> list = new List<KinematicCharacterMotor>(); string[] array = configEntry.Value.Split(new string[2] { ", ", "," }, StringSplitOptions.RemoveEmptyEntries); KinematicCharacterMotor item = default(KinematicCharacterMotor); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text == "all") { log.info("found all for " + ((ConfigEntryBase)configEntry).Definition.Key); if (gatherAll) { GameObject[] bodyPrefabs = BodyCatalog.bodyPrefabs; foreach (GameObject val in bodyPrefabs) { if (Object.op_Implicit((Object)(object)val) && val.TryGetComponent<KinematicCharacterMotor>(ref item)) { list.Add(item); } } return list; } return null; } GameObject val2 = BodyCatalog.FindBodyPrefab(text); if (!Object.op_Implicit((Object)(object)val2)) { log.warning("failed to find body '" + text + "'"); continue; } KinematicCharacterMotor component = val2.GetComponent<KinematicCharacterMotor>(); if (!Object.op_Implicit((Object)(object)component)) { log.warning(text + " does not have a KinematicCharacterMotor"); } else { list.Add(component); } } return list; } private static void AddSafeMovementCheck_On_BeforeCharacterUpdate_CharacterMotor(Action<CharacterMotor, float> orig, CharacterMotor self, float deltaTime) { if (!((BaseCharacterController)self).Motor.usingOldKCC) { orig(self, deltaTime); return; } float sqrMagnitude = ((Vector3)(ref self.rootMotion)).sqrMagnitude; if (sqrMagnitude > 0f) { ((BaseCharacterController)self).Motor.SafeMovement = sqrMagnitude >= 1.1736112f; } orig(self, deltaTime); ((BaseCharacterController)self).Motor.SafeMovement = ((Vector3)(ref self.velocity)).sqrMagnitude * Time.fixedDeltaTime * Time.fixedDeltaTime >= 1.1736112f; } private static void SubscribePlayerBodyStart_On_Awake_PlayerCharacterMasterController(Action<PlayerCharacterMasterController> orig, PlayerCharacterMasterController self) { orig(self); self.master.onBodyStart += OnPlayerBodyStart; } private static void OnPlayerBodyStart(CharacterBody body) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) CharacterMotor characterMotor = body.characterMotor; if (!Object.op_Implicit((Object)(object)characterMotor) || (oldKccBlacklist.Length != 0 && ((int)oldKccBlacklist[0] == -1 || oldKccBlacklist.Contains(body.bodyIndex)))) { return; } if (!Object.op_Implicit((Object)(object)((BaseCharacterController)characterMotor).Motor)) { ((BaseCharacterController)characterMotor).SetupCharacterMotor(((Component)characterMotor).GetComponent<KinematicCharacterMotor>()); } if (((BaseCharacterController)characterMotor).Motor.usingOldKCC) { return; } if (((Behaviour)((BaseCharacterController)characterMotor).Motor).enabled) { KinematicCharacterSystem.UnregisterCharacterMotor(((BaseCharacterController)characterMotor).Motor); ((BaseCharacterController)characterMotor).Motor.usingOldKCC = true; OldKinematicCharacterSystem.RegisterCharacterMotor(((BaseCharacterController)characterMotor).Motor); } else { ((BaseCharacterController)characterMotor).Motor.usingOldKCC = true; } GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(body.bodyIndex); if (Object.op_Implicit((Object)(object)bodyPrefab)) { KinematicCharacterMotor component = bodyPrefab.GetComponent<KinematicCharacterMotor>(); if (Object.op_Implicit((Object)(object)component)) { component.usingOldKCC = true; } } } private static void CheckIfUsingOld_On_Register_KinematicCharacterSystem(Action<KinematicCharacterMotor> orig, KinematicCharacterMotor motor) { if (motor.usingOldKCC) { OldKinematicCharacterSystem.RegisterCharacterMotor(motor); } else { orig(motor); } } private static void CheckIfUsingOld_On_Unregister_KinematicCharacterSystem(Action<KinematicCharacterMotor> orig, KinematicCharacterMotor motor) { if (motor.usingOldKCC) { OldKinematicCharacterSystem.UnregisterCharacterMotor(motor); } else { orig(motor); } } } public static class OldKinematicCharacterMotor { public static KinematicCharacterMotor kcm; public const bool PreventSnappingOnLedges = false; public const int MaxHitsBudget = 16; public const int MaxCollisionBudget = 16; public const int MaxGroundingSweepIterations = 2; public const int MaxMovementSweepIterations = 6; public const int MaxSteppingSweepIterations = 3; public const int MaxRigidbodyOverlapsCount = 16; public const int MaxDiscreteCollisionIterations = 3; public const float CollisionOffset = 0.001f; public const float GroundProbeReboundDistance = 0.02f; public const float MinimumGroundProbingDistance = 0.005f; public const float GroundProbingBackstepDistance = 0.1f; public const float SweepProbingBackstepDistance = 0.002f; public const float SecondaryProbesVertical = 0.02f; public const float SecondaryProbesHorizontal = 0.001f; public const float MinVelocityMagnitude = 0.01f; public const float SteppingForwardDistance = 0.03f; public const float MinDistanceForLedge = 0.05f; public const float CorrelationForVerticalObstruction = 0.01f; public const float ExtraSteppingForwardDistance = 0.01f; public const float ExtraStepHeightPadding = 0.01f; public static void UpdatePhase1(float deltaTime) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0113: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_05bb: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_0665: Unknown result type (might be due to invalid IL or missing references) //IL_066a: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0685: Unknown result type (might be due to invalid IL or missing references) //IL_0686: Unknown result type (might be due to invalid IL or missing references) //IL_069a: Unknown result type (might be due to invalid IL or missing references) //IL_069f: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_06aa: Unknown result type (might be due to invalid IL or missing references) //IL_06b4: Unknown result type (might be due to invalid IL or missing references) //IL_06b9: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Unknown result type (might be due to invalid IL or missing references) //IL_06c8: Unknown result type (might be due to invalid IL or missing references) //IL_06cd: Unknown result type (might be due to invalid IL or missing references) //IL_06d1: Unknown result type (might be due to invalid IL or missing references) //IL_06d6: Unknown result type (might be due to invalid IL or missing references) //IL_06dd: Unknown result type (might be due to invalid IL or missing references) //IL_06e4: Unknown result type (might be due to invalid IL or missing references) //IL_06e9: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Unknown result type (might be due to invalid IL or missing references) //IL_0636: Unknown result type (might be due to invalid IL or missing references) //IL_063b: Unknown result type (might be due to invalid IL or missing references) //IL_0640: Unknown result type (might be due to invalid IL or missing references) //IL_064b: Unknown result type (might be due to invalid IL or missing references) //IL_0650: Unknown result type (might be due to invalid IL or missing references) //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_0656: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_083a: Unknown result type (might be due to invalid IL or missing references) //IL_0844: Unknown result type (might be due to invalid IL or missing references) //IL_084a: Unknown result type (might be due to invalid IL or missing references) //IL_084f: Unknown result type (might be due to invalid IL or missing references) //IL_0854: Unknown result type (might be due to invalid IL or missing references) //IL_07d1: Unknown result type (might be due to invalid IL or missing references) //IL_07d7: Unknown result type (might be due to invalid IL or missing references) //IL_0828: Unknown result type (might be due to invalid IL or missing references) //IL_082d: Unknown result type (might be due to invalid IL or missing references) //IL_0802: Unknown result type (might be due to invalid IL or missing references) //IL_0811: Unknown result type (might be due to invalid IL or missing references) //IL_0817: Unknown result type (might be due to invalid IL or missing references) //IL_081c: Unknown result type (might be due to invalid IL or missing references) //IL_0776: Unknown result type (might be due to invalid IL or missing references) //IL_0780: Unknown result type (might be due to invalid IL or missing references) //IL_078a: Unknown result type (might be due to invalid IL or missing references) //IL_078f: Unknown result type (might be due to invalid IL or missing references) //IL_0794: Unknown result type (might be due to invalid IL or missing references) //IL_0799: Unknown result type (might be due to invalid IL or missing references) if (float.IsNaN(kcm.BaseVelocity.x) || float.IsNaN(kcm.BaseVelocity.y) || float.IsNaN(kcm.BaseVelocity.z)) { kcm.BaseVelocity = Vector3.zero; } if (float.IsNaN(kcm._attachedRigidbodyVelocity.x) || float.IsNaN(kcm._attachedRigidbodyVelocity.y) || float.IsNaN(kcm._attachedRigidbodyVelocity.z)) { kcm._attachedRigidbodyVelocity = Vector3.zero; } if (kcm._mustUngroundTimeCounter > 0f) { kcm._mustUngroundTimeCounter = 0f; } kcm.CharacterController.BeforeCharacterUpdate(deltaTime); kcm._transientPosition = kcm._transform.position; kcm.TransientRotation = kcm._transform.rotation; kcm._initialSimulationPosition = kcm._transientPosition; kcm._initialSimulationRotation = kcm.TransientRotation; kcm._rigidbodyProjectionHitCount = 0; kcm._overlapsCount = 0; kcm._lastSolvedOverlapNormalDirty = false; if (kcm._movePositionDirty) { if (kcm._solveMovementCollisions) { if (InternalCharacterMove(kcm._movePositionTarget - kcm._transientPosition, deltaTime, out kcm._internalResultingMovementMagnitude, out kcm._internalResultingMovementDirection) && kcm.InteractiveRigidbodyHandling) { Vector3 zero = Vector3.zero; kcm.ProcessVelocityForRigidbodyHits(ref zero, deltaTime); } } else { kcm._transientPosition = kcm._movePositionTarget; } kcm._movePositionDirty = false; } ((CharacterTransientGroundingReport)(ref kcm.LastGroundingStatus)).CopyFrom(kcm.GroundingStatus); kcm.GroundingStatus = default(CharacterGroundingReport); kcm.GroundingStatus.GroundNormal = kcm._characterUp; if (kcm._solveMovementCollisions) { Vector3 val = kcm._cachedWorldUp; float num = 0f; int i = 0; bool flag = false; for (; i < 3; i++) { if (flag) { break; } int num2 = kcm.CharacterCollisionsOverlap(kcm._transientPosition, kcm.TransientRotation, kcm._internalProbedColliders, 0f, false); if (num2 > 0) { for (int j = 0; j < num2; j++) { Rigidbody attachedRigidbody = kcm._internalProbedColliders[j].attachedRigidbody; if (Object.op_Implicit((Object)(object)attachedRigidbody) && (!attachedRigidbody.isKinematic || Object.op_Implicit((Object)(object)((Component)attachedRigidbody).GetComponent<PhysicsMover>()))) { continue; } Transform component = ((Component)kcm._internalProbedColliders[j]).GetComponent<Transform>(); if (Physics.ComputePenetration((Collider)(object)kcm.Capsule, kcm._transientPosition, kcm.TransientRotation, kcm._internalProbedColliders[j], component.position, component.rotation, ref val, ref num)) { HitStabilityReport val2 = default(HitStabilityReport); val2.IsStable = kcm.IsStableOnNormal(val); val = kcm.GetObstructionNormal(val, val2.IsStable); Vector3 val3 = val * (num + 0.001f); KinematicCharacterMotor obj = kcm; obj._transientPosition += val3; if (kcm._overlapsCount < kcm._overlaps.Length) { kcm._overlaps[kcm._overlapsCount] = new OverlapResult(val, kcm._internalProbedColliders[j]); KinematicCharacterMotor obj2 = kcm; obj2._overlapsCount++; } break; } } } else { flag = true; } } } if (kcm._solveGrounding) { if (kcm._mustUnground) { KinematicCharacterMotor obj3 = kcm; obj3._transientPosition += kcm._characterUp * 0.0075f; } else { float probingDistance = 0.005f; if (!kcm.LastGroundingStatus.SnappingPrevented && (kcm.LastGroundingStatus.IsStableOnGround || kcm.LastMovementIterationFoundAnyGround)) { probingDistance = (((int)kcm.StepHandling == 0) ? kcm.CapsuleRadius : Mathf.Max(kcm.CapsuleRadius, kcm.MaxStepHeight)); probingDistance += kcm.GroundDetectionExtraDistance; } ProbeGround(ref kcm._transientPosition, kcm.TransientRotation, probingDistance, ref kcm.GroundingStatus); } } kcm.LastMovementIterationFoundAnyGround = false; kcm._mustUnground = false; if (kcm._solveGrounding) { kcm.CharacterController.PostGroundingUpdate(deltaTime); } if (!kcm.InteractiveRigidbodyHandling) { return; } kcm._lastAttachedRigidbody = kcm._attachedRigidbody; if (Object.op_Implicit((Object)(object)kcm.AttachedRigidbodyOverride)) { kcm._attachedRigidbody = kcm.AttachedRigidbodyOverride; } else if (kcm.GroundingStatus.IsStableOnGround && Object.op_Implicit((Object)(object)kcm.GroundingStatus.GroundCollider.attachedRigidbody)) { Rigidbody interactiveRigidbody = kcm.GetInteractiveRigidbody(kcm.GroundingStatus.GroundCollider); if (Object.op_Implicit((Object)(object)interactiveRigidbody)) { kcm._attachedRigidbody = interactiveRigidbody; } } else { kcm._attachedRigidbody = null; } Vector3 val4 = Vector3.zero; if (Object.op_Implicit((Object)(object)kcm._attachedRigidbody)) { val4 = GetVelocityFromRigidbodyMovement(kcm._attachedRigidbody, kcm._transientPosition, deltaTime); } if (kcm.PreserveAttachedRigidbodyMomentum && (Object)(object)kcm._lastAttachedRigidbody != (Object)null && (Object)(object)kcm._attachedRigidbody != (Object)(object)kcm._lastAttachedRigidbody) { KinematicCharacterMotor obj4 = kcm; obj4.BaseVelocity += kcm._attachedRigidbodyVelocity; KinematicCharacterMotor obj5 = kcm; obj5.BaseVelocity -= val4; } kcm._attachedRigidbodyVelocity = kcm._cachedZeroVector; if (Object.op_Implicit((Object)(object)kcm._attachedRigidbody)) { kcm._attachedRigidbodyVelocity = val4; Vector3 val5 = Vector3.ProjectOnPlane(Quaternion.Euler(57.29578f * kcm._attachedRigidbody.angularVelocity * deltaTime) * kcm._characterForward, kcm._characterUp); Vector3 normalized = ((Vector3)(ref val5)).normalized; kcm.TransientRotation = Quaternion.LookRotation(normalized, kcm._characterUp); } if (Object.op_Implicit((Object)(object)kcm.GroundingStatus.GroundCollider) && Object.op_Implicit((Object)(object)kcm.GroundingStatus.GroundCollider.attachedRigidbody) && (Object)(object)kcm.GroundingStatus.GroundCollider.attachedRigidbody == (Object)(object)kcm._attachedRigidbody && (Object)(object)kcm._attachedRigidbody != (Object)null && (Object)(object)kcm._lastAttachedRigidbody == (Object)null) { KinematicCharacterMotor obj6 = kcm; obj6.BaseVelocity -= Vector3.ProjectOnPlane(kcm._attachedRigidbodyVelocity, kcm._characterUp); } if (!(((Vector3)(ref kcm._attachedRigidbodyVelocity)).sqrMagnitude > 0f)) { return; } kcm._isMovingFromAttachedRigidbody = true; if (kcm._solveMovementCollisions) { if (InternalCharacterMove(kcm._attachedRigidbodyVelocity * deltaTime, deltaTime, out kcm._internalResultingMovementMagnitude, out kcm._internalResultingMovementDirection)) { kcm._attachedRigidbodyVelocity = kcm._internalResultingMovementDirection * kcm._internalResultingMovementMagnitude / deltaTime; } else { kcm._attachedRigidbodyVelocity = Vector3.zero; } } else { KinematicCharacterMotor obj7 = kcm; obj7._transientPosition += kcm._attachedRigidbodyVelocity * deltaTime; } kcm._isMovingFromAttachedRigidbody = false; } public static void UpdatePhase2(float deltaTime) { //IL_0024: 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_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_0583: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: 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_01b6: 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_0135: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) kcm.CharacterController.UpdateRotation(ref kcm._transientRotation, deltaTime); kcm.TransientRotation = kcm._transientRotation; if (kcm._moveRotationDirty) { kcm.TransientRotation = kcm._moveRotationTarget; kcm._moveRotationDirty = false; } if (kcm._solveMovementCollisions && kcm.InteractiveRigidbodyHandling) { if (kcm.InteractiveRigidbodyHandling && Object.op_Implicit((Object)(object)kcm._attachedRigidbody)) { float radius = kcm.Capsule.radius; RaycastHit val = default(RaycastHit); if (kcm.CharacterGroundSweep(kcm._transientPosition + kcm._characterUp * radius, kcm.TransientRotation, -kcm._characterUp, radius, ref val) && (Object)(object)((RaycastHit)(ref val)).collider.attachedRigidbody == (Object)(object)kcm._attachedRigidbody && kcm.IsStableOnNormal(((RaycastHit)(ref val)).normal)) { float num = radius - ((RaycastHit)(ref val)).distance; kcm._transientPosition = kcm._transientPosition + kcm._characterUp * num + kcm._characterUp * 0.001f; } } if (kcm.SafeMovement || kcm.InteractiveRigidbodyHandling) { Vector3 val2 = kcm._cachedWorldUp; float num2 = 0f; int i = 0; bool flag = false; for (; i < 3; i++) { if (flag) { break; } int num3 = kcm.CharacterCollisionsOverlap(kcm._transientPosition, kcm.TransientRotation, kcm._internalProbedColliders, 0f, false); if (num3 > 0) { for (int j = 0; j < num3; j++) { Transform component = ((Component)kcm._internalProbedColliders[j]).GetComponent<Transform>(); if (!Physics.ComputePenetration((Collider)(object)kcm.Capsule, kcm._transientPosition, kcm.TransientRotation, kcm._internalProbedColliders[j], component.position, component.rotation, ref val2, ref num2)) { continue; } HitStabilityReport val3 = default(HitStabilityReport); val3.IsStable = kcm.IsStableOnNormal(val2); val2 = kcm.GetObstructionNormal(val2, val3.IsStable); Vector3 val4 = val2 * (num2 + 0.001f); KinematicCharacterMotor obj = kcm; obj._transientPosition += val4; if (kcm.InteractiveRigidbodyHandling) { Rigidbody attachedRigidbody = kcm._internalProbedColliders[j].attachedRigidbody; if (Object.op_Implicit((Object)(object)attachedRigidbody)) { PhysicsMover component2 = ((Component)attachedRigidbody).GetComponent<PhysicsMover>(); if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)attachedRigidbody) && (!attachedRigidbody.isKinematic || Object.op_Implicit((Object)(object)component2))) { HitStabilityReport val5 = default(HitStabilityReport); val5.IsStable = kcm.IsStableOnNormal(val2); if (val5.IsStable) { kcm.LastMovementIterationFoundAnyGround = val5.IsStable; } if (Object.op_Implicit((Object)(object)component2.Rigidbody) && (Object)(object)component2.Rigidbody != (Object)(object)kcm._attachedRigidbody) { _ = kcm._transientPosition + kcm.TransientRotation * kcm._characterTransformToCapsuleCenter; Vector3 transientPosition = kcm._transientPosition; kcm.StoreRigidbodyHit(component2.Rigidbody, kcm.Velocity, transientPosition, val2, val5); } } } } if (kcm._overlapsCount < kcm._overlaps.Length) { kcm._overlaps[kcm._overlapsCount] = new OverlapResult(val2, kcm._internalProbedColliders[j]); KinematicCharacterMotor obj2 = kcm; obj2._overlapsCount++; } break; } } else { flag = true; } } } } kcm.CharacterController.UpdateVelocity(ref kcm.BaseVelocity, deltaTime); if (((Vector3)(ref kcm.BaseVelocity)).magnitude < 0.01f) { kcm.BaseVelocity = Vector3.zero; } if (((Vector3)(ref kcm.BaseVelocity)).sqrMagnitude > 0f) { if (kcm._solveMovementCollisions) { if (InternalCharacterMove(kcm.BaseVelocity * deltaTime, deltaTime, out kcm._internalResultingMovementMagnitude, out kcm._internalResultingMovementDirection)) { kcm.BaseVelocity = kcm._internalResultingMovementDirection * kcm._internalResultingMovementMagnitude / deltaTime; } else { kcm.BaseVelocity = Vector3.zero; } } else { KinematicCharacterMotor obj3 = kcm; obj3._transientPosition += kcm.BaseVelocity * deltaTime; } } if (kcm.InteractiveRigidbodyHandling) { kcm.ProcessVelocityForRigidbodyHits(ref kcm.BaseVelocity, deltaTime); } if (kcm.HasPlanarConstraint) { kcm._transientPosition = kcm._initialSimulationPosition + Vector3.ProjectOnPlane(kcm._transientPosition - kcm._initialSimulationPosition, ((Vector3)(ref kcm.PlanarConstraintAxis)).normalized); } if (kcm.DiscreteCollisionEvents) { int num4 = kcm.CharacterCollisionsOverlap(kcm._transientPosition, kcm.TransientRotation, kcm._internalProbedColliders, 0.002f, false); for (int k = 0; k < num4; k++) { kcm.CharacterController.OnDiscreteCollisionDetected(kcm._internalProbedColliders[k]); } } kcm.CharacterController.AfterCharacterUpdate(deltaTime); } private static void ProbeGround(ref Vector3 probingPosition, Quaternion atRotation, float probingDistance, ref CharacterGroundingReport groundingReport) { //IL_0013: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) if (probingDistance < 0.005f) { probingDistance = 0.005f; } int num = 0; RaycastHit val = default(RaycastHit); bool flag = false; Vector3 val2 = probingPosition; Vector3 val3 = atRotation * -kcm._cachedWorldUp; float num2 = probingDistance; while (num2 > 0f && num <= 2 && !flag) { if (kcm.CharacterGroundSweep(val2, atRotation, val3, num2, ref val)) { Vector3 val4 = val2 + val3 * ((RaycastHit)(ref val)).distance; HitStabilityReport val5 = default(HitStabilityReport); kcm.EvaluateHitStability(((RaycastHit)(ref val)).collider, ((RaycastHit)(ref val)).normal, ((RaycastHit)(ref val)).point, val4, kcm.TransientRotation, kcm.BaseVelocity, ref val5); if (val5.LedgeDetected && val5.IsOnEmptySideOfLedge && val5.DistanceFromLedge > kcm.MaxStableDistanceFromLedge) { val5.IsStable = false; } groundingReport.FoundAnyGround = true; groundingReport.GroundNormal = ((RaycastHit)(ref val)).normal; groundingReport.InnerGroundNormal = val5.InnerNormal; groundingReport.OuterGroundNormal = val5.OuterNormal; groundingReport.GroundCollider = ((RaycastHit)(ref val)).collider; groundingReport.GroundPoint = ((RaycastHit)(ref val)).point; groundingReport.SnappingPrevented = false; if (val5.IsStable) { if (kcm.LedgeAndDenivelationHandling && kcm.LastGroundingStatus.FoundAnyGround && ((Vector3)(ref val5.InnerNormal)).sqrMagnitude != 0f && ((Vector3)(ref val5.OuterNormal)).sqrMagnitude != 0f) { if (Vector3.Angle(val5.InnerNormal, val5.OuterNormal) > kcm.MaxStableDenivelationAngle) { groundingReport.SnappingPrevented = true; } else if (Vector3.Angle(kcm.LastGroundingStatus.InnerGroundNormal, val5.OuterNormal) > kcm.MaxStableDenivelationAngle) { groundingReport.SnappingPrevented = true; } } groundingReport.IsStableOnGround = true; if (!groundingReport.SnappingPrevented) { val4 += -val3 * 0.001f; InternalMoveCharacterPosition(ref probingPosition, val4, atRotation); } kcm.CharacterController.OnGroundHit(((RaycastHit)(ref val)).collider, ((RaycastHit)(ref val)).normal, ((RaycastHit)(ref val)).point, ref val5); flag = true; } else { Vector3 val6 = val3 * ((RaycastHit)(ref val)).distance + atRotation * Vector3.up * Mathf.Clamp(0.001f, 0f, ((RaycastHit)(ref val)).distance); val2 += val6; num2 = Mathf.Min(0.02f, Mathf.Clamp(num2 - ((Vector3)(ref val6)).magnitude, 0f, float.PositiveInfinity)); Vector3 val7 = Vector3.ProjectOnPlane(val3, ((RaycastHit)(ref val)).normal); val3 = ((Vector3)(ref val7)).normalized; } } else { flag = true; } num++; } } private static bool InternalCharacterMove(Vector3 movement, float deltaTime, out float resultingMovementMagnitude, out Vector3 resultingMovementDirection) { //IL_000f: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_0116: 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_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: 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_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0390: 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_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) kcm._rigidbodiesPushedCount = 0; bool result = true; Vector3 remainingMovementDirection = ((Vector3)(ref movement)).normalized; float remainingMovementMagnitude = ((Vector3)(ref movement)).magnitude; resultingMovementDirection = remainingMovementDirection; resultingMovementMagnitude = remainingMovementMagnitude; int num = 0; bool flag = true; Vector3 val = kcm._transientPosition; Vector3 transientPosition = kcm._transientPosition; Vector3 normalized = ((Vector3)(ref movement)).normalized; Vector3 previousObstructionNormal = kcm._cachedZeroVector; MovementSweepState sweepState = (MovementSweepState)0; for (int i = 0; i < kcm._overlapsCount; i++) { if (Vector3.Dot(remainingMovementDirection, kcm._overlaps[i].Normal) < 0f) { InternalHandleMovementProjection(kcm.IsStableOnNormal(kcm._overlaps[i].Normal) && !kcm._mustUnground, kcm._overlaps[i].Normal, kcm._overlaps[i].Normal, normalized, ref sweepState, ref previousObstructionNormal, ref resultingMovementMagnitude, ref remainingMovementDirection, ref remainingMovementMagnitude); } } RaycastHit val2 = default(RaycastHit); RaycastHit val6 = default(RaycastHit); while (remainingMovementMagnitude > 0f && num <= 6 && flag) { if (kcm.CharacterCollisionsSweep(val, kcm.TransientRotation, remainingMovementDirection, remainingMovementMagnitude + 0.001f, ref val2, kcm._internalCharacterHits, 0f, false) > 0) { transientPosition = val + remainingMovementDirection * ((RaycastHit)(ref val2)).distance + ((RaycastHit)(ref val2)).normal * 0.001f; Vector3 val3 = transientPosition - val; HitStabilityReport stabilityReport = default(HitStabilityReport); EvaluateHitStability(((RaycastHit)(ref val2)).collider, ((RaycastHit)(ref val2)).normal, ((RaycastHit)(ref val2)).point, transientPosition, kcm.TransientRotation, ref stabilityReport); bool flag2 = false; if (kcm._solveGrounding && (int)kcm.StepHandling != 0 && stabilityReport.ValidStepDetected && Mathf.Abs(Vector3.Dot(((RaycastHit)(ref val2)).normal, kcm._characterUp)) <= 0.01f) { Vector3 val4 = Vector3.ProjectOnPlane(-((RaycastHit)(ref val2)).normal, kcm._characterUp); Vector3 normalized2 = ((Vector3)(ref val4)).normalized; Vector3 val5 = transientPosition + normalized2 * 0.03f + kcm._characterUp * kcm.MaxStepHeight; int num2 = kcm.CharacterCollisionsSweep(val5, kcm.TransientRotation, -kcm._characterUp, kcm.MaxStepHeight, ref val6, kcm._internalCharacterHits, 0f, false); for (int j = 0; j < num2; j++) { if ((Object)(object)((RaycastHit)(ref kcm._internalCharacterHits[j])).collider == (Object)(object)stabilityReport.SteppedCollider) { val = val5 + -kcm._characterUp * (((RaycastHit)(ref kcm._internalCharacterHits[j])).distance - 0.001f); flag2 = true; remainingMovementMagnitude = Mathf.Clamp(remainingMovementMagnitude - ((Vector3)(ref val3)).magnitude, 0f, float.PositiveInfinity); break; } } } if (!flag2) { val = transientPosition; remainingMovementMagnitude = Mathf.Clamp(remainingMovementMagnitude - ((Vector3)(ref val3)).magnitude, 0f, float.PositiveInfinity); kcm.CharacterController.OnMovementHit(((RaycastHit)(ref val2)).collider, ((RaycastHit)(ref val2)).normal, ((RaycastHit)(ref val2)).point, ref stabilityReport); Vector3 obstructionNormal = kcm.GetObstructionNormal(((RaycastHit)(ref val2)).normal, stabilityReport.IsStable); if (kcm.InteractiveRigidbodyHandling && Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).collider.attachedRigidbody)) { kcm.StoreRigidbodyHit(((RaycastHit)(ref val2)).collider.attachedRigidbody, remainingMovementDirection * resultingMovementMagnitude / deltaTime, ((RaycastHit)(ref val2)).point, obstructionNormal, stabilityReport); } InternalHandleMovementProjection(stabilityReport.IsStable && !kcm._mustUnground, ((RaycastHit)(ref val2)).normal, obstructionNormal, normalized, ref sweepState, ref previousObstructionNormal, ref resultingMovementMagnitude, ref remainingMovementDirection, ref remainingMovementMagnitude); } } else { flag = false; } num++; if (num > 6) { remainingMovementMagnitude = 0f; result = false; } } Vector3 targetPosition = val + remainingMovementDirection * remainingMovementMagnitude; InternalMoveCharacterPosition(ref kcm._transientPosition, targetPosition, kcm.TransientRotation); resultingMovementDirection = remainingMovementDirection; return result; } private static void InternalHandleMovementProjection(bool stableOnHit, Vector3 hitNormal, Vector3 obstructionNormal, Vector3 originalMoveDirection, ref MovementSweepState sweepState, ref Vector3 previousObstructionNormal, ref float resultingMovementMagnitude, ref Vector3 remainingMovementDirection, ref float remainingMovementMagnitude) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) if (remainingMovementMagnitude <= 0f) { return; } Vector3 movement = originalMoveDirection * remainingMovementMagnitude; float num = remainingMovementMagnitude; if (stableOnHit) { kcm.LastMovementIterationFoundAnyGround = true; } if ((int)sweepState == 2) { remainingMovementMagnitude = 0f; resultingMovementMagnitude = 0f; sweepState = (MovementSweepState)3; } else { HandleMovementProjection(ref movement, obstructionNormal, stableOnHit); remainingMovementDirection = ((Vector3)(ref movement)).normalized; remainingMovementMagnitude = ((Vector3)(ref movement)).magnitude; resultingMovementMagnitude = remainingMovementMagnitude / num * resultingMovementMagnitude; if ((int)sweepState == 0) { sweepState = (MovementSweepState)1; } else if ((int)sweepState == 1 && Vector3.Dot(previousObstructionNormal, remainingMovementDirection) < 0f) { Vector3 val = Vector3.Cross(previousObstructionNormal, obstructionNormal); Vector3 normalized = ((Vector3)(ref val)).normalized; movement = Vector3.Project(movement, normalized); remainingMovementDirection = ((Vector3)(ref movement)).normalized; remainingMovementMagnitude = ((Vector3)(ref movement)).magnitude; resultingMovementMagnitude = remainingMovementMagnitude / num * resultingMovementMagnitude; sweepState = (MovementSweepState)2; } } previousObstructionNormal = obstructionNormal; } private static bool InternalMoveCharacterPosition(ref Vector3 movedPosition, Vector3 targetPosition, Quaternion atRotation) { //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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) bool flag = true; if (kcm.SafeMovement && kcm.CharacterCollisionsOverlap(targetPosition, atRotation, kcm._internalProbedColliders, 0f, false) > 0) { flag = false; } if (flag) { movedPosition = targetPosition; return true; } return false; } private static Vector3 GetVelocityFromRigidbodyMovement(Rigidbody interactiveRigidbody, Vector3 atPoint, float deltaTime) { //IL_007d: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (deltaTime > 0f) { Vector3 val = interactiveRigidbody.velocity; if (interactiveRigidbody.angularVelocity != Vector3.zero) { Vector3 val2 = interactiveRigidbody.position + interactiveRigidbody.centerOfMass; Vector3 val3 = atPoint - val2; Quaternion val4 = Quaternion.Euler(57.29578f * interactiveRigidbody.angularVelocity * deltaTime); Vector3 val5 = val2 + val4 * val3; val += (val5 - atPoint) / deltaTime; } return val; } return Vector3.zero; } private static void EvaluateHitStability(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, Vector3 atCharacterPosition, Quaternion atCharacterRotation, ref HitStabilityReport stabilityReport) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_011a: 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_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) if (!kcm._solveGrounding) { stabilityReport.IsStable = false; return; } Vector3 val = atCharacterRotation * Vector3.up; Vector3 val2 = Vector3.ProjectOnPlane(hitNormal, val); Vector3 normalized = ((Vector3)(ref val2)).normalized; bool flag = kcm.I