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 CloverPitValuables v1.2.0
CloverPitValuablesScripts.dll
Decompiled 3 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; using UnityEngine.Events; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("LORAY")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CloverPitValuablesScripts")] [assembly: AssemblyTitle("CloverPitValuablesScripts")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.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 CloverPitValuablesScripts { public class CartSpawnOnBreakBehaviour : MonoBehaviour { public enum CartSize { Small, Medium, Big } [SerializeField] private CartSize cartSize = CartSize.Small; private const string SmallPath = "items/Item Cart Small"; private const string MediumPath = "items/Item Cart Medium"; private bool spawned; private void Start() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown PhysGrabObjectImpactDetector component = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>(); if (component != null) { component.onDestroy.AddListener(new UnityAction(SpawnCart)); } } private void SpawnCart() { //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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) if (!spawned && SemiFunc.IsMasterClientOrSingleplayer()) { spawned = true; Vector3 position = ((Component)this).transform.position; CapsuleCollider componentInChildren = ((Component)PlayerController.instance).GetComponentInChildren<CapsuleCollider>(); float num = (((Object)(object)componentInChildren != (Object)null) ? componentInChildren.height : 1.8f); float num2 = ((Component)PlayerController.instance).transform.position.y + num * 0.5f; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(position.x, num2, position.z); Vector3 val2 = val - ((Component)PlayerController.instance).transform.position; val2.y = 0f; Quaternion rotation = ((val2 != Vector3.zero) ? Quaternion.LookRotation(val2) : Quaternion.identity); if (cartSize == CartSize.Big) { SpawnOne("items/Item Cart Medium", val + Vector3.left, rotation); SpawnOne("items/Item Cart Medium", val + Vector3.right, rotation); } else { SpawnOne((cartSize == CartSize.Small) ? "items/Item Cart Small" : "items/Item Cart Medium", val, rotation); } } } private void SpawnOne(string path, Vector3 position, Quaternion rotation) { //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_0018: 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) if (GameManager.instance.gameMode == 0) { Object.Instantiate<GameObject>(Resources.Load<GameObject>(path), position, rotation); } else { PhotonNetwork.InstantiateRoomObject(path, position, rotation, (byte)0, (object[])null); } } } [BepInPlugin("LORAY.CloverPitValuablesScripts", "CloverPitValuablesScripts", "1.0.0")] public class CloverPitValuablesScripts : BaseUnityPlugin { internal static CloverPitValuablesScripts Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); } internal void Patch() { //IL_001a: 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_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } public class GoldenFruitBehaviour : MonoBehaviour { [SerializeField] [Tooltip("The regular fruit prefab name that this golden fruit multiplies the value of (e.g., 'ValuableLemon')")] private string? affectedFruitPrefabName; [SerializeField] [Tooltip("The value multiplier for affected fruits (default: 2 = doubles the value)")] private float valueMultiplier = 2f; [SerializeField] [Tooltip("Optional sound to play when a fruit's value is multiplied")] private readonly AudioClip? multiplierSound = null; [SerializeField] [Tooltip("Optional sound to play once when all fruit values are restored")] private readonly AudioClip? restoreSound = null; private AudioSource? audioSource; private static readonly HashSet<GameObject> fruitsBeingApplied = new HashSet<GameObject>(); private static readonly HashSet<GameObject> fruitsCurrentlyShaking = new HashSet<GameObject>(); private string? thisGoldenFruitName; private readonly HashSet<GameObject> multipliedFruits = new HashSet<GameObject>(); private bool isApplyingMultiplier = false; private static float currentPitch = 1f; private static float currentDelay = 0.5f; private static int delayDecreseCount = 0; private void Awake() { thisGoldenFruitName = ((Object)((Component)this).gameObject).name.Replace("(Clone)", "").Trim(); audioSource = ((Component)this).gameObject.AddComponent<AudioSource>(); audioSource.playOnAwake = false; if (string.IsNullOrEmpty(affectedFruitPrefabName) && thisGoldenFruitName.Contains("Golden ")) { affectedFruitPrefabName = thisGoldenFruitName.Replace("Golden ", ""); } } private void Start() { ((MonoBehaviour)this).StartCoroutine(MonitorExtractionPoint()); } private IEnumerator MonitorExtractionPoint() { yield return null; while ((Object)(object)((Component)this).gameObject != (Object)null) { UpdateMultipliers(); yield return (object)new WaitForSeconds(0.2f); } } private void UpdateMultipliers() { //IL_0122: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(affectedFruitPrefabName) || RoundDirector.instance?.dollarHaulList == null) { return; } if (!RoundDirector.instance.dollarHaulList.Contains(((Component)this).gameObject)) { if (multipliedFruits.Count > 0) { RestoreAllMultipliedFruits(); } return; } List<GameObject> list = new List<GameObject>(); list.AddRange(from item in RoundDirector.instance.dollarHaulList where (Object)(object)item != (Object)null && (Object)(object)item != (Object)(object)((Component)this).gameObject where ((Object)item).name.Replace("(Clone)", "").Trim() == affectedFruitPrefabName select item); List<GameObject> currentMatchingFruits = list; List<GameObject> list2 = new List<GameObject>(); list2.AddRange(multipliedFruits.Where((GameObject fruit) => !currentMatchingFruits.Contains(fruit))); List<GameObject> list3 = list2; if ((Object)(object)restoreSound != (Object)null && list3.Count > 0 && !fruitsCurrentlyShaking.Contains(list3[0])) { AudioSource.PlayClipAtPoint(restoreSound, list3[0].transform.position); } foreach (GameObject item in list3) { RestoreMultipliedFruit(item); Rigidbody component = item.GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null && fruitsCurrentlyShaking.Add(item)) { ((MonoBehaviour)this).StartCoroutine(ShakeFruitCoroutine(component)); } currentPitch = Mathf.Max(currentPitch - 0.1f, 1f); delayDecreseCount = 0; } foreach (GameObject item2 in currentMatchingFruits) { if (!multipliedFruits.Contains(item2) && !isApplyingMultiplier && !fruitsBeingApplied.Contains(item2)) { ((MonoBehaviour)this).StartCoroutine(ApplyMultiplierCoroutine(item2)); } } } private void ApplyMultiplier(GameObject targetFruit) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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) if ((Object)(object)targetFruit == (Object)null) { return; } ValuableObject component = targetFruit.GetComponent<ValuableObject>(); if (!((Object)(object)component == (Object)null)) { multipliedFruits.Add(targetFruit); component.dollarValueOriginal *= valueMultiplier; component.dollarValueCurrent *= valueMultiplier; component.dollarValueOverride = (int)((float)component.dollarValueOverride * valueMultiplier); Rigidbody component2 = targetFruit.GetComponent<Rigidbody>(); if ((Object)(object)component2 != (Object)null) { component2.velocity += Vector3.up * 3f; ((MonoBehaviour)this).StartCoroutine(SpinFruitCoroutine(component2)); } } } private IEnumerator SpinFruitCoroutine(Rigidbody rb) { Rigidbody rb2 = rb; PhysGrabObject physGrabObject = ((Component)rb2).GetComponent<PhysGrabObject>(); if (((Object)(object)physGrabObject == (Object)null || !physGrabObject.grabbed) && Mathf.Abs(rb2.velocity.x) < 1f && Mathf.Abs(rb2.velocity.z) < 1f) { Rigidbody obj = rb2; obj.constraints = (RigidbodyConstraints)(obj.constraints | 0xA); } rb2.angularVelocity = new Vector3(Random.Range(-20f, 20f), 0f, Random.Range(-20f, 20f)); yield return (object)new WaitForFixedUpdate(); yield return (object)new WaitUntil((Func<bool>)delegate { //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) int result; if (!((Object)(object)rb2 == (Object)null)) { Vector3 velocity = rb2.velocity; result = ((((Vector3)(ref velocity)).magnitude < 0.5f) ? 1 : 0); } else { result = 1; } return (byte)result != 0; }); if ((Object)(object)rb2 != (Object)null) { Rigidbody obj2 = rb2; obj2.constraints = (RigidbodyConstraints)(obj2.constraints & -11); rb2.angularVelocity = Vector3.zero; } } private void PlayClipAtPositionWithPitch(AudioClip clip, Vector3 position, float pitch) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("TempAudio"); val.transform.position = position; AudioSource val2 = val.AddComponent<AudioSource>(); val2.clip = clip; val2.pitch = pitch; val2.volume = 0.6f; val2.Play(); Object.Destroy((Object)(object)val, clip.length / pitch + 0.1f); } private IEnumerator ApplyMultiplierCoroutine(GameObject fruit) { isApplyingMultiplier = true; fruitsBeingApplied.Add(fruit); ApplyMultiplier(fruit); if ((Object)(object)multiplierSound != (Object)null) { PlayClipAtPositionWithPitch(multiplierSound, fruit.transform.position, currentPitch); if (currentPitch < 1.5f) { currentPitch = Mathf.Min(currentPitch + 0.1f, 1.5f); } else if (delayDecreseCount == 1) { delayDecreseCount = 0; currentDelay = Mathf.Max(currentDelay - 0.05f, 0.2f); } else { delayDecreseCount++; } yield return (object)new WaitForSeconds(currentDelay); } fruitsBeingApplied.Remove(fruit); isApplyingMultiplier = false; } private void RestoreMultipliedFruit(GameObject targetFruit) { if (!((Object)(object)targetFruit == (Object)null) && multipliedFruits.Contains(targetFruit)) { multipliedFruits.Remove(targetFruit); ValuableObject component = targetFruit.GetComponent<ValuableObject>(); if (!((Object)(object)component == (Object)null)) { component.dollarValueOriginal /= valueMultiplier; component.dollarValueCurrent /= valueMultiplier; component.dollarValueOverride = (int)((float)component.dollarValueOverride / valueMultiplier); } } } private IEnumerator ShakeFruitCoroutine(Rigidbody rb) { PhysGrabObject physGrabObject = ((Component)rb).GetComponent<PhysGrabObject>(); if (((Object)(object)physGrabObject == (Object)null || !physGrabObject.grabbed) && Mathf.Abs(rb.velocity.x) < 1f && Mathf.Abs(rb.velocity.z) < 1f) { rb.constraints = (RigidbodyConstraints)(rb.constraints | 0xA); } float elapsed = 0f; float duration = 0.6f; float shakeSpeed = 30f; float shakeStrength = 12f; while (elapsed < duration) { rb.angularVelocity = new Vector3(0f, 0f, Mathf.Sin(elapsed * shakeSpeed) * shakeStrength); elapsed += Time.deltaTime; yield return null; } rb.angularVelocity = Vector3.zero; rb.constraints = (RigidbodyConstraints)(rb.constraints & -11); fruitsCurrentlyShaking.Remove(((Component)rb).gameObject); } private void RestoreAllMultipliedFruits() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) HashSet<GameObject> hashSet = multipliedFruits; List<GameObject> list = new List<GameObject>(hashSet.Count); list.AddRange(hashSet); List<GameObject> list2 = list; if ((Object)(object)restoreSound != (Object)null && list2.Count > 0 && !fruitsCurrentlyShaking.Contains(list2[0])) { AudioSource.PlayClipAtPoint(restoreSound, list2[0].transform.position); } foreach (GameObject item in list2) { RestoreMultipliedFruit(item); Rigidbody component = item.GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null && fruitsCurrentlyShaking.Add(item)) { ((MonoBehaviour)this).StartCoroutine(ShakeFruitCoroutine(component)); } } multipliedFruits.Clear(); currentPitch = 1f; currentDelay = 0.5f; } public void SetAffectedFruitPrefabName(string prefabName) { affectedFruitPrefabName = prefabName; } public void SetValueMultiplier(float multiplier) { valueMultiplier = multiplier; } } } namespace CloverPitBriefcaseBehaviour { public class BriefcaseComponent : MonoBehaviour { private ValuableObject? valuableObject; private void Awake() { valuableObject = ((Component)this).GetComponent<ValuableObject>(); } private void Start() { ((MonoBehaviour)this).StartCoroutine(SetValue()); } private IEnumerator SetValue() { while ((Object)(object)ValuableDirector.instance == (Object)null || !ValuableDirector.instance.setupComplete || (Object)(object)RoundDirector.instance == (Object)null || RoundDirector.instance.haulGoal == 0 || RoundDirector.instance.extractionPoints == 0) { yield return (object)new WaitForSeconds(0.1f); } float thirtyPercent = (float)(RoundDirector.instance.haulGoal / RoundDirector.instance.extractionPoints) * 0.3f; if ((Object)(object)valuableObject != (Object)null) { valuableObject.dollarValueOverride = (int)thirtyPercent; valuableObject.dollarValueCurrent = thirtyPercent; valuableObject.dollarValueOriginal = thirtyPercent; } } } }