using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using CruiserCourier.Patches;
using HarmonyLib;
using Unity.Netcode;
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("CruiserCourier")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CruiserCourier")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("04db65a9-a0d5-4ffd-a53b-1c22f862d268")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CruiserCourier
{
[BepInPlugin("rogan.CruiserCourier", "Cruiser Courier", "2.0.1")]
public class CruiserCourierBase : BaseUnityPlugin
{
private const string modGUID = "rogan.CruiserCourier";
private const string modName = "Cruiser Courier";
private const string modVersion = "2.0.1";
private readonly Harmony harmony = new Harmony("rogan.CruiserCourier");
private static CruiserCourierBase Instance;
internal static ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("rogan.CruiserCourier");
mls.LogInfo((object)"CruiserCourier Started!");
harmony.PatchAll(typeof(CruiserCourierBase));
harmony.PatchAll(typeof(MagnetPatch));
harmony.PatchAll(typeof(VehicleSpawnPatch));
harmony.PatchAll(typeof(VehiclePrefabPatch));
harmony.PatchAll(typeof(VehicleControllerPatch));
harmony.PatchAll(typeof(VehicleControllerPatch));
}
}
}
namespace CruiserCourier.Patches
{
[HarmonyPatch(typeof(Terminal))]
internal class VehiclePrefabPatch
{
public static GameObject VehiclePrefab;
public static GameObject SecondaryPrefab;
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void BuyableVehiclesPatch(ref BuyableVehicle[] ___buyableVehicles)
{
if (Object.op_Implicit((Object)(object)VehiclePrefab))
{
return;
}
BuyableVehicle[] array = ___buyableVehicles;
foreach (BuyableVehicle val in array)
{
if (val.vehicleDisplayName == "Cruiser")
{
VehiclePrefab = val.vehiclePrefab;
SecondaryPrefab = val.secondaryPrefab;
}
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class MagnetPatch
{
[HarmonyPatch("StartGame")]
[HarmonyPostfix]
private static void SetMagnetPatch(ref bool ___magnetOn, ref AnimatedObjectTrigger ___magnetLever)
{
if (GameNetworkManager.Instance.isHostingGame && !___magnetOn)
{
___magnetLever.TriggerAnimation(StartOfRound.Instance.localPlayerController);
}
}
}
[HarmonyPatch(typeof(VehicleController))]
public static class VehicleControllerPatch
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
internal static void StartPostfixPatch(VehicleController __instance)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
__instance.mainRigidbody.MovePosition(((Component)__instance).transform.position);
__instance.hasBeenSpawned = true;
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class VehicleSpawnPatch
{
[HarmonyPatch("StartGame")]
[HarmonyPostfix]
private static void SpawnCruiserPatch(ref Transform ___magnetPoint, ref bool ___isObjectAttachedToMagnet)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: 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)
if (GameNetworkManager.Instance.isHostingGame && !___isObjectAttachedToMagnet && Object.op_Implicit((Object)(object)VehiclePrefabPatch.VehiclePrefab))
{
Object.Instantiate<GameObject>(VehiclePrefabPatch.VehiclePrefab, ___magnetPoint.position, Quaternion.Euler(0f, -90f, 0f), RoundManager.Instance.VehiclesContainer).GetComponent<NetworkObject>().Spawn(false);
Object.Instantiate<GameObject>(VehiclePrefabPatch.SecondaryPrefab, ___magnetPoint.position, Quaternion.Euler(0f, -90f, 0f), RoundManager.Instance.VehiclesContainer).GetComponent<NetworkObject>().Spawn(false);
}
}
}
}