Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of WorthALittle v1.0.0
WorthALittle.dll
Decompiled 5 days agousing System; using System.Diagnostics; 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 UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: AssemblyCompany("Catburger")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Makes objects torn off their hinges valuable!")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9e451ff20550737991e9024d7ac761d601d99fad")] [assembly: AssemblyProduct("Worth a little")] [assembly: AssemblyTitle("WorthALittle")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 WorthALittle { [BepInPlugin("WorthALittle", "Worth a little", "1.0.0")] public class WorthALittle : BaseUnityPlugin { public readonly ConfigEntry<float> Multiplier; public readonly ConfigEntry<bool> DoRange; public readonly ConfigEntry<bool> Stackable; public readonly ConfigEntry<int> MinValue; public readonly ConfigEntry<int> MaxValue; internal static WorthALittle Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } public WorthALittle() { Multiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Value multiplier", 1f, "Feel free to make it worthalot!!"); Stackable = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Halloween stackable", false, "Determines if the valuables count in stacking"); DoRange = ((BaseUnityPlugin)this).Config.Bind<bool>("Bounds", "Enable clamp between min and max", true, "Determines if the values below are actually used"); MinValue = ((BaseUnityPlugin)this).Config.Bind<int>("Bounds", "Minimum valuable value", 100, "The minimum cost a valuable *something* can generate at."); MaxValue = ((BaseUnityPlugin)this).Config.Bind<int>("Bounds", "Maximum valuable value", 5000, "The maximum cost a valuable *something* can generate at."); } private void Awake() { //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_001b: Expected O, but got Unknown //IL_0020: Expected O, but got Unknown Instance = this; if (Harmony == null) { Harmony val = new Harmony("at.kibbyc.WorthALittle"); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(typeof(WorthALittle)); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } [HarmonyPatch(typeof(PhysGrabHinge), "Awake")] [HarmonyPostfix] public static void EntryPointMaybe(PhysGrabHinge __instance) { ((Component)__instance).gameObject.AddComponent<WorthALittleMore>(); } [HarmonyPatch(typeof(PhysGrabHinge), "OnJointBreak")] [HarmonyPostfix] public static void Break(PhysGrabHinge __instance) { ((Component)__instance).GetComponent<WorthALittleMore>().MakeValuable(); } [HarmonyPatch(typeof(ValuableObject), "Awake")] [HarmonyPostfix] public static void MaybeDisableHalloweenStacking(ValuableObject __instance) { WorthALittleMore worthALittleMore = default(WorthALittleMore); ExtractionHalloweenContact val = default(ExtractionHalloweenContact); if (!Instance.Stackable.Value && ((Component)__instance).gameObject.TryGetComponent<WorthALittleMore>(ref worthALittleMore) && ((Component)__instance).TryGetComponent<ExtractionHalloweenContact>(ref val)) { ((Behaviour)val).enabled = false; } } public static void SetBrokenHingeValuable(PhysGrabHinge? hinge) { if (!Object.op_Implicit((Object)(object)hinge)) { Logger.LogError((object)"hinge object is null, cant continue."); return; } GameObject gameObject = ((Component)hinge).gameObject; Logger.LogInfo((object)("Object \"" + ((Object)gameObject).name + "\" has been broken off its hinge, making valuable!")); PhysGrabObject val = default(PhysGrabObject); if (!gameObject.TryGetComponent<PhysGrabObject>(ref val)) { Logger.LogError((object)"physGrab is null, cant continue."); return; } NotValuableObject val2 = default(NotValuableObject); if (!gameObject.TryGetComponent<NotValuableObject>(ref val2)) { Logger.LogError((object)"NotValuable is null, cant continue."); return; } PhysGrabObjectImpactDetector impactDetector = default(PhysGrabObjectImpactDetector); if (!gameObject.TryGetComponent<PhysGrabObjectImpactDetector>(ref impactDetector)) { Logger.LogError((object)"ImpactDetector is null, cant continue."); return; } DisableHingeAudioSource(hinge); SetPhysGrabValues(val); ValuableObject valuableALittle = SetValuableObject(gameObject, val, val2); SetImpactDetectorValues(impactDetector, valuableALittle); Object.Destroy((Object)(object)gameObject.GetComponent<HingeJoint>()); Object.Destroy((Object)(object)hinge); Object.Destroy((Object)(object)val2); } private static void DisableHingeAudioSource(PhysGrabHinge instance) { if (!Object.op_Implicit((Object)(object)instance.audioSource)) { Logger.LogInfo((object)"The hinge object doesnt have a audiosource to disable"); return; } AudioLowPassLogic val = default(AudioLowPassLogic); if (((Component)instance.audioSource).gameObject.TryGetComponent<AudioLowPassLogic>(ref val)) { ((Behaviour)val).enabled = false; } if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.AudioLowpassFilter)) { ((Behaviour)val.AudioLowpassFilter).enabled = false; } ((Behaviour)instance.audioSource).enabled = false; } private static void SetPhysGrabValues(PhysGrabObject physGrab) { physGrab.isNonValuable = false; physGrab.isValuable = true; physGrab.hinge = null; physGrab.hasHinge = false; physGrab.hasNeverBeenGrabbed = true; } private static ValuableObject SetValuableObject(GameObject worthALittle, PhysGrabObject physGrab, NotValuableObject notValuable) { ValuableObject obj = worthALittle.AddComponent<ValuableObject>(); float num = physGrab.massOriginal * physGrab.massOriginal * Instance.Multiplier.Value; num = (int)Mathf.Round(num) * 100; if (Instance.DoRange.Value) { num = Mathf.Clamp(num, (float)Instance.MinValue.Value, (float)Instance.MaxValue.Value); } obj.dollarValueOverride = (int)num; obj.durabilityPreset = notValuable.durabilityPreset; obj.particleColors = notValuable.particleColors; obj.audioPreset = notValuable.audioPreset; obj.audioPresetPitch = notValuable.audioPresetPitch; obj.physAttributePreset = notValuable.physAttributePreset; return obj; } private static void SetImpactDetectorValues(PhysGrabObjectImpactDetector impactDetector, ValuableObject valuableALittle) { impactDetector.isHinge = false; impactDetector.isBrokenHinge = false; impactDetector.isValuable = true; impactDetector.valuableObject = valuableALittle; } } public class WorthALittleMore : MonoBehaviour { private PhotonView? _view; private PhysGrabHinge? _grabHinge; private bool _madeValuable; private void Awake() { _view = ((Component)this).GetComponent<PhotonView>(); _grabHinge = ((Component)this).GetComponent<PhysGrabHinge>(); } public void MakeValuable() { if (_madeValuable) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView? view = _view; if (view != null) { view.RPC("SetBrokenHingeValuable", (RpcTarget)0, Array.Empty<object>()); } } else { SetBrokenHingeValuable(); } _madeValuable = true; } [PunRPC] private void SetBrokenHingeValuable() { WorthALittle.SetBrokenHingeValuable(_grabHinge); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "WorthALittle"; public const string PLUGIN_NAME = "Worth a little"; public const string PLUGIN_VERSION = "1.0.0"; } }