using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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 UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("polska_autopskola.HusariaCruiser")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("2.1.37.0")] [assembly: AssemblyInformationalVersion("2.1.37")] [assembly: AssemblyProduct("HusariaCruiser")] [assembly: AssemblyTitle("polska_autopskola.HusariaCruiser")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.1.37.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 NuclearCruiser { public class CruiserSkinApplier : MonoBehaviour { private void Start() { MeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val in array) { if ((((Object)((Component)val).transform).name.Contains("MainBody") || ((Object)((Component)val).transform).name == "CarHoodMesh" || ((Object)((Component)val).transform).name == "Door") && ((Renderer)val).materials.Length != 0) { ((Renderer)val).materials[0].mainTexture = (Texture)(object)NuclearCruiser.cruiserTexture; } } } } [HarmonyPatch(typeof(VehicleController), "Start")] internal class CruiserSkinPatch { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public VehicleController vc; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; ApplySkin(vc); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static void Postfix(VehicleController __instance) { ((MonoBehaviour)__instance).StartCoroutine(ApplyNextFrame(__instance)); } [IteratorStateMachine(typeof(d__1))] private static IEnumerator ApplyNextFrame(VehicleController vc) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { vc = vc }; } private static void ApplySkin(VehicleController vc) { if ((Object)(object)vc == (Object)null) { return; } MeshRenderer[] componentsInChildren = ((Component)vc).GetComponentsInChildren(); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val in array) { if ((((Object)((Component)val).transform).name.Contains("MainBody") || ((Object)((Component)val).transform).name == "CarHoodMesh" || ((Object)((Component)val).transform).name == "Door") && ((Renderer)val).materials.Length != 0) { ((Renderer)val).materials[0].mainTexture = (Texture)(object)NuclearCruiser.cruiserTexture; } } } } [BepInPlugin("polska_autopskola.HusariaCruiser", "HusariaCruiser", "2.1.37")] public class NuclearCruiser : BaseUnityPlugin { internal static Texture2D? cruiserTexture; internal static Texture2D? destroyedCruiserTexture; public static NuclearCruiser Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } private void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Instance = this; Harmony val = new Harmony("polska_autopskola.HusariaCruiser"); val.PatchAll(); string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); cruiserTexture = GetTexture(Path.Combine(directoryName, "cruiser.png")); destroyedCruiserTexture = GetTexture(Path.Combine(directoryName, "cruiser_blown.png")); if ((Object)(object)cruiserTexture == (Object)null || (Object)(object)destroyedCruiserTexture == (Object)null) { Logger.LogError((object)"Failed to load textures. Plugin loading failed."); } else { Logger.LogInfo((object)"Cosmetic Cruiser mod loaded (textures only)."); } } internal static Texture2D? GetTexture(string path) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown if (!File.Exists(path)) { return null; } Texture2D val = new Texture2D(2, 2); ImageConversion.LoadImage(val, File.ReadAllBytes(path)); return val; } } [HarmonyPatch(typeof(VehicleController), "Start")] internal class VehicleSkinPatch { private static void Postfix(VehicleController __instance) { if ((Object)(object)((Component)__instance).GetComponent() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "polska_autopskola.HusariaCruiser"; public const string PLUGIN_NAME = "HusariaCruiser"; public const string PLUGIN_VERSION = "2.1.37"; } }