Decompiled source of SylhShrinkerCartPlus v0.4.4
SylhShrinkerCartPlus.dll
Decompiled 3 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using SylhShrinkerCartPlus.Components; using SylhShrinkerCartPlus.Config; using SylhShrinkerCartPlus.Manager; using SylhShrinkerCartPlus.Models; using SylhShrinkerCartPlus.Resolver.Valuable; using SylhShrinkerCartPlus.Utils; using SylhShrinkerCartPlus.Utils.Cheat.Cart; using SylhShrinkerCartPlus.Utils.Cheat.Enemy; using SylhShrinkerCartPlus.Utils.Events; using SylhShrinkerCartPlus.Utils.GameManagerUtils; using SylhShrinkerCartPlus.Utils.RunManagerUtils; using SylhShrinkerCartPlus.Utils.Shrink; using SylhShrinkerCartPlus.Utils.Shrink.Network; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("SylhShrinkerCartPlus")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a5c7f99653905a599ee413f12ae4031aa1b7c9b8")] [assembly: AssemblyProduct("SylhShrinkerCartPlus")] [assembly: AssemblyTitle("SylhShrinkerCartPlus")] [assembly: AssemblyVersion("1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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; } } } namespace SylhShrinkerCartPlus { [BepInPlugin("sylhaance.SylhShrinkerCartPlus", "Sylh Shrinker Cart Plus", "0.4.4")] public class Plugin : BaseUnityPlugin { private const string mod_guid = "sylhaance.SylhShrinkerCartPlus"; private const string mod_name = "Sylh Shrinker Cart Plus"; private const string mod_version = "0.4.4"; private Harmony harmony; internal static ManualLogSource Log; private void Awake() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"[SylhShrinkerCartPlus] Plugin loaded."); ConfigManager.Initialize(this); StaticConfig.RefreshInstanceFromCurrentConfig(); ConfigEvents.Initialize(); CategoryResolverRegistry.Register(new EnemyCategoryResolver()); CategoryResolverRegistry.Register(new StandardValuableCategoryResolver()); CategoryResolverRegistry.Register(new SpecialCategoryResolver()); harmony = new Harmony("sylhaance.SylhShrinkerCartPlus"); harmony.PatchAll(); ShrinkEvents.OnShrinkStarted += delegate(ShrinkableTracker tracker) { LogWrapper.Debug("⏳ Début du rétrécissement pour " + ((Object)tracker).name + " !", "Event"); NetworkHelper.ProcessingChangingMass(tracker); }; ShrinkEvents.OnShrinkCompleted += delegate(ShrinkableTracker tracker) { LogWrapper.Debug("\ud83c\udf89 Fin du rétrécissement pour " + ((Object)tracker).name + " !", "Event"); tracker.MakeBreakable(); }; ShrinkEvents.OnExpandStarted += delegate(ShrinkableTracker tracker) { LogWrapper.Debug("⏳ Début de l'agrandissement pour " + ((Object)tracker).name + " !", "Event"); NetworkHelper.ProcessingRestoringMass(tracker); }; ShrinkEvents.OnExpandCompleted += delegate(ShrinkableTracker tracker) { LogWrapper.Debug("\ud83c\udf89 Fin de l'agrandissement pour " + ((Object)tracker).name + " !", "Event"); tracker.MakeBreakable(); }; ShrinkEvents.OnEnteredCart += delegate(ShrinkableTracker tracker) { LogWrapper.Debug("\ud83d\udce5 " + ((Object)tracker).name + " vient d'entrer dans un CART !", "Event"); NetworkHelper.ProcessingChangingBatteryLife(tracker); tracker.MakeUnbreakable(); }; ShrinkEvents.OnExitedCart += delegate(ShrinkableTracker tracker) { LogWrapper.Debug("\ud83d\udce4 " + ((Object)tracker).name + " vient de sortir d’un CART !", "Event"); tracker.MakeBreakable(); }; ShrinkEvents.OnMassChanged += delegate(ShrinkableTracker obj, float newMass) { LogWrapper.Debug($"⚖\ufe0f {((Object)obj).name} → masse changée à {newMass:F2}"); }; CartEvents.OnCartObjectAdded += delegate(PhysGrabCart cart, PhysGrabObject obj) { LogWrapper.Debug(" \ud83e\uddf2 Objet " + ((Object)obj).name + " ajouté dans le cart : " + ((Object)cart).name); }; } } [HarmonyPatch(typeof(PhysGrabInCart), "Add")] public static class PhysGrabInCartAddPatch { [HarmonyPostfix] private static void Postfix(PhysGrabInCart __instance, PhysGrabObject _physGrabObject) { if (RunManagerHelper.IsInsideValidLevel()) { CartEvents.FireCartObjectAdded(__instance, _physGrabObject); } } } [HarmonyPatch(typeof(PhysGrabObject), "DestroyPhysGrabObjectRPC")] public static class DestroyPhysGrabObjectRPCPatch { [HarmonyPrefix] public static void Prefix(PhysGrabObject __instance) { if (RunManagerHelper.IsInsideValidLevel()) { ShrinkableTracker component = ((Component)__instance).gameObject.GetComponent<ShrinkableTracker>(); ShrinkTrackerManager.Instance.UnregisterShrinkCompletion(component.CurrentCart, component.GrabObject); ShrinkTrackerManager.Instance.Unregister(component); LogWrapper.Warning("L'objet " + ((Object)__instance).name + " vient de subir une destruction par le biais d'un autre méthode que subir des dégâts"); } } } [HarmonyPatch(typeof(PhysGrabObject), "Start")] public static class PhysGrabObjectAwakePatch { [HarmonyPostfix] public static void PostFix(PhysGrabObject __instance) { try { if (RunManagerHelper.IsInsideValidLevel()) { ShrinkableTracker component = ((Component)__instance).GetComponent<ShrinkableTracker>(); if ((Object)(object)component == (Object)null) { component = ((Component)__instance).gameObject.AddComponent<ShrinkableTracker>(); component.Init(__instance); } if ((Object)(object)((Component)__instance).GetComponent<PhotonView>() == (Object)null) { PhotonView val = ((Component)__instance).gameObject.AddComponent<PhotonView>(); val.ViewID = 0; } if ((Object)(object)((Component)__instance).GetComponent<ShrinkNetworkDispatcher>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<ShrinkNetworkDispatcher>(); } } } catch (Exception arg) { LogWrapper.Error($"[StartPatch] ❌ Erreur pendant le patch Start : {arg}"); } } } [HarmonyPatch(typeof(PlayerAvatar), "Start")] public static class PlayerAvatarStartPatch { [HarmonyPostfix] public static void Postfix(PlayerAvatar __instance) { if ((Object)(object)((Component)__instance).GetComponent<ConfigNetworkDispatcher>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<ConfigNetworkDispatcher>(); LogWrapper.Debug("[SyncInit] Dispatcher ajouté à " + ((Object)__instance).name); } } } [HarmonyPatch(typeof(RunManager), "ChangeLevel")] public static class RunManagerChangeLevelPatch { [HarmonyPostfix] private static void Postfix(RunManager __instance, bool _completedLevel, bool _levelFailed, ChangeLevelType _changeLevelType = 0) { ShrinkTrackerManager.Instance.ClearAll(); CartEventHookManager.Clear(); ShrinkerCartPatch.PushConfigToClients(); } } [HarmonyPatch(typeof(PhysGrabCart), "ObjectsInCart")] public static class ShrinkerCartPatch { [HarmonyPostfix] public static void Postfix(PhysGrabCart __instance) { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) if (!RunManagerHelper.IsInsideValidLevel()) { return; } FastReflectionHelper<PhysGrabCart> fastReflectionHelper = new FastReflectionHelper<PhysGrabCart>(__instance); if (!fastReflectionHelper.TryGetField<List<PhysGrabObject>>("itemsInCart", out var value) || value == null) { return; } HashSet<PhysGrabObject> hashSet = new HashSet<PhysGrabObject>(value); HashSet<PhysGrabObject> hashSet2 = new HashSet<PhysGrabObject>(ShrinkTrackerManager.Instance.GetCompletedShrunkObjects(__instance)); foreach (PhysGrabObject item in hashSet.Except(hashSet2)) { ShrinkableTracker tracker = GetTracker(item); if (!((Object)(object)tracker == (Object)null)) { ShrinkEvents.RaiseEnterCart(tracker); tracker.PreviousCart = tracker.CurrentCart; tracker.CurrentCart = __instance; tracker.InterruptExpanding(); if (tracker.IsValidShrinkableItem()) { ShrinkData shrinkData = ShrinkUtils.GetShrinkData(tracker.GrabObject); Vector3 initialScale = tracker.InitialScale; Vector3 target = SetTargetShrink(initialScale, shrinkData); shrinkData.Target = target; NetworkHelper.ProcessingShrinking(tracker, shrinkData); } ShrinkTrackerManager.Instance.RegisterShrinkCompletion(__instance, tracker.GrabObject); } } foreach (PhysGrabObject item2 in hashSet2.Except(hashSet)) { ShrinkableTracker tracker2 = GetTracker(item2); if (!((Object)(object)tracker2 == (Object)null)) { tracker2.PreviousCart = tracker2.CurrentCart; tracker2.ClearCart(); if (!StaticConfig.Instance.shouldKeepShrunk && tracker2.IsExpandable() && tracker2.IsValidShrinkableItem()) { NetworkHelper.ProcessingExpanding(tracker2); } ShrinkEvents.RaiseExitCart(tracker2); ShrinkTrackerManager.Instance.UnregisterShrinkCompletion(__instance, tracker2.GrabObject); } } } public static ShrinkableTracker GetTracker(PhysGrabObject obj) { if ((Object)(object)obj == (Object)null || (Object)(object)((Component)obj).gameObject == (Object)null) { return null; } ShrinkableTracker shrinkableTracker = ((Component)obj).GetComponent<ShrinkableTracker>(); if ((Object)(object)shrinkableTracker == (Object)null) { shrinkableTracker = ((Component)obj).gameObject.AddComponent<ShrinkableTracker>(); shrinkableTracker.Init(obj); } return shrinkableTracker; } public static Vector3 SetTargetShrink(Vector3 original, ShrinkData data) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Max(original * data.ScaleShrinkFactor, original * data.MinShrinkRatio); return Vector3.Min(val, original); } public static void PushConfigToClients() { try { if (!RunManagerHelper.IsInsideValidLevel() || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } StaticConfig.RefreshInstanceFromCurrentConfig(); string text = StaticConfig.Instance.ToJson(); List<PlayerAvatar> list = SemiFunc.PlayerGetAll(); if (!list.Any()) { return; } foreach (PlayerAvatar item in list) { if (!item.photonView.IsMine) { item.photonView.RPC("SyncShrinkConfigRPC", (RpcTarget)0, new object[1] { text }); LogWrapper.Info("[ShrinkSync] \ud83d\udce4 Envoi de la configuration en cours ..."); } } LogWrapper.Info("[ShrinkSync] \ud83c\udf89 Configuration envoyée à tous les joueurs !"); } catch (Exception ex) { LogWrapper.Error("[ShrinkSync] ❌ Exception lors de l’envoi : " + ex.Message); } } } } namespace SylhShrinkerCartPlus.Utils { public static class LogWrapper { private static ManualLogSource Log => Plugin.Log; private static string GenerateMessageStructure(string message, string prefix = "") { string arg = (string.IsNullOrWhiteSpace(prefix) ? "SylhShrinkerCartPlus" : prefix); return $"[{DateTime.Now:HH:mm:ss}][{arg}] - {message}"; } private static void LogMessage(LogLevel level, string message, string prefix = "", bool force = false) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 if (!force && !ConfigManager.enableDebugLogs.Value) { return; } string text = GenerateMessageStructure(message, prefix); if ((int)level <= 4) { if ((int)level == 2) { Log.LogError((object)text); return; } if ((int)level == 4) { Log.LogWarning((object)text); return; } } else { if ((int)level == 16) { Log.LogInfo((object)text); return; } if ((int)level == 32) { Log.LogDebug((object)text); return; } } Log.LogMessage((object)text); } public static void Info(string message, string prefix = "") { LogMessage((LogLevel)16, message, prefix); } public static void Debug(string message, string prefix = "") { LogMessage((LogLevel)32, message, prefix); } public static void Warning(string message, string prefix = "") { LogMessage((LogLevel)4, message, prefix); } public static void Error(string message, string prefix = "") { LogMessage((LogLevel)2, message, prefix); } public static void ForceInfo(string message, string prefix = "") { LogMessage((LogLevel)16, message, prefix, force: true); } public static void ForceWarning(string message, string prefix = "") { LogMessage((LogLevel)4, message, prefix, force: true); } public static void ForceError(string message, string prefix = "") { LogMessage((LogLevel)2, message, prefix, force: true); } } public class NameUtils { public static string CleanName(string name) { return name.Replace("Valuable ", "").Replace("(Clone)", "").Trim(); } public static string CleanCloneSuffix(string name) { return name.Replace("(Clone)", "").Trim(); } public static bool ContainsIgnoreCase(string source, string toCheck, StringComparison comp = StringComparison.OrdinalIgnoreCase) { return source != null && source.IndexOf(toCheck, comp) >= 0; } public static bool TryParseEnemyValuable(string name, out string baseName, out string type) { baseName = null; type = null; string text = CleanName(name); if (!text.StartsWith("Enemy")) { return false; } string[] array = text.Split(new char[1] { '-' }); if (array.Length < 2) { return false; } baseName = array[0].Trim(); type = array[1].Trim(); return true; } } public class FastReflectionHelper<T> { private readonly T _instance; private static readonly Type _type = typeof(T); private static readonly ConcurrentDictionary<string, FieldInfo> _fieldCache = new ConcurrentDictionary<string, FieldInfo>(); private static readonly ConcurrentDictionary<string, PropertyInfo> _propertyCache = new ConcurrentDictionary<string, PropertyInfo>(); private static readonly ConcurrentDictionary<string, MethodInfo> _methodCache = new ConcurrentDictionary<string, MethodInfo>(); public FastReflectionHelper(T instance) { if (instance == null) { throw new ArgumentNullException("instance"); } _instance = instance; } public TField GetField<TField>(string fieldName, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { FieldInfo orAdd = _fieldCache.GetOrAdd(fieldName, (string name) => _type.GetField(name, flags) ?? throw new MissingFieldException(_type.FullName, name)); return (TField)orAdd.GetValue(_instance); } public bool TryGetField<TField>(string fieldName, out TField value, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { if (_fieldCache.TryGetValue(fieldName, out FieldInfo value2) || (value2 = _type.GetField(fieldName, flags)) != null) { _fieldCache[fieldName] = value2; value = (TField)value2.GetValue(_instance); return true; } value = default(TField); return false; } public void SetField<TField>(string fieldName, TField value, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { FieldInfo orAdd = _fieldCache.GetOrAdd(fieldName, (string name) => _type.GetField(name, flags) ?? throw new MissingFieldException(_type.FullName, name)); orAdd.SetValue(_instance, value); } public TProperty GetProperty<TProperty>(string propertyName, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { PropertyInfo orAdd = _propertyCache.GetOrAdd(propertyName, (string name) => _type.GetProperty(name, flags) ?? throw new MissingMemberException(_type.FullName, name)); return (TProperty)orAdd.GetValue(_instance); } public bool TryGetProperty<TProperty>(string propertyName, out TProperty value, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { if (_propertyCache.TryGetValue(propertyName, out PropertyInfo value2) || (value2 = _type.GetProperty(propertyName, flags)) != null) { _propertyCache[propertyName] = value2; value = (TProperty)value2.GetValue(_instance); return true; } value = default(TProperty); return false; } public void SetProperty<TProperty>(string propertyName, TProperty value, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { PropertyInfo orAdd = _propertyCache.GetOrAdd(propertyName, (string name) => _type.GetProperty(name, flags) ?? throw new MissingMemberException(_type.FullName, name)); orAdd.SetValue(_instance, value); } public TResult CallMethod<TResult>(string methodName, object[] parameters = null, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { MethodInfo orAdd = _methodCache.GetOrAdd(methodName, (string name) => _type.GetMethod(name, flags) ?? throw new MissingMethodException(_type.FullName, name)); return (TResult)orAdd.Invoke(_instance, parameters); } public void CallMethod(string methodName, object[] parameters = null, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { MethodInfo orAdd = _methodCache.GetOrAdd(methodName, (string name) => _type.GetMethod(name, flags) ?? throw new MissingMethodException(_type.FullName, name)); orAdd.Invoke(_instance, parameters); } public bool TryCallMethod<TResult>(string methodName, out TResult result, object[] parameters = null, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { if (_methodCache.TryGetValue(methodName, out MethodInfo value) || (value = _type.GetMethod(methodName, flags)) != null) { _methodCache[methodName] = value; result = (TResult)value.Invoke(_instance, parameters); return true; } result = default(TResult); return false; } public bool TryCallMethod(string methodName, object[] parameters = null, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { if (_methodCache.TryGetValue(methodName, out MethodInfo value) || (value = _type.GetMethod(methodName, flags)) != null) { _methodCache[methodName] = value; value.Invoke(_instance, parameters); return true; } return false; } } public static class FastReflection { private static readonly ConcurrentDictionary<(Type, string), FieldInfo> _fieldCache = new ConcurrentDictionary<(Type, string), FieldInfo>(); private static readonly ConcurrentDictionary<(Type, string), PropertyInfo> _propertyCache = new ConcurrentDictionary<(Type, string), PropertyInfo>(); private static readonly ConcurrentDictionary<(Type, string), MethodInfo> _methodCache = new ConcurrentDictionary<(Type, string), MethodInfo>(); public static T GetField<T>(Type type, object instance, string fieldName, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { Type type2 = type; string fieldName2 = fieldName; (Type, string) key = (type2, fieldName2); FieldInfo orAdd = _fieldCache.GetOrAdd(key, ((Type, string) _) => type2.GetField(fieldName2, flags) ?? throw new MissingFieldException(type2.FullName, fieldName2)); return (T)orAdd.GetValue(instance); } public static bool TryGetField<T>(Type type, object instance, string fieldName, out T value, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { (Type, string) key = (type, fieldName); if (_fieldCache.TryGetValue(key, out FieldInfo value2) || (value2 = type.GetField(fieldName, flags)) != null) { _fieldCache[key] = value2; value = (T)value2.GetValue(instance); return true; } value = default(T); return false; } public static void SetField<T>(Type type, object instance, string fieldName, T value, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { Type type2 = type; string fieldName2 = fieldName; (Type, string) key = (type2, fieldName2); FieldInfo orAdd = _fieldCache.GetOrAdd(key, ((Type, string) _) => type2.GetField(fieldName2, flags) ?? throw new MissingFieldException(type2.FullName, fieldName2)); orAdd.SetValue(instance, value); } public static T GetProperty<T>(Type type, object instance, string propertyName, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { Type type2 = type; string propertyName2 = propertyName; (Type, string) key = (type2, propertyName2); PropertyInfo orAdd = _propertyCache.GetOrAdd(key, ((Type, string) _) => type2.GetProperty(propertyName2, flags) ?? throw new MissingMemberException(type2.FullName, propertyName2)); return (T)orAdd.GetValue(instance); } public static bool TryGetProperty<T>(Type type, object instance, string propertyName, out T value, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { (Type, string) key = (type, propertyName); if (_propertyCache.TryGetValue(key, out PropertyInfo value2) || (value2 = type.GetProperty(propertyName, flags)) != null) { _propertyCache[key] = value2; value = (T)value2.GetValue(instance); return true; } value = default(T); return false; } public static void SetProperty<T>(Type type, object instance, string propertyName, T value, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { Type type2 = type; string propertyName2 = propertyName; (Type, string) key = (type2, propertyName2); PropertyInfo orAdd = _propertyCache.GetOrAdd(key, ((Type, string) _) => type2.GetProperty(propertyName2, flags) ?? throw new MissingMemberException(type2.FullName, propertyName2)); orAdd.SetValue(instance, value); } public static T InvokeMethod<T>(Type type, object instance, string methodName, object[] parameters = null, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { Type type2 = type; string methodName2 = methodName; (Type, string) key = (type2, methodName2); MethodInfo orAdd = _methodCache.GetOrAdd(key, ((Type, string) _) => type2.GetMethod(methodName2, flags) ?? throw new MissingMethodException(type2.FullName, methodName2)); return (T)orAdd.Invoke(instance, parameters); } public static void InvokeMethod(Type type, object instance, string methodName, object[] parameters = null, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { Type type2 = type; string methodName2 = methodName; (Type, string) key = (type2, methodName2); MethodInfo orAdd = _methodCache.GetOrAdd(key, ((Type, string) _) => type2.GetMethod(methodName2, flags) ?? throw new MissingMethodException(type2.FullName, methodName2)); orAdd.Invoke(instance, parameters); } public static bool TryInvokeMethod<TResult>(Type type, object instance, string methodName, out TResult result, object[] parameters = null, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { (Type, string) key = (type, methodName); if (_methodCache.TryGetValue(key, out MethodInfo value) || (value = type.GetMethod(methodName, flags)) != null) { _methodCache[key] = value; result = (TResult)value.Invoke(instance, parameters); return true; } result = default(TResult); return false; } public static bool TryInvokeMethod(Type type, object instance, string methodName, object[] parameters = null, BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic) { (Type, string) key = (type, methodName); if (_methodCache.TryGetValue(key, out MethodInfo value) || (value = type.GetMethod(methodName, flags)) != null) { _methodCache[key] = value; value.Invoke(instance, parameters); return true; } return false; } } } namespace SylhShrinkerCartPlus.Utils.Shrink { public static class ShrinkBatteryUtils { public static int BigBatteryLife = 9999; public static void ApplyBatteryLifeAll(ShrinkableTracker tracker) { ApplyCartWeaponBattery(tracker); ApplyBatteryLogic<ItemMelee>(tracker, StaticConfig.Instance.shouldItemMeleeBatteryLifeInfinite); ApplyBatteryLogic<ItemGun>(tracker, StaticConfig.Instance.shouldItemGunBatteryLifeInfinite); ApplyBatteryLogic<ItemDrone>(tracker, StaticConfig.Instance.shouldItemDroneBatteryLifeInfinite); ApplyGenericBattery(tracker); } private static void ApplyCartWeaponBattery(ShrinkableTracker tracker) { if (ItemCartWeaponUtils.TryGetCartWeaponBattery(tracker.GrabObject, out ItemBattery battery) && !((Object)(object)battery == (Object)null)) { if (StaticConfig.Instance.shouldCartWeaponBatteryLifeInfinite) { SetBatteryLife(battery, BigBatteryLife); tracker.CanResetBattery = true; } else if (tracker.CanResetBattery) { SetBatteryLife(battery, tracker.BatteryLife); tracker.CanResetBattery = false; } } } private static void ApplyBatteryLogic<T>(ShrinkableTracker tracker, bool shouldForceInfinite) where T : Component { T val = default(T); ItemBattery battery = default(ItemBattery); if (((Component)tracker).TryGetComponent<T>(ref val) && ((Component)tracker).TryGetComponent<ItemBattery>(ref battery)) { if (shouldForceInfinite) { SetBatteryLife(battery, BigBatteryLife); tracker.CanResetBattery = true; } else if (tracker.CanResetBattery) { SetBatteryLife(battery, tracker.BatteryLife); tracker.CanResetBattery = false; } } } private static void ApplyGenericBattery(ShrinkableTracker tracker) { ItemBattery battery = default(ItemBattery); if (!ItemCartWeaponUtils.TryGetCartWeapon(tracker.GrabObject, out Component _) && !((Object)(object)((Component)tracker).GetComponent<ItemMelee>() != (Object)null) && !((Object)(object)((Component)tracker).GetComponent<ItemGun>() != (Object)null) && !((Object)(object)((Component)tracker).GetComponent<ItemDrone>() != (Object)null) && !Object.op_Implicit((Object)(object)((Component)tracker).GetComponent<ItemGrenade>()) && ((Component)tracker).TryGetComponent<ItemBattery>(ref battery)) { if (StaticConfig.Instance.shouldItemGenericBatteryLifeInfinite) { SetBatteryLife(battery, BigBatteryLife); tracker.CanResetBattery = true; } else if (tracker.CanResetBattery) { SetBatteryLife(battery, tracker.BatteryLife); tracker.CanResetBattery = false; } } } public static void SetBatteryLife(ItemBattery battery, int amount = 9999) { battery.batteryLife = amount; battery.SetBatteryLife(amount); } } public static class ShrinkUtils { private static float initialShrinkFactor = 1f; public static ShrinkData HandleEnemyValuable(EnemyValuableCategory category, ShrinkData shrinkData) { if (!StaticConfig.Instance.shouldShrinkEnemyOrbs) { return shrinkData; } switch (category.Category) { case EnemyValuableCategoryEnum.Small: shrinkData.MinShrinkRatio = StaticConfig.Instance.shrinkEnemyOrbSmall; break; case EnemyValuableCategoryEnum.Medium: shrinkData.MinShrinkRatio = StaticConfig.Instance.shrinkEnemyOrbMedium; break; case EnemyValuableCategoryEnum.Big: shrinkData.MinShrinkRatio = StaticConfig.Instance.shrinkEnemyOrbBig; break; case EnemyValuableCategoryEnum.Berserker: shrinkData.MinShrinkRatio = StaticConfig.Instance.shrinkEnemyOrbBig; break; } return shrinkData; } public static ShrinkData HandleSpecialValuable(SpecialValuableCategory category, ShrinkData shrinkData) { if (category.Category == SpecialValuableCategoryEnum.SurplusValuable) { shrinkData.MinShrinkRatio = 0.2f; } return shrinkData; } public static ShrinkData HandleValuable(ValuableCategory category, ShrinkData shrinkData) { switch (category.Category) { case ValuableCategoryEnum.Tiny: if (!StaticConfig.Instance.shouldShrinkTiny) { return shrinkData; } shrinkData.MinShrinkRatio = StaticConfig.Instance.shrinkFactorTiny; break; case ValuableCategoryEnum.Small: if (!StaticConfig.Instance.shouldShrinkSmall) { return shrinkData; } shrinkData.MinShrinkRatio = StaticConfig.Instance.shrinkFactorSmall; break; case ValuableCategoryEnum.Medium: if (!StaticConfig.Instance.shouldShrinkMedium) { return shrinkData; } shrinkData.MinShrinkRatio = StaticConfig.Instance.shrinkFactorMedium; break; case ValuableCategoryEnum.Big: if (!StaticConfig.Instance.shouldShrinkBig) { return shrinkData; } shrinkData.MinShrinkRatio = StaticConfig.Instance.shrinkFactorBig; break; case ValuableCategoryEnum.Wide: if (!StaticConfig.Instance.shouldShrinkWide) { return shrinkData; } shrinkData.MinShrinkRatio = StaticConfig.Instance.shrinkFactorWide; break; case ValuableCategoryEnum.Tall: if (!StaticConfig.Instance.shouldShrinkTall) { return shrinkData; } shrinkData.MinShrinkRatio = StaticConfig.Instance.shrinkFactorTall; break; case ValuableCategoryEnum.VeryTall: if (!StaticConfig.Instance.shouldShrinkVeryTall) { return shrinkData; } shrinkData.MinShrinkRatio = StaticConfig.Instance.shrinkFactorVeryTall; break; } return shrinkData; } public static Vector3 GetItemDimensions(PhysGrabObject item) { //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_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_005c: Unknown result type (might be due to invalid IL or missing references) FastReflectionHelper<PhysGrabObject> fastReflectionHelper = new FastReflectionHelper<PhysGrabObject>(item); BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic; if (!fastReflectionHelper.TryGetField<float>("itemWidthX", out var value, flags) || !fastReflectionHelper.TryGetField<float>("itemHeightY", out var value2, flags) || !fastReflectionHelper.TryGetField<float>("itemLengthZ", out var value3, flags)) { return Vector3.zero; } return new Vector3(value, value2, value3); } public static float GetItemScaleShrinkFactor(ShrinkData shrinkData) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Min(new float[3] { shrinkData.Dimensions.x, shrinkData.Dimensions.y, shrinkData.Dimensions.z }); float num2 = Mathf.Max(new float[3] { shrinkData.Dimensions.x, shrinkData.Dimensions.y, shrinkData.Dimensions.z }); float num3 = num2 / num; float num4 = ((!(num3 <= 2.5f)) ? (shrinkData.MinShrinkRatio / num2) : (shrinkData.MinShrinkRatio / num)); return Mathf.Clamp(num4, shrinkData.MinShrinkRatio, 1f); } public static ShrinkData GetShrinkData(PhysGrabObject item) { //IL_0032: 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_004f: Unknown result type (might be due to invalid IL or missing references) string name = NameUtils.CleanName(((Object)item).name); ValuableCategoryBase valuableCategoryBase = CategoryResolverRegistry.Resolve(item); ShrinkableTracker component = ((Component)item).GetComponent<ShrinkableTracker>(); ShrinkData shrinkData = new ShrinkData(name, Object.op_Implicit((Object)(object)component) ? component.InitialScale : ((Component)item).transform.localScale, item.massOriginal); shrinkData.Dimensions = GetItemDimensions(item); if (valuableCategoryBase == null) { shrinkData.MinShrinkRatio = StaticConfig.Instance.fallbackShrinkFactor; } else { shrinkData.Category = valuableCategoryBase; ValuableCategoryBase valuableCategoryBase2 = valuableCategoryBase; ValuableCategoryBase valuableCategoryBase3 = valuableCategoryBase2; if (!(valuableCategoryBase3 is EnemyValuableCategory category)) { if (!(valuableCategoryBase3 is ValuableCategory category2)) { if (valuableCategoryBase3 is SpecialValuableCategory category3) { shrinkData = HandleSpecialValuable(category3, shrinkData); } else { shrinkData.MinShrinkRatio = StaticConfig.Instance.fallbackShrinkFactor; } } else { shrinkData = HandleValuable(category2, shrinkData); } } else { shrinkData = HandleEnemyValuable(category, shrinkData); } } shrinkData.ScaleShrinkFactor = GetItemScaleShrinkFactor(shrinkData); return shrinkData; } } } namespace SylhShrinkerCartPlus.Utils.Shrink.Network { public class ConfigNetworkDispatcher : MonoBehaviourPun { [PunRPC] public void SyncShrinkConfigRPC(string json) { StaticConfig.RefreshInstanceFromJson(json); LogWrapper.Warning("✅ Configuration shrink synchronisée depuis le host !"); } } public static class NetworkHelper { public static void ProcessingShrinking(ShrinkableTracker tracker, ShrinkData data) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0089: Unknown result type (might be due to invalid IL or missing references) if (GameModeHelper.IsSinglePlayer) { ApplyShrink(tracker, data); return; } PhotonView component = ((Component)tracker.GrabObject).GetComponent<PhotonView>(); ShrinkNetworkDispatcher component2 = ((Component)tracker.GrabObject).GetComponent<ShrinkNetworkDispatcher>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { Debug.LogError((object)"[Shrink] PhotonView ou Dispatcher manquant !"); return; } Vector3 val2 = (data.Target = ShrinkerCartPatch.SetTargetShrink(tracker.InitialScale, data)); component.RPC("ProcessingShrinkingRPC", (RpcTarget)0, new object[4] { data.OriginalScale, val2, data.ScaleShrinkFactor, data.MinShrinkRatio }); } public static void ApplyShrink(ShrinkableTracker tracker, ShrinkData data) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) tracker.StartShrinking(data.Target); } public static void ProcessingChangingMass(ShrinkableTracker tracker) { if (GameModeHelper.IsSinglePlayer) { ApplyMass(tracker, StaticConfig.Instance.shrinkMassValue); return; } PhotonView component = ((Component)tracker.GrabObject).GetComponent<PhotonView>(); ShrinkNetworkDispatcher component2 = ((Component)tracker.GrabObject).GetComponent<ShrinkNetworkDispatcher>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { Debug.LogError((object)"[Shrink] PhotonView ou Dispatcher manquant !"); return; } component.RPC("ProcessingChangingMassRPC", (RpcTarget)0, new object[2] { StaticConfig.Instance.shrinkMassValue, StaticConfig.Instance.shouldChangingMass }); } public static void ApplyMass(ShrinkableTracker tracker, float amount) { tracker.ApplyMass(amount); } public static void ProcessingExpanding(ShrinkableTracker tracker) { if (GameModeHelper.IsSinglePlayer) { ApplyExpanding(tracker); RestoreMass(tracker); return; } PhotonView component = ((Component)tracker.GrabObject).GetComponent<PhotonView>(); ShrinkNetworkDispatcher component2 = ((Component)tracker.GrabObject).GetComponent<ShrinkNetworkDispatcher>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { Debug.LogError((object)"[Expand] PhotonView ou Dispatcher manquant !"); } else { component.RPC("ProcessingExpandingRPC", (RpcTarget)0, Array.Empty<object>()); } } public static void ApplyExpanding(ShrinkableTracker tracker) { tracker.StartExpanding(); } public static void ProcessingRestoringMass(ShrinkableTracker tracker) { if (GameModeHelper.IsSinglePlayer) { RestoreMass(tracker); return; } PhotonView component = ((Component)tracker.GrabObject).GetComponent<PhotonView>(); ShrinkNetworkDispatcher component2 = ((Component)tracker.GrabObject).GetComponent<ShrinkNetworkDispatcher>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { Debug.LogError((object)"[Shrink] PhotonView ou Dispatcher manquant !"); } else { component.RPC("ProcessingRestoringMassRPC", (RpcTarget)0, Array.Empty<object>()); } } public static void RestoreMass(ShrinkableTracker tracker) { tracker.RestoreMass(); } public static void ProcessingChangingBatteryLife(ShrinkableTracker tracker) { if (GameModeHelper.IsSinglePlayer) { ApplyChangingBatteryLife(tracker); return; } PhotonView component = ((Component)tracker.GrabObject).GetComponent<PhotonView>(); ShrinkNetworkDispatcher component2 = ((Component)tracker.GrabObject).GetComponent<ShrinkNetworkDispatcher>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { Debug.LogError((object)"[Expand] PhotonView ou Dispatcher manquant !"); } else { component.RPC("ProcessingChangingBatteryLifeRPC", (RpcTarget)0, Array.Empty<object>()); } } public static void ApplyChangingBatteryLife(ShrinkableTracker tracker) { ShrinkBatteryUtils.ApplyBatteryLifeAll(tracker); } } public class ShrinkNetworkDispatcher : MonoBehaviourPun { [PunRPC] public void ProcessingShrinkingRPC(Vector3 originalScale, Vector3 targetScale, float shrinkFactor, float minShrinkRatio) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) PhysGrabObject component = ((Component)this).GetComponent<PhysGrabObject>(); if ((Object)(object)component == (Object)null) { Debug.LogError((object)"[ShrinkRPC] Aucun PhysGrabObject trouvé sur l'objet !"); return; } ShrinkableTracker tracker = ShrinkerCartPatch.GetTracker(component); ShrinkData shrinkData = new ShrinkData(((Object)component).name, tracker.InitialScale, tracker.InitialMass); shrinkData.ScaleShrinkFactor = shrinkFactor; shrinkData.MinShrinkRatio = minShrinkRatio; shrinkData.Target = targetScale; NetworkHelper.ApplyShrink(tracker, shrinkData); } [PunRPC] public void ProcessingChangingMassRPC(float massValue, bool isChangingMass) { PhysGrabObject component = ((Component)this).GetComponent<PhysGrabObject>(); if ((Object)(object)component == (Object)null) { Debug.LogError((object)"[ShrinkRPC] Aucun PhysGrabObject trouvé sur l'objet !"); return; } ShrinkableTracker tracker = ShrinkerCartPatch.GetTracker(component); if (isChangingMass) { NetworkHelper.ApplyMass(tracker, massValue); } } [PunRPC] public void ProcessingRestoringMassRPC() { PhysGrabObject component = ((Component)this).GetComponent<PhysGrabObject>(); if ((Object)(object)component == (Object)null) { Debug.LogError((object)"[ShrinkRPC] Aucun PhysGrabObject trouvé sur l'objet !"); return; } ShrinkableTracker tracker = ShrinkerCartPatch.GetTracker(component); NetworkHelper.RestoreMass(tracker); } [PunRPC] public void ProcessingExpandingRPC() { PhysGrabObject component = ((Component)this).GetComponent<PhysGrabObject>(); if ((Object)(object)component == (Object)null) { Debug.LogError((object)"[ExpandRPC] Aucun PhysGrabObject trouvé !"); return; } ShrinkableTracker tracker = ShrinkerCartPatch.GetTracker(component); NetworkHelper.ApplyExpanding(tracker); NetworkHelper.RestoreMass(tracker); } [PunRPC] public void ProcessingChangingBatteryLifeRPC() { PhysGrabObject component = ((Component)this).GetComponent<PhysGrabObject>(); if ((Object)(object)component == (Object)null) { Debug.LogError((object)"[ExpandRPC] Aucun PhysGrabObject trouvé !"); return; } ShrinkableTracker tracker = ShrinkerCartPatch.GetTracker(component); NetworkHelper.ApplyChangingBatteryLife(tracker); } } } namespace SylhShrinkerCartPlus.Utils.RunManagerUtils { public static class RunManagerHelper { public static bool IsLevelShop() { return (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelShop; } public static bool IsLevelLobby() { return (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelLobby; } public static bool IsLevelSplashScreen() { return (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelSplashScreen; } public static bool IsLevelArena() { return (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelArena; } public static bool IsInsideValidLevel() { return !IsLevelShop() && !IsLevelLobby() && !IsLevelSplashScreen() && !IsLevelArena(); } } } namespace SylhShrinkerCartPlus.Utils.GameManagerUtils { public static class GameModeHelper { public static bool IsSinglePlayer => GameManager.instance.gameMode == 0; public static bool IsMultiplayer => GameManager.instance.gameMode == 1; } } namespace SylhShrinkerCartPlus.Utils.Events { public class CartEvents { public static event Action<PhysGrabCart, PhysGrabObject> OnCartObjectAdded; public static event Action<PhysGrabObject, PhysGrabCart> OnEnterCart; public static void FireCartObjectAdded(PhysGrabInCart inCart, PhysGrabObject obj) { ShrinkableTracker tracker = ShrinkerCartPatch.GetTracker(obj); if (!((Object)(object)tracker == (Object)null)) { tracker.InitProtectTimer(); if (StaticConfig.Instance.shouldInstantKillEnemyInCart) { EnemyExecutionManager.TryMarkForExecution(tracker); } PhysGrabCart cart = inCart.cart; if (!tracker.IsInsideSameCart(cart) && !tracker.IsInCart()) { CartEvents.OnCartObjectAdded?.Invoke(cart, obj); } } } public static void RaiseEnterCart(PhysGrabObject obj, PhysGrabCart cart) { CartEvents.OnEnterCart?.Invoke(obj, cart); } } public static class ConfigEvents { public static void Initialize() { ConfigManager.defaultShrinkSpeed.SettingChanged += OnSettingChanged; ConfigManager.fallbackShrinkFactor.SettingChanged += OnSettingChanged; ConfigManager.shouldShrinkEnemyOrbs.SettingChanged += OnSettingChanged; ConfigManager.shrinkEnemyOrbSmall.SettingChanged += OnSettingChanged; ConfigManager.shrinkEnemyOrbMedium.SettingChanged += OnSettingChanged; ConfigManager.shrinkEnemyOrbBig.SettingChanged += OnSettingChanged; ConfigManager.shouldShrinkTiny.SettingChanged += OnSettingChanged; ConfigManager.shrinkFactorTiny.SettingChanged += OnSettingChanged; ConfigManager.shouldShrinkSmall.SettingChanged += OnSettingChanged; ConfigManager.shrinkFactorSmall.SettingChanged += OnSettingChanged; ConfigManager.shouldShrinkMedium.SettingChanged += OnSettingChanged; ConfigManager.shrinkFactorMedium.SettingChanged += OnSettingChanged; ConfigManager.shouldShrinkBig.SettingChanged += OnSettingChanged; ConfigManager.shrinkFactorBig.SettingChanged += OnSettingChanged; ConfigManager.shouldShrinkWide.SettingChanged += OnSettingChanged; ConfigManager.shrinkFactorWide.SettingChanged += OnSettingChanged; ConfigManager.shouldShrinkTall.SettingChanged += OnSettingChanged; ConfigManager.shrinkFactorTall.SettingChanged += OnSettingChanged; ConfigManager.shouldShrinkVeryTall.SettingChanged += OnSettingChanged; ConfigManager.shrinkFactorVeryTall.SettingChanged += OnSettingChanged; ConfigManager.shouldKeepShrunk.SettingChanged += OnSettingChanged; ConfigManager.shouldChangingMass.SettingChanged += OnShouldChangingMassSettingChanged; ConfigManager.shrinkMassValue.SettingChanged += OnSettingChanged; ConfigManager.shouldInstantKillEnemyInCart.SettingChanged += OnInstantKillSettingChanged; ConfigManager.shouldCartWeaponBatteryLifeInfinite.SettingChanged += OnShouldItemBatteryLifeInfiniteSettingChanged; ConfigManager.shouldItemGunBatteryLifeInfinite.SettingChanged += OnShouldItemBatteryLifeInfiniteSettingChanged; ConfigManager.shouldItemMeleeBatteryLifeInfinite.SettingChanged += OnShouldItemBatteryLifeInfiniteSettingChanged; ConfigManager.shouldItemDroneBatteryLifeInfinite.SettingChanged += OnShouldItemBatteryLifeInfiniteSettingChanged; ConfigManager.shouldItemGenericBatteryLifeInfinite.SettingChanged += OnShouldItemBatteryLifeInfiniteSettingChanged; } public static void RefreshingConfigToClients() { ShrinkerCartPatch.PushConfigToClients(); } public static void OnSettingChanged(object sender, EventArgs e) { RefreshingConfigToClients(); } public static void OnInstantKillSettingChanged(object sender, EventArgs e) { RefreshingConfigToClients(); RefreshEnemiesInAllCarts(); } public static void RefreshEnemiesInAllCarts() { if (!RunManagerHelper.IsInsideValidLevel() || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } LogWrapper.Warning("[Config Refresh] ⚙\ufe0f Mise à jour des ennemis dans les CARTs suite à changement d'option"); if (!StaticConfig.Instance.shouldInstantKillEnemyInCart) { return; } List<ShrinkableTracker> list = ShrinkTrackerManager.Instance.GetTrackersInCart().ToList(); if (!list.Any()) { return; } foreach (ShrinkableTracker item in list) { EnemyExecutionManager.TryMarkForExecution(item); LogWrapper.Info("\ud83d\udc80 Exécution instantanée forcée de " + ((Object)item.GrabObject).name); } } public static void OnShouldItemBatteryLifeInfiniteSettingChanged(object sender, EventArgs e) { RefreshingConfigToClients(); RefreshItemBatteryInAllCarts(); } public static void RefreshItemBatteryInAllCarts() { if (!RunManagerHelper.IsInsideValidLevel() || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } LogWrapper.Warning("⚙\ufe0f Mise à jour des Batteries"); List<ShrinkableTracker> list = ShrinkTrackerManager.Instance.GetAll().ToList(); if (!list.Any()) { return; } foreach (ShrinkableTracker item in list) { ShrinkBatteryUtils.ApplyBatteryLifeAll(item); } } public static void OnShouldChangingMassSettingChanged(object sender, EventArgs e) { RefreshingConfigToClients(); RefreshItemMassInAllCarts(); } public static void RefreshItemMassInAllCarts() { if (!RunManagerHelper.IsInsideValidLevel() || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } LogWrapper.Warning("[Config Refresh] ⚙\ufe0f Mise à jour des Mass pour les Items"); List<ShrinkableTracker> list = ShrinkTrackerManager.Instance.GetAll().ToList(); if (!list.Any()) { return; } float shrinkMassValue = StaticConfig.Instance.shrinkMassValue; foreach (ShrinkableTracker item in list) { if (item.IsValidShrinkableItem()) { if (StaticConfig.Instance.shouldChangingMass) { item.ApplyMass(shrinkMassValue); LogWrapper.Warning($"[Config Refresh] ⚙\ufe0f La mass de l'objet {((Object)item.GrabObject).name} est maintenant de {shrinkMassValue}"); } else { item.RestoreMass(); LogWrapper.Warning($"[Config Refresh] ⚙\ufe0f La mass de l'objet {((Object)item.GrabObject).name} est maintenant de {item.InitialMass}"); } } } } } } namespace SylhShrinkerCartPlus.Utils.Cheat.Enemy { public static class EnemyExecutionManager { public static class EnemyReflectionUtils { public static bool TryGetEnemyComponents(ShrinkableTracker tracker, out object enemy, out object health, out int currentHp, out UnityEvent onDeathEvent) { enemy = null; health = null; currentHp = 0; onDeathEvent = null; PhysGrabObject grabObject = tracker.GrabObject; if ((Object)(object)grabObject == (Object)null || !SemiFunc.IsMasterClientOrSingleplayer()) { return false; } if (!FastReflection.TryGetField<bool>(typeof(PhysGrabObject), grabObject, "isEnemy", out var value) || !value) { return false; } if (!FastReflection.TryGetField<object>(typeof(PhysGrabObject), grabObject, "enemyRigidbody", out var value2) || value2 == null) { return false; } if (!FastReflection.TryGetField<object>(value2.GetType(), value2, "enemy", out enemy, BindingFlags.Instance | BindingFlags.Public) || enemy == null) { return false; } if (!FastReflection.TryGetField<bool>(enemy.GetType(), enemy, "HasHealth", out var value3) || !value3) { return false; } if (!FastReflection.TryGetField<object>(enemy.GetType(), enemy, "Health", out health) || health == null) { return false; } if (!FastReflection.TryGetField<bool>(health.GetType(), health, "dead", out var value4) || value4) { return false; } if (!FastReflection.TryGetField<int>(health.GetType(), health, "healthCurrent", out currentHp)) { return false; } if (!FastReflection.TryGetField<UnityEvent>(health.GetType(), health, "onDeath", out onDeathEvent, BindingFlags.Instance | BindingFlags.Public) || onDeathEvent == null) { return false; } return true; } } private static readonly HashSet<object> enemiesToKill; static EnemyExecutionManager() { enemiesToKill = new HashSet<object>(); SceneManager.sceneLoaded += delegate { enemiesToKill.Clear(); Plugin.Log.LogInfo((object)"[ExecutionManager] Cleared enemiesToKill list on scene load."); }; } public static void TryMarkForExecution(ShrinkableTracker tracker) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (EnemyReflectionUtils.TryGetEnemyComponents(tracker, out object enemy, out object health, out int currentHp, out UnityEvent onDeathEvent) && !enemiesToKill.Contains(enemy)) { enemiesToKill.Add(enemy); UnityAction deathHandler = null; deathHandler = (UnityAction)delegate { enemiesToKill.Remove(enemy); onDeathEvent.RemoveListener(deathHandler); }; onDeathEvent.AddListener(deathHandler); FastReflection.TryInvokeMethod(health.GetType(), health, "Hurt", new object[2] { currentHp + 1, Vector3.up }, BindingFlags.Instance | BindingFlags.Public); } } } } namespace SylhShrinkerCartPlus.Utils.Cheat.Cart { public static class ItemBatteryUtils { public static ItemBattery? TryGetBattery(PhysGrabObject item, out ItemBattery? battery) { if ((Object)(object)item == (Object)null) { battery = null; return battery; } if (ItemCartWeaponUtils.TryGetCartWeaponBattery(item, out ItemBattery battery2)) { battery = battery2; return battery; } ItemMelee val = default(ItemMelee); if (((Component)item).TryGetComponent<ItemMelee>(ref val)) { battery = ((Component)val).GetComponent<ItemBattery>(); return battery; } ItemGun val2 = default(ItemGun); if (((Component)item).TryGetComponent<ItemGun>(ref val2)) { battery = ((Component)val2).GetComponent<ItemBattery>(); return battery; } ItemDrone val3 = default(ItemDrone); if (((Component)item).TryGetComponent<ItemDrone>(ref val3)) { battery = ((Component)val3).GetComponent<ItemBattery>(); return battery; } ItemBattery val4 = default(ItemBattery); if (((Component)item).TryGetComponent<ItemBattery>(ref val4)) { battery = val4; return battery; } battery = null; return battery; } } public static class ItemCartWeaponUtils { public static bool TryGetCartWeapon(PhysGrabObject obj, out Component? component) { if ((Object)(object)obj == (Object)null) { component = null; return false; } Type[] array = new Type[2] { typeof(ItemCartCannon), typeof(ItemCartLaser) }; Type[] array2 = array; foreach (Type type in array2) { Component component2 = ((Component)obj).GetComponent(type); if ((Object)(object)component2 != (Object)null) { component = component2; return true; } } component = null; return false; } public static bool TryGetCartWeaponBattery(PhysGrabObject obj, out ItemBattery? battery) { Type[] array = new Type[2] { typeof(ItemCartCannon), typeof(ItemCartLaser) }; if ((Object)(object)obj == (Object)null) { battery = null; return false; } Type[] array2 = array; foreach (Type type in array2) { Component component = ((Component)obj).GetComponent(type); if (!((Object)(object)component == (Object)null)) { ItemBattery component2 = component.GetComponent<ItemBattery>(); if (!((Object)(object)component2 == (Object)null)) { battery = component2; return true; } } } battery = null; return false; } } } namespace SylhShrinkerCartPlus.Resolver.Valuable { public static class CategoryResolverRegistry { private static readonly List<ICategoryResolver> _resolvers = new List<ICategoryResolver>(); public static void Register(ICategoryResolver resolver) { _resolvers.Add(resolver); } public static ValuableCategoryBase? Resolve(PhysGrabObject item) { foreach (ICategoryResolver resolver in _resolvers) { ValuableCategoryBase valuableCategoryBase = resolver.ResolveCategory(item); if (valuableCategoryBase != null) { return valuableCategoryBase; } } return null; } } public class EnemyCategoryResolver : ICategoryResolver { private static readonly Dictionary<string, EnemyValuableCategoryEnum> _mappings = new Dictionary<string, EnemyValuableCategoryEnum>(StringComparer.OrdinalIgnoreCase) { { "Small", EnemyValuableCategoryEnum.Small }, { "Medium", EnemyValuableCategoryEnum.Medium }, { "Big", EnemyValuableCategoryEnum.Big }, { "Berserker", EnemyValuableCategoryEnum.Berserker } }; public ValuableCategoryBase? ResolveCategory(PhysGrabObject item) { string name = NameUtils.CleanName(((Object)item).name); if (!NameUtils.TryParseEnemyValuable(name, out string _, out string type)) { return null; } EnemyValuableCategoryEnum value; return _mappings.TryGetValue(type, out value) ? new EnemyValuableCategory(value) : null; } } public interface ICategoryResolver { ValuableCategoryBase? ResolveCategory(PhysGrabObject item); } public class SpecialCategoryResolver : ICategoryResolver { public ValuableCategoryBase? ResolveCategory(PhysGrabObject item) { if (Object.op_Implicit((Object)(object)((Component)item).GetComponent<SurplusValuable>())) { return new SpecialValuableCategory(SpecialValuableCategoryEnum.SurplusValuable); } return null; } } public class StandardValuableCategoryResolver : ICategoryResolver { private static readonly Dictionary<Func<LevelValuables, List<GameObject>>, ValuableCategoryEnum> _mappings = new Dictionary<Func<LevelValuables, List<GameObject>>, ValuableCategoryEnum> { { (LevelValuables v) => v.tiny, ValuableCategoryEnum.Tiny }, { (LevelValuables v) => v.small, ValuableCategoryEnum.Small }, { (LevelValuables v) => v.medium, ValuableCategoryEnum.Medium }, { (LevelValuables v) => v.big, ValuableCategoryEnum.Big }, { (LevelValuables v) => v.wide, ValuableCategoryEnum.Wide }, { (LevelValuables v) => v.tall, ValuableCategoryEnum.Tall }, { (LevelValuables v) => v.veryTall, ValuableCategoryEnum.VeryTall } }; public ValuableCategoryBase? ResolveCategory(PhysGrabObject item) { string itemName = NameUtils.CleanName(((Object)item).name); foreach (LevelValuables valuablePreset in RunManager.instance.levelCurrent.ValuablePresets) { foreach (KeyValuePair<Func<LevelValuables, List<GameObject>>, ValuableCategoryEnum> mapping in _mappings) { List<GameObject> source = mapping.Key(valuablePreset); if (source.Any((GameObject v) => NameUtils.CleanName(((Object)v).name) == itemName)) { return new ValuableCategory(mapping.Value); } } } return null; } } public abstract class ValuableCategoryBase { public abstract string DisplayName { get; } } public sealed class ValuableCategory : ValuableCategoryBase { public ValuableCategoryEnum Category { get; } public override string DisplayName => Category.ToString(); public ValuableCategory(ValuableCategoryEnum category) { Category = category; } } public sealed class EnemyValuableCategory : ValuableCategoryBase { public EnemyValuableCategoryEnum Category { get; } public override string DisplayName => Category.ToString(); public EnemyValuableCategory(EnemyValuableCategoryEnum category) { Category = category; } } public sealed class SpecialValuableCategory : ValuableCategoryBase { public SpecialValuableCategoryEnum Category { get; } public override string DisplayName => Category.ToString(); public SpecialValuableCategory(SpecialValuableCategoryEnum category) { Category = category; } } public enum ValuableCategoryEnum { Tiny, Small, Medium, Big, Wide, Tall, VeryTall } public enum EnemyValuableCategoryEnum { Small, Medium, Big, Berserker } public enum SpecialValuableCategoryEnum { SurplusValuable } } namespace SylhShrinkerCartPlus.Models { public class ShrinkData { [Range(0.01f, 1f)] public float MinShrinkRatio; public string Name { get; set; } public Vector3 OriginalScale { get; set; } public Vector3 Target { get; set; } public float OriginalMass { get; set; } public Vector3 Dimensions { get; set; } public float ScaleShrinkFactor { get; set; } public ValuableCategoryBase Category { get; set; } public ShrinkData(string name = "", Vector3 originalScale = default(Vector3), float originalMass = 0f, float minShrinkRatio = 1f, float scaleShrinkFactor = 1f) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) Name = name; OriginalScale = originalScale; OriginalMass = originalMass; MinShrinkRatio = minShrinkRatio; ScaleShrinkFactor = scaleShrinkFactor; } public override string ToString() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) return "'- Name: " + Name + "' " + $"- Original Scale: {OriginalScale}" + $"- Original Mass: {OriginalMass}" + $"- Min Shrink Ratio: {MinShrinkRatio}" + $"- Scale Shrink Factor: {ScaleShrinkFactor}" + $"- Dimensions: {Dimensions}" + $"- Category: {Category}"; } } } namespace SylhShrinkerCartPlus.Manager { public static class CartEventHookManager { private static readonly Dictionary<PhysGrabObject, bool> currentCartStates = new Dictionary<PhysGrabObject, bool>(); public static void Update() { foreach (ShrinkableTracker item in ShrinkTrackerManager.Instance.GetAll()) { PhysGrabObject grabObject = item.GrabObject; if (!((Object)(object)grabObject == (Object)null)) { bool flag = (Object)(object)item.CurrentCart != (Object)null; bool value; bool flag2 = currentCartStates.TryGetValue(grabObject, out value) && value; if (flag && !flag2) { ShrinkEvents.RaiseEnterCart(item); } else if (!flag && flag2) { ShrinkEvents.RaiseExitCart(item); } currentCartStates[grabObject] = flag; } } } public static void Clear() { currentCartStates.Clear(); } } public static class ShrinkEvents { [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private static UnityAction<ShrinkableTracker> m_OnShrinkStarted; [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private static UnityAction<ShrinkableTracker> m_OnShrinkCompleted; [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private static UnityAction<ShrinkableTracker> m_OnExpandStarted; [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private static UnityAction<ShrinkableTracker> m_OnExpandCompleted; [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private static UnityAction<ShrinkableTracker> m_OnEnteredCart; [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private static UnityAction<ShrinkableTracker> m_OnExitedCart; [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private static UnityAction<ShrinkableTracker, float> m_OnMassChanged; public static event UnityAction<ShrinkableTracker> OnShrinkStarted { [CompilerGenerated] add { UnityAction<ShrinkableTracker> val = ShrinkEvents.m_OnShrinkStarted; UnityAction<ShrinkableTracker> val2; do { val2 = val; UnityAction<ShrinkableTracker> value2 = (UnityAction<ShrinkableTracker>)(object)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref ShrinkEvents.m_OnShrinkStarted, value2, val2); } while (val != val2); } [CompilerGenerated] remove { UnityAction<ShrinkableTracker> val = ShrinkEvents.m_OnShrinkStarted; UnityAction<ShrinkableTracker> val2; do { val2 = val; UnityAction<ShrinkableTracker> value2 = (UnityAction<ShrinkableTracker>)(object)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref ShrinkEvents.m_OnShrinkStarted, value2, val2); } while (val != val2); } } public static event UnityAction<ShrinkableTracker> OnShrinkCompleted { [CompilerGenerated] add { UnityAction<ShrinkableTracker> val = ShrinkEvents.m_OnShrinkCompleted; UnityAction<ShrinkableTracker> val2; do { val2 = val; UnityAction<ShrinkableTracker> value2 = (UnityAction<ShrinkableTracker>)(object)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref ShrinkEvents.m_OnShrinkCompleted, value2, val2); } while (val != val2); } [CompilerGenerated] remove { UnityAction<ShrinkableTracker> val = ShrinkEvents.m_OnShrinkCompleted; UnityAction<ShrinkableTracker> val2; do { val2 = val; UnityAction<ShrinkableTracker> value2 = (UnityAction<ShrinkableTracker>)(object)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref ShrinkEvents.m_OnShrinkCompleted, value2, val2); } while (val != val2); } } public static event UnityAction<ShrinkableTracker> OnExpandStarted { [CompilerGenerated] add { UnityAction<ShrinkableTracker> val = ShrinkEvents.m_OnExpandStarted; UnityAction<ShrinkableTracker> val2; do { val2 = val; UnityAction<ShrinkableTracker> value2 = (UnityAction<ShrinkableTracker>)(object)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref ShrinkEvents.m_OnExpandStarted, value2, val2); } while (val != val2); } [CompilerGenerated] remove { UnityAction<ShrinkableTracker> val = ShrinkEvents.m_OnExpandStarted; UnityAction<ShrinkableTracker> val2; do { val2 = val; UnityAction<ShrinkableTracker> value2 = (UnityAction<ShrinkableTracker>)(object)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref ShrinkEvents.m_OnExpandStarted, value2, val2); } while (val != val2); } } public static event UnityAction<ShrinkableTracker> OnExpandCompleted { [CompilerGenerated] add { UnityAction<ShrinkableTracker> val = ShrinkEvents.m_OnExpandCompleted; UnityAction<ShrinkableTracker> val2; do { val2 = val; UnityAction<ShrinkableTracker> value2 = (UnityAction<ShrinkableTracker>)(object)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref ShrinkEvents.m_OnExpandCompleted, value2, val2); } while (val != val2); } [CompilerGenerated] remove { UnityAction<ShrinkableTracker> val = ShrinkEvents.m_OnExpandCompleted; UnityAction<ShrinkableTracker> val2; do { val2 = val; UnityAction<ShrinkableTracker> value2 = (UnityAction<ShrinkableTracker>)(object)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref ShrinkEvents.m_OnExpandCompleted, value2, val2); } while (val != val2); } } public static event UnityAction<ShrinkableTracker> OnEnteredCart { [CompilerGenerated] add { UnityAction<ShrinkableTracker> val = ShrinkEvents.m_OnEnteredCart; UnityAction<ShrinkableTracker> val2; do { val2 = val; UnityAction<ShrinkableTracker> value2 = (UnityAction<ShrinkableTracker>)(object)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref ShrinkEvents.m_OnEnteredCart, value2, val2); } while (val != val2); } [CompilerGenerated] remove { UnityAction<ShrinkableTracker> val = ShrinkEvents.m_OnEnteredCart; UnityAction<ShrinkableTracker> val2; do { val2 = val; UnityAction<ShrinkableTracker> value2 = (UnityAction<ShrinkableTracker>)(object)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref ShrinkEvents.m_OnEnteredCart, value2, val2); } while (val != val2); } } public static event UnityAction<ShrinkableTracker> OnExitedCart { [CompilerGenerated] add { UnityAction<ShrinkableTracker> val = ShrinkEvents.m_OnExitedCart; UnityAction<ShrinkableTracker> val2; do { val2 = val; UnityAction<ShrinkableTracker> value2 = (UnityAction<ShrinkableTracker>)(object)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref ShrinkEvents.m_OnExitedCart, value2, val2); } while (val != val2); } [CompilerGenerated] remove { UnityAction<ShrinkableTracker> val = ShrinkEvents.m_OnExitedCart; UnityAction<ShrinkableTracker> val2; do { val2 = val; UnityAction<ShrinkableTracker> value2 = (UnityAction<ShrinkableTracker>)(object)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref ShrinkEvents.m_OnExitedCart, value2, val2); } while (val != val2); } } public static event UnityAction<ShrinkableTracker, float> OnMassChanged { [CompilerGenerated] add { UnityAction<ShrinkableTracker, float> val = ShrinkEvents.m_OnMassChanged; UnityAction<ShrinkableTracker, float> val2; do { val2 = val; UnityAction<ShrinkableTracker, float> value2 = (UnityAction<ShrinkableTracker, float>)(object)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref ShrinkEvents.m_OnMassChanged, value2, val2); } while (val != val2); } [CompilerGenerated] remove { UnityAction<ShrinkableTracker, float> val = ShrinkEvents.m_OnMassChanged; UnityAction<ShrinkableTracker, float> val2; do { val2 = val; UnityAction<ShrinkableTracker, float> value2 = (UnityAction<ShrinkableTracker, float>)(object)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref ShrinkEvents.m_OnMassChanged, value2, val2); } while (val != val2); } } internal static void RaiseShrinkStarted(ShrinkableTracker tracker) { ShrinkEvents.OnShrinkStarted?.Invoke(tracker); } internal static void RaiseShrinkCompleted(ShrinkableTracker tracker) { ShrinkEvents.OnShrinkCompleted?.Invoke(tracker); } internal static void RaiseExpandedStarted(ShrinkableTracker tracker) { ShrinkEvents.OnExpandStarted?.Invoke(tracker); } internal static void RaiseExpandedCompleted(ShrinkableTracker tracker) { ShrinkEvents.OnExpandCompleted?.Invoke(tracker); } internal static void RaiseExitCart(ShrinkableTracker tracker) { ShrinkEvents.OnExitedCart?.Invoke(tracker); } internal static void RaiseEnterCart(ShrinkableTracker tracker) { ShrinkEvents.OnEnteredCart?.Invoke(tracker); } internal static void RaiseMassChanged(ShrinkableTracker tracker, float mass) { ShrinkEvents.OnMassChanged?.Invoke(tracker, mass); } } public class ShrinkTrackerManager { private static readonly ShrinkTrackerManager _instance = new ShrinkTrackerManager(); private readonly Dictionary<PhysGrabObject, ShrinkableTracker> _trackers = new Dictionary<PhysGrabObject, ShrinkableTracker>(); private readonly Dictionary<PhysGrabCart, HashSet<PhysGrabObject>> _completedShrunkItemsPerCart = new Dictionary<PhysGrabCart, HashSet<PhysGrabObject>>(); public static ShrinkTrackerManager Instance => _instance; private ShrinkTrackerManager() { } public void Register(ShrinkableTracker tracker) { if (!((Object)(object)tracker?.GrabObject == (Object)null) && !_trackers.ContainsKey(tracker.GrabObject)) { _trackers.Add(tracker.GrabObject, tracker); LogWrapper.Debug("✅ Registered: " + ((Object)tracker.GrabObject).name); } } public void Unregister(ShrinkableTracker tracker) { if (!((Object)(object)tracker?.GrabObject == (Object)null) && _trackers.Remove(tracker.GrabObject)) { LogWrapper.Debug("❌ Unregistered: " + ((Object)tracker.GrabObject).name); } } public void ClearAll() { ClearAllShrinkCompletions(); ClearAllTrackers(); } public void ClearAllShrinkCompletions() { _completedShrunkItemsPerCart.Clear(); LogWrapper.Info("\ud83e\uddf9 Tous les objets shrinkés ont été réinitialisés !"); } public void ClearAllTrackers() { _trackers.Clear(); LogWrapper.Info("\ud83e\uddf9 Tous les trackers ont été réinitialisés !"); } public ShrinkableTracker GetTracker(PhysGrabObject GrabObject) { if ((Object)(object)GrabObject == (Object)null) { return null; } ShrinkableTracker value; return _trackers.TryGetValue(GrabObject, out value) ? value : null; } public IEnumerable<ShrinkableTracker> GetAll() { return _trackers.Values; } public IEnumerable<ShrinkableTracker> GetTrackersNotInCart() { return _trackers.Values.Where((ShrinkableTracker t) => (Object)(object)t != (Object)null && (Object)(object)t.CurrentCart == (Object)null); } public IEnumerable<ShrinkableTracker> GetTrackersInCart() { return _trackers.Values.Where((ShrinkableTracker t) => t.IsInCart()); } public IEnumerable<ShrinkableTracker> GetTrackersInCart(PhysGrabCart cart) { PhysGrabCart cart2 = cart; return _trackers.Values.Where((ShrinkableTracker t) => (Object)(object)t != (Object)null && (Object)(object)t.CurrentCart == (Object)(object)cart2); } public IEnumerable<ShrinkableTracker> GetShrinkingInCart(PhysGrabCart cart) { PhysGrabCart cart2 = cart; return _trackers.Values.Where((ShrinkableTracker t) => (Object)(object)t != (Object)null && (Object)(object)t.CurrentCart == (Object)(object)cart2 && t.IsShrinking); } public IEnumerable<ShrinkableTracker> GetExpandedInCart(PhysGrabCart cart) { PhysGrabCart cart2 = cart; return _trackers.Values.Where((ShrinkableTracker t) => (Object)(object)t != (Object)null && (Object)(object)t.CurrentCart == (Object)(object)cart2 && t.IsExpanded); } public IEnumerable<ShrinkableTracker> GetIdleInCart(PhysGrabCart cart) { PhysGrabCart cart2 = cart; return _trackers.Values.Where((ShrinkableTracker t) => (Object)(object)t != (Object)null && (Object)(object)t.CurrentCart == (Object)(object)cart2 && !t.IsShrinking && !t.IsExpanding && !t.IsExpanded); } public IEnumerable<ShrinkableTracker> GetShrinking() { return _trackers.Values.Where((ShrinkableTracker t) => (Object)(object)t != (Object)null && t.IsShrinking); } public IEnumerable<ShrinkableTracker> GetExpanded() { return _trackers.Values.Where((ShrinkableTracker t) => (Object)(object)t != (Object)null && t.IsExpanded); } public IEnumerable<ShrinkableTracker> GetIdle() { return _trackers.Values.Where((ShrinkableTracker t) => (Object)(object)t != (Object)null && !t.IsShrinking && !t.IsExpanding && !t.IsExpanded); } public void RegisterShrinkCompletion(PhysGrabCart cart, PhysGrabObject obj) { if (!((Object)(object)cart == (Object)null) && !((Object)(object)obj == (Object)null)) { if (!_completedShrunkItemsPerCart.TryGetValue(cart, out HashSet<PhysGrabObject> value)) { value = new HashSet<PhysGrabObject>(); _completedShrunkItemsPerCart[cart] = value; } value.Add(obj); } } public void UnregisterShrinkCompletion(PhysGrabCart cart, PhysGrabObject obj) { if (!((Object)(object)cart == (Object)null) && !((Object)(object)obj == (Object)null) && _completedShrunkItemsPerCart.TryGetValue(cart, out HashSet<PhysGrabObject> value)) { value.Remove(obj); if (value.Count == 0) { _completedShrunkItemsPerCart.Remove(cart); } } } public HashSet<PhysGrabObject> GetCompletedShrunkObjects(PhysGrabCart cart) { if ((Object)(object)cart == (Object)null) { return new HashSet<PhysGrabObject>(); } HashSet<PhysGrabObject> value; return _completedShrunkItemsPerCart.TryGetValue(cart, out value) ? new HashSet<PhysGrabObject>(value) : new HashSet<PhysGrabObject>(); } public void LogAll() { LogWrapper.Info($"[TrackerManager] \ud83e\udde0 {_trackers.Count} tracker(s) enregistrés."); foreach (ShrinkableTracker value in _trackers.Values) { PhysGrabObject grabObject = value.GrabObject; LogWrapper.Info(string.Format(" - {0} | InCart: {1} | Shrinking: {2}", ((grabObject != null) ? ((Object)grabObject).name : null) ?? "???", new Func<bool>(value.IsInCart), value.IsShrinking)); } } } } namespace SylhShrinkerCartPlus.Config { public class ConfigManager { public static ConfigEntry<float> defaultShrinkSpeed; public static ConfigEntry<float> fallbackShrinkFactor; public static ConfigEntry<bool> enableDebugLogs; public static ConfigEntry<bool> shouldShrinkEnemyOrbs; public static ConfigEntry<float> shrinkEnemyOrbSmall; public static ConfigEntry<float> shrinkEnemyOrbMedium; public static ConfigEntry<float> shrinkEnemyOrbBig; public static ConfigEntry<bool> shouldInstantKillEnemyInCart; public static ConfigEntry<bool> shouldShrinkTiny; public static ConfigEntry<float> shrinkFactorTiny; public static ConfigEntry<bool> shouldShrinkSmall; public static ConfigEntry<float> shrinkFactorSmall; public static ConfigEntry<bool> shouldShrinkMedium; public static ConfigEntry<float> shrinkFactorMedium; public static ConfigEntry<bool> shouldShrinkBig; public static ConfigEntry<float> shrinkFactorBig; public static ConfigEntry<bool> shouldShrinkWide; public static ConfigEntry<float> shrinkFactorWide; public static ConfigEntry<bool> shouldShrinkTall; public static ConfigEntry<float> shrinkFactorTall; public static ConfigEntry<bool> shouldShrinkVeryTall; public static ConfigEntry<float> shrinkFactorVeryTall; public static ConfigEntry<bool> shouldKeepShrunk; public static ConfigEntry<bool> shouldChangingMass; public static ConfigEntry<float> shrinkMassValue; public static ConfigEntry<bool> shouldCartWeaponBatteryLifeInfinite; public static ConfigEntry<bool> shouldItemMeleeBatteryLifeInfinite; public static ConfigEntry<bool> shouldItemGunBatteryLifeInfinite; public static ConfigEntry<bool> shouldItemDroneBatteryLifeInfinite; public static ConfigEntry<bool> shouldItemGenericBatteryLifeInfinite; internal static void Initialize(Plugin plugin) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Expected O, but got Unknown //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Expected O, but got Unknown //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Expected O, but got Unknown //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Expected O, but got Unknown //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Expected O, but got Unknown //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Expected O, but got Unknown //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Expected O, but got Unknown //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Expected O, but got Unknown //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Expected O, but got Unknown //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Expected O, but got Unknown //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Expected O, but got Unknown //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Expected O, but got Unknown //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Expected O, but got Unknown //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Expected O, but got Unknown //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Expected O, but got Unknown //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Expected O, but got Unknown //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Expected O, but got Unknown //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Expected O, but got Unknown //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Expected O, but got Unknown //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_059a: Expected O, but got Unknown //IL_05bb: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Expected O, but got Unknown //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Expected O, but got Unknown defaultShrinkSpeed = ((BaseUnityPlugin)plugin).Config.Bind<float>("Options", "Default Shrink Speed Value", 0.75f, new ConfigDescription("The default shrink speed value.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.6f, 0.99f), Array.Empty<object>())); fallbackShrinkFactor = ((BaseUnityPlugin)plugin).Config.Bind<float>("Options", "Fallback Shrink Factor", 0.2f, new ConfigDescription("The default shrink factor to apply, if item cannot be categorised", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>())); enableDebugLogs = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Debug", "Enable Debug Logs", false, new ConfigDescription("If enabled, debug logs will be printed to the console.", (AcceptableValueBase)null, Array.Empty<object>())); shouldKeepShrunk = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Options", "Keep Shrunk Valuable", false, new ConfigDescription("When activated, Keeps the item shrunk even after it's taken out of the cart.", (AcceptableValueBase)null, Array.Empty<object>())); shouldChangingMass = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Options", "Changing Mass", true, new ConfigDescription("When activated, Item Mass will change when leaving / entering in the cart.", (AcceptableValueBase)null, Array.Empty<object>())); shrinkMassValue = ((BaseUnityPlugin)plugin).Config.Bind<float>("Options", "Shrink Mass Multiplier", 1f, new ConfigDescription("Value applied to the mass after shrink.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 2f), Array.Empty<object>())); shouldShrinkEnemyOrbs = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Enemy", "Shrink Enemy Orbs", true, new ConfigDescription("When activated, all Enemy Orbs-class Valuables will be shrunk.", (AcceptableValueBase)null, Array.Empty<object>())); shrinkEnemyOrbSmall = ((BaseUnityPlugin)plugin).Config.Bind<float>("Enemy", "Shrink Enemy Orb Small", 0.2f, new ConfigDescription("The shrink factor for small enemy orb valuable (if shouldShrinkEnemyOrbs is true).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>())); shrinkEnemyOrbMedium = ((BaseUnityPlugin)plugin).Config.Bind<float>("Enemy", "Shrink Enemy Orb Medium", 0.2f, new ConfigDescription("The shrink factor for medium enemy orb valuable (if shouldShrinkEnemyOrbs is true).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>())); shrinkEnemyOrbBig = ((BaseUnityPlugin)plugin).Config.Bind<float>("Enemy", "Shrink Enemy Orb Big", 0.2f, new ConfigDescription("The shrink factor for big enemy orb valuable (if shouldShrinkEnemyOrbs is true).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>())); shouldShrinkTiny = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Valuable", "Shrink Tiny", false, new ConfigDescription("When activated, all Tiny-class Valuables will be shrunk.", (AcceptableValueBase)null, Array.Empty<object>())); shrinkFactorTiny = ((BaseUnityPlugin)plugin).Config.Bind<float>("Valuable", "Shrink Factor Tiny", 0.2f, new ConfigDescription("The shrink factor for all Tiny valuable (if shouldShrinkTiny is true).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>())); shouldShrinkSmall = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Valuable", "Shrink Small", false, new ConfigDescription("When activated, all Small-class Valuables will be shrunk.", (AcceptableValueBase)null, Array.Empty<object>())); shrinkFactorSmall = ((BaseUnityPlugin)plugin).Config.Bind<float>("Valuable", "Shrink Factor Small", 0.2f, new ConfigDescription("The shrink factor for all Small valuable (if shouldShrinkSmall is true).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>())); shouldShrinkMedium = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Valuable", "Shrink Medium", true, new ConfigDescription("When activated, all Medium-class Valuables will be shrunk.", (AcceptableValueBase)null, Array.Empty<object>())); shrinkFactorMedium = ((BaseUnityPlugin)plugin).Config.Bind<float>("Valuable", "Shrink Factor Medium", 0.2f, new ConfigDescription("The shrink factor for all Medium valuable (if shouldShrinkMedium is true).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>())); shouldShrinkBig = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Valuable", "Shrink Big", true, new ConfigDescription("When activated, all Big-class Valuables will be shrunk.", (AcceptableValueBase)null, Array.Empty<object>())); shrinkFactorBig = ((BaseUnityPlugin)plugin).Config.Bind<float>("Valuable", "Shrink Factor Big", 0.2f, new ConfigDescription("The shrink factor for all Big valuable (if shouldShrinkBig is true).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>())); shouldShrinkWide = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Valuable", "Shrink Wide", true, new ConfigDescription("When activated, all Wide-class Valuables will be shrunk.", (AcceptableValueBase)null, Array.Empty<object>())); shrinkFactorWide = ((BaseUnityPlugin)plugin).Config.Bind<float>("Valuable", "Shrink Factor Wide", 0.2f, new ConfigDescription("The shrink factor for all Wide valuable (if shouldShrinkWide is true).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>())); shouldShrinkTall = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Valuable", "Shrink Tall", true, new ConfigDescription("When activated, all Tall-class Valuables will be shrunk.", (AcceptableValueBase)null, Array.Empty<object>())); shrinkFactorTall = ((BaseUnityPlugin)plugin).Config.Bind<float>("Valuable", "Shrink Factor Tall", 0.2f, new ConfigDescription("The shrink factor for all Tall valuable (if shouldShrinkTall is true).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>())); shouldShrinkVeryTall = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Valuable", "Shrink VeryTall", true, new ConfigDescription("When activated, all Very-class Valuables will be shrunk.", (AcceptableValueBase)null, Array.Empty<object>())); shrinkFactorVeryTall = ((BaseUnityPlugin)plugin).Config.Bind<float>("Valuable", "Shrink Factor VeryTall", 0.2f, new ConfigDescription("The shrink factor for all VeryTall valuable (if shouldShrinkVeryTall is true).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>())); shouldInstantKillEnemyInCart = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Cheat", "Instant Kill Enemy In Cart", false, new ConfigDescription("When activated, enemies will be killed instantly if they entering inside a C.A.R.T.", (AcceptableValueBase)null, Array.Empty<object>())); shouldCartWeaponBatteryLifeInfinite = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Cheat", "Infinite Cart Weapon Battery Life", false, new ConfigDescription("When activated, the battery becomes infinite for C.A.R.T Canon / Laser", (AcceptableValueBase)null, Array.Empty<object>())); shouldItemMeleeBatteryLifeInfinite = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Cheat", "Infinite Melee Battery Life", false, new ConfigDescription("When activated, the battery becomes infinite for Item Melee", (AcceptableValueBase)null, Array.Empty<object>())); shouldItemGunBatteryLifeInfinite = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Cheat", "Infinite Gun Battery Life", false, new ConfigDescription("When activated, the battery becomes infinite for Item Gun", (AcceptableValueBase)null, Array.Empty<object>())); shouldItemDroneBatteryLifeInfinite = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Cheat", "Infinite Drone Battery Life", false, new ConfigDescription("When activated, the battery becomes infinite for Item Drone", (AcceptableValueBase)null, Array.Empty<object>())); shouldItemGenericBatteryLifeInfinite = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Cheat", "Infinite Other Item Battery Life", false, new ConfigDescription("When activated, the battery becomes infinite for other Item ", (AcceptableValueBase)null, Array.Empty<object>())); } } [Serializable] public class StaticConfig { private static StaticConfig instance = null; private static readonly object padlock = new object(); [Range(0.6f, 1f)] public float defaultShrinkSpeed = 0.6f; [Range(0.2f, 1f)] public float fallbackShrinkFactor = 0.2f; public bool shouldShrinkEnemyOrbs = true; [Range(0.2f, 1f)] public float shrinkEnemyOrbSmall = 0.2f; [Range(0.2f, 1f)] public float shrinkEnemyOrbMedium = 0.2f; [Range(0.2f, 1f)] public float shrinkEnemyOrbBig = 0.2f; public bool shouldInstantKillEnemyInCart = false; public bool shouldShrinkTiny = true; [Range(0.2f, 1f)] public float shrinkFactorTiny = 0.2f; public bool shouldShrinkSmall = true; [Range(0.2f, 1f)] public float shrinkFactorSmall = 0.2f; public bool shouldShrinkMedium = true; [Range(0.2f, 1f)] public float shrinkFactorMedium = 0.2f; public bool shouldShrinkBig = true; [Range(0.2f, 1f)] public float shrinkFactorBig = 0.2f; public bool shouldShrinkWide = true; [Range(0.2f, 1f)] public float shrinkFactorWide = 0.2f; public bool shouldShrinkTall = true; [Range(0.2f, 1f)] public float shrinkFactorTall = 0.2f; public bool shouldShrinkVeryTall = true; [Range(0.2f, 1f)] public float shrinkFactorVeryTall = 0.2f; public bool shouldKeepShrunk = false; public bool shouldChangingMass = true; [Range(0.25f, 1f)] public float shrinkMassValue = 0.25f; public bool shouldCartWeaponBatteryLifeInfinite = false; public bool shouldItemMeleeBatteryLifeInfinite = false; public bool shouldItemGunBatteryLifeInfinite = false; public bool shouldItemDroneBatteryLifeInfinite = false; public bool shouldItemGenericBatteryLifeInfinite = false; public static StaticConfig Instance { get { lock (padlock) { if (instance == null) { LogWrapper.Warning("Instance demandée avant initialisation ! Utilisation d’une config vide."); instance = new StaticConfig(); } return instance; } } } public static void RefreshInstanceFromCurrentConfig() { lock (padlock) { instance = FromCurrentConfig(); } } private static StaticConfig FromCurrentConfig() { return new StaticConfig { defaultShrinkSpeed = ConfigManager.defaultShrinkSpeed.Value, fallbackShrinkFactor = ConfigManager.fallbackShrinkFactor.Value, shouldShrinkEnemyOrbs = ConfigManager.shouldShrinkEnemyOrbs.Value, shrinkEnemyOrbSmall = ConfigManager.shrinkEnemyOrbSmall.Value, shrinkEnemyOrbMedium = ConfigManager.shrinkEnemyOrbMedium.Value, shrinkEnemyOrbBig = ConfigManager.shrinkEnemyOrbBig.Value, shouldInstantKillEnemyInCart = ConfigManager.shouldInstantKillEnemyInCart.Value, shouldShrinkTiny = ConfigManager.shouldShrinkTiny.Value, shrinkFactorTiny = ConfigManager.shrinkFactorTiny.Value, shouldShrinkSmall = ConfigManager.shouldShrinkSmall.Value, shrinkFactorSmall = ConfigManager.shrinkFactorSmall.Value, shouldShrinkMedium = ConfigManager.shouldShrinkMedium.Value, shrinkFactorMedium = ConfigManager.shrinkFactorMedium.Value, shouldShrinkBig = ConfigManager.shouldShrinkBig.Value, shrinkFactorBig = ConfigManager.shrinkFactorBig.Value, shouldShrinkWide = ConfigManager.shouldShrinkWide.Value, shrinkFactorWide = ConfigManager.shrinkFactorWide.Value, shouldShrinkTall = ConfigManager.shouldShrinkTall.Value, shrinkFactorTall = ConfigManager.shrinkFactorTall.Value, shouldShrinkVeryTall = ConfigManager.shouldShrinkVeryTall.Value, shrinkFactorVeryTall = ConfigManager.shrinkFactorVeryTall.Value, shouldKeepShrunk = ConfigManager.shouldKeepShrunk.Value, shouldChangingMass = ConfigManager.shouldChangingMass.Value, shrinkMassValue = ConfigManager.shrinkMassValue.Value, shouldCartWeaponBatteryLifeInfinite = ConfigManager.shouldCartWeaponBatteryLifeInfinite.Value, shouldItemMeleeBatteryLifeInfinite = ConfigManager.shouldItemMeleeBatteryLifeInfinite.Value, shouldItemGunBatteryLifeInfinite = ConfigManager.shouldItemGunBatteryLifeInfinite.Value, shouldItemDroneBatteryLifeInfinite = ConfigManager.shouldItemDroneBatteryLifeInfinite.Value, shouldItemGenericBatteryLifeInfinite = ConfigManager.shouldItemGenericBatteryLifeInfinite.Value }; } public string ToJson() { return JsonUtility.ToJson((object)this); } public static void RefreshInstanceFromJson(string json) { lock (padlock) { instance = FromJson(json); } } private static StaticConfig FromJson(string json) { try { StaticConfig staticConfig = JsonUtility.FromJson<StaticConfig>(json); return staticConfig ?? new StaticConfig(); } catch (Exception ex) { LogWrapper.Error("❌ Erreur de désérialisation JSON : " + ex.Message); return new StaticConfig(); } } } } namespace SylhShrinkerCartPlus.Components { public class ShrinkableTracker : MonoBehaviour { public PhysGrabObject GrabObject; private float _shrinkSpeed; public PhysGrabObjectImpactDetector Detector; private readonly float _defaultProtectTimerValue = 3f; public PhysGrabCart CurrentCart { get; set; } public PhysGrabCart PreviousCart { get; set; } public bool IsShrunk { get; set; } = false; public bool IsShrinking { get; set; } = false; public bool IsExpanded { get; set; } = true; public bool IsExpanding { get; set; } = false; public float InitialMass { get; private set; } public Vector3 InitialScale { get; private set; } public Vector3 TargetScale { get; private set; } public bool CanResetBattery { get; set; } = false; public int BatteryLife { get; set; } = 0; public float InitialFragility { get; private set; } public float Fragility { get; private set; } public bool IsValidValuable { get; private set; } public float ProtectTimer { get; private set; } public bool IsInCart() { return (Object)(object)CurrentCart != (Object)null; } public bool IsInsideSameCart(PhysGrabCart otherCart) { return ((object)CurrentCart).Equals((object?)otherCart); } public void Init(PhysGrabObject owner) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) GrabObject = owner; IsValidValuable = IsValidShrinkableItem(); InitialScale = ((Component)owner).transform.localScale; InitialMass = owner.massOriginal; _shrinkSpeed = StaticConfig.Instance.defaultShrinkSpeed; InitBattery(); InitFragility(); InitProtectTimer(); } public void InitBattery() { if (HasBattery(out ItemBattery battery)) { int batteryLife = ((battery.batteryLife > 100f) ? 100 : ((int)battery.batteryLife)); BatteryLife = batteryLife; } } public void InitFragility() { Detector = ((Component)GrabObject).GetComponent<PhysGrabObjectImpactDetector>(); if (!((Object)(object)Detector == (Object)null)) { InitialFragility = Detector.fragility; Fragility = 0f; } } public void InitProtectTimer() { if (IsValidValuable) { ProtectTimer = _defaultProtectTimerValue; MakeUnbreakable(); } } public void MakeUnbreakable() { if (IsValidValuable) { Detector.fragility = Fragility; } } public void MakeBreakable() { if (IsValidValuable) { Detector.fragility = InitialFragility; } } private void Awake() { //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_004e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)GrabObject == (Object)null) { GrabObject = ((Component)this).GetComponent<PhysGrabObject>(); } if ((Object)(object)GrabObject != (Object)null && InitialScale == Vector3.zero) { InitialScale = ((Component)GrabObject).transform.localScale; } ShrinkTrackerManager.Instance.Register(this); } private void OnDestroy() { ShrinkTrackerManager.Instance.Unregister(this); } private void Update() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to