using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LGUCompanyPosters")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Spawns Y4NGZ propaganda posters on the Company Building wall")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+8c5521e37f37e3d76518a16d04e5d1051842f105")] [assembly: AssemblyProduct("LGUCompanyPosters")] [assembly: AssemblyTitle("LGUCompanyPosters")] [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 LGUCompanyPosters { [BepInPlugin("com.y4ngz.lgucompanyposters", "LGUCompanyPosters", "1.2.0")] public class Plugin : BaseUnityPlugin { public const string PLUGIN_GUID = "com.y4ngz.lgucompanyposters"; public const string PLUGIN_NAME = "LGUCompanyPosters"; public const string PLUGIN_VERSION = "1.2.0"; internal static ManualLogSource Log; internal static Harmony harmony; internal static Texture2D posterTexture; internal static Material posterMaterial; internal static bool assetsReady = false; internal static bool spawnedThisLanding = false; internal static readonly Vector3 POSTER_LEFT_POS = new Vector3(-26f, 35f, -37f); internal static readonly Vector3 POSTER_LEFT_ROT = new Vector3(0f, 90f, 0f); internal static readonly Vector3 POSTER_RIGHT_POS = new Vector3(-26f, 35f, 0f); internal static readonly Vector3 POSTER_RIGHT_ROT = new Vector3(0f, 90f, 0f); internal static readonly Vector3 POSTER_SCALE = new Vector3(22.5f, 30f, 0.02f); private void Awake() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"LGUCompanyPosters v1.2.0 loaded!"); LoadTextureFromFile(); harmony = new Harmony("com.y4ngz.lgucompanyposters"); harmony.PatchAll(); } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } private void LoadTextureFromFile() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown try { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "PropagandaPoster.png"); if (!File.Exists(text)) { Log.LogError((object)("Poster texture not found at: " + text)); Log.LogError((object)"Place PropagandaPoster.png next to LGUCompanyPosters.dll"); return; } byte[] array = File.ReadAllBytes(text); posterTexture = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(posterTexture, array)) { Log.LogError((object)"Failed to decode PNG data."); return; } ((Object)posterTexture).name = "PropagandaPoster"; ((Texture)posterTexture).wrapMode = (TextureWrapMode)1; ((Texture)posterTexture).filterMode = (FilterMode)1; Log.LogInfo((object)$"Poster texture loaded: {((Texture)posterTexture).width}x{((Texture)posterTexture).height}"); assetsReady = true; } catch (Exception arg) { Log.LogError((object)$"Failed to load poster texture: {arg}"); } } internal static Shader FindWorkingShader() { string[] array = new string[3] { "Unlit/Texture", "HDRP/Unlit", "Universal Render Pipeline/Unlit" }; foreach (string text in array) { Shader val = Shader.Find(text); if ((Object)(object)val != (Object)null) { Log.LogInfo((object)("Using preferred shader: " + text)); return val; } } try { MeshRenderer[] array2 = Object.FindObjectsOfType(); foreach (MeshRenderer val2 in array2) { string name = ((Object)((Component)val2).gameObject).name; if (name.StartsWith("Poster") && (Object)(object)((Renderer)val2).sharedMaterial != (Object)null && (Object)(object)((Renderer)val2).sharedMaterial.shader != (Object)null) { Log.LogInfo((object)("Borrowed shader '" + ((Object)((Renderer)val2).sharedMaterial.shader).name + "' from '" + name + "'")); return ((Renderer)val2).sharedMaterial.shader; } } } catch (Exception ex) { Log.LogWarning((object)("Error searching for poster shader: " + ex.Message)); } array = new string[3] { "HDRP/Lit", "Universal Render Pipeline/Lit", "Standard" }; foreach (string text2 in array) { Shader val3 = Shader.Find(text2); if ((Object)(object)val3 != (Object)null) { Log.LogInfo((object)("Using fallback shader: " + text2)); return val3; } } Log.LogError((object)"Could not find any working shader!"); return null; } internal static Material GetOrCreateMaterial() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)posterMaterial != (Object)null) { return posterMaterial; } Shader val = FindWorkingShader(); if ((Object)(object)val == (Object)null) { return null; } posterMaterial = new Material(val); ((Object)posterMaterial).name = "PropagandaPoster_Mat"; posterMaterial.mainTexture = (Texture)(object)posterTexture; posterMaterial.color = Color.white; if (posterMaterial.HasProperty("_Cull")) { posterMaterial.SetFloat("_Cull", 0f); } try { if (posterMaterial.HasProperty("_Metallic")) { posterMaterial.SetFloat("_Metallic", 0f); } if (posterMaterial.HasProperty("_Smoothness")) { posterMaterial.SetFloat("_Smoothness", 0f); } if (posterMaterial.HasProperty("_Glossiness")) { posterMaterial.SetFloat("_Glossiness", 0f); } if (posterMaterial.HasProperty("_SpecColor")) { posterMaterial.SetColor("_SpecColor", Color.black); } if (posterMaterial.HasProperty("_EmissiveColor")) { posterMaterial.SetColor("_EmissiveColor", new Color(0.5f, 0.5f, 0.5f)); posterMaterial.EnableKeyword("_EMISSION"); } else if (posterMaterial.HasProperty("_EmissionColor")) { posterMaterial.SetColor("_EmissionColor", new Color(0.5f, 0.5f, 0.5f)); posterMaterial.EnableKeyword("_EMISSION"); } } catch (Exception ex) { Log.LogWarning((object)("Could not set all material properties: " + ex.Message)); } Log.LogInfo((object)("Material created with shader: " + ((Object)val).name)); return posterMaterial; } internal static Mesh CreateQuadMesh() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: 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_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) Mesh val = new Mesh(); ((Object)val).name = "PosterQuad"; val.vertices = (Vector3[])(object)new Vector3[8] { new Vector3(-0.5f, -0.5f, 0f), new Vector3(0.5f, -0.5f, 0f), new Vector3(0.5f, 0.5f, 0f), new Vector3(-0.5f, 0.5f, 0f), new Vector3(-0.5f, -0.5f, 0f), new Vector3(0.5f, -0.5f, 0f), new Vector3(0.5f, 0.5f, 0f), new Vector3(-0.5f, 0.5f, 0f) }; val.uv = (Vector2[])(object)new Vector2[8] { new Vector2(1f, 0f), new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(0f, 1f) }; val.triangles = new int[12] { 0, 1, 2, 0, 2, 3, 4, 6, 5, 4, 7, 6 }; val.normals = (Vector3[])(object)new Vector3[8] { -Vector3.forward, -Vector3.forward, -Vector3.forward, -Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward }; val.RecalculateBounds(); return val; } internal static void TrySpawnPosters() { //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) if (!assetsReady || (Object)(object)posterTexture == (Object)null) { Log.LogWarning((object)"Cannot spawn posters — texture not loaded."); return; } if (spawnedThisLanding) { Log.LogDebug((object)"Posters already spawned this landing, skipping."); return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.currentLevel == (Object)null) { Log.LogDebug((object)"[TrySpawn] StartOfRound or currentLevel is null."); return; } string text = instance.currentLevel.PlanetName ?? ""; string text2 = instance.currentLevel.sceneName ?? ""; Log.LogInfo((object)("[TrySpawn] Planet: \"" + text + "\" Scene: \"" + text2 + "\"")); if (!text.Contains("Gordion") && !text.Contains("Company") && text2 != "CompanyBuilding") { Log.LogInfo((object)"[TrySpawn] Not Company moon — posters will not spawn."); return; } Material orCreateMaterial = GetOrCreateMaterial(); if ((Object)(object)orCreateMaterial == (Object)null) { Log.LogError((object)"Failed to create material. Posters not spawned."); return; } Mesh mesh = CreateQuadMesh(); SpawnPoster("PropagandaPoster_Left", POSTER_LEFT_POS, POSTER_LEFT_ROT, POSTER_SCALE, orCreateMaterial, mesh); SpawnPoster("PropagandaPoster_Right", POSTER_RIGHT_POS, POSTER_RIGHT_ROT, POSTER_SCALE, orCreateMaterial, mesh); spawnedThisLanding = true; Log.LogInfo((object)"Propaganda posters spawned on Company Building wall."); } private static void SpawnPoster(string instanceName, Vector3 position, Vector3 rotation, Vector3 scale, Material mat, Mesh mesh) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = new GameObject(instanceName); val.transform.position = position; val.transform.localRotation = Quaternion.Euler(rotation); val.transform.localScale = scale; val.AddComponent().sharedMesh = mesh; MeshRenderer obj = val.AddComponent(); ((Renderer)obj).sharedMaterial = mat; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)2; ((Renderer)obj).receiveShadows = true; AddPosterLight(val, scale); Log.LogInfo((object)$"[{instanceName}] Poster spawned at {position}, shader: {((Object)mat.shader).name}"); } catch (Exception arg) { Log.LogError((object)$"Failed to spawn poster '{instanceName}': {arg}"); } } private static void AddPosterLight(GameObject poster, Vector3 posterScale) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("PosterSpotLight"); val.transform.SetParent(poster.transform); float y = posterScale.y; val.transform.localPosition = new Vector3(0f, y * 0.6f, -0.5f); val.transform.localRotation = Quaternion.Euler(45f, 0f, 0f); Light obj = val.AddComponent(); obj.type = (LightType)0; obj.color = new Color(1f, 0.95f, 0.85f); obj.intensity = 15f; obj.range = 8f; obj.spotAngle = 60f; obj.shadows = (LightShadows)2; } internal static void DespawnPosters() { GameObject val = GameObject.Find("PropagandaPoster_Left"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } GameObject val2 = GameObject.Find("PropagandaPoster_Right"); if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)val2); } } } [HarmonyPatch(typeof(StartOfRound), "openingDoorsSequence")] internal class PosterSpawnOnLandingPatch { [HarmonyPostfix] private static void Postfix() { try { Plugin.Log.LogInfo((object)"[PosterSpawn] openingDoorsSequence fired."); Plugin.TrySpawnPosters(); } catch (Exception arg) { Plugin.Log.LogError((object)$"PosterSpawnOnLandingPatch error: {arg}"); } } } [HarmonyPatch(typeof(StartOfRound), "ShipLeave")] internal class PosterResetOnLeavePatch { [HarmonyPostfix] private static void Postfix() { Plugin.DespawnPosters(); Plugin.spawnedThisLanding = false; } } [HarmonyPatch(typeof(StartOfRound), "ShipLeaveAutomatically")] internal class PosterResetOnAutoLeavePatch { [HarmonyPostfix] private static void Postfix() { Plugin.DespawnPosters(); Plugin.spawnedThisLanding = false; } } }