using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } [BepInPlugin("fix.vagon.cartweightfix", "CartWeightFix", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class CartWeightFix : BaseUnityPlugin { [HarmonyPatch(typeof(Vagon), "FixedUpdate")] private static class Vagon_FixedUpdate_Restore { [HarmonyPostfix] private static void Postfix(Vagon __instance) { if (UpdateMass == null) { return; } if (__instance.IsAttached() && AttachJoin != null) { try { object value = AttachJoin.GetValue(__instance); if (value != null) { PropertyInfo property = value.GetType().GetProperty("connectedBody"); if (property == null) { property = value.GetType().BaseType.GetProperty("connectedBody"); } if (property != null) { object value2 = property.GetValue(value, null); if (value2 != null) { Component val = (Component)((value2 is Component) ? value2 : null); if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponent() != (Object)null) { return; } } } } } catch { } } try { UpdateMass.Invoke(__instance, null); } catch { } } } public const string PluginGUID = "fix.vagon.cartweightfix"; public const string PluginName = "CartWeightFix"; public const string PluginVersion = "1.0.0"; internal static MethodInfo UpdateMass; internal static FieldInfo AttachJoin; private void Awake() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; UpdateMass = typeof(Vagon).GetMethod("UpdateMass", bindingAttr); AttachJoin = typeof(Vagon).GetField("m_attachJoin", bindingAttr); if (UpdateMass == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Vagon.UpdateMass not found — cart weight fix inactive"); return; } new Harmony("fix.vagon.cartweightfix").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"CartWeightFix loaded — vanilla cart weight physics restored"); } }