using 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.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("CustomPosters")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Replaces the default posters in the ship with custom posters")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0")]
[assembly: AssemblyProduct("CustomPosters")]
[assembly: AssemblyTitle("CustomPosters")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.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 : MonoBehaviour
{
private class PosterRenderer : MonoBehaviour
{
public void Initialize(Texture2D texture, Material materialTemplate)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
MeshRenderer component = ((Component)this).GetComponent<MeshRenderer>();
Material val = new Material(materialTemplate);
if ((Object)(object)texture != (Object)null)
{
val.mainTexture = (Texture)(object)texture;
((Renderer)component).material = val;
}
else
{
Plugin.Log.LogError((object)"No texture provided for poster");
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass17_0
{
public Dictionary<string, List<(Texture2D texture, string filePath)>> allTextures;
public Dictionary<string, (Texture2D texture, string filePath)> prioritizedTextures;
}
[CompilerGenerated]
private sealed class <>c__DisplayClass17_1
{
public string[] validExtensions;
public <>c__DisplayClass17_0 CS$<>8__locals1;
public Func<string, bool> <>9__6;
internal bool <CreateCustomPostersAsync>b__6(string f)
{
if (validExtensions.Contains(Path.GetExtension(f).ToLower()))
{
return PosterConfig.IsFileEnabled(f);
}
return false;
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass17_2
{
public string file;
public <>c__DisplayClass17_1 CS$<>8__locals2;
internal void <CreateCustomPostersAsync>b__8((Texture2D texture, string filePath) result)
{
if ((Object)(object)result.texture != (Object)null)
{
string key = Path.GetFileNameWithoutExtension(file).ToLower();
if (!CS$<>8__locals2.CS$<>8__locals1.allTextures.ContainsKey(key))
{
CS$<>8__locals2.CS$<>8__locals1.allTextures[key] = new List<(Texture2D, string)>();
}
CS$<>8__locals2.CS$<>8__locals1.allTextures[key].Add((result.texture, file));
}
else
{
Plugin.Log.LogWarning((object)("Failed to load texture from " + file));
}
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass17_3
{
public KeyValuePair<string, List<(Texture2D texture, string filePath)>> kvp;
public <>c__DisplayClass17_0 CS$<>8__locals3;
internal bool <CreateCustomPostersAsync>b__11((Texture2D texture, string filePath) t)
{
return t.filePath != CS$<>8__locals3.prioritizedTextures[kvp.Key].filePath;
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass17_4
{
public (Texture2D texture, string filePath) selected;
internal bool <CreateCustomPostersAsync>b__14((Texture2D texture, string filePath) t)
{
return t.filePath != selected.filePath;
}
}
[CompilerGenerated]
private sealed class <CreateCustomPostersAsync>d__17 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
private <>c__DisplayClass17_0 <>8__1;
private <>c__DisplayClass17_1 <>8__2;
private GameObject <hangarShip>5__2;
private GameObject <postersParent>5__3;
private GameObject <posterPlane>5__4;
private (Vector3 position, Vector3 rotation, Vector3 scale, string name)[] <posterData>5__5;
private bool <anyPosterLoaded>5__6;
private List<string>.Enumerator <>7__wrap6;
private List<string> <filesToLoad>5__8;
private int <i>5__9;
private List<string>.Enumerator <>7__wrap9;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CreateCustomPostersAsync>d__17(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if ((uint)(num - -4) <= 1u || (uint)(num - 1) <= 1u)
{
try
{
if (num == -4 || num == 1)
{
try
{
}
finally
{
<>m__Finally2();
}
}
}
finally
{
<>m__Finally1();
}
}
<>8__1 = null;
<>8__2 = null;
<hangarShip>5__2 = null;
<postersParent>5__3 = null;
<posterPlane>5__4 = null;
<posterData>5__5 = null;
<>7__wrap6 = default(List<string>.Enumerator);
<filesToLoad>5__8 = null;
<>7__wrap9 = default(List<string>.Enumerator);
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_2058: Unknown result type (might be due to invalid IL or missing references)
//IL_207a: Unknown result type (might be due to invalid IL or missing references)
//IL_207f: Unknown result type (might be due to invalid IL or missing references)
//IL_20a1: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_0370: Unknown result type (might be due to invalid IL or missing references)
//IL_0384: Unknown result type (might be due to invalid IL or missing references)
//IL_0398: Unknown result type (might be due to invalid IL or missing references)
//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
//IL_06eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0715: Unknown result type (might be due to invalid IL or missing references)
//IL_0729: Unknown result type (might be due to invalid IL or missing references)
//IL_073d: Unknown result type (might be due to invalid IL or missing references)
//IL_0767: Unknown result type (might be due to invalid IL or missing references)
//IL_077b: Unknown result type (might be due to invalid IL or missing references)
//IL_078f: Unknown result type (might be due to invalid IL or missing references)
//IL_07b9: Unknown result type (might be due to invalid IL or missing references)
//IL_07cd: Unknown result type (might be due to invalid IL or missing references)
//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0c35: Unknown result type (might be due to invalid IL or missing references)
//IL_0c49: Unknown result type (might be due to invalid IL or missing references)
//IL_0c5d: Unknown result type (might be due to invalid IL or missing references)
//IL_0c87: Unknown result type (might be due to invalid IL or missing references)
//IL_0c9b: Unknown result type (might be due to invalid IL or missing references)
//IL_0caf: Unknown result type (might be due to invalid IL or missing references)
//IL_0cd9: Unknown result type (might be due to invalid IL or missing references)
//IL_0ced: Unknown result type (might be due to invalid IL or missing references)
//IL_0d01: Unknown result type (might be due to invalid IL or missing references)
//IL_0d2b: Unknown result type (might be due to invalid IL or missing references)
//IL_0d3f: Unknown result type (might be due to invalid IL or missing references)
//IL_0d53: Unknown result type (might be due to invalid IL or missing references)
//IL_0d7d: Unknown result type (might be due to invalid IL or missing references)
//IL_0d91: Unknown result type (might be due to invalid IL or missing references)
//IL_0da5: Unknown result type (might be due to invalid IL or missing references)
//IL_0810: Unknown result type (might be due to invalid IL or missing references)
//IL_0824: Unknown result type (might be due to invalid IL or missing references)
//IL_0838: Unknown result type (might be due to invalid IL or missing references)
//IL_0862: Unknown result type (might be due to invalid IL or missing references)
//IL_0876: Unknown result type (might be due to invalid IL or missing references)
//IL_088a: Unknown result type (might be due to invalid IL or missing references)
//IL_08b4: Unknown result type (might be due to invalid IL or missing references)
//IL_08c8: Unknown result type (might be due to invalid IL or missing references)
//IL_08dc: Unknown result type (might be due to invalid IL or missing references)
//IL_0906: Unknown result type (might be due to invalid IL or missing references)
//IL_091a: Unknown result type (might be due to invalid IL or missing references)
//IL_092e: Unknown result type (might be due to invalid IL or missing references)
//IL_0958: Unknown result type (might be due to invalid IL or missing references)
//IL_096c: Unknown result type (might be due to invalid IL or missing references)
//IL_0980: Unknown result type (might be due to invalid IL or missing references)
//IL_09aa: Unknown result type (might be due to invalid IL or missing references)
//IL_09be: Unknown result type (might be due to invalid IL or missing references)
//IL_09d2: Unknown result type (might be due to invalid IL or missing references)
//IL_0469: Unknown result type (might be due to invalid IL or missing references)
//IL_047d: Unknown result type (might be due to invalid IL or missing references)
//IL_0491: Unknown result type (might be due to invalid IL or missing references)
//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
//IL_050d: Unknown result type (might be due to invalid IL or missing references)
//IL_0521: Unknown result type (might be due to invalid IL or missing references)
//IL_0535: Unknown result type (might be due to invalid IL or missing references)
//IL_055f: Unknown result type (might be due to invalid IL or missing references)
//IL_0573: Unknown result type (might be due to invalid IL or missing references)
//IL_0587: Unknown result type (might be due to invalid IL or missing references)
//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
//IL_0603: Unknown result type (might be due to invalid IL or missing references)
//IL_0617: Unknown result type (might be due to invalid IL or missing references)
//IL_062b: Unknown result type (might be due to invalid IL or missing references)
//IL_100b: Unknown result type (might be due to invalid IL or missing references)
//IL_101f: Unknown result type (might be due to invalid IL or missing references)
//IL_1033: Unknown result type (might be due to invalid IL or missing references)
//IL_105d: Unknown result type (might be due to invalid IL or missing references)
//IL_1071: Unknown result type (might be due to invalid IL or missing references)
//IL_1085: Unknown result type (might be due to invalid IL or missing references)
//IL_10af: Unknown result type (might be due to invalid IL or missing references)
//IL_10c3: Unknown result type (might be due to invalid IL or missing references)
//IL_10d7: Unknown result type (might be due to invalid IL or missing references)
//IL_1101: Unknown result type (might be due to invalid IL or missing references)
//IL_1115: Unknown result type (might be due to invalid IL or missing references)
//IL_1129: Unknown result type (might be due to invalid IL or missing references)
//IL_1153: Unknown result type (might be due to invalid IL or missing references)
//IL_1167: Unknown result type (might be due to invalid IL or missing references)
//IL_117b: Unknown result type (might be due to invalid IL or missing references)
//IL_11a5: Unknown result type (might be due to invalid IL or missing references)
//IL_11b9: Unknown result type (might be due to invalid IL or missing references)
//IL_11cd: Unknown result type (might be due to invalid IL or missing references)
//IL_0dfc: Unknown result type (might be due to invalid IL or missing references)
//IL_0e10: Unknown result type (might be due to invalid IL or missing references)
//IL_0e24: Unknown result type (might be due to invalid IL or missing references)
//IL_0e4e: Unknown result type (might be due to invalid IL or missing references)
//IL_0e62: Unknown result type (might be due to invalid IL or missing references)
//IL_0e76: Unknown result type (might be due to invalid IL or missing references)
//IL_0ea0: Unknown result type (might be due to invalid IL or missing references)
//IL_0eb4: Unknown result type (might be due to invalid IL or missing references)
//IL_0ec8: Unknown result type (might be due to invalid IL or missing references)
//IL_0ef2: Unknown result type (might be due to invalid IL or missing references)
//IL_0f06: Unknown result type (might be due to invalid IL or missing references)
//IL_0f1a: Unknown result type (might be due to invalid IL or missing references)
//IL_0f44: Unknown result type (might be due to invalid IL or missing references)
//IL_0f58: Unknown result type (might be due to invalid IL or missing references)
//IL_0f6c: Unknown result type (might be due to invalid IL or missing references)
//IL_0f96: Unknown result type (might be due to invalid IL or missing references)
//IL_0faa: Unknown result type (might be due to invalid IL or missing references)
//IL_0fbe: Unknown result type (might be due to invalid IL or missing references)
//IL_0a1c: Unknown result type (might be due to invalid IL or missing references)
//IL_0a30: Unknown result type (might be due to invalid IL or missing references)
//IL_0a44: Unknown result type (might be due to invalid IL or missing references)
//IL_0a6e: Unknown result type (might be due to invalid IL or missing references)
//IL_0a82: Unknown result type (might be due to invalid IL or missing references)
//IL_0a96: Unknown result type (might be due to invalid IL or missing references)
//IL_0ac0: Unknown result type (might be due to invalid IL or missing references)
//IL_0ad4: Unknown result type (might be due to invalid IL or missing references)
//IL_0ae8: Unknown result type (might be due to invalid IL or missing references)
//IL_0b12: Unknown result type (might be due to invalid IL or missing references)
//IL_0b26: Unknown result type (might be due to invalid IL or missing references)
//IL_0b3a: Unknown result type (might be due to invalid IL or missing references)
//IL_0b64: Unknown result type (might be due to invalid IL or missing references)
//IL_0b78: Unknown result type (might be due to invalid IL or missing references)
//IL_0b8c: Unknown result type (might be due to invalid IL or missing references)
//IL_0bb6: Unknown result type (might be due to invalid IL or missing references)
//IL_0bca: Unknown result type (might be due to invalid IL or missing references)
//IL_0bde: Unknown result type (might be due to invalid IL or missing references)
//IL_13f5: Unknown result type (might be due to invalid IL or missing references)
//IL_1409: Unknown result type (might be due to invalid IL or missing references)
//IL_141d: Unknown result type (might be due to invalid IL or missing references)
//IL_1447: Unknown result type (might be due to invalid IL or missing references)
//IL_145b: Unknown result type (might be due to invalid IL or missing references)
//IL_146f: Unknown result type (might be due to invalid IL or missing references)
//IL_1499: Unknown result type (might be due to invalid IL or missing references)
//IL_14ad: Unknown result type (might be due to invalid IL or missing references)
//IL_14c1: Unknown result type (might be due to invalid IL or missing references)
//IL_14eb: Unknown result type (might be due to invalid IL or missing references)
//IL_14ff: Unknown result type (might be due to invalid IL or missing references)
//IL_1513: Unknown result type (might be due to invalid IL or missing references)
//IL_153d: Unknown result type (might be due to invalid IL or missing references)
//IL_1551: Unknown result type (might be due to invalid IL or missing references)
//IL_1565: Unknown result type (might be due to invalid IL or missing references)
//IL_1238: Unknown result type (might be due to invalid IL or missing references)
//IL_124c: Unknown result type (might be due to invalid IL or missing references)
//IL_1260: Unknown result type (might be due to invalid IL or missing references)
//IL_128a: Unknown result type (might be due to invalid IL or missing references)
//IL_129e: Unknown result type (might be due to invalid IL or missing references)
//IL_12b2: Unknown result type (might be due to invalid IL or missing references)
//IL_12dc: Unknown result type (might be due to invalid IL or missing references)
//IL_12f0: Unknown result type (might be due to invalid IL or missing references)
//IL_1304: Unknown result type (might be due to invalid IL or missing references)
//IL_132e: Unknown result type (might be due to invalid IL or missing references)
//IL_1342: Unknown result type (might be due to invalid IL or missing references)
//IL_1356: Unknown result type (might be due to invalid IL or missing references)
//IL_1380: Unknown result type (might be due to invalid IL or missing references)
//IL_1394: Unknown result type (might be due to invalid IL or missing references)
//IL_13a8: Unknown result type (might be due to invalid IL or missing references)
//IL_15ad: Unknown result type (might be due to invalid IL or missing references)
//IL_15c1: Unknown result type (might be due to invalid IL or missing references)
//IL_15d5: Unknown result type (might be due to invalid IL or missing references)
//IL_15ff: Unknown result type (might be due to invalid IL or missing references)
//IL_1613: Unknown result type (might be due to invalid IL or missing references)
//IL_1627: Unknown result type (might be due to invalid IL or missing references)
//IL_1651: Unknown result type (might be due to invalid IL or missing references)
//IL_1665: Unknown result type (might be due to invalid IL or missing references)
//IL_1679: Unknown result type (might be due to invalid IL or missing references)
//IL_16a3: Unknown result type (might be due to invalid IL or missing references)
//IL_16b7: Unknown result type (might be due to invalid IL or missing references)
//IL_16cb: Unknown result type (might be due to invalid IL or missing references)
//IL_16f5: Unknown result type (might be due to invalid IL or missing references)
//IL_1709: Unknown result type (might be due to invalid IL or missing references)
//IL_171d: Unknown result type (might be due to invalid IL or missing references)
try
{
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
<>8__1 = new <>c__DisplayClass17_0();
CleanUpPosters();
GameObject val = GameObject.Find("Environment");
if ((Object)(object)val == (Object)null)
{
Plugin.Log.LogError((object)"Environment GameObject not found in the scene hierarchy");
return false;
}
Transform obj = val.transform.Find("HangarShip");
<hangarShip>5__2 = ((obj != null) ? ((Component)obj).gameObject : null);
if ((Object)(object)<hangarShip>5__2 == (Object)null)
{
Plugin.Log.LogError((object)"HangarShip GameObject not found under Environment");
return false;
}
<postersParent>5__3 = new GameObject("CustomPosters");
<postersParent>5__3.transform.SetParent(<hangarShip>5__2.transform);
<postersParent>5__3.transform.localPosition = Vector3.zero;
<posterPlane>5__4 = GameObject.Find("Environment/HangarShip/Plane.001");
if ((Object)(object)<posterPlane>5__4 == (Object)null)
{
Plugin.Log.LogError((object)"Poster [Plane.001] not found under HangarShip");
return false;
}
MeshRenderer component = <posterPlane>5__4.GetComponent<MeshRenderer>();
if ((Object)(object)component == (Object)null || ((Renderer)component).materials.Length == 0)
{
Plugin.Log.LogError((object)"Poster plane renderer or materials not found");
return false;
}
<posterData>5__5 = 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.Service.IsShipWindowsInstalled && Plugin.Service.IsWindow2Enabled)
{
Plugin.Log.LogInfo((object)"Repositioning posters due to ShipWindows Right Window enabled");
<posterData>5__5[1] = (new Vector3(6.4202f, 2.2577f, -10.8226f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2");
<posterData>5__5[3] = (new Vector3(6.4449f, 3.0961f, -10.8221f), new Vector3(0f, 0.026f, 2.68f), new Vector3(0.7289f, 0.9989f, 1f), "Poster4");
}
if (Plugin.Service.IsShipWindowsInstalled && Plugin.Service.IsWindow2Enabled && Plugin.Service.IsWiderShipModInstalled && Plugin.Service.WiderShipExtendedSide == "Left")
{
Plugin.Log.LogInfo((object)"Repositioning posters due to ShipWindows Left Window, Right Window and WiderShipMod Extended Side Left enabled");
<posterData>5__5[1] = (new Vector3(6.4202f, 2.2577f, -10.8226f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2");
<posterData>5__5[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>5__5[0] = (new Vector3(4.6777f, 2.9007f, -19.63f), new Vector3(0f, 118.2274f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1");
<posterData>5__5[2] = (new Vector3(9.7197f, 2.8151f, -17.4716f), new Vector3(0f, 180f, 356.3345f), new Vector3(0.7487f, 1.0539f, 1f), "Poster3");
<posterData>5__5[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__5[5] = (new Vector3(2.8647f, 2.7774f, -11.7341f), new Vector3(0f, 0f, 358.6752f), new Vector3(0.8596f, 1.2194f, 1f), "CustomTips");
}
if (Plugin.Service.IsWiderShipModInstalled)
{
Plugin.Log.LogInfo((object)("Repositioning posters due to WiderShipMod Extended Side: " + Plugin.Service.WiderShipExtendedSide));
switch (Plugin.Service.WiderShipExtendedSide)
{
case "Both":
<posterData>5__5[0] = (new Vector3(4.6877f, 2.9407f, -19.62f), new Vector3(0f, 118.2274f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1");
<posterData>5__5[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>5__5[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__5[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>5__5[0] = (new Vector3(4.2224f, 2.9318f, -16.8609f), new Vector3(0f, 200.9872f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1");
<posterData>5__5[1] = (new Vector3(6.4202f, 2.4776f, -10.8226f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2");
<posterData>5__5[2] = (new Vector3(9.9426f, 2.8591f, -17.4716f), new Vector3(0f, 180f, 356.3345f), new Vector3(0.7487f, 1.0539f, 1f), "Poster3");
<posterData>5__5[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>5__5[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__5[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":
if (!Plugin.Service.IsShipWindowsInstalled || !Plugin.Service.IsWindow2Enabled)
{
<posterData>5__5[0] = (new Vector3(4.6777f, 2.9007f, -19.63f), new Vector3(0f, 118.2274f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1");
<posterData>5__5[1] = (new Vector3(6.4202f, 2.2577f, -10.8226f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4882f, 2f), "Poster2");
<posterData>5__5[2] = (new Vector3(9.7197f, 2.8151f, -17.4716f), new Vector3(0f, 180f, 356.3345f), new Vector3(0.7487f, 1.0539f, 1f), "Poster3");
<posterData>5__5[3] = (new Vector3(5.2187f, 2.5963f, -11.0945f), new Vector3(0f, 337.5868f, 2.68f), new Vector3(0.7289f, 0.9989f, 1f), "Poster4");
<posterData>5__5[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__5[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.Service.Is2StoryShipModInstalled)
{
if (Plugin.Service.IsShipWindowsInstalled)
{
Plugin.Log.LogInfo((object)"Repositioning posters due to ShipWindows and 2 Story Ship Mod detected");
<posterData>5__5[0] = (new Vector3(6.5923f, 2.9318f, -17.4766f), new Vector3(0f, 179.2201f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1");
<posterData>5__5[1] = (new Vector3(9.0884f, 2.4776f, -8.8229f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2");
<posterData>5__5[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>5__5[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__5[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.Service.IsShipWindowsInstalled && Plugin.Service.IsWiderShipModInstalled)
{
Plugin.Log.LogInfo((object)"Repositioning posters due to ShipWindows and WiderShipMod detected with 2 Story Ship Mod");
<posterData>5__5[0] = (new Vector3(6.5923f, 2.9318f, -22.4766f), new Vector3(0f, 179.2201f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1");
<posterData>5__5[1] = (new Vector3(9.0884f, 2.4776f, -5.8265f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2");
<posterData>5__5[2] = (new Vector3(10.1364f, 2.8591f, -22.4788f), new Vector3(0f, 180.3376f, 0f), new Vector3(0.7487f, 1.0539f, 1f), "Poster3");
<posterData>5__5[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>5__5[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__5[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.Service.IsWiderShipModInstalled)
{
Plugin.Log.LogInfo((object)"Repositioning posters due to WiderShipMod detected with 2 Story Ship Mod");
<posterData>5__5[0] = (new Vector3(6.3172f, 2.9407f, -22.4766f), new Vector3(0f, 180f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1");
<posterData>5__5[1] = (new Vector3(9.5975f, 2.5063f, -5.8245f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2");
<posterData>5__5[2] = (new Vector3(10.1364f, 2.8591f, -22.4788f), new Vector3(0f, 180f, 356.3345f), new Vector3(0.7487f, 1.0539f, 1f), "Poster3");
<posterData>5__5[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>5__5[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__5[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
{
Plugin.Log.LogInfo((object)"Repositioning posters due to 2 Story Ship Mod detected");
if (Plugin.Service.EnableRightWindows && Plugin.Service.EnableLeftWindows)
{
Plugin.Log.LogInfo((object)"Repositioning posters due to 2 Story Ship Mod Left and Right windows enabled");
<posterData>5__5[0] = (new Vector3(10.1567f, 2.75f, -8.8293f), new Vector3(0f, 0f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1");
<posterData>5__5[1] = (new Vector3(9.0884f, 2.4776f, -8.8229f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2");
<posterData>5__5[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>5__5[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__5[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.Service.EnableRightWindows)
{
Plugin.Log.LogInfo((object)"Repositioning posters due to 2 Story Ship Mod Right window disabled");
<posterData>5__5[0] = (new Vector3(4.0286f, 2.9318f, -16.7774f), new Vector3(0f, 200.9872f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1");
<posterData>5__5[1] = (new Vector3(9.0884f, 2.4776f, -8.8229f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2");
<posterData>5__5[3] = (new Vector3(5.3599f, 2.5963f, -9.455f), new Vector3(0f, 307.2657f, 0f), new Vector3(0.7289f, 0.9989f, 1f), "Poster4");
<posterData>5__5[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__5[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.Service.EnableLeftWindows)
{
Plugin.Log.LogInfo((object)"Repositioning posters due to 2 Story Ship Mod Left window disabled");
<posterData>5__5[0] = (new Vector3(9.8324f, 2.9318f, -8.8257f), new Vector3(0f, 0f, 0f), new Vector3(0.6391f, 0.4882f, 2f), "Poster1");
<posterData>5__5[1] = (new Vector3(7.3648f, 2.4776f, -8.8229f), new Vector3(0f, 0f, 0f), new Vector3(0.7296f, 0.4896f, 1f), "Poster2");
<posterData>5__5[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>5__5[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__5[5] = (new Vector3(2.5679f, 2.6763f, -11.7341f), new Vector3(0f, 0f, 358.6752f), new Vector3(0.8596f, 1.2194f, 1f), "CustomTips");
}
}
}
}
List<string> list = Plugin.Service.PosterFolders.Where((string folder) => PosterConfig.IsPackEnabled(folder)).ToList();
if (list.Count == 0)
{
Plugin.Log.LogWarning((object)"No enabled packs found");
if ((Object)(object)<posterPlane>5__4 != (Object)null)
{
<posterPlane>5__4.SetActive(true);
}
return false;
}
list.Select((string pack) => Path.GetFileName(pack)).ToList();
List<string> list3;
if (PosterConfig.RandomizerModeSetting.Value == PosterConfig.RandomizerMode.PerPack)
{
if (!PosterConfig.PerSession.Value || _selectedPack == null || !list.Contains(_selectedPack))
{
List<int> list2 = list.Select((string p) => PosterConfig.GetPackChance(p)).ToList();
if (list2.Any((int c) => c > 0))
{
int num = list2.Sum();
double num2 = Plugin.Service.Rand.NextDouble() * (double)num;
double num3 = 0.0;
for (int i = 0; i < list.Count; i++)
{
num3 += (double)list2[i];
if (num2 <= num3)
{
_selectedPack = list[i];
break;
}
}
if (_selectedPack == null)
{
_selectedPack = list[0];
}
}
else
{
_selectedPack = list[Plugin.Service.Rand.Next(list.Count)];
}
string fileName = Path.GetFileName(_selectedPack);
Plugin.Log.LogInfo((object)("PerPack randomization enabled. Using pack: " + fileName + " [Chances: " + string.Join(", ", list2) + "]"));
}
list3 = new List<string> { _selectedPack };
}
else
{
if (!PosterConfig.PerSession.Value)
{
_selectedPack = null;
}
list3 = list;
Plugin.Log.LogInfo((object)"PerPoster - true, combining enabled packs");
}
<>8__1.allTextures = new Dictionary<string, List<(Texture2D, string)>>();
<>7__wrap6 = list3.GetEnumerator();
<>1__state = -3;
goto IL_1c7a;
}
case 1:
<>1__state = -4;
goto IL_1c0c;
case 2:
<>1__state = -3;
<i>5__9 += 5;
goto IL_1c56;
case 3:
{
<>1__state = -1;
goto IL_21d5;
}
IL_21e7:
if (<i>5__9 < <posterData>5__5.Length)
{
GameObject val2 = CreatePoster();
if (!((Object)(object)val2 == (Object)null))
{
((Object)val2).name = <posterData>5__5[<i>5__9].name;
val2.transform.SetParent(<postersParent>5__3.transform);
val2.transform.position = <posterData>5__5[<i>5__9].position;
val2.transform.rotation = Quaternion.Euler(<posterData>5__5[<i>5__9].rotation);
val2.transform.localScale = <posterData>5__5[<i>5__9].scale;
string key = <posterData>5__5[<i>5__9].name.ToLower();
if (<>8__1.prioritizedTextures.ContainsKey(key) && PosterConfig.IsFileEnabled(<>8__1.prioritizedTextures[key].filePath))
{
val2.AddComponent<PosterRenderer>().Initialize(<>8__1.prioritizedTextures[key].texture, _copiedMaterial);
Plugin.Log.LogDebug((object)("Loaded poster " + <posterData>5__5[<i>5__9].name + " from " + <>8__1.prioritizedTextures[key].filePath));
CreatedPosters.Add(val2);
<anyPosterLoaded>5__6 = true;
}
else
{
Plugin.Log.LogWarning((object)("No enabled texture found for " + <posterData>5__5[<i>5__9].name + ". Destroying the poster"));
Object.Destroy((Object)(object)val2);
}
<>2__current = null;
<>1__state = 3;
return true;
}
goto IL_21d5;
}
if (<anyPosterLoaded>5__6)
{
if ((Object)(object)<posterPlane>5__4 != (Object)null)
{
Object.Destroy((Object)(object)<posterPlane>5__4);
}
Transform obj2 = <hangarShip>5__2.transform.Find("Plane");
GameObject val3 = ((obj2 != null) ? ((Component)obj2).gameObject : null);
if ((Object)(object)val3 != (Object)null)
{
Object.Destroy((Object)(object)val3);
}
Plugin.Log.LogInfo((object)"Custom posters created successfully");
}
else if ((Object)(object)<posterPlane>5__4 != (Object)null)
{
<posterPlane>5__4.SetActive(true);
Plugin.Log.LogWarning((object)"Re-enabled vanilla Plane.001 poster due to no custom posters loaded");
}
return false;
IL_1c0c:
if (<>7__wrap9.MoveNext())
{
<>c__DisplayClass17_2 CS$<>8__locals0 = new <>c__DisplayClass17_2
{
CS$<>8__locals2 = <>8__2,
file = <>7__wrap9.Current
};
<>2__current = LoadTextureAsync(CS$<>8__locals0.file, delegate((Texture2D texture, string filePath) result)
{
if ((Object)(object)result.texture != (Object)null)
{
string key2 = Path.GetFileNameWithoutExtension(CS$<>8__locals0.file).ToLower();
if (!CS$<>8__locals0.CS$<>8__locals2.CS$<>8__locals1.allTextures.ContainsKey(key2))
{
CS$<>8__locals0.CS$<>8__locals2.CS$<>8__locals1.allTextures[key2] = new List<(Texture2D, string)>();
}
CS$<>8__locals0.CS$<>8__locals2.CS$<>8__locals1.allTextures[key2].Add((result.texture, CS$<>8__locals0.file));
}
else
{
Plugin.Log.LogWarning((object)("Failed to load texture from " + CS$<>8__locals0.file));
}
});
<>1__state = 1;
return true;
}
<>m__Finally2();
<>7__wrap9 = default(List<string>.Enumerator);
<>2__current = null;
<>1__state = 2;
return true;
IL_21d5:
<i>5__9++;
goto IL_21e7;
IL_1c56:
if (<i>5__9 < <filesToLoad>5__8.Count)
{
List<string> list4 = <filesToLoad>5__8.Skip(<i>5__9).Take(5).ToList();
<>7__wrap9 = list4.GetEnumerator();
<>1__state = -4;
goto IL_1c0c;
}
<>8__2 = null;
<filesToLoad>5__8 = null;
goto IL_1c7a;
IL_1c7a:
if (<>7__wrap6.MoveNext())
{
string current = <>7__wrap6.Current;
<>8__2 = new <>c__DisplayClass17_1();
<>8__2.CS$<>8__locals1 = <>8__1;
Path.GetFileName(current);
string text = Path.Combine(current, "posters");
string text2 = Path.Combine(current, "tips");
string text3 = Path.Combine(current, "CustomPosters", "posters");
string text4 = Path.Combine(current, "CustomPosters", "tips");
<filesToLoad>5__8 = new List<string>();
<>8__2.validExtensions = new string[4] { ".png", ".jpg", ".jpeg", ".bmp" };
foreach (string item in (from p in new string[4] { text, text2, text3, text4 }
where Directory.Exists(p)
select Path.GetFullPath(p).Replace('\\', '/')).Distinct<string>(StringComparer.OrdinalIgnoreCase).ToList())
{
List<string> collection = (from f in Directory.GetFiles(item)
where <>8__2.validExtensions.Contains(Path.GetExtension(f).ToLower()) && PosterConfig.IsFileEnabled(f)
select Path.GetFullPath(f).Replace('\\', '/')).ToList();
<filesToLoad>5__8.AddRange(collection);
}
<filesToLoad>5__8 = <filesToLoad>5__8.Distinct<string>(StringComparer.OrdinalIgnoreCase).ToList();
<i>5__9 = 0;
goto IL_1c56;
}
<>m__Finally1();
<>7__wrap6 = default(List<string>.Enumerator);
<>8__1.prioritizedTextures = new Dictionary<string, (Texture2D, string)>();
using (Dictionary<string, List<(Texture2D, string)>>.Enumerator enumerator2 = <>8__1.allTextures.GetEnumerator())
{
while (enumerator2.MoveNext())
{
<>c__DisplayClass17_3 CS$<>8__locals1 = new <>c__DisplayClass17_3
{
CS$<>8__locals3 = <>8__1,
kvp = enumerator2.Current
};
if (CS$<>8__locals1.kvp.Value.Count > 1)
{
List<int> list5 = CS$<>8__locals1.kvp.Value.Select(((Texture2D texture, string filePath) t) => PosterConfig.GetFileChance(t.filePath)).ToList();
if (list5.Any((int c) => c > 0))
{
int num4 = list5.Sum();
double num5 = Plugin.Service.Rand.NextDouble() * (double)num4;
double num6 = 0.0;
for (int j = 0; j < CS$<>8__locals1.kvp.Value.Count; j++)
{
num6 += (double)list5[j];
if (num5 <= num6)
{
CS$<>8__locals1.CS$<>8__locals3.prioritizedTextures[CS$<>8__locals1.kvp.Key] = CS$<>8__locals1.kvp.Value[j];
break;
}
}
if (!CS$<>8__locals1.CS$<>8__locals3.prioritizedTextures.ContainsKey(CS$<>8__locals1.kvp.Key))
{
CS$<>8__locals1.CS$<>8__locals3.prioritizedTextures[CS$<>8__locals1.kvp.Key] = CS$<>8__locals1.kvp.Value[0];
}
Path.GetFileName(CS$<>8__locals1.CS$<>8__locals3.prioritizedTextures[CS$<>8__locals1.kvp.Key].filePath);
_ = from t in CS$<>8__locals1.kvp.Value
where t.filePath != CS$<>8__locals1.CS$<>8__locals3.prioritizedTextures[CS$<>8__locals1.kvp.Key].filePath
select Path.GetFileName(t.filePath);
}
else
{
<>c__DisplayClass17_4 CS$<>8__locals2 = new <>c__DisplayClass17_4
{
selected = CS$<>8__locals1.kvp.Value.OrderBy(((Texture2D texture, string filePath) t) => Plugin.Service.GetFilePriority(t.filePath)).First()
};
CS$<>8__locals1.CS$<>8__locals3.prioritizedTextures[CS$<>8__locals1.kvp.Key] = CS$<>8__locals2.selected;
_ = from t in CS$<>8__locals1.kvp.Value
where t.filePath != CS$<>8__locals2.selected.filePath
select Path.GetFileName(t.filePath);
}
}
else
{
CS$<>8__locals1.CS$<>8__locals3.prioritizedTextures[CS$<>8__locals1.kvp.Key] = CS$<>8__locals1.kvp.Value[0];
}
}
}
if (<>8__1.allTextures.Count == 0)
{
Plugin.Log.LogWarning((object)"No textures found in enabled packs");
if ((Object)(object)<posterPlane>5__4 != (Object)null)
{
<posterPlane>5__4.SetActive(true);
}
return false;
}
<anyPosterLoaded>5__6 = false;
<i>5__9 = 0;
goto IL_21e7;
}
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
((IDisposable)<>7__wrap6).Dispose();
}
private void <>m__Finally2()
{
<>1__state = -3;
((IDisposable)<>7__wrap9).Dispose();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <DelayedUpdateMaterialsAsync>d__18 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public StartOfRound instance;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <DelayedUpdateMaterialsAsync>d__18(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if (_materialsUpdated)
{
return false;
}
<>2__current = (object)new WaitForEndOfFrame();
<>1__state = 1;
return true;
case 1:
{
<>1__state = -1;
GameObject val = GameObject.Find("Environment/HangarShip/Plane.001");
if ((Object)(object)val != (Object)null)
{
val.SetActive(false);
}
HideVanillaPosterPlane();
<>2__current = ((MonoBehaviour)instance).StartCoroutine(CreateCustomPostersAsync());
<>1__state = 2;
return true;
}
case 2:
<>1__state = -1;
_materialsUpdated = true;
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();
}
}
[CompilerGenerated]
private sealed class <LoadTextureAsync>d__11 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public string filePath;
public Action<(Texture2D texture, string filePath)> onComplete;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadTextureAsync>d__11(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Expected O, but got Unknown
if (<>1__state != 0)
{
return false;
}
<>1__state = -1;
try
{
if (!File.Exists(filePath))
{
Plugin.Log.LogError((object)("File not found: " + filePath));
onComplete?.Invoke((null, null));
return false;
}
Texture2D cachedTexture = Plugin.Service.GetCachedTexture(filePath);
if ((Object)(object)cachedTexture != (Object)null)
{
onComplete?.Invoke((cachedTexture, filePath));
return false;
}
byte[] array = File.ReadAllBytes(filePath);
Texture2D val = new Texture2D(2, 2);
if (!ImageConversion.LoadImage(val, array))
{
Plugin.Log.LogError((object)("Failed to load texture from " + filePath));
onComplete?.Invoke((null, null));
return false;
}
((Texture)val).filterMode = (FilterMode)0;
Plugin.Service.CacheTexture(filePath, val);
onComplete?.Invoke((val, filePath));
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Error loading file " + filePath + ": " + ex.Message));
onComplete?.Invoke((null, null));
}
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 bool _materialsUpdated = false;
private static string _selectedPack = null;
private static Material _copiedMaterial = null;
private static readonly List<GameObject> CreatedPosters = new List<GameObject>();
private static int _sessionMapSeed = 0;
private static bool _isNewLobby = true;
private static bool _sessionSeedInitialized = false;
[HarmonyPatch(typeof(GameNetworkManager), "Start")]
[HarmonyPostfix]
private static void GameNetworkManagerStartPatch()
{
_sessionSeedInitialized = false;
_sessionMapSeed = 0;
Plugin.Log.LogDebug((object)"Reset session seed initialization");
}
[HarmonyPatch(typeof(StartOfRound), "Start")]
[HarmonyPostfix]
private static void StartPatch(StartOfRound __instance)
{
_materialsUpdated = false;
CopyPlane001Material();
if (_isNewLobby)
{
if (!_sessionSeedInitialized)
{
_sessionMapSeed = (PosterConfig.PerSession.Value ? StartOfRound.Instance.randomMapSeed : Environment.TickCount);
_sessionSeedInitialized = true;
Plugin.Log.LogDebug((object)$"Initialized session with map seed: {_sessionMapSeed}");
}
int randomSeed;
if (PosterConfig.PerSession.Value)
{
randomSeed = _sessionMapSeed;
}
else
{
randomSeed = Environment.TickCount;
_selectedPack = null;
}
Plugin.Service.SetRandomSeed(randomSeed);
}
if (__instance.inShipPhase)
{
((MonoBehaviour)__instance).StartCoroutine(DelayedUpdateMaterialsAsync(__instance));
}
_isNewLobby = false;
}
[HarmonyPatch(typeof(GameNetworkManager), "StartHost")]
[HarmonyPostfix]
private static void StartHostPatch()
{
_isNewLobby = true;
}
[HarmonyPatch(typeof(GameNetworkManager), "JoinLobby")]
[HarmonyPostfix]
private static void JoinLobbyPatch()
{
_isNewLobby = true;
}
[IteratorStateMachine(typeof(<LoadTextureAsync>d__11))]
private static IEnumerator LoadTextureAsync(string filePath, Action<(Texture2D texture, string filePath)> onComplete)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadTextureAsync>d__11(0)
{
filePath = filePath,
onComplete = onComplete
};
}
private static void CopyPlane001Material()
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
GameObject val = GameObject.Find("Environment/HangarShip/Plane.001");
if ((Object)(object)val == (Object)null)
{
Plugin.Log.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)
{
Plugin.Log.LogError((object)"Poster plane renderer or materials not found");
}
else
{
_copiedMaterial = new Material(((Renderer)component).material);
}
}
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()
{
foreach (GameObject createdPoster in CreatedPosters)
{
if ((Object)(object)createdPoster != (Object)null)
{
PosterRenderer component = createdPoster.GetComponent<PosterRenderer>();
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
Object.Destroy((Object)(object)createdPoster);
}
}
CreatedPosters.Clear();
}
private static GameObject CreatePoster()
{
GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5);
if ((Object)(object)obj == (Object)null)
{
Plugin.Log.LogError((object)"Failed to create new poster GameObject");
}
return obj;
}
[IteratorStateMachine(typeof(<CreateCustomPostersAsync>d__17))]
private static IEnumerator CreateCustomPostersAsync()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CreateCustomPostersAsync>d__17(0);
}
[IteratorStateMachine(typeof(<DelayedUpdateMaterialsAsync>d__18))]
private static IEnumerator DelayedUpdateMaterialsAsync(StartOfRound instance)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <DelayedUpdateMaterialsAsync>d__18(0)
{
instance = instance
};
}
public static void ChangePosterPack(string packName)
{
if (string.IsNullOrEmpty(packName))
{
List<string> enabledPackNames = Plugin.Service.GetEnabledPackNames();
if (enabledPackNames.Count == 0)
{
return;
}
int num = enabledPackNames.FindIndex((string p) => p.Equals(_selectedPack, StringComparison.OrdinalIgnoreCase));
_selectedPack = enabledPackNames[(num + 1) % enabledPackNames.Count];
}
else
{
if (!Plugin.Service.GetEnabledPackNames().Contains<string>(packName, StringComparer.OrdinalIgnoreCase))
{
Plugin.Log.LogWarning((object)("Attempted to select invalid pack: " + packName));
return;
}
_selectedPack = packName;
}
Plugin.Service.SetRandomSeed(Environment.TickCount);
Plugin.Log.LogInfo((object)("Changed poster pack to - " + _selectedPack));
_materialsUpdated = false;
StartOfRound val = Object.FindObjectOfType<StartOfRound>();
if ((Object)(object)val != (Object)null && val.inShipPhase)
{
((MonoBehaviour)val).StartCoroutine(DelayedUpdateMaterialsAsync(val));
}
}
}
[BepInPlugin("seeya.customposters", "CustomPosters", "2.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "seeya.customposters";
public const string PLUGIN_NAME = "CustomPosters";
public const string PLUGIN_VERSION = "2.0.0";
}
private readonly Harmony _harmony = new Harmony("seeya.customposters");
public static Plugin Instance { get; private set; }
public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;
public static PosterService Service { get; private set; }
private void Awake()
{
Instance = this;
Log.LogInfo((object)"Initializing CustomPosters");
Service = new PosterService();
PosterConfig.Initialize(Log);
Log.LogDebug((object)"Applying patches");
_harmony.PatchAll(typeof(Patches));
Log.LogInfo((object)"Patches applied successfully");
Log.LogInfo((object)"CustomPosters is loaded!");
}
}
internal class PosterConfig
{
[Serializable]
public enum RandomizerMode
{
PerPack,
PerPoster
}
private static ConfigFile configFile;
public static ConfigEntry<RandomizerMode> RandomizerModeSetting { get; set; }
public static ConfigEntry<bool> PerSession { get; set; }
public static ConfigEntry<bool> EnableTextureCaching { get; set; }
public static void Initialize(ManualLogSource logger)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Expected O, but got Unknown
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Expected O, but got Unknown
//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
//IL_03b8: Expected O, but got Unknown
string text = Path.Combine(Paths.ConfigPath, "CustomPosters.cfg");
configFile = new ConfigFile(text, true);
configFile.SaveOnConfigSet = false;
MigrateOldConfigEntries(logger, text);
if (File.Exists(text))
{
File.WriteAllText(text, string.Empty);
}
RandomizerModeSetting = configFile.Bind<RandomizerMode>("Settings", "RandomizerMode", RandomizerMode.PerPack, "Controls how textures are randomized. PerPack: Selects one pack randomly for all posters. PerPoster: Randomizes textures for each poster from all enabled packs.");
PerSession = configFile.Bind<bool>("Settings", "PerSession", false, "When enabled, locks the randomization (PerPack or PerPoster) for the entire game session until the game is restarted. When disabled, randomization refreshes each time the lobby reloads.");
EnableTextureCaching = configFile.Bind<bool>("Settings", "EnableTextureCaching", true, "If true, caches textures in memory to improve performance. Disable to reduce memory usage.");
HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "CustomPosters", "seechela-CustomPosters" };
foreach (string posterFolder in Plugin.Service.PosterFolders)
{
try
{
string fileName = Path.GetFileName(posterFolder);
if (string.IsNullOrEmpty(fileName) || fileName.Equals("plugins", StringComparison.OrdinalIgnoreCase) || hashSet.Contains(fileName))
{
continue;
}
configFile.Bind<bool>(fileName, "Enabled", true, "Enable or disable the " + fileName + " pack");
configFile.Bind<int>(fileName, "Chance", 0, new ConfigDescription("Chance of selecting the " + fileName + " pack in PerPack randomization mode [0-100]. Set to 0 to use equal probability with other packs.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
string text2 = Path.Combine(posterFolder, "posters");
string text3 = Path.Combine(posterFolder, "tips");
string path = Path.Combine(posterFolder, "CustomPosters");
string text4 = Path.Combine(path, "posters");
string text5 = Path.Combine(path, "tips");
foreach (string item in new string[2] { text2, text4 }.Where(Directory.Exists))
{
foreach (string item2 in (from f in Directory.GetFiles(item)
where new string[4] { ".png", ".jpg", ".jpeg", ".bmp" }.Contains(Path.GetExtension(f).ToLower())
select f).ToList() ?? new List<string>())
{
string fileName2 = Path.GetFileName(item2);
configFile.Bind<bool>(fileName, fileName2, true, "Enable or disable poster file " + fileName2 + " in pack " + fileName);
configFile.Bind<int>(fileName, fileName2 + ".Chance", 0, new ConfigDescription("Chance of selecting poster " + fileName2 + " in PerPoster randomization mode [0-100]. Set to 0 to use equal probability with other posters.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
}
}
foreach (string item3 in new string[2] { text3, text5 }.Where(Directory.Exists))
{
foreach (string item4 in (from f in Directory.GetFiles(item3)
where new string[4] { ".png", ".jpg", ".jpeg", ".bmp" }.Contains(Path.GetExtension(f).ToLower())
select f).ToList() ?? new List<string>())
{
string fileName3 = Path.GetFileName(item4);
configFile.Bind<bool>(fileName, fileName3, true, "Enable or disable tip file " + fileName3 + " in pack " + fileName);
configFile.Bind<int>(fileName, fileName3 + ".Chance", 0, new ConfigDescription("Chance of selecting tip " + fileName3 + " in PerPoster randomization mode [0-100]. Set to 0 to use equal probability with other tips.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
}
}
}
catch (Exception ex)
{
logger.LogError((object)("Failed to parse mod path " + posterFolder + ": " + ex.Message));
}
}
ClearOrphanedEntries();
configFile.Save();
configFile.SaveOnConfigSet = true;
}
private static void MigrateOldConfigEntries(ManualLogSource logger, string configPath)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Expected O, but got Unknown
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Expected O, but got Unknown
if (!File.Exists(configPath))
{
return;
}
try
{
ConfigFile val = new ConfigFile(configPath, false);
List<(ConfigDefinition, ConfigDefinition, bool)> list = new List<(ConfigDefinition, ConfigDefinition, bool)>();
foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item4 in val)
{
string section = item4.Key.Section;
string key = item4.Key.Key;
if (key.StartsWith("Poster_", StringComparison.OrdinalIgnoreCase) || key.StartsWith("Tip_", StringComparison.OrdinalIgnoreCase))
{
string text = (key.StartsWith("Poster_") ? key.Substring(7) : key.Substring(4));
ConfigDefinition item = new ConfigDefinition(section, key);
ConfigDefinition item2 = new ConfigDefinition(section, text);
bool item3 = (bool)item4.Value.BoxedValue;
list.Add((item, item2, item3));
}
}
foreach (var (val2, val3, flag) in list)
{
val.Bind<bool>(val3, flag, new ConfigDescription("Migrated from " + val2.Key, (AcceptableValueBase)null, Array.Empty<object>()));
val.Remove(val2);
}
if (list.Count > 0)
{
val.Save();
}
}
catch (Exception ex)
{
logger.LogError((object)("Failed to migrate old config entries: " + ex.Message));
}
}
public static bool IsPackEnabled(string packPath)
{
string fileName = Path.GetFileName(packPath);
if (string.IsNullOrEmpty(fileName))
{
return false;
}
bool value = configFile.Bind<bool>(fileName, "Enabled", true, (ConfigDescription)null).Value;
Plugin.Log.LogDebug((object)$"Pack {fileName} enabled - {value}");
return value;
}
public static int GetPackChance(string packPath)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
string fileName = Path.GetFileName(packPath);
if (string.IsNullOrEmpty(fileName))
{
return 0;
}
return configFile.Bind<int>(fileName, "Chance", 0, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())).Value;
}
public static bool IsFileEnabled(string filePath)
{
string fileName = Path.GetFileName(filePath);
string normalizedFilePath = Path.GetFullPath(filePath).Replace('\\', '/').ToLower();
string text = Plugin.Service.PosterFolders.FirstOrDefault(delegate(string f)
{
string text2 = Path.GetFullPath(f).Replace('\\', '/').ToLower();
string value = Path.Combine(text2, "CustomPosters").Replace('\\', '/');
return normalizedFilePath.Contains(text2) || normalizedFilePath.Contains(value);
});
if (text == null)
{
return false;
}
string fileName2 = Path.GetFileName(text);
if (!configFile.Bind<bool>(fileName2, "Enabled", true, (ConfigDescription)null).Value)
{
return false;
}
return configFile.Bind<bool>(fileName2, fileName, true, (ConfigDescription)null).Value;
}
public static int GetFileChance(string filePath)
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
string fileName = Path.GetFileName(filePath);
string normalizedFilePath = Path.GetFullPath(filePath).Replace('\\', '/').ToLower();
string text = Plugin.Service.PosterFolders.FirstOrDefault(delegate(string f)
{
string text2 = Path.GetFullPath(f).Replace('\\', '/').ToLower();
string value = Path.Combine(text2, "CustomPosters").Replace('\\', '/');
return normalizedFilePath.Contains(text2) || normalizedFilePath.Contains(value);
});
if (text == null)
{
return 0;
}
string fileName2 = Path.GetFileName(text);
return configFile.Bind<int>(fileName2, fileName + ".Chance", 0, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())).Value;
}
private static void ClearOrphanedEntries()
{
((Dictionary<ConfigDefinition, string>)AccessTools.Property(typeof(ConfigFile), "OrphanedEntries").GetValue(configFile)).Clear();
}
}
public class PosterService
{
private readonly List<string> _posterFolders = new List<string>();
private readonly Dictionary<string, Texture2D> _textureCache = new Dictionary<string, Texture2D>();
private readonly string[] _validExtensions = new string[4] { ".png", ".jpg", ".jpeg", ".bmp" };
private Random _rand;
public IReadOnlyList<string> PosterFolders => _posterFolders.AsReadOnly();
public bool IsShipWindowsInstalled { get; private set; }
public bool IsWindow2Enabled { get; private set; }
public bool IsWiderShipModInstalled { get; private set; }
public string WiderShipExtendedSide { get; private set; }
public bool Is2StoryShipModInstalled { get; private set; }
public bool EnableRightWindows { get; private set; }
public bool EnableLeftWindows { get; private set; }
public Dictionary<string, bool> ShipWindowsStates { get; private set; } = new Dictionary<string, bool>();
public Random Rand => _rand;
public PosterService()
{
try
{
string pluginPath = Paths.PluginPath;
HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "CustomPosters", "seechela-CustomPosters" };
string[] directories = Directory.GetDirectories(pluginPath);
foreach (string text in directories)
{
string fileName = Path.GetFileName(text);
if (fileName.Equals("plugins", StringComparison.OrdinalIgnoreCase) || hashSet.Contains(fileName))
{
continue;
}
string path = Path.Combine(text, "posters").Replace('\\', '/').ToLower();
string path2 = Path.Combine(text, "tips").Replace('\\', '/').ToLower();
string path3 = Path.Combine(text, "CustomPosters");
string path4 = Path.Combine(path3, "posters").Replace('\\', '/').ToLower();
string path5 = Path.Combine(path3, "tips").Replace('\\', '/').ToLower();
if (Directory.Exists(path) || Directory.Exists(path2) || Directory.Exists(path4) || Directory.Exists(path5))
{
if (Directory.Exists(text))
{
Directory.GetDirectories(text).Select(Path.GetFileName);
}
_posterFolders.Add(text);
}
}
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Failed to initialize PosterService: " + ex.Message));
}
InitializeShipWindows();
InitializeWiderShipMod();
Initialize2StoryShipMod();
SetRandomSeed(Environment.TickCount);
}
private void InitializeShipWindows()
{
IsShipWindowsInstalled = Chainloader.PluginInfos.ContainsKey("TestAccount666.ShipWindows");
if (!IsShipWindowsInstalled)
{
return;
}
string path = Path.Combine(Paths.ConfigPath, "TestAccount666.ShipWindows.cfg");
if (!File.Exists(path))
{
Plugin.Log.LogWarning((object)"ShipWindows config file not found");
return;
}
try
{
string[] array = File.ReadAllLines(path);
bool flag = false;
string[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
string text = array2[i].Trim();
bool result;
if (text.StartsWith("[Right Window (SideRight)]"))
{
flag = true;
}
else if (flag && text.StartsWith("["))
{
flag = false;
}
else if (flag && text.StartsWith("1. Enabled = ") && bool.TryParse(text.Replace("1. Enabled = ", "").Trim(), out result))
{
IsWindow2Enabled = result;
Plugin.Log.LogInfo((object)$"ShipWindows Right Window Enabled - {IsWindow2Enabled}");
break;
}
}
if (!flag && !IsWindow2Enabled)
{
Plugin.Log.LogDebug((object)"Right Window section not found or disabled");
}
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Failed to read ShipWindows config: " + ex.Message));
}
}
private void InitializeWiderShipMod()
{
IsWiderShipModInstalled = Chainloader.PluginInfos.ContainsKey("mborsh.WiderShipMod");
if (!IsWiderShipModInstalled)
{
return;
}
try
{
Type type = Type.GetType("WiderShipMod");
if (type == null)
{
ReadWiderShipConfigFile();
return;
}
FieldInfo field = type.GetField("ExtendedSide", BindingFlags.Static | BindingFlags.Public);
if (field == null)
{
ReadWiderShipConfigFile();
return;
}
WiderShipExtendedSide = (string)field.GetValue(null);
Plugin.Log.LogInfo((object)("WiderShipMod detected with Extended Side - " + WiderShipExtendedSide));
}
catch (Exception)
{
ReadWiderShipConfigFile();
}
}
private void ReadWiderShipConfigFile()
{
string path = Path.Combine(Paths.ConfigPath, "mborsh.WiderShipMod.cfg");
if (!File.Exists(path))
{
Plugin.Log.LogError((object)"WiderShipMod config file not found, defaulting ExtendedSide to 'Both'");
WiderShipExtendedSide = "Both";
return;
}
try
{
string[] array = File.ReadAllLines(path);
for (int i = 0; i < array.Length; i++)
{
string text = array[i].Trim();
if (text.StartsWith("Extended Side = ", StringComparison.OrdinalIgnoreCase))
{
WiderShipExtendedSide = text.Substring("Extended Side = ".Length).Trim();
Plugin.Log.LogInfo((object)("WiderShipMod detected with Extended Side - " + WiderShipExtendedSide));
return;
}
}
Plugin.Log.LogWarning((object)"Extended Side not found in WiderShipMod config, defaulting to 'Both'");
WiderShipExtendedSide = "Both";
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Failed to read WiderShipMod config: " + ex.Message + ", defaulting ExtendedSide to 'Both'"));
WiderShipExtendedSide = "Both";
}
}
private void Initialize2StoryShipMod()
{
Is2StoryShipModInstalled = Chainloader.PluginInfos.ContainsKey("MelanieMelicious.2StoryShip");
if (!Is2StoryShipModInstalled)
{
return;
}
try
{
Type type = Type.GetType("2StoryShip");
if (type == null)
{
Read2StoryShipConfigFile();
return;
}
FieldInfo field = type.GetField("EnableRightWindows", BindingFlags.Static | BindingFlags.Public);
FieldInfo field2 = type.GetField("EnableLeftWindows", BindingFlags.Static | BindingFlags.Public);
if (field == null || field2 == null)
{
Plugin.Log.LogWarning((object)"Failed to find EnableRightWindows or EnableLeftWindows fields in 2StoryShipConfig");
Read2StoryShipConfigFile();
}
else
{
EnableRightWindows = (bool)field.GetValue(null);
EnableLeftWindows = (bool)field2.GetValue(null);
Plugin.Log.LogInfo((object)$"2StoryShipMod detected. RightWindows - {EnableRightWindows}, LeftWindows - {EnableLeftWindows}");
}
}
catch (Exception)
{
Read2StoryShipConfigFile();
}
}
private void Read2StoryShipConfigFile()
{
string path = Path.Combine(Paths.ConfigPath, "MelanieMelicious.2StoryShip.cfg");
if (!File.Exists(path))
{
Plugin.Log.LogError((object)"2StoryShipMod config file not found, defaulting RightWindows and LeftWindows to true");
EnableRightWindows = true;
EnableLeftWindows = true;
Plugin.Log.LogInfo((object)$"2StoryShipMod detected. RightWindows - {EnableRightWindows}, LeftWindows - {EnableLeftWindows}");
return;
}
try
{
string[] array = File.ReadAllLines(path);
bool flag = false;
bool flag2 = false;
string[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
string text = array2[i].Trim();
bool result2;
if (text.StartsWith("Enable Right Windows = ", StringComparison.OrdinalIgnoreCase))
{
if (bool.TryParse(text.Substring("Enable Right Windows = ".Length).Trim(), out var result))
{
EnableRightWindows = result;
flag = true;
}
}
else if (text.StartsWith("Enable Left Windows = ", StringComparison.OrdinalIgnoreCase) && bool.TryParse(text.Substring("Enable Left Windows = ".Length).Trim(), out result2))
{
EnableLeftWindows = result2;
flag2 = true;
}
if (flag && flag2)
{
break;
}
}
if (!flag || !flag2)
{
Plugin.Log.LogWarning((object)"One or both window settings not found in 2StoryShipMod config, defaulting unset values to true");
if (!flag)
{
EnableRightWindows = true;
}
if (!flag2)
{
EnableLeftWindows = true;
}
}
Plugin.Log.LogInfo((object)$"2StoryShipMod detected. RightWindows - {EnableRightWindows}, LeftWindows - {EnableLeftWindows}");
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Failed to read 2StoryShipMod config: " + ex.Message + ", defaulting RightWindows and LeftWindows to true"));
EnableRightWindows = true;
EnableLeftWindows = true;
Plugin.Log.LogInfo((object)$"2StoryShipMod detected. RightWindows - {EnableRightWindows}, LeftWindows - {EnableLeftWindows}");
}
}
public void SetRandomSeed(int seed)
{
_rand = new Random(seed);
}
public Texture2D GetCachedTexture(string filePath)
{
if (!PosterConfig.EnableTextureCaching.Value)
{
return null;
}
if (!_textureCache.TryGetValue(filePath, out var value))
{
return null;
}
return value;
}
public void CacheTexture(string filePath, Texture2D texture)
{
if (PosterConfig.EnableTextureCaching.Value && !_textureCache.ContainsKey(filePath))
{
_textureCache[filePath] = texture;
}
}
public void ClearCache()
{
foreach (Texture2D value in _textureCache.Values)
{
if ((Object)(object)value != (Object)null)
{
Object.Destroy((Object)(object)value);
}
}
_textureCache.Clear();
}
public List<string> GetEnabledPackNames()
{
List<string> list = (from f in PosterFolders
where PosterConfig.IsPackEnabled(f)
select Path.GetFullPath(f).Replace('\\', '/')).Distinct<string>(StringComparer.OrdinalIgnoreCase).ToList();
List<string> values = list.Select(Path.GetFileName).ToList();
Plugin.Log.LogDebug((object)("Enabled pack names: " + string.Join(", ", values)));
return list;
}
public int GetFilePriority(string filePath)
{
return Path.GetExtension(filePath).ToLower() switch
{
".png" => 1,
".jpg" => 2,
".jpeg" => 3,
".bmp" => 4,
_ => int.MaxValue,
} * 1000 + Rand.Next(0, 1000);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "CustomPosters";
public const string PLUGIN_NAME = "CustomPosters";
public const string PLUGIN_VERSION = "2.0.0";
}
}