Decompiled source of CartDuplicator v1.2.1

CartDuplicator.dll

Decompiled a day ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CartDuplicator.Patches;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("CartDuplicator")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CartDuplicator")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c3dd3bd7-b7d1-4490-ad3d-0422f13bcbfd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CartDuplicator
{
	[BepInPlugin("Bocon.CartDuplicator", "Cart Duplicator", "1.2.0")]
	public class CartDuplicator : BaseUnityPlugin
	{
		private const string modGUID = "Bocon.CartDuplicator";

		private const string modeName = "Cart Duplicator";

		private const string modVersion = "1.2.0";

		private readonly Harmony harmony = new Harmony("Bocon.CartDuplicator");

		private static CartDuplicator Instance;

		internal ManualLogSource mls;

		private ConfigEntry<Vector3> duplicationOffset;

		private ConfigEntry<int> duplicationAmount;

		private void Awake()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Bocon.CartDuplicator");
			duplicationOffset = ((BaseUnityPlugin)this).Config.Bind<Vector3>("General", "DuplicationOffset", new Vector3(2f, 0f, 0f), "Offset for the duplicated cart position");
			duplicationAmount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "DuplicationAmount", 1, "Number of additional carts to duplicate");
			mls.LogInfo((object)"Cart Duplicator Mod Loaded");
			harmony.PatchAll(typeof(CartDuplicator));
			harmony.PatchAll(typeof(DuplicateCartPatch));
		}

		public static Vector3 GetDuplicationOffset()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return Instance.duplicationOffset.Value;
		}

		public static int GetDuplicationAmount()
		{
			return Instance.duplicationAmount.Value;
		}
	}
}
namespace CartDuplicator.Patches
{
	[HarmonyPatch(typeof(PunManager))]
	[HarmonyPatch("SpawnItem")]
	public class DuplicateCartPatch : MonoBehaviourPunCallbacks
	{
		[HarmonyPostfix]
		public static void After_SpawnItem(Item item, ItemVolume volume)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)item == (Object)null || (Object)(object)volume == (Object)null || item.itemAssetName != "Item Cart Medium")
			{
				return;
			}
			int duplicationAmount = CartDuplicator.GetDuplicationAmount();
			Vector3 duplicationOffset = CartDuplicator.GetDuplicationOffset();
			if (PhotonNetwork.IsConnected && PhotonNetwork.IsMasterClient)
			{
				for (int i = 0; i < duplicationAmount; i++)
				{
					PhotonNetwork.InstantiateRoomObject("Items/" + ((Object)item.prefab).name, ((Component)volume).transform.position + duplicationOffset * (float)(i + 1), item.spawnRotationOffset, (byte)0, (object[])null);
				}
			}
			else if (!PhotonNetwork.IsConnected)
			{
				for (int j = 0; j < duplicationAmount; j++)
				{
					Object.Instantiate<GameObject>(item.prefab, ((Component)volume).transform.position + duplicationOffset * (float)(j + 1), item.spawnRotationOffset);
				}
			}
		}

		public override void OnEnable()
		{
			((MonoBehaviourPunCallbacks)this).OnEnable();
			Debug.Log((object)"Cart Duplicator: Patch enabled");
		}
	}
}