using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib; using REPOLib.Modules; using REPOLib.Objects.Sdk; using UnityEngine; using com.github.zehsteam.DestructibleDrone.Extensions; using com.github.zehsteam.DestructibleDrone.Helpers; using com.github.zehsteam.DestructibleDrone.Managers; using com.github.zehsteam.DestructibleDrone.MonoBehaviours; using com.github.zehsteam.DestructibleDrone.Objects; using com.github.zehsteam.DestructibleDrone.Patches; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Zehs")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2026 Zehs")] [assembly: AssemblyDescription("Adds a new drone that's the opposite of an indestructible drone. This drone gives a higher reward but at an even higher risk.")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0+4bd23167a834f530d5f05fbe976af69f6044349d")] [assembly: AssemblyProduct("DestructibleDrone")] [assembly: AssemblyTitle("com.github.zehsteam.DestructibleDrone")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.0.0")] [module: UnverifiableCode] [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 com.github.zehsteam.DestructibleDrone { internal static class Logger { public static ManualLogSource ManualLogSource { get; private set; } public static void Initialize(ManualLogSource manualLogSource) { ManualLogSource = manualLogSource; } public static void LogDebug(object data) { Log((LogLevel)32, data); } public static void LogInfo(object data, bool extended = false) { Log((LogLevel)16, data, extended); } public static void LogMessage(object data, bool extended = false) { Log((LogLevel)8, data, extended); } public static void LogWarning(object data, bool extended = false) { Log((LogLevel)4, data, extended); } public static void LogError(object data, bool extended = false) { Log((LogLevel)2, data, extended); } public static void LogFatal(object data, bool extended = false) { Log((LogLevel)1, data, extended); } public static void Log(LogLevel logLevel, object data, bool extended = false) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!extended || IsExtendedLoggingEnabled()) { ManualLogSource manualLogSource = ManualLogSource; if (manualLogSource != null) { manualLogSource.Log(logLevel, data); } } } public static bool IsExtendedLoggingEnabled() { return ConfigManager.ExtendedLogging?.Value ?? false; } } [BepInPlugin("com.github.zehsteam.DestructibleDrone", "DestructibleDrone", "1.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("com.github.zehsteam.DestructibleDrone"); internal static Plugin Instance { get; private set; } private void Awake() { Instance = this; Logger.Initialize(Logger.CreateLogSource("com.github.zehsteam.DestructibleDrone")); Logger.LogInfo("DestructibleDrone has awoken!"); _harmony.PatchAll(typeof(ValuableDirector_Patches)); _harmony.PatchAll(typeof(PhysGrabObject_Patches)); ConfigManager.Initialize(((BaseUnityPlugin)this).Config); string text = Path.Combine(Utils.GetPluginDirectory(), "destructibledrone_assets"); BundleLoader.LoadBundle(text, (Action)delegate(AssetBundle assetBundle) { ItemContent val = assetBundle.LoadAsset("Drone Destructible Item"); Items.RegisterItem(val); }, false); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.zehsteam.DestructibleDrone"; public const string PLUGIN_NAME = "DestructibleDrone"; public const string PLUGIN_VERSION = "1.3.0"; } } namespace com.github.zehsteam.DestructibleDrone.Patches { [HarmonyPatch(typeof(PhysGrabObject))] internal static class PhysGrabObject_Patches { [HarmonyPatch("OverrideTimersTick")] [HarmonyPostfix] private static void OverrideTimersTick_Patch(PhysGrabObject __instance) { if (!__instance.IsDestructible()) { ItemDroneDestructible.DecreasePhysGrabObjectValue(__instance); } } [HarmonyPatch("OverrideIndestructible")] [HarmonyPrefix] private static bool OverrideIndestructible_Patch(PhysGrabObject __instance) { if (__instance.IsDestructible()) { return false; } return true; } } [HarmonyPatch(typeof(ValuableDirector))] internal static class ValuableDirector_Patches { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] private static void SetupHost_Patch() { ItemDroneDestructible.ResetDestructibleDataList(); } } } namespace com.github.zehsteam.DestructibleDrone.Objects { public class DestructibleData { private float _currentValueMultiplier; public PhysGrabObject PhysGrabObject { get; private set; } public ValuableObject ValuableObject { get; private set; } public float TimeSinceDestructible { get; set; } = float.NegativeInfinity; public bool IsValueOverwritten { get; private set; } public static float ValueMultiplier => GetValueMultiplier(); public static float FragilityMultiplier => GetFragilityMultiplier(); public DestructibleData(PhysGrabObject physGrabObject) { if (!((Object)(object)physGrabObject == (Object)null)) { PhysGrabObject = physGrabObject; ValuableObject = ((Component)physGrabObject).GetComponent(); _currentValueMultiplier = ValueMultiplier; } } public void UpdateTimeSinceDestructible() { TimeSinceDestructible = Time.realtimeSinceStartup; } public bool IsDestructible() { return Time.realtimeSinceStartup - TimeSinceDestructible <= 0.1f; } public void IncreaseValue() { if (!((Object)(object)ValuableObject == (Object)null) && SemiFunc.IsMasterClientOrSingleplayer() && !IsValueOverwritten) { IsValueOverwritten = true; _currentValueMultiplier = ValueMultiplier; float dollarValueCurrent = ValuableObject.dollarValueCurrent; dollarValueCurrent *= _currentValueMultiplier; ValuableObject.SetDollarValue(dollarValueCurrent); } } public void DecreaseValue() { if (!((Object)(object)ValuableObject == (Object)null) && SemiFunc.IsMasterClientOrSingleplayer() && IsValueOverwritten) { IsValueOverwritten = false; float dollarValueCurrent = ValuableObject.dollarValueCurrent; dollarValueCurrent /= _currentValueMultiplier; ValuableObject.SetDollarValue(dollarValueCurrent); } } private static float GetValueMultiplier() { if (ConfigManager.ValueMultiplier == null) { return 3f; } return ConfigManager.ValueMultiplier.Value; } private static float GetFragilityMultiplier() { if (ConfigManager.FragilityMultiplier == null) { return 100f; } return ConfigManager.FragilityMultiplier.Value; } } } namespace com.github.zehsteam.DestructibleDrone.MonoBehaviours { public class ItemDroneDestructible : MonoBehaviour { private ItemDrone _itemDrone; private PhysGrabObject _myPhysGrabObject; private ItemEquippable _itemEquippable; private PhysGrabObject _previousMagnetTargetPhysGrabObject; public static Dictionary DestructibleDataList { get; private set; } = new Dictionary(); private void Start() { _itemDrone = ((Component)this).GetComponent(); _myPhysGrabObject = ((Component)this).GetComponent(); _itemEquippable = ((Component)this).GetComponent(); } private void Update() { if (!SemiFunc.IsMasterClientOrSingleplayer() || _itemEquippable.isEquipped || !_itemDrone.itemActivated) { return; } _myPhysGrabObject.OverrideZeroGravity(0.1f); _myPhysGrabObject.OverrideDrag(1f, 0.1f); _myPhysGrabObject.OverrideAngularDrag(10f, 0.1f); PhysGrabObject magnetTargetPhysGrabObject = _itemDrone.magnetTargetPhysGrabObject; if ((Object)(object)magnetTargetPhysGrabObject == (Object)null || (Object)(object)magnetTargetPhysGrabObject.impactDetector == (Object)null) { _previousMagnetTargetPhysGrabObject = null; } if (!_itemDrone.magnetActive) { return; } if ((Object)(object)magnetTargetPhysGrabObject != (Object)(object)_previousMagnetTargetPhysGrabObject) { _previousMagnetTargetPhysGrabObject = magnetTargetPhysGrabObject; if (!CanAttachDroneToObject(magnetTargetPhysGrabObject)) { _itemDrone.ForceTurnOff(); _itemDrone.DeactivateMagnet(); return; } } if (magnetTargetPhysGrabObject.IsMassOrDragOverwritten()) { _itemDrone.ForceTurnOff(); _itemDrone.DeactivateMagnet(); } else { SetDestructible(magnetTargetPhysGrabObject); } } private static bool CanAttachDroneToObject(PhysGrabObject physGrabObject) { if ((Object)(object)physGrabObject == (Object)null || (Object)(object)physGrabObject.impactDetector == (Object)null) { return false; } if (physGrabObject.impactDetector.inCart) { return false; } if (physGrabObject.grabbed) { return false; } if (physGrabObject.IsMassOrDragOverwritten()) { return false; } SurplusValuable val = default(SurplusValuable); if (((Component)physGrabObject).TryGetComponent(ref val)) { return false; } return true; } public static void ResetDestructibleDataList() { DestructibleDataList.Clear(); } public static void SetDestructible(PhysGrabObject physGrabObject) { if (!((Object)(object)physGrabObject == (Object)null) && TryGetOrCreateDestructibleData(physGrabObject, out var destructibleData)) { destructibleData.UpdateTimeSinceDestructible(); physGrabObject.OverrideFragility(DestructibleData.FragilityMultiplier); IncreasePhysGrabObjectValue(physGrabObject); } } public static void IncreasePhysGrabObjectValue(PhysGrabObject physGrabObject) { if (!((Object)(object)physGrabObject == (Object)null) && TryGetOrCreateDestructibleData(physGrabObject, out var destructibleData)) { destructibleData.IncreaseValue(); } } public static void DecreasePhysGrabObjectValue(PhysGrabObject physGrabObject) { if (!((Object)(object)physGrabObject == (Object)null) && TryGetOrCreateDestructibleData(physGrabObject, out var destructibleData)) { destructibleData.DecreaseValue(); } } public static bool TryGetDestructibleData(PhysGrabObject physGrabObject, out DestructibleData destructibleData) { if ((Object)(object)physGrabObject == (Object)null) { destructibleData = null; return false; } return DestructibleDataList.TryGetValue(physGrabObject, out destructibleData); } public static bool TryGetOrCreateDestructibleData(PhysGrabObject physGrabObject, out DestructibleData destructibleData) { if ((Object)(object)physGrabObject == (Object)null) { destructibleData = null; return false; } if (TryGetDestructibleData(physGrabObject, out destructibleData)) { return true; } destructibleData = new DestructibleData(physGrabObject); DestructibleDataList[physGrabObject] = destructibleData; return true; } } } namespace com.github.zehsteam.DestructibleDrone.Managers { internal static class ConfigManager { public static ConfigFile ConfigFile { get; private set; } public static ConfigEntry ExtendedLogging { get; private set; } public static ConfigEntry ValueMultiplier { get; private set; } public static ConfigEntry FragilityMultiplier { get; private set; } public static void Initialize(ConfigFile configFile) { ConfigFile = configFile; BindConfigs(); } private static void BindConfigs() { ExtendedLogging = ConfigFile.Bind("General", "ExtendedLogging", false, "Enable extended logging."); ValueMultiplier = ConfigFile.Bind("Destructible Drone", "ValueMultiplier", 3f, "The value multiplier for destructible valuables.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 10f)); FragilityMultiplier = ConfigFile.Bind("Destructible Drone", "FragilityMultiplier", 100f, "The fragility multiplier for destructible valuables.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 100f)); } } } namespace com.github.zehsteam.DestructibleDrone.Helpers { internal static class Utils { public static string GetPluginDirectory() { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } } } namespace com.github.zehsteam.DestructibleDrone.Extensions { internal static class ConfigFileExtensions { public static ConfigEntry Bind(this ConfigFile configFile, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown return configFile.Bind(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty())); } } public static class PhysGrabObjectExtensions { public static bool IsDestructible(this PhysGrabObject physGrabObject) { if ((Object)(object)physGrabObject == (Object)null) { return false; } if (!ItemDroneDestructible.TryGetDestructibleData(physGrabObject, out var destructibleData)) { return false; } return destructibleData.IsDestructible(); } public static bool IsMassOrDragOverwritten(this PhysGrabObject physGrabObject) { if ((Object)(object)physGrabObject == (Object)null) { return false; } if (physGrabObject.overrideMassGoDownTimer > 0f) { return true; } if (physGrabObject.overrideDragGoDownTimer > 0f) { return true; } return false; } } internal static class ValuableObjectExtensions { public static void SetDollarValue(this ValuableObject valuableObject, float value) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)valuableObject == (Object)null) && SemiFunc.IsMasterClientOrSingleplayer()) { if (SemiFunc.IsMultiplayer()) { valuableObject.photonView.RPC("DollarValueSetRPC", (RpcTarget)0, new object[1] { value }); } else { valuableObject.DollarValueSetRPC(value, default(PhotonMessageInfo)); } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }