using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using REPOLib.Modules; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("TIValuableSpawner2")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TIValuableSpawner2")] [assembly: AssemblyTitle("TIValuableSpawner2")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 TIValuableSpawner2 { [BepInPlugin("jonathan.tivaluablespawner2", "TI Valuable Spawner v2 (camera-relative)", "1.0.0")] public class Plugin : BaseUnityPlugin { private static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"TI Valuable Spawner v2 loaded. F10=TwilightImperiumBox, F1=ProphecyOfKingsBox, F2=ThundersEdgeBox - spawns 2m in front of the camera."); } private void Update() { if (Input.GetKeyDown((KeyCode)291)) { TrySpawnInFrontOfCamera("TwilightImperiumBox"); } if (Input.GetKeyDown((KeyCode)282)) { TrySpawnInFrontOfCamera("ProphecyOfKingsBox"); } if (Input.GetKeyDown((KeyCode)283)) { TrySpawnInFrontOfCamera("ThundersEdgeBox"); } } private void TrySpawnInFrontOfCamera(string prefabName) { //IL_0030: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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_01be: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Camera.main != (Object)null) { Log.LogInfo((object)$"DIAG: Camera.main = '{((Object)((Component)Camera.main).gameObject).name}' pos={((Component)Camera.main).transform.position} fwd={((Component)Camera.main).transform.forward}"); } else { Log.LogInfo((object)"DIAG: Camera.main is null."); } PlayerController instance = PlayerController.instance; if ((Object)(object)instance == (Object)null) { Log.LogError((object)"PlayerController.instance is null - can't compute a spawn point."); return; } Log.LogInfo((object)$"DIAG: PlayerController pos={((Component)instance).transform.position} fwd={((Component)instance).transform.forward}"); PrefabRef val = null; foreach (PrefabRef allValuable in Valuables.AllValuables) { if (((PrefabRef)(object)allValuable).PrefabName == prefabName) { val = allValuable; break; } } if (val == null) { Log.LogError((object)("Could not find a registered PrefabRef named '" + prefabName + "' in Valuables.AllValuables.")); return; } Vector3 val2 = ((Component)instance).transform.position + Vector3.up * 1.2f + ((Component)instance).transform.forward * 2f; Quaternion val3 = Quaternion.LookRotation(-((Component)instance).transform.forward, Vector3.up); GameObject val4 = Valuables.SpawnValuable(val, val2, val3); if ((Object)(object)val4 == (Object)null) { Log.LogError((object)"SpawnValuable returned null."); return; } Log.LogInfo((object)$"SUCCESS: Spawned '{prefabName}' at {val2} (PlayerController-relative), facing the camera, 2m away."); DumpSpawnedObjectImmediate(val4); ((MonoBehaviour)this).StartCoroutine(CheckSpawnedObjectAfterDelay(val4, val2)); } private void DumpSpawnedObjectImmediate(GameObject spawned) { //IL_016b: Unknown result type (might be due to invalid IL or missing references) Log.LogInfo((object)$"DIAG immediate: active={spawned.activeInHierarchy} activeSelf={spawned.activeSelf} layer={LayerMask.LayerToName(spawned.layer)} tag={spawned.tag}"); Renderer[] componentsInChildren = spawned.GetComponentsInChildren(true); Log.LogInfo((object)$"DIAG immediate: found {componentsInChildren.Length} Renderer(s) in children (includeInactive)"); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { string text = "none"; if (val.sharedMaterials != null && val.sharedMaterials.Length != 0) { List list = new List(); Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 == (Object)null) { list.Add("NULL-MATERIAL"); continue; } string text2 = (((Object)(object)val2.shader != (Object)null) ? ((Object)val2.shader).name : "NULL-SHADER"); list.Add(((Object)val2).name + "(shader=" + text2 + ")"); } text = string.Join(", ", list); } Log.LogInfo((object)$"DIAG immediate: Renderer '{((Object)((Component)val).gameObject).name}' enabled={val.enabled} isVisible={val.isVisible} bounds={val.bounds} materials=[{text}]"); } } private IEnumerator CheckSpawnedObjectAfterDelay(GameObject spawned, Vector3 originalSpawnPosition) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) yield return (object)new WaitForSeconds(1f); if ((Object)(object)spawned == (Object)null) { Log.LogWarning((object)"DIAG +1s: the spawned GameObject is NULL/destroyed - it did not survive one second. This would explain an empty screenshot taken shortly after spawn."); yield break; } float num = Vector3.Distance(spawned.transform.position, originalSpawnPosition); Log.LogInfo((object)$"DIAG +1s: object still exists. pos={spawned.transform.position} drift_from_spawn={num:F3}m active={spawned.activeInHierarchy}"); Renderer[] componentsInChildren = spawned.GetComponentsInChildren(true); if (componentsInChildren.Length == 0) { Log.LogWarning((object)"DIAG +1s: object exists but has ZERO Renderer components anywhere in its hierarchy - this alone would fully explain an invisible object (no mesh renderer path was ever wired onto this prefab, or it's on a child that isn't part of the instantiated hierarchy)."); } Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Log.LogInfo((object)$"DIAG +1s: Renderer '{((Object)((Component)val).gameObject).name}' enabled={val.enabled} isVisible={val.isVisible} bounds={val.bounds}"); } } } }