using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using CruiserMap.Patches;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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("RadiationIsCool")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RadiationIsCool")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8ee335db-0cbe-470c-8fbc-69263f01b35a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace CruiserMap
{
[BepInPlugin("Piggy.CruiserMap", "CruiserMap", "1.0.5")]
public class Plugin : BaseUnityPlugin
{
private const string modGUID = "Piggy.CruiserMap";
private const string modName = "CruiserMap";
private const string modVersion = "1.0.5";
private readonly Harmony harmony = new Harmony("Piggy.CruiserMap");
private static Plugin Instance;
public static ManualLogSource mls;
public static AssetBundle Bundle;
public static string PluginDirectory;
public static GameObject cruiserMapperPrefab;
public static bool resetWheel;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Piggy.CruiserMap");
PluginDirectory = ((BaseUnityPlugin)this).Info.Location;
Bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "cruisermap"));
cruiserMapperPrefab = Bundle.LoadAsset<GameObject>("Navigation.prefab");
resetWheel = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Wheel Reset", false, "Resets the rotation of the steering wheel when no steering wheel keystrokes are detected.").Value;
mls.LogInfo((object)"CruiserMap is loaded!");
harmony.PatchAll(typeof(Plugin));
harmony.PatchAll(typeof(VehicleControllerPatch));
}
}
}
namespace CruiserMap.Patches
{
public class VehicleMapper : MonoBehaviour
{
public VehicleController vehicle;
public GameObject cruiserMap;
public Transform cameraTarget;
public Transform cruiserCameraTransform;
private void Start()
{
SpawnCruiserMapper();
}
private void Update()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)cruiserCameraTransform != (Object)null)
{
cruiserCameraTransform.position = Vector3.Lerp(cruiserCameraTransform.position, cameraTarget.position, Time.deltaTime * 5f);
cruiserCameraTransform.rotation = Quaternion.Lerp(cruiserCameraTransform.rotation, cameraTarget.rotation, Time.deltaTime * 6f);
}
if ((Object)(object)cruiserMap == (Object)null || (Object)(object)cruiserCameraTransform == (Object)null)
{
SpawnCruiserMapper();
}
}
private void SpawnCruiserMapper()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: 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)
if ((Object)(object)cruiserMap == (Object)null)
{
cruiserMap = Object.Instantiate<GameObject>(Plugin.cruiserMapperPrefab);
cruiserMap.transform.SetParent(((Component)vehicle).transform);
cruiserMap.transform.localPosition = Vector3.zero;
cruiserMap.transform.localRotation = Quaternion.identity;
cruiserMap.transform.localScale = new Vector3(1f, 1f, 1f);
}
if ((Object)(object)cruiserCameraTransform == (Object)null)
{
cruiserCameraTransform = ((Component)cruiserMap.transform.Find("CruiserNavCamera")).transform;
}
cameraTarget = ((Component)cruiserMap.transform.Find("CameraTarget")).transform;
cruiserCameraTransform.SetParent((Transform)null);
}
}
[HarmonyPatch(typeof(VehicleController))]
internal class VehicleControllerPatch
{
public static VehicleMapper vehicleMapper;
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(VehicleController __instance)
{
vehicleMapper = ((Component)__instance).gameObject.AddComponent<VehicleMapper>();
vehicleMapper.vehicle = __instance;
}
[HarmonyPostfix]
[HarmonyPatch("Update")]
private static void Update_Postfix(VehicleController __instance, ref float ___steeringWheelAnimFloat, ref float ___steeringWheelTurnSpeed)
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)vehicleMapper == (Object)null)
{
if ((Object)(object)((Component)__instance).gameObject.GetComponent<VehicleMapper>() == (Object)null)
{
vehicleMapper = ((Component)__instance).gameObject.AddComponent<VehicleMapper>();
vehicleMapper.vehicle = __instance;
}
else
{
vehicleMapper = ((Component)__instance).gameObject.GetComponent<VehicleMapper>();
vehicleMapper.vehicle = __instance;
}
}
if (((Vector2)(ref __instance.moveInputVector)).normalized.x == 0f && Plugin.resetWheel)
{
__instance.steeringInput = 0f;
__instance.steeringAnimValue = Mathf.Lerp(__instance.steeringAnimValue, 0f, Time.deltaTime);
___steeringWheelAnimFloat = Mathf.Lerp(___steeringWheelAnimFloat, 0f, Time.deltaTime);
}
}
}
}