Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of PechaPosters v1.0.1
CustomPosters.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; 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: TargetFramework(".NETFramework,Version=v4.7", FrameworkDisplayName = "")] [assembly: AssemblyCompany("CustomPosters")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("LC posters API")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CustomPosters")] [assembly: AssemblyTitle("CustomPosters")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CustomPosters { internal class Patches { private static bool _materialsUpdated = false; private static string _selectedPack = null; private static Material _copiedMaterial = null; private static readonly List<GameObject> CreatedPosters = new List<GameObject>(); private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] private static void StartPatch(StartOfRound __instance) { _materialsUpdated = false; CopyPlane001Material(); ((MonoBehaviour)__instance).StartCoroutine(DelayedUpdateMaterialsAsync()); } [HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")] [HarmonyPostfix] private static void GenerateNewLevelClientRpcPatch(int randomSeed, StartOfRound __instance) { if (!_materialsUpdated) { ((MonoBehaviour)__instance).StartCoroutine(DelayedUpdateMaterialsAsync()); } } [HarmonyPatch(typeof(StartOfRound), "OnShipLandedMiscEvents")] [HarmonyPostfix] private static void OnShipLandedMiscEventsPatch(StartOfRound __instance) { if (!_materialsUpdated) { ((MonoBehaviour)__instance).StartCoroutine(DelayedUpdateMaterialsAsync()); } } [HarmonyPatch(typeof(StartOfRound), "OnClientDisconnect")] [HarmonyPostfix] private static void OnClientDisconnectPatch(ulong clientId) { _materialsUpdated = false; Logger.LogInfo((object)"Lobby left. Resetting materials."); CleanUpPosters(); } private static IEnumerator LoadTextureAsync(string filePath, Action<Texture2D> onComplete) { try { if (!File.Exists(filePath)) { Logger.LogError((object)("Texture file not found: " + filePath)); onComplete?.Invoke(null); yield break; } Texture2D texture = new Texture2D(2, 2); byte[] fileData = File.ReadAllBytes(filePath); if (ImageConversion.LoadImage(texture, fileData)) { ((Texture)texture).filterMode = (FilterMode)0; onComplete?.Invoke(texture); } else { Logger.LogError((object)("Failed to load texture from " + filePath)); onComplete?.Invoke(null); } } catch (Exception ex2) { Exception ex = ex2; Logger.LogError((object)("Error loading texture from " + filePath + ": " + ex.Message)); onComplete?.Invoke(null); } } private static void CopyPlane001Material() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown GameObject val = GameObject.Find("Environment/HangarShip/Plane.001"); if ((Object)(object)val == (Object)null) { Logger.LogError((object)"Poster plane (Plane.001) not found under HangarShip!"); return; } MeshRenderer component = val.GetComponent<MeshRenderer>(); if ((Object)(object)component == (Object)null || ((Renderer)component).materials.Length == 0) { Logger.LogError((object)"Poster plane renderer or materials not found!"); return; } _copiedMaterial = new Material(((Renderer)component).material); Logger.LogInfo((object)"Copied material from Plane.001."); } private static void HideVanillaPosterPlane() { GameObject val = GameObject.Find("Environment/HangarShip/Plane.001 (Old)"); if ((Object)(object)val != (Object)null) { val.SetActive(false); return; } val = GameObject.Find("Environment/HangarShip/Plane.001"); if ((Object)(object)val != (Object)null) { val.SetActive(false); } } private static void CleanUpPosters() { if (CreatedPosters.Count == 0) { return; } Logger.LogInfo((object)"Cleaning up existing posters."); foreach (GameObject createdPoster in CreatedPosters) { if ((Object)(object)createdPoster != (Object)null) { Object.Destroy((Object)(object)createdPoster); } } CreatedPosters.Clear(); } private static IEnumerator CreateCustomPostersAsync() { CleanUpPosters(); GameObject environment = GameObject.Find("Environment"); if ((Object)(object)environment == (Object)null) { Logger.LogError((object)"Environment GameObject not found in the scene hierarchy!"); yield break; } Transform obj = environment.transform.Find("HangarShip"); GameObject hangarShip = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)hangarShip == (Object)null) { Logger.LogError((object)"HangarShip GameObject not found under Environment!"); yield break; } GameObject postersParent = new GameObject("CustomPosters"); postersParent.transform.SetParent(hangarShip.transform); postersParent.transform.localPosition = Vector3.zero; GameObject posterPlane = GameObject.Find("Environment/HangarShip/Plane.001"); if ((Object)(object)posterPlane == (Object)null) { Logger.LogError((object)"Poster plane (Plane.001) not found under HangarShip!"); yield break; } MeshRenderer originalRenderer = posterPlane.GetComponent<MeshRenderer>(); if ((Object)(object)originalRenderer == (Object)null || ((Renderer)originalRenderer).materials.Length == 0) { Logger.LogError((object)"Poster plane renderer or materials not found!"); yield break; } _ = ((Renderer)originalRenderer).material; (Vector3 position, Vector3 rotation, Vector3 scale, string name)[] posterData = new(Vector3, Vector3, Vector3, string)[6] { (new Vector3(4.1886f, 2.9318f, -16.8409f), new Vector3(0f, 200.9872f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1"), (new Vector3(6.4202f, 2.4776f, -10.8226f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2"), (new Vector3(9.9186f, 2.8591f, -17.4716f), new Vector3(0f, 180f, 356.3345f), new Vector3(0.7487f, 1.0539f, 1f), "Poster3"), (new Vector3(5.2187f, 2.5963f, -11.0945f), new Vector3(0f, 337.5868f, 2.68f), new Vector3(0.7289f, 0.9989f, 1f), "Poster4"), (new Vector3(5.5286f, 2.5882f, -17.3541f), new Vector3(0f, 201.1556f, 359.8f), new Vector3(0.5516f, 0.769f, 1f), "Poster5"), (new Vector3(3.0647f, 2.8174f, -11.7341f), new Vector3(0f, 0f, 358.6752f), new Vector3(0.8596f, 1.2194f, 1f), "CustomTips") }; if (Plugin.IsWiderShipModInstalled) { Logger.LogInfo((object)("Adjusting poster positions for WiderShipMod Extended Side: " + Plugin.WiderShipExtendedSide)); switch (Plugin.WiderShipExtendedSide) { case "Both": posterData[0] = (new Vector3(4.6877f, 2.9407f, -19.62f), new Vector3(0f, 118.2274f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1"); posterData[3] = (new Vector3(5.5699f, 2.5963f, -10.3268f), new Vector3(0f, 62.0324f, 2.6799f), new Vector3(0.7289f, 0.9989f, 1f), "Poster4"); posterData[4] = (new Vector3(5.3602f, 2.5882f, -18.3793f), new Vector3(0f, 118.0114f, 359.8f), new Vector3(0.5516f, 0.769f, 1f), "Poster5"); posterData[5] = (new Vector3(3.0947f, 2.8174f, -6.7253f), new Vector3(0f, 0f, 358.6752f), new Vector3(0.8596f, 1.2194f, 1f), "CustomTips"); break; case "Right": posterData[0] = (new Vector3(4.2224f, 2.9318f, -16.8609f), new Vector3(0f, 200.9872f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1"); posterData[1] = (new Vector3(6.4202f, 2.4776f, -10.8226f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2"); posterData[2] = (new Vector3(9.9426f, 2.8591f, -17.4716f), new Vector3(0f, 180f, 356.3345f), new Vector3(0.7487f, 1.0539f, 1f), "Poster3"); posterData[3] = (new Vector3(5.5699f, 2.5963f, -10.3268f), new Vector3(0f, 62.0324f, 2.6799f), new Vector3(0.7289f, 0.9989f, 1f), "Poster4"); posterData[4] = (new Vector3(5.5386f, 2.5882f, -17.3641f), new Vector3(0f, 200.9099f, 359.8f), new Vector3(0.5516f, 0.769f, 1f), "Poster5"); posterData[5] = (new Vector3(3.0947f, 2.8174f, -6.733f), new Vector3(0f, 0f, 358.6752f), new Vector3(0.8596f, 1.2194f, 1f), "CustomTips"); break; case "Left": posterData[0] = (new Vector3(4.6777f, 2.9007f, -19.63f), new Vector3(0f, 118.2274f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1"); posterData[1] = (new Vector3(6.4202f, 2.2577f, -10.8226f), new Vector3(0f, 0f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster2"); posterData[2] = (new Vector3(9.7197f, 2.8151f, -17.4716f), new Vector3(0f, 180f, 356.3345f), new Vector3(0.7487f, 1.0539f, 1f), "Poster3"); posterData[3] = (new Vector3(6.4449f, 3.0961f, -10.8221f), new Vector3(0f, 0.026f, 2.68f), new Vector3(0.7289f, 0.9989f, 1f), "Poster4"); posterData[4] = (new Vector3(5.3602f, 2.5482f, -18.3793f), new Vector3(0f, 118.0114f, 359.8f), new Vector3(0.5516f, 0.769f, 1f), "Poster5"); posterData[5] = (new Vector3(2.8647f, 2.7774f, -11.7341f), new Vector3(0f, 0f, 358.6752f), new Vector3(0.8596f, 1.2194f, 1f), "CustomTips"); break; } } if (Plugin.Is2StoryShipModInstalled) { if (Plugin.IsShipWindowsInstalled) { Logger.LogInfo((object)"ShipWindows and 2 Story Ship Mod detected. Ignoring both configs and repositioning posters."); posterData[0] = (new Vector3(6.5923f, 2.9318f, -17.4766f), new Vector3(0f, 179.2201f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1"); posterData[1] = (new Vector3(9.0884f, 2.4776f, -8.8229f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2"); posterData[3] = (new Vector3(5.3599f, 2.5963f, -9.455f), new Vector3(0f, 307.2657f, 2.68f), new Vector3(0.7289f, 0.9989f, 1f), "Poster4"); posterData[4] = (new Vector3(10.2813f, 2.7482f, -8.8271f), new Vector3(0f, 0.9014f, 359.8f), new Vector3(0.5516f, 0.769f, 1f), "Poster5"); posterData[5] = (new Vector3(2.5679f, 2.6763f, -11.7341f), new Vector3(0f, 0f, 358.6752f), new Vector3(0.8596f, 1.2194f, 1f), "CustomTips"); } if (Plugin.IsShipWindowsInstalled && Plugin.IsWiderShipModInstalled) { Logger.LogInfo((object)"ShipWindows and WiderShipMod detected with 2 Story Ship Mod. Using default 2 Story Ship Mod positions."); posterData[0] = (new Vector3(6.5923f, 2.9318f, -22.4766f), new Vector3(0f, 179.2201f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1"); posterData[1] = (new Vector3(9.0884f, 2.4776f, -5.8265f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2"); posterData[2] = (new Vector3(10.1364f, 2.8591f, -22.4788f), new Vector3(0f, 180.3376f, 0f), new Vector3(0.7487f, 1.0539f, 1f), "Poster3"); posterData[3] = (new Vector3(5.3599f, 2.5963f, -9.455f), new Vector3(0f, 307.2657f, 2.68f), new Vector3(0.7289f, 0.9989f, 1f), "Poster4"); posterData[4] = (new Vector3(7.8577f, 2.7482f, -22.4803f), new Vector3(0f, 179.7961f, 359.8f), new Vector3(0.5516f, 0.769f, 1f), "Poster5"); posterData[5] = (new Vector3(-5.8111f, 2.541f, -17.577f), new Vector3(0f, 270.0942f, 358.6752f), new Vector3(0.8596f, 1.2194f, 1f), "CustomTips"); } else if (Plugin.IsWiderShipModInstalled) { Logger.LogInfo((object)"WiderShipMod detected with 2 Story Ship Mod. Using WiderShipMod-compatible positions."); posterData[0] = (new Vector3(6.3172f, 2.9407f, -22.4766f), new Vector3(0f, 180f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1"); posterData[1] = (new Vector3(9.5975f, 2.5063f, -5.8245f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2"); posterData[2] = (new Vector3(10.1364f, 2.8591f, -22.4788f), new Vector3(0f, 180f, 356.3345f), new Vector3(0.7487f, 1.0539f, 1f), "Poster3"); posterData[3] = (new Vector3(5.3599f, 2.5963f, -9.455f), new Vector3(0f, 307.2657f, 2.68f), new Vector3(0.7289f, 0.9989f, 1f), "Poster4"); posterData[4] = (new Vector3(7.5475f, 2.5882f, -22.4803f), new Vector3(0f, 180f, 359.8f), new Vector3(0.5516f, 0.769f, 1f), "Poster5"); posterData[5] = (new Vector3(-5.8111f, 2.541f, -17.577f), new Vector3(0f, 270.0942f, 358.6752f), new Vector3(0.8596f, 1.2194f, 1f), "CustomTips"); } else { Logger.LogInfo((object)"2 Story Ship Mod detected. Repositioning posters based on window settings."); if (Plugin.EnableRightWindows && Plugin.EnableLeftWindows) { Logger.LogInfo((object)"All windows are enabled. Repositioning posters to default 2 Story Ship Mod positions."); posterData[0] = (new Vector3(10.1567f, 2.75f, -8.8293f), new Vector3(0f, 0f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1"); posterData[1] = (new Vector3(9.0884f, 2.4776f, -8.8229f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2"); posterData[3] = (new Vector3(5.3599f, 2.5963f, -9.455f), new Vector3(0f, 307.2657f, 2.68f), new Vector3(0.7289f, 0.9989f, 1f), "Poster4"); posterData[4] = (new Vector3(6.1473f, 2.8195f, -17.4729f), new Vector3(0f, 179.7123f, 359.8f), new Vector3(0.5516f, 0.769f, 1f), "Poster5"); posterData[5] = (new Vector3(2.5679f, 2.6763f, -11.7341f), new Vector3(0f, 0f, 358.6752f), new Vector3(0.8596f, 1.2194f, 1f), "CustomTips"); } else { if (!Plugin.EnableRightWindows) { Logger.LogInfo((object)"Right windows are disabled. Repositioning posters."); posterData[0] = (new Vector3(4.0286f, 2.9318f, -16.7774f), new Vector3(0f, 200.9872f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1"); posterData[1] = (new Vector3(9.0884f, 2.4776f, -8.8229f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2"); posterData[3] = (new Vector3(5.3599f, 2.5963f, -9.455f), new Vector3(0f, 307.2657f, 0f), new Vector3(0.7289f, 0.9989f, 1f), "Poster4"); posterData[4] = (new Vector3(5.3282f, 2.7482f, -17.2754f), new Vector3(0f, 202.3357f, 359.8f), new Vector3(0.5516f, 0.769f, 1f), "Poster5"); posterData[5] = (new Vector3(2.5679f, 2.6763f, -11.7341f), new Vector3(0f, 0f, 358.6752f), new Vector3(0.8596f, 1.2194f, 1f), "CustomTips"); } if (!Plugin.EnableLeftWindows) { Logger.LogInfo((object)"Left windows are disabled. Repositioning posters."); posterData[0] = (new Vector3(9.8324f, 2.9318f, -8.8257f), new Vector3(0f, 0f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1"); posterData[1] = (new Vector3(7.3648f, 2.4776f, -8.8229f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2"); posterData[3] = (new Vector3(5.3599f, 2.5963f, -9.455f), new Vector3(0f, 307.2657f, 2.68f), new Vector3(0.7289f, 0.9989f, 1f), "Poster4"); posterData[4] = (new Vector3(6.1473f, 2.8195f, -17.4729f), new Vector3(0f, 179.7123f, 359.8f), new Vector3(0.5516f, 0.769f, 1f), "Poster5"); posterData[5] = (new Vector3(2.5679f, 2.6763f, -11.7341f), new Vector3(0f, 0f, 358.6752f), new Vector3(0.8596f, 1.2194f, 1f), "CustomTips"); } } } } if (Plugin.IsShipWindowsInstalled && Plugin.IsWindow2Enabled && !Plugin.IsWiderShipModInstalled && !Plugin.Is2StoryShipModInstalled) { Logger.LogInfo((object)"ShipWindows compatibility: Repositioning Poster4 due to window2 being enabled."); posterData[3].position = new Vector3(6.4449f, 3.0961f, -10.8221f); posterData[1].position = new Vector3(6.4202f, 2.2577f, -10.8226f); posterData[3].rotation = new Vector3(0f, 0f, 358.0874f); posterData[3].scale = new Vector3(0.7289f, 0.9989f, 1f); } List<string> enabledPacks = Plugin.PosterFolders.Where((string folder) => PosterConfig.IsPackEnabled(folder)).ToList(); if (enabledPacks.Count == 0) { Logger.LogWarning((object)"No enabled packs found!"); yield break; } List<string> enabledPackNames = enabledPacks.Select((string pack) => Path.GetFileName(Path.GetDirectoryName(pack))).ToList(); Logger.LogInfo((object)("Enabled poster packs: " + string.Join(", ", enabledPackNames))); List<string> packsToUse; if (PosterConfig.PosterRandomizer.Value) { _selectedPack = enabledPacks[Plugin.Rand.Next(enabledPacks.Count)]; packsToUse = new List<string> { _selectedPack }; string selectedPackName = Path.GetFileName(Path.GetDirectoryName(_selectedPack)); Logger.LogInfo((object)("PosterRandomizer enabled. Using pack: " + selectedPackName)); } else { packsToUse = enabledPacks; Logger.LogInfo((object)"PosterRandomizer disabled. Combining all enabled packs."); } Dictionary<string, List<(Texture2D texture, string filePath)>> allTextures = new Dictionary<string, List<(Texture2D, string)>>(); foreach (string pack2 in packsToUse) { string postersPath = Path.Combine(pack2, "posters"); string tipsPath = Path.Combine(pack2, "tips"); if (Directory.Exists(postersPath)) { string[] files = Directory.GetFiles(postersPath, "*.png"); foreach (string file2 in files) { yield return LoadTextureAsync(file2, delegate(Texture2D texture) { if ((Object)(object)texture != (Object)null) { string fileNameWithoutExtension2 = Path.GetFileNameWithoutExtension(file2); if (!allTextures.ContainsKey(fileNameWithoutExtension2)) { allTextures[fileNameWithoutExtension2] = new List<(Texture2D, string)>(); } allTextures[fileNameWithoutExtension2].Add((texture, file2)); } }); } } if (!Directory.Exists(tipsPath)) { continue; } string[] files2 = Directory.GetFiles(tipsPath, "*.png"); foreach (string file in files2) { yield return LoadTextureAsync(file, delegate(Texture2D texture) { if ((Object)(object)texture != (Object)null) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file); if (!allTextures.ContainsKey(fileNameWithoutExtension)) { allTextures[fileNameWithoutExtension] = new List<(Texture2D, string)>(); } allTextures[fileNameWithoutExtension].Add((texture, file)); } }); } } if (allTextures.Count == 0) { Logger.LogWarning((object)"No textures found in enabled packs!"); yield break; } bool anyTextureLoaded = false; for (int i = 0; i < posterData.Length; i++) { GameObject poster = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)poster).name = posterData[i].name; poster.transform.SetParent(postersParent.transform); poster.transform.position = posterData[i].position; poster.transform.rotation = Quaternion.Euler(posterData[i].rotation); poster.transform.localScale = posterData[i].scale; MeshRenderer renderer = poster.GetComponent<MeshRenderer>(); if (allTextures.TryGetValue(((Object)poster).name, out var textures) && textures.Count > 0) { (Texture2D texture, string filePath) textureData = textures[Plugin.Rand.Next(textures.Count)]; Material material = new Material(_copiedMaterial); material.mainTexture = (Texture)(object)textureData.texture; ((Renderer)renderer).material = material; anyTextureLoaded = true; Logger.LogInfo((object)("Loaded texture for " + ((Object)poster).name + " from " + textureData.filePath)); CreatedPosters.Add(poster); } else { Logger.LogError((object)("No textures found for " + ((Object)poster).name + ". Disabling the poster.")); poster.SetActive(false); } yield return null; textures = null; } if (!anyTextureLoaded) { Object.Destroy((Object)(object)postersParent); Logger.LogWarning((object)"No custom posters were created due to missing textures."); yield break; } Transform obj2 = hangarShip.transform.Find("Plane.001"); GameObject vanillaPlane = ((obj2 != null) ? ((Component)obj2).gameObject : null); if ((Object)(object)vanillaPlane != (Object)null) { Logger.LogInfo((object)"Destroying vanilla Plane.001."); Object.Destroy((Object)(object)vanillaPlane); } Logger.LogInfo((object)"Custom posters created successfully."); } private static IEnumerator DelayedUpdateMaterialsAsync() { if (!_materialsUpdated) { yield return (object)new WaitForSeconds(1f); Logger.LogInfo((object)"Updating materials for custom posters"); GameObject posterPlane = GameObject.Find("Environment/HangarShip/Plane.001"); if ((Object)(object)posterPlane != (Object)null) { posterPlane.SetActive(false); } HideVanillaPosterPlane(); yield return CreateCustomPostersAsync(); _materialsUpdated = true; } } } [BepInPlugin("seeya.customposters", "CustomPosters", "1.3.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PLUGIN_GUID = "seeya.customposters"; public const string PLUGIN_NAME = "CustomPosters"; public const string PLUGIN_VERSION = "1.3.2"; public static List<string> PosterFolders = new List<string>(); public static readonly List<string> PosterFiles = new List<string>(); public static readonly List<string> TipFiles = new List<string>(); public static Random Rand = new Random(); public static bool IsShipWindowsInstalled { get; private set; } public static bool IsWindow2Enabled { get; private set; } public static bool Is2StoryShipModInstalled { get; private set; } public static bool EnableRightWindows { get; private set; } = true; public static bool EnableLeftWindows { get; private set; } = true; public static bool IsWiderShipModInstalled { get; private set; } public static string WiderShipExtendedSide { get; private set; } public static ManualLogSource StaticLogger { get; private set; } private static void Check2StoryShipModConfig() { try { string path = Path.Combine(Paths.ConfigPath, "MelanieMelicious.2StoryShip.cfg"); if (!File.Exists(path)) { StaticLogger.LogWarning((object)"2 Story Ship Mod config file not found. Using default window settings."); return; } string[] array = File.ReadAllLines(path); string[] array2 = array; foreach (string text in array2) { if (text.Contains("Enable Right Windows")) { EnableRightWindows = text.Contains("true"); } else if (text.Contains("Enable Left Windows")) { EnableLeftWindows = text.Contains("true"); } } } catch (Exception ex) { StaticLogger.LogError((object)("Failed to read 2 Story Ship Mod config: " + ex.Message)); } } private void Awake() { //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Expected O, but got Unknown try { StaticLogger = ((BaseUnityPlugin)this).Logger; PosterFolders = Directory.GetDirectories(Paths.PluginPath, "CustomPosters", SearchOption.AllDirectories).ToList(); foreach (string posterFolder in PosterFolders) { string path = Path.Combine(posterFolder, "posters"); string path2 = Path.Combine(posterFolder, "tips"); if (Directory.Exists(path)) { string[] files = Directory.GetFiles(path); foreach (string text in files) { if (Path.GetExtension(text) != ".old") { PosterFiles.Add(text); } } } if (!Directory.Exists(path2)) { continue; } string[] files2 = Directory.GetFiles(path2); foreach (string text2 in files2) { if (Path.GetExtension(text2) != ".old") { TipFiles.Add(text2); } } } Is2StoryShipModInstalled = Chainloader.PluginInfos.ContainsKey("MelanieMelicious.2StoryShip"); if (Is2StoryShipModInstalled) { StaticLogger.LogInfo((object)"2 Story Ship Mod detected."); Check2StoryShipModConfig(); } IsShipWindowsInstalled = Chainloader.PluginInfos.ContainsKey("TestAccount666.ShipWindows"); if (IsShipWindowsInstalled) { StaticLogger.LogInfo((object)"ShipWindows detected."); IsWindow2Enabled = CheckIfWindow2Enabled(); } IsWiderShipModInstalled = Chainloader.PluginInfos.ContainsKey("mborsh.WiderShipMod"); if (IsWiderShipModInstalled) { StaticLogger.LogInfo((object)"WiderShipMod detected."); WiderShipExtendedSide = GetWiderShipExtendedSide(); StaticLogger.LogInfo((object)("WiderShipMod Extended Side: " + WiderShipExtendedSide)); } PosterConfig.Init(((BaseUnityPlugin)this).Logger); Patches.Init(((BaseUnityPlugin)this).Logger); Harmony val = new Harmony("seeya.customposters"); val.PatchAll(typeof(Patches)); StaticLogger.LogInfo((object)"Plugin CustomPosters (1.3.2) is loaded!"); } catch (Exception ex) { StaticLogger.LogError((object)("Failed to initialize plugin: " + ex.Message)); } } private static bool CheckIfWindow2Enabled() { try { string path = Path.Combine(Paths.ConfigPath, "TestAccount666.ShipWindows.cfg"); if (!File.Exists(path)) { StaticLogger.LogWarning((object)"ShipWindows config file not found. Assuming Window2 is disabled."); return false; } string[] array = File.ReadAllLines(path); string[] array2 = array; foreach (string text in array2) { if (text.Contains("EnableWindow2") && text.Contains("true")) { return true; } } } catch (Exception ex) { StaticLogger.LogError((object)("Failed to read ShipWindows config: " + ex.Message)); } return false; } private static string GetWiderShipExtendedSide() { try { string path = Path.Combine(Paths.ConfigPath, "mborsh.WiderShipMod.cfg"); if (!File.Exists(path)) { StaticLogger.LogWarning((object)"WiderShipMod config file not found. Assuming Extended Side is 'Both'."); return "Both"; } string[] array = File.ReadAllLines(path); string[] array2 = array; foreach (string text in array2) { if (text.Contains("Extended Side")) { if (text.Contains("Both")) { return "Both"; } if (text.Contains("Right")) { return "Right"; } if (text.Contains("Left")) { return "Left"; } } } } catch (Exception ex) { StaticLogger.LogError((object)("Failed to read WiderShipMod config: " + ex.Message)); } return "Both"; } } internal class PosterConfig { private static ConfigFile configFile; private static ManualLogSource Logger { get; set; } public static ConfigEntry<bool> PosterRandomizer { get; private set; } public static ConfigEntry<bool> LobbyRandom { get; private set; } public static void Init(ManualLogSource logger) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown Logger = logger; configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "CustomPosters.cfg"), true); PosterRandomizer = configFile.Bind<bool>("Settings", "PosterRandomizer", true, "If true, randomizes only poster packs. If false, combines all enabled packs and randomizes textures."); foreach (string posterFolder in Plugin.PosterFolders) { int num = posterFolder.IndexOf("plugins\\", StringComparison.Ordinal); if (num == -1) { Logger.LogError((object)("Invalid mod folder path: 'plugins\\' not found in " + posterFolder)); continue; } num += "plugins\\".Length; int num2 = posterFolder.IndexOf("\\CustomPosters", num, StringComparison.Ordinal); if (num2 == -1) { Logger.LogError((object)("Invalid mod folder path: '\\CustomPosters' not found in " + posterFolder)); continue; } string text = posterFolder.Substring(num, num2 - num); ConfigEntry<bool> val = configFile.Bind<bool>(text, "Enabled", true, "Enable or disable " + text); } } public static bool IsPackEnabled(string folder) { int num = folder.IndexOf("plugins\\", StringComparison.Ordinal); if (num == -1) { return false; } num += "plugins\\".Length; int num2 = folder.IndexOf("\\CustomPosters", num, StringComparison.Ordinal); if (num2 == -1) { return false; } string text = folder.Substring(num, num2 - num); return configFile.Bind<bool>(text, "Enabled", true, (ConfigDescription)null).Value; } } public static class PluginInfo { public const string PLUGIN_GUID = "CustomPosters"; public const string PLUGIN_NAME = "CustomPosters"; public const string PLUGIN_VERSION = "1.0.0"; } }