using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using InControl;
using SFQoL;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("SmoothMotion")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+54692bef5c141a92a946951efc97b841cfb84330")]
[assembly: AssemblyProduct("SmoothMotion")]
[assembly: AssemblyTitle("SmoothMotion")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SFQoL
{
internal static class Compat
{
private static bool searched;
private static FieldInfo roundsActive;
private static PropertyInfo roundsArmed;
private static FieldInfo cardPicking;
private static bool cardSearched;
public static bool Rounds
{
get
{
Find();
try
{
if ((object)roundsArmed != null && (bool)roundsArmed.GetValue(null, null))
{
return true;
}
if ((object)roundsActive != null && (bool)roundsActive.GetValue(null))
{
return true;
}
}
catch
{
}
return false;
}
}
public static bool CardScreen
{
get
{
if (!cardSearched)
{
Type type = RoundsType("StickRounds.CardPick");
cardSearched = (object)type != null || Time.frameCount > 1;
if ((object)type != null)
{
cardPicking = type.GetField("Picking", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
}
}
try
{
return (object)cardPicking != null && (bool)cardPicking.GetValue(null);
}
catch
{
return false;
}
}
}
public static bool RoundsMatch
{
get
{
Find();
try
{
return (object)roundsActive != null && (bool)roundsActive.GetValue(null) && !GameManager.stillInMenu;
}
catch
{
return false;
}
}
}
private static Type RoundsType(string name)
{
if (!Chainloader.PluginInfos.TryGetValue("stickfight.stickrounds", out var value) || (Object)(object)value.Instance == (Object)null)
{
return null;
}
return ((object)value.Instance).GetType().Assembly.GetType(name, throwOnError: false);
}
private static void Find()
{
if (!searched)
{
Type type = RoundsType("StickRounds.RoundsMode");
searched = (object)type != null || Time.frameCount > 1;
if ((object)type != null)
{
roundsActive = type.GetField("Active", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
roundsArmed = type.GetProperty("Armed", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
}
}
}
public static bool IsBotDevice(InputDevice d)
{
if (d != null)
{
return ((object)d).GetType().Name == "BotDevice";
}
return false;
}
}
internal static class QolConfig
{
public static ConfigEntry<bool> Enabled(ConfigFile config, string section, string description)
{
return config.Bind<bool>(section, "Enabled", true, description);
}
private static Dictionary<ConfigDefinition, string> Orphans(ConfigFile config)
{
return Traverse.Create((object)config).Property("OrphanedEntries", (object[])null).GetValue<Dictionary<ConfigDefinition, string>>();
}
public static string Old(ConfigFile config, string section, string key)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
Dictionary<ConfigDefinition, string> dictionary = Orphans(config);
if (dictionary == null || !dictionary.TryGetValue(new ConfigDefinition(section, key), out var value))
{
return null;
}
return value;
}
public static void SetOld(ConfigFile config, string section, string key, string value)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
Dictionary<ConfigDefinition, string> dictionary = Orphans(config);
if (dictionary != null)
{
dictionary[new ConfigDefinition(section, key)] = value;
}
}
public static void DropOld(ConfigFile config)
{
Dictionary<ConfigDefinition, string> dictionary = Orphans(config);
if (dictionary != null && dictionary.Count != 0)
{
dictionary.Clear();
config.Save();
}
}
public static void DropOld(ConfigFile config, params string[] keep)
{
Dictionary<ConfigDefinition, string> dictionary = Orphans(config);
if (dictionary == null || dictionary.Count == 0)
{
return;
}
List<ConfigDefinition> list = new List<ConfigDefinition>();
foreach (ConfigDefinition key in dictionary.Keys)
{
if (Array.IndexOf(keep, key.Section) < 0)
{
list.Add(key);
}
}
if (list.Count == 0)
{
return;
}
foreach (ConfigDefinition item in list)
{
dictionary.Remove(item);
}
config.Save();
}
}
internal static class Ui
{
public static readonly Color Panel = new Color(0.176f, 0.176f, 0.176f);
public static readonly Color Strip = new Color(0.147f, 0.147f, 0.147f);
public static readonly Color Item = new Color(0.265f, 0.265f, 0.265f);
public static readonly Color Grey = new Color(0.6f, 0.6f, 0.6f);
private static TMP_FontAsset font;
private static Sprite box;
private static bool boxSearched;
private static Camera menuCam;
private static float menuCamSearchAt;
public static TMP_FontAsset Font
{
get
{
if ((Object)(object)font == (Object)null)
{
GameManager instance = GameManager.Instance;
if ((Object)(object)instance != (Object)null && (Object)(object)instance.winText != (Object)null)
{
font = ((TMP_Text)instance.winText).font;
}
if ((Object)(object)font == (Object)null)
{
TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
foreach (TMP_FontAsset val in array)
{
if (((Object)val).name.StartsWith("Anton"))
{
font = val;
break;
}
}
}
}
return font;
}
}
public static Sprite BoxSprite
{
get
{
if ((Object)(object)box == (Object)null && !boxSearched)
{
boxSearched = true;
Sprite[] array = Resources.FindObjectsOfTypeAll<Sprite>();
foreach (Sprite val in array)
{
if (((Object)val).name == "box")
{
box = val;
break;
}
}
}
return box;
}
}
public static int MenuLayer
{
get
{
int num = LayerMask.NameToLayer("MENU");
if (num < 0)
{
return 31;
}
return num;
}
}
public static void Attach(Canvas c)
{
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Invalid comparison between Unknown and I4
if ((Object)(object)c == (Object)null)
{
return;
}
if (((Object)(object)menuCam == (Object)null || !((Behaviour)menuCam).isActiveAndEnabled) && Time.unscaledTime >= menuCamSearchAt)
{
menuCamSearchAt = Time.unscaledTime + 1f;
menuCam = null;
Camera[] allCameras = Camera.allCameras;
foreach (Camera val in allCameras)
{
if (((Object)val).name == "Camera_Pause" && (val.cullingMask & (1 << MenuLayer)) != 0)
{
menuCam = val;
break;
}
}
}
if ((Object)(object)menuCam != (Object)null && ((Behaviour)menuCam).isActiveAndEnabled)
{
if ((int)c.renderMode != 1 || (Object)(object)c.worldCamera != (Object)(object)menuCam)
{
c.renderMode = (RenderMode)1;
c.worldCamera = menuCam;
c.planeDistance = 1f;
}
}
else if ((int)c.renderMode != 0)
{
c.renderMode = (RenderMode)0;
}
}
public static Canvas MakeCanvas(string name, int order)
{
//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_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0017: 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)
GameObject val = new GameObject(name)
{
layer = MenuLayer
};
Object.DontDestroyOnLoad((Object)val);
Canvas val2 = val.AddComponent<Canvas>();
val2.renderMode = (RenderMode)0;
val2.sortingOrder = order;
Attach(val2);
CanvasScaler obj = val.AddComponent<CanvasScaler>();
obj.uiScaleMode = (ScaleMode)1;
obj.referenceResolution = new Vector2(1920f, 1080f);
obj.matchWidthOrHeight = 0.5f;
return val2;
}
public static RectTransform Rect(Transform parent, string name)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) })
{
layer = ((Component)parent).gameObject.layer
};
val.transform.SetParent(parent, false);
RectTransform val2 = (RectTransform)val.transform;
Vector2 val3 = default(Vector2);
((Vector2)(ref val3))..ctor(0.5f, 0.5f);
val2.anchorMax = val3;
val2.anchorMin = val3;
val2.pivot = new Vector2(0.5f, 0.5f);
return val2;
}
public static Image Box(Transform parent, string name, Color color, Vector2 pos, Vector2 size, bool rounded = false)
{
//IL_0008: 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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
RectTransform obj = Rect(parent, name);
obj.anchoredPosition = pos;
obj.sizeDelta = size;
Image val = ((Component)obj).gameObject.AddComponent<Image>();
((Graphic)val).color = color;
((Graphic)val).raycastTarget = false;
if (rounded && (Object)(object)BoxSprite != (Object)null)
{
val.sprite = BoxSprite;
Vector4 border = BoxSprite.border;
if (((Vector4)(ref border)).sqrMagnitude > 0f)
{
val.type = (Type)1;
}
}
return val;
}
public static void Fill(RectTransform rt, float inset)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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)
rt.anchorMin = Vector2.zero;
rt.anchorMax = Vector2.one;
rt.offsetMin = new Vector2(inset, inset);
rt.offsetMax = new Vector2(0f - inset, 0f - inset);
}
public static TextMeshProUGUI Text(Transform parent, string name, string text, float size, Color color, TextAlignmentOptions align)
{
//IL_0032: 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)
TextMeshProUGUI val = ((Component)Rect(parent, name)).gameObject.AddComponent<TextMeshProUGUI>();
if ((Object)(object)Font != (Object)null)
{
((TMP_Text)val).font = Font;
}
((TMP_Text)val).fontSize = size;
((Graphic)val).color = color;
((TMP_Text)val).alignment = align;
((TMP_Text)val).enableWordWrapping = false;
((TMP_Text)val).richText = true;
((Graphic)val).raycastTarget = false;
((TMP_Text)val).text = text;
return val;
}
public static Color PlayerColor(Controller c)
{
//IL_00bf: 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_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)c != (Object)null)
{
SpriteRenderer componentInChildren = ((Component)c).GetComponentInChildren<SpriteRenderer>();
SetColorWhenDamaged val = (((Object)(object)componentInChildren != (Object)null) ? ((Component)componentInChildren).GetComponent<SetColorWhenDamaged>() : null);
if ((Object)(object)val == (Object)null)
{
val = ((Component)c).GetComponentInChildren<SetColorWhenDamaged>(true);
}
if ((Object)(object)val != (Object)null && val.startColor.a > 0f)
{
Color startColor = val.startColor;
startColor.a = 1f;
return startColor;
}
ControllerHandler instance = ControllerHandler.Instance;
if ((Object)(object)instance != (Object)null && instance.colors != null && c.playerID >= 0 && c.playerID < instance.colors.Length && (Object)(object)instance.colors[c.playerID] != (Object)null)
{
return instance.colors[c.playerID].color;
}
}
return Color.white;
}
public static Color SlotColor(int id)
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
ControllerHandler instance = ControllerHandler.Instance;
if ((Object)(object)instance != (Object)null && instance.colors != null && id >= 0 && id < instance.colors.Length && (Object)(object)instance.colors[id] != (Object)null)
{
Color color = instance.colors[id].color;
color.a = 1f;
return color;
}
return Color.white;
}
public static string Hex(Color c)
{
//IL_0005: 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_0043: Unknown result type (might be due to invalid IL or missing references)
return "#" + ((int)(Mathf.Clamp01(c.r) * 255f)).ToString("X2") + ((int)(Mathf.Clamp01(c.g) * 255f)).ToString("X2") + ((int)(Mathf.Clamp01(c.b) * 255f)).ToString("X2");
}
public static string Colored(string text, Color c)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
return "<color=" + Hex(c) + ">" + text + "</color>";
}
public static Color WithAlpha(Color c, float a)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
c.a = a;
return c;
}
}
}
namespace SmoothMotion
{
[HarmonyPatch(typeof(Balance), "StayBalanced")]
internal static class BalancePatch
{
private static readonly FieldRef<Balance, CharacterInformation> info = AccessTools.FieldRefAccess<Balance, CharacterInformation>("info");
private static readonly FieldRef<Balance, Rigidbody> leftKnee = AccessTools.FieldRefAccess<Balance, Rigidbody>("leftKnee");
private static readonly FieldRef<Balance, Rigidbody> rightKnee = AccessTools.FieldRefAccess<Balance, Rigidbody>("rightKnee");
private static readonly FieldRef<Balance, Rigidbody> leftLeg = AccessTools.FieldRefAccess<Balance, Rigidbody>("leftLeg");
private static readonly FieldRef<Balance, Rigidbody> rightLeg = AccessTools.FieldRefAccess<Balance, Rigidbody>("rightLeg");
private static bool Prefix(Balance __instance)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_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_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.Enabled.Value)
{
return true;
}
Rigidbody val = leftLeg.Invoke(__instance);
Rigidbody val2 = rightLeg.Invoke(__instance);
if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
{
return true;
}
Vector3 val3 = val.rotation * Vector3.up;
Vector3 val4 = val2.rotation * Vector3.up;
Rigidbody val5 = ((Vector3.Angle(val3, Vector3.up) < Vector3.Angle(val4, Vector3.up)) ? leftKnee.Invoke(__instance) : rightKnee.Invoke(__instance));
if ((Object)(object)val5 == (Object)null)
{
return true;
}
Vector3 val6 = val3 + val4;
val6.y = 0f;
float num = ((info.Invoke(__instance).paceState == 0) ? 1.5f : 1f);
val5.AddForce(val6 * 10000f * __instance.balanceForce * num * Time.deltaTime, (ForceMode)5);
return false;
}
}
[HarmonyPatch(typeof(Rotation), "Update")]
internal static class RotationPatch
{
private static readonly FieldRef<Rotation, Rigidbody> hip = AccessTools.FieldRefAccess<Rotation, Rigidbody>("hip");
private static bool Prefix(Rotation __instance)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: 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_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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)
if (!Plugin.Enabled.Value)
{
return true;
}
Rigidbody val = hip.Invoke(__instance);
if ((Object)(object)val == (Object)null)
{
return true;
}
Vector3 val2 = val.position + (__instance.lookingRight ? Vector3.forward : Vector3.back) * 10f;
float x = ((Component)val).transform.lossyScale.x;
float num = (Quaternion.Inverse(val.rotation) * (val2 - val.position)).x / ((x != 0f) ? x : 1f);
val.AddTorque(Vector3.up * Time.deltaTime * __instance.rotationForce * (0f - num), (ForceMode)5);
return false;
}
}
[HarmonyPatch(typeof(WeaponPickUp), "Update")]
internal static class PickupPatch
{
private static readonly MethodInfo getPosition = AccessTools.PropertyGetter(typeof(Transform), "position");
private static readonly MethodInfo pose = AccessTools.Method(typeof(PickupPatch), "PhysicsPosition", (Type[])null, (Type[])null);
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
int n = 0;
foreach (CodeInstruction instruction in instructions)
{
if ((instruction.opcode == OpCodes.Callvirt || instruction.opcode == OpCodes.Call) && object.Equals(instruction.operand, getPosition))
{
n++;
yield return new CodeInstruction(OpCodes.Call, (object)pose)
{
labels = instruction.labels,
blocks = instruction.blocks
};
}
else
{
yield return instruction;
}
}
Plugin.Log.LogInfo((object)("Pickup hover ray from the physics pose (" + n + " reads)."));
}
private static Vector3 PhysicsPosition(Transform t)
{
//IL_000d: 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_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.Enabled.Value)
{
return t.position;
}
Rigidbody component = ((Component)t).GetComponent<Rigidbody>();
if (!((Object)(object)component != (Object)null) || (int)component.interpolation == 0)
{
return t.position;
}
return component.position;
}
}
[BepInPlugin("stickfight.smoothmotion", "Smooth Motion", "1.1.1")]
public class Plugin : BaseUnityPlugin
{
public const string Guid = "stickfight.smoothmotion";
public const string Name = "Smooth Motion";
public const string Version = "1.1.1";
internal static ConfigEntry<bool> Enabled;
internal static ManualLogSource Log;
private static int gameQueue;
private void Awake()
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Expected O, but got Unknown
Enabled = QolConfig.Enabled(((BaseUnityPlugin)this).Config, "Smoothing", "Draw players, weapons and props smoothly between physics steps at normal speed (the game only does this in slow motion). Physics is unchanged. Also lets the graphics card queue one frame instead of two, so the picture shows up sooner. Off = the game's own behaviour.");
QolConfig.DropOld(((BaseUnityPlugin)this).Config);
gameQueue = QualitySettings.maxQueuedFrames;
ApplyQueue();
Log = ((BaseUnityPlugin)this).Logger;
Enabled.SettingChanged += delegate
{
ApplyQueue();
Spawns.ScanAll();
};
Harmony val = new Harmony("stickfight.smoothmotion");
val.PatchAll(typeof(Plugin).Assembly);
Spawns.Patch(val);
((BaseUnityPlugin)this).Logger.LogInfo((object)("Smooth Motion 1.1.1 loaded (frame queue " + QualitySettings.maxQueuedFrames + ", game's " + gameQueue + ")."));
}
private static void ApplyQueue()
{
QualitySettings.maxQueuedFrames = (Enabled.Value ? 1 : gameQueue);
}
}
[HarmonyPatch(typeof(TimeHandler), "Update")]
internal static class TimePatch
{
private static readonly FieldRef<TimeHandler, bool> interpolating = AccessTools.FieldRefAccess<TimeHandler, bool>("rigsAreInterpolating");
private const float ScanEvery = 10f;
private static float nextScan;
private static bool Prefix(TimeHandler __instance)
{
if (!Plugin.Enabled.Value)
{
return true;
}
Time.timeScale = ((TimeHandler.pauseTime != 1f) ? TimeHandler.pauseTime : TimeHandler.managerTime);
interpolating.Invoke(__instance) = true;
if (Time.unscaledTime >= nextScan)
{
nextScan = Time.unscaledTime + 10f;
Spawns.ScanAll();
}
return false;
}
}
internal static class Spawns
{
private static readonly List<Rigidbody> found = new List<Rigidbody>();
public static void Patch(Harmony h)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
HarmonyMethod val = new HarmonyMethod(typeof(Spawns), "Spawned", (Type[])null);
int num = 0;
MethodInfo[] methods = typeof(Object).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
if ((!(methodInfo.Name == "Instantiate") && !(methodInfo.Name == "Internal_InstantiateSingle") && !(methodInfo.Name == "Internal_InstantiateSingleWithParent")) || methodInfo.GetMethodBody() == null)
{
continue;
}
MethodInfo methodInfo2 = methodInfo;
if (methodInfo.IsGenericMethodDefinition)
{
if (methodInfo.GetParameters().Length != 1)
{
continue;
}
methodInfo2 = methodInfo.MakeGenericMethod(typeof(Object));
}
try
{
h.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
num++;
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("Couldn't watch " + methodInfo?.ToString() + ": " + ex.Message));
}
}
SceneManager.sceneLoaded += delegate
{
ScanAll();
};
Plugin.Log.LogInfo((object)("Watching " + num + " spawn methods for new rigidbodies."));
}
private static void Spawned(Object __result)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.Enabled.Value || __result == (Object)null)
{
return;
}
GameObject val = (GameObject)(object)((__result is GameObject) ? __result : null);
if ((Object)(object)val == (Object)null)
{
Component val2 = (Component)(object)((__result is Component) ? __result : null);
if ((Object)(object)val2 == (Object)null)
{
return;
}
val = val2.gameObject;
}
val.GetComponentsInChildren<Rigidbody>(true, found);
for (int i = 0; i < found.Count; i++)
{
if ((int)found[i].interpolation == 0)
{
found[i].interpolation = (RigidbodyInterpolation)1;
}
}
found.Clear();
}
public static void ScanAll()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.Enabled.Value)
{
return;
}
Rigidbody[] array = Object.FindObjectsOfType<Rigidbody>();
foreach (Rigidbody val in array)
{
if ((int)val.interpolation == 0)
{
val.interpolation = (RigidbodyInterpolation)1;
}
}
}
}
}