Decompiled source of SquibbinCruiser v1.0.1

CruiserSkin.dll

Decompiled 7 hours ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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("iSHAK")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("iSHAK")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("61bf0656-343b-4d77-bb0d-9a0214ffaea2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CruiserSkin;

internal class Patch
{
	private static ManualLogSource log;

	public static void Init(ManualLogSource logger)
	{
		log = logger;
	}

	[HarmonyPatch(typeof(VehicleController), "Start")]
	[HarmonyPrefix]
	private static void StartPatch(VehicleController __instance)
	{
		Transform[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Transform>();
		foreach (Transform val in componentsInChildren)
		{
			if (((Object)val).name.Contains("MainBody") || ((Object)val).name == "CarHoodMesh")
			{
				((Renderer)((Component)val).GetComponent<MeshRenderer>()).materials[0].mainTexture = (Texture)(object)Plugin.main;
			}
			else if (((Object)val).name == "DoorRightContainer" || ((Object)val).name == "DoorLeftContainer")
			{
				((Renderer)((Component)val).GetComponentInChildren<MeshRenderer>()).materials[0].mainTexture = (Texture)(object)Plugin.main;
			}
			else if (((Object)val).name == "BackDoorMesh")
			{
				((Renderer)((Component)val).GetComponent<SkinnedMeshRenderer>()).materials[0].mainTexture = (Texture)(object)Plugin.main;
			}
		}
	}

	[HarmonyPatch(typeof(VehicleController), "DestroyCar")]
	[HarmonyPostfix]
	private static void DestroyCarPatch(VehicleController __instance)
	{
		Transform[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Transform>();
		foreach (Transform val in componentsInChildren)
		{
			if (((Object)val).name.Contains("MainBody") || ((Object)val).name == "CarHoodMesh")
			{
				((Renderer)((Component)val).GetComponent<MeshRenderer>()).materials[0].mainTexture = (Texture)(object)Plugin.destroyed;
			}
			else if (((Object)val).name == "DoorRightContainer" || ((Object)val).name == "DoorLeftContainer")
			{
				((Renderer)((Component)val).GetComponentInChildren<MeshRenderer>()).materials[0].mainTexture = (Texture)(object)Plugin.destroyed;
			}
			else if (((Object)val).name == "BackDoorMesh")
			{
				((Renderer)((Component)val).GetComponent<SkinnedMeshRenderer>()).materials[0].mainTexture = (Texture)(object)Plugin.destroyed;
			}
		}
	}
}
[BepInPlugin("CruiserSkin", "CruiserSkin", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public static Texture2D main;

	public static Texture2D destroyed;

	private void Awake()
	{
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		ImageConversion.LoadImage(main, File.ReadAllBytes(Path.Combine(directoryName, "CruiserSkin/cruiser.png")));
		ImageConversion.LoadImage(destroyed, File.ReadAllBytes(Path.Combine(directoryName, "CruiserSkin/cruiser_destroyed.png")));
		Patch.Init(((BaseUnityPlugin)this).Logger);
		new Harmony("CruiserSkin").PatchAll(typeof(Patch));
		((BaseUnityPlugin)this).Logger.LogInfo((object)"CruiserSkin is loaded!");
	}

	static Plugin()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Expected O, but got Unknown
		main = new Texture2D(2, 2);
		destroyed = new Texture2D(2, 2);
	}
}