Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ExpressTrainToHell v0.9.0
plugins/ExpressTrainToHell.dll
Decompiled 3 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ExpressTrainToHell")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c9da09715ca6697196f42b9c04674c871b89d42c")] [assembly: AssemblyProduct("ExpressTrainToHell")] [assembly: AssemblyTitle("ExpressTrainToHell")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 ExpressTrainToHell { internal static class Assets { private const int SoundRate = 24000; private static readonly Dictionary<string, Mesh> meshes = new Dictionary<string, Mesh>(); private static readonly Dictionary<string, AudioClip> sounds = new Dictionary<string, AudioClip>(); private static readonly int[] AdpcmSteps = new int[89] { 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 }; private static readonly int[] AdpcmIndex = new int[8] { -1, -1, -1, -1, 2, 4, 6, 8 }; private static AudioMixerGroup mixer; private static AudioMixerGroup Mixer { get { if (Object.op_Implicit((Object)(object)mixer) || !Object.op_Implicit((Object)(object)AudioManager.instance) || !Object.op_Implicit((Object)(object)AudioManager.instance.SoundMasterGroup)) { return mixer; } AudioMixerGroup[] array = AudioManager.instance.SoundMasterGroup.audioMixer.FindMatchingGroups("Sound Effects"); mixer = ((array.Length != 0) ? array[0] : AudioManager.instance.SoundMasterGroup); return mixer; } } internal static byte[] Bytes(string name) { using Stream stream = typeof(Assets).Assembly.GetManifestResourceStream("ExpressTrainToHell." + name); if (stream == null) { throw new FileNotFoundException("Embedded asset missing: " + name); } byte[] array = new byte[stream.Length]; for (int i = 0; i < array.Length; i += stream.Read(array, i, array.Length - i)) { } return array; } internal static Mesh LoadMesh(string name) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown if (meshes.TryGetValue(name, out var value) && Object.op_Implicit((Object)(object)value)) { return value; } byte[] array = Bytes(name + ".mesh"); int num = BitConverter.ToInt32(array, 0); int num2 = BitConverter.ToInt32(array, 4); int num3 = 8; Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector3[] array3 = (Vector3[])(object)new Vector3[num]; Vector2[] array4 = (Vector2[])(object)new Vector2[num]; int[] array5 = new int[num2]; int num4 = 0; while (num4 < num) { array2[num4] = new Vector3(F(array, num3), F(array, num3 + 4), F(array, num3 + 8)); num4++; num3 += 12; } int num5 = 0; while (num5 < num) { array3[num5] = new Vector3(F(array, num3), F(array, num3 + 4), F(array, num3 + 8)); num5++; num3 += 12; } int num6 = 0; while (num6 < num) { array4[num6] = new Vector2(F(array, num3), F(array, num3 + 4)); num6++; num3 += 8; } int num7 = 0; while (num7 < num2) { array5[num7] = BitConverter.ToInt32(array, num3); num7++; num3 += 4; } Mesh val = new Mesh { name = name }; if (num > 65535) { val.indexFormat = (IndexFormat)1; } val.vertices = array2; val.normals = array3; val.uv = array4; val.triangles = array5; val.RecalculateBounds(); return meshes[name] = val; } private static float F(byte[] b, int o) { return BitConverter.ToSingle(b, o); } internal static Texture2D LoadTexture(string name) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002f: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true) { name = name, wrapMode = (TextureWrapMode)1 }; ImageConversion.LoadImage(val, Bytes(name + ".png")); return val; } internal static Texture2D LoadCompressed(string name, bool linear = false) { //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_0011: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = name, wrapMode = (TextureWrapMode)1, anisoLevel = 4 }; ImageConversion.LoadImage(val, Bytes(name + ".png")); val.Compress(true); val.Apply(false, true); return val; } internal static Material Metal(Material mat, Texture2D normal, float metallic, float smoothness) { string[] array = new string[2] { "_NormalTexture", "_BumpMap" }; foreach (string text in array) { if (mat.HasProperty(text)) { mat.SetTexture(text, (Texture)(object)normal); } } array = new string[2] { "_NormalStrength", "_BumpScale" }; foreach (string text2 in array) { if (mat.HasProperty(text2)) { mat.SetFloat(text2, 1f); } } mat.EnableKeyword("_NORMALMAP"); if (mat.HasProperty("_Metallic")) { mat.SetFloat("_Metallic", metallic); } array = new string[2] { "_Smoothness", "_Glossiness" }; foreach (string text3 in array) { if (mat.HasProperty(text3)) { mat.SetFloat(text3, smoothness); } } return mat; } internal static Material GlowingPalette(Material baseMat, string name, Texture2D palette, float strength) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) Material val = MakeMaterial(baseMat, name, palette); string[] array = new string[2] { "_EmissionTexture", "_EmissionMap" }; foreach (string text in array) { if (val.HasProperty(text)) { val.SetTexture(text, (Texture)(object)palette); } } if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", Color.white * strength); } array = new string[3] { "_BaseColor", "_Color", "_AlbedoColor" }; foreach (string text2 in array) { if (val.HasProperty(text2)) { val.SetColor(text2, Color.black); } } array = new string[4] { "_Smoothness", "_Glossiness", "_Metallic", "_FresnelAmount" }; foreach (string text3 in array) { if (val.HasProperty(text3)) { val.SetFloat(text3, 0f); } } val.EnableKeyword("_EMISSION"); val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1; return val; } internal static Texture2D LoadPalette(string name) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0036: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { name = name, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)0 }; ImageConversion.LoadImage(val, Bytes(name + ".png")); return val; } internal static AudioClip LoadSound(string name) { if (sounds.TryGetValue(name, out var value) && Object.op_Implicit((Object)(object)value)) { return value; } float[] array; if (Has(name + ".adpcm")) { array = Adpcm(Bytes(name + ".adpcm")); } else { byte[] array2 = Bytes(name + ".pcm"); array = new float[array2.Length / 2]; for (int i = 0; i < array.Length; i++) { array[i] = (float)BitConverter.ToInt16(array2, i * 2) / 32768f; } } value = AudioClip.Create(name, array.Length, 1, 24000, false); value.SetData(array, 0); return sounds[name] = value; } private static bool Has(string name) { return typeof(Assets).Assembly.GetManifestResourceInfo("ExpressTrainToHell." + name) != null; } private static float[] Adpcm(byte[] b) { int num = BitConverter.ToInt32(b, 0); float[] array = new float[num]; int num2 = 0; int num3 = 0; for (int i = 0; i < num; i++) { int num4 = (b[4 + (i >> 1)] >> (i & 1) * 4) & 0xF; int num5 = AdpcmSteps[num3]; int num6 = num5 >> 3; if ((num4 & 4) != 0) { num6 += num5; } if ((num4 & 2) != 0) { num6 += num5 >> 1; } if ((num4 & 1) != 0) { num6 += num5 >> 2; } num2 = Mathf.Clamp(((num4 & 8) != 0) ? (num2 - num6) : (num2 + num6), -32768, 32767); num3 = Mathf.Clamp(num3 + AdpcmIndex[num4 & 7], 0, 88); array[i] = (float)num2 / 32768f; } return array; } private static AudioSource Source(string label, AudioClip clip, Transform parent, float volume, float maxDistance) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ExpressTrain " + label + " " + (Object.op_Implicit((Object)(object)clip) ? ((Object)clip).name : "?")); val.transform.SetParent(parent, false); AudioSource obj = val.AddComponent<AudioSource>(); obj.clip = clip; obj.volume = volume; obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = 1.5f; obj.maxDistance = maxDistance; obj.dopplerLevel = 0f; obj.outputAudioMixerGroup = Mixer; return obj; } internal static void Play(AudioClip clip, Transform follow, float volume = 1f, float maxDistance = 15f) { if (Object.op_Implicit((Object)(object)clip)) { AudioSource obj = Source("Sound", clip, follow, volume, maxDistance); obj.Play(); Object.Destroy((Object)(object)((Component)obj).gameObject, clip.length + 0.2f); } } internal static AudioSource Loop(AudioClip clip, Transform follow, float volume = 1f, float maxDistance = 15f) { AudioSource val = Source("Loop", clip, follow, volume, maxDistance); val.loop = true; if (Object.op_Implicit((Object)(object)clip)) { val.time = Random.Range(0f, clip.length); val.Play(); } return val; } internal static Material MakeMaterial(Material baseMat, string name, Texture2D albedo, float smoothness = 0.15f) { //IL_001a: 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_0020: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) Material val = (Object.op_Implicit((Object)(object)baseMat) ? new Material(baseMat) : new Material(Shader.Find("Standard"))); ((Object)val).name = name; string[] array = new string[4] { "_BaseTexture", "_MainTex", "_BaseMap", "_AlbedoTexture" }; foreach (string text in array) { if (val.HasProperty(text)) { val.SetTexture(text, (Texture)(object)albedo); } } array = new string[2] { "_NormalTexture", "_BumpMap" }; foreach (string text2 in array) { if (val.HasProperty(text2)) { val.SetTexture(text2, (Texture)null); } } array = new string[3] { "_BaseColor", "_Color", "_AlbedoColor" }; foreach (string text3 in array) { if (val.HasProperty(text3)) { val.SetColor(text3, Color.white); } } array = new string[4] { "_MetallicTexture", "_SmoothnessTexture", "_MetallicGlossMap", "_SpecGlossMap" }; foreach (string text4 in array) { if (val.HasProperty(text4)) { val.SetTexture(text4, (Texture)null); } } val.DisableKeyword("_METALLICGLOSSMAP"); val.DisableKeyword("_SPECGLOSSMAP"); val.DisableKeyword("_NORMALMAP"); if (val.HasProperty("_SmoothnessTextureChannel")) { val.SetFloat("_SmoothnessTextureChannel", 0f); } if (val.HasProperty("_GlossMapScale")) { val.SetFloat("_GlossMapScale", 1f); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } array = new string[2] { "_Smoothness", "_Glossiness" }; foreach (string text5 in array) { if (val.HasProperty(text5)) { val.SetFloat(text5, smoothness); } } if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", Color.black); } if (val.HasProperty("_FresnelAmount")) { val.SetFloat("_FresnelAmount", 0f); } if (val.HasProperty("_EmissionTexture")) { val.SetTexture("_EmissionTexture", (Texture)null); } if (val.HasProperty("_TilingX")) { val.SetFloat("_TilingX", 1f); val.SetFloat("_TilingY", 1f); } if (val.HasProperty("_OffsetX")) { val.SetFloat("_OffsetX", 0f); val.SetFloat("_OffsetY", 0f); } return val; } } internal class Booth : MonoBehaviour { internal const string PrefabName = "Valuable ExpressTrainBooth"; internal const string DisplayName = "Express Train to Hell"; private const string BoothMesh = "train_booth"; private const string EyesMesh = "train_eyes"; private const string LampMesh = "train_lamp"; private const string SellSound = "train_sell"; private const float BW = 1.88f; private const float BD = 0.85f; private const float BH = 2.5f; private static readonly float[] LX = new float[4] { 0.4515f, 0.1462f, -0.1699f, -0.4881f }; private const float LZ = 0.731f; private const float WX = -0.0086f; private const float WZ = 1.3932f; private const float S = 1.1f; private const float WW = 0.9f; private const float WH = 0.79f; internal static readonly Color LampLit = new Color(1f, 0.72f, 0.24f); private static PrefabRef prefab; private static Material boothMat; private static Material eyesMat; internal static Material baseMaterial; private PhysGrabObject grab; private PhotonView view; private Collider[] mine; private Vector3 anchor; private Quaternion anchorRot; private Material[] lampMats = (Material[])(object)new Material[4]; private Light glow; private int lamps; private bool found; private float lampTimer; private float lookTimer; private float lastAsk; private float flicker; private bool reportedSeen; private float heldAt = -10f; private static bool IsHost => SemiFunc.IsMasterClientOrSingleplayer(); private static Transform CameraT { get { if (!Object.op_Implicit((Object)(object)CameraUtils.Instance) || !Object.op_Implicit((Object)(object)CameraUtils.Instance.MainCamera)) { if (!Object.op_Implicit((Object)(object)Camera.main)) { return null; } return ((Component)Camera.main).transform; } return ((Component)CameraUtils.Instance.MainCamera).transform; } } private static string Key => "<color=#FFFFFF>[" + SemiFunc.InputDisplayReplaceTags("[interact]", "<u><b>", "</b></u>") + "]</color>"; internal static void BuildAndRegister() { //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0142: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Expected O, but got Unknown //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Expected O, but got Unknown //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Unknown result type (might be due to invalid IL or missing references) //IL_063e: Unknown result type (might be due to invalid IL or missing references) //IL_0650: Unknown result type (might be due to invalid IL or missing references) //IL_0686: Unknown result type (might be due to invalid IL or missing references) //IL_069a: Unknown result type (might be due to invalid IL or missing references) //IL_06a4: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) Material baseMat; BoxCollider box; GameObject val = Loot.CloneValuable(Loot.Big, "Valuable ExpressTrainBooth", out baseMat, out box); Loot.Feel(val, "Very Heavy", "Strong+", null); ValuableObject component = val.GetComponent<ValuableObject>(); NotValuableObject val2 = val.AddComponent<NotValuableObject>(); if (Object.op_Implicit((Object)(object)component)) { val2.physAttributePreset = component.physAttributePreset; val2.audioPreset = component.audioPreset; val2.durabilityPreset = component.durabilityPreset; Object.DestroyImmediate((Object)(object)component); } val2.hasHealth = false; baseMaterial = baseMat; boothMat = Assets.Metal(Assets.MakeMaterial(baseMat, "Express Train to Hell Booth", Assets.LoadCompressed("train_booth_albedo")), Assets.LoadCompressed("booth_normal", linear: true), 0f, 0.05f); string[] array = new string[2] { "_NormalStrength", "_BumpScale" }; foreach (string text in array) { if (boothMat.HasProperty(text)) { boothMat.SetFloat(text, 0.5f); } } eyesMat = Glowing("Clerk's Eyes", new Color(1f, 0.82f, 0.35f), 2.2f); GameObject val3 = new GameObject("Booth Model") { layer = val.layer }; val3.transform.SetParent(val.transform, false); val3.transform.localScale = Vector3.one * 1.1f; Part(val3.transform, "Booth", "train_booth", boothMat, val.layer); Part(val3.transform, "Eyes", "train_eyes", eyesMat, val.layer); GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5); Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>()); ((Object)obj).name = "Window Dark"; obj.layer = val.layer; obj.transform.SetParent(val3.transform, false); obj.transform.localPosition = new Vector3(-0.0086f, 1.3932f, 0.41000003f); obj.transform.localRotation = Quaternion.Euler(0f, 180f, 0f); obj.transform.localScale = new Vector3(0.9f, 0.79f, 1f); Shader val4 = Shader.Find("UI/Default") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard"); Material sharedMaterial = new Material(val4) { name = "Express Train to Hell Window Dark", color = Color.black }; Plugin.Log.LogDebug((object)("Booth window dark: " + ((Object)val4).name)); MeshRenderer component2 = obj.GetComponent<MeshRenderer>(); ((Renderer)component2).sharedMaterial = sharedMaterial; ((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0; float num = 0.39999998f; float num2 = 0.345f; float num3 = 0.61f; (Vector3, Vector3)[] array2 = new(Vector3, Vector3)[4] { (new Vector3(-0.0086f, 1.3932f + num2, num3), new Vector3(num * 2f, 0.01f, 0.4f)), (new Vector3(-0.0086f, 1.3932f - num2, num3), new Vector3(num * 2f, 0.01f, 0.4f)), (new Vector3(-0.0086f - num, 1.3932f, num3), new Vector3(0.01f, num2 * 2f, 0.4f)), (new Vector3(-0.0086f + num, 1.3932f, num3), new Vector3(0.01f, num2 * 2f, 0.4f)) }; for (int i = 0; i < array2.Length; i++) { (Vector3, Vector3) tuple = array2[i]; Vector3 item = tuple.Item1; Vector3 item2 = tuple.Item2; GameObject obj2 = GameObject.CreatePrimitive((PrimitiveType)3); Object.DestroyImmediate((Object)(object)obj2.GetComponent<Collider>()); ((Object)obj2).name = "Window Dark Side"; obj2.layer = val.layer; obj2.transform.SetParent(val3.transform, false); obj2.transform.localPosition = item; obj2.transform.localScale = item2; MeshRenderer component3 = obj2.GetComponent<MeshRenderer>(); ((Renderer)component3).sharedMaterial = sharedMaterial; ((Renderer)component3).shadowCastingMode = (ShadowCastingMode)0; } Material val5 = new Material(Shader.Find("Standard")) { name = "Express Train to Hell Bars", color = new Color(0.36f, 0.31f, 0.26f) }; if (val5.HasProperty("_Metallic")) { val5.SetFloat("_Metallic", 0.6f); } if (val5.HasProperty("_Glossiness")) { val5.SetFloat("_Glossiness", 0.3f); } float[] array3 = new float[3] { -0.225f, 0f, 0.225f }; foreach (float num4 in array3) { GameObject obj3 = GameObject.CreatePrimitive((PrimitiveType)2); Object.DestroyImmediate((Object)(object)obj3.GetComponent<Collider>()); ((Object)obj3).name = "Bar"; obj3.layer = val.layer; obj3.transform.SetParent(val3.transform, false); obj3.transform.localPosition = new Vector3(-0.0086f + num4, 1.3932f, 0.78000003f); obj3.transform.localScale = new Vector3(0.045f, 0.425f, 0.045f); ((Renderer)obj3.GetComponent<MeshRenderer>()).sharedMaterial = val5; } for (int j = 0; j < 4; j++) { Part(val3.transform, "Lamp " + (j + 1), "train_lamp", Glowing("Lamp", LampLit, 0f), val.layer).transform.localPosition = new Vector3(LX[j], 0.731f, 0.82000005f); } Light obj4 = new GameObject("Lamp Glow").AddComponent<Light>(); ((Component)obj4).transform.SetParent(val.transform, false); ((Component)obj4).transform.localPosition = new Vector3(0f, 0.80410004f, 1.4350001f); obj4.type = (LightType)2; obj4.color = LampLit; obj4.range = 4f; obj4.intensity = 0f; obj4.shadows = (LightShadows)0; Loot.FitBox(box, new Bounds(new Vector3(0f, 1.375f, 0.46750003f), new Vector3(1.88f, 2.5f, 0.85f) * 1.1f)); val.AddComponent<Booth>(); prefab = Loot.Register(val, inLevels: false); } internal static Material Glowing(string name, Color c, float emit) { //IL_000a: 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) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(Shader.Find("Standard")) { name = "Express Train to Hell " + name, color = c * 0.35f }; val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", c * emit); val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)0; if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.4f); } return val; } private static GameObject Part(Transform parent, string name, string mesh, Material mat, int layer) { //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_000e: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown GameObject val = new GameObject(name) { layer = layer }; val.transform.SetParent(parent, false); val.AddComponent<MeshFilter>().sharedMesh = Assets.LoadMesh(mesh); ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = mat; return val; } internal static void LevelReady() { //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) if (prefab == null || !SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.RunIsLevel()) { return; } float value = Random.value; if (value >= Plugin.Chance.Value) { Plugin.Log.LogInfo((object)$"Express Train to Hell: the booth isn't in this level (rolled {value:0.00}, needs under {Plugin.Chance.Value:0.00})."); return; } Physics.SyncTransforms(); List<LevelPoint> list = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? LevelGenerator.Instance.LevelPathPoints : null); if (list == null || list.Count == 0) { return; } Dictionary<LevelPoint, int> hops = new Dictionary<LevelPoint, int>(); Queue<LevelPoint> queue = new Queue<LevelPoint>(); foreach (LevelPoint item in list) { if (Object.op_Implicit((Object)(object)item) && (item.inStartRoom || item.Truck || (Object.op_Implicit((Object)(object)item.Room) && item.Room.Truck))) { hops[item] = 0; queue.Enqueue(item); } } while (queue.Count > 0) { LevelPoint val = queue.Dequeue(); if (val.ConnectedPoints == null) { continue; } foreach (LevelPoint connectedPoint in val.ConnectedPoints) { if (Object.op_Implicit((Object)(object)connectedPoint) && !hops.ContainsKey(connectedPoint)) { hops[connectedPoint] = hops[val] + 1; queue.Enqueue(connectedPoint); } } } List<LevelPoint> list2 = new List<LevelPoint>(); foreach (KeyValuePair<LevelPoint, int> item2 in hops) { if (item2.Value >= 1 && item2.Value <= 6) { list2.Add(item2.Key); } } list2.Sort((LevelPoint a, LevelPoint b) => ((float)hops[a] + Random.value * 0.9f).CompareTo((float)hops[b] + Random.value * 0.9f)); foreach (LevelPoint item3 in list2) { if (!Object.op_Implicit((Object)(object)item3) || (Object.op_Implicit((Object)(object)item3.Room) && item3.Room.Truck)) { continue; } for (int num = 0; num < 8; num++) { float num2 = (float)num * 45f + Random.Range(-15f, 15f); if (WallSpot(((Component)item3).transform.position, Quaternion.Euler(0f, num2, 0f) * Vector3.forward, out var at, out var facing)) { NetworkPrefabs.SpawnNetworkPrefab(prefab, at, facing, (byte)0, (object[])null); Plugin.Log.LogInfo((object)$"Express Train to Hell: the booth turned up, {hops[item3]} steps from the truck's room."); return; } } } Plugin.Log.LogInfo((object)"Express Train to Hell: no wall for the booth near the truck this level."); } internal static string SpawnForTest() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: 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_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) if (prefab == null) { return "the ticket booth isn't registered"; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { return "Only the host can place the ticket booth"; } PlayerAvatar me = PlayerAvatar.instance; if (!Object.op_Implicit((Object)(object)me)) { return "Join a level first"; } Physics.SyncTransforms(); Vector3 forward = (Object.op_Implicit((Object)(object)Camera.main) ? ((Component)Camera.main).transform : ((Component)me).transform).forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f) { forward = ((Component)me).transform.forward; } ((Vector3)(ref forward)).Normalize(); List<Vector3> list = new List<Vector3> { ((Component)me).transform.position }; List<LevelPoint> list2 = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? LevelGenerator.Instance.LevelPathPoints : null); if (list2 != null) { List<LevelPoint> list3 = new List<LevelPoint>(); foreach (LevelPoint item in list2) { if (Object.op_Implicit((Object)(object)item)) { Vector3 val = ((Component)item).transform.position - ((Component)me).transform.position; if (((Vector3)(ref val)).sqrMagnitude < 225f) { list3.Add(item); } } } list3.Sort(delegate(LevelPoint a, LevelPoint b) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Vector3 val2 = ((Component)a).transform.position - ((Component)me).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; val2 = ((Component)b).transform.position - ((Component)me).transform.position; return sqrMagnitude.CompareTo(((Vector3)(ref val2)).sqrMagnitude); }); foreach (LevelPoint item2 in list3) { list.Add(((Component)item2).transform.position); } } foreach (Vector3 item3 in list) { for (int num = 0; num < 16; num++) { float num2 = (float)(((num % 2 == 0) ? 1 : (-1)) * ((num + 1) / 2)) * 22.5f; if (WallSpot(item3, Quaternion.Euler(0f, num2, 0f) * forward, out var at, out var facing)) { NetworkPrefabs.SpawnNetworkPrefab(prefab, at, facing, (byte)0, (object[])null); return $"Placed the ticket booth {Vector3.Distance(at, ((Component)me).transform.position):0} m away"; } } } return "No bare wall near you for the ticket booth"; } internal static void SummonForTest() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_0109: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar instance = PlayerAvatar.instance; Transform val = (Object.op_Implicit((Object)(object)Camera.main) ? ((Component)Camera.main).transform : (Object.op_Implicit((Object)(object)instance) ? ((Component)instance).transform : null)); if (Object.op_Implicit((Object)(object)val)) { Vector3 at = (Object.op_Implicit((Object)(object)instance) ? ((Component)instance).transform.position : val.position); Vector3 dir = val.forward; dir.y = 0f; if (((Vector3)(ref dir)).sqrMagnitude < 0.0001f) { dir = val.up; } dir.y = 0f; ((Vector3)(ref dir)).Normalize(); (Vector3 a, Vector3 b) tuple = Track.Through(at, dir); Vector3 item = tuple.a; Vector3 item2 = tuple.b; Booth booth = ((IsHost && SemiFunc.IsMultiplayer()) ? Object.FindAnyObjectByType<Booth>() : null); if (Object.op_Implicit((Object)(object)booth)) { booth.Send("TrainRPC", (RpcTarget)0, item, item2, true); } else { TrainRun.Start(item, item2, found: true); } Plugin.Log.LogInfo((object)$"Express Train to Hell: summoned a train through you ({Vector3.Distance(item, item2):0} m run)."); } } internal static bool Solid(Collider c) { if (Object.op_Implicit((Object)(object)c) && !c.isTrigger && !Object.op_Implicit((Object)(object)((Component)c).GetComponentInParent<PhysGrabObject>()) && !Object.op_Implicit((Object)(object)((Component)c).GetComponentInParent<PlayerAvatar>())) { return !Object.op_Implicit((Object)(object)((Component)c).GetComponentInParent<EnemyParent>()); } return false; } private static bool WallSpot(Vector3 from, Vector3 dir, out Vector3 at, out Quaternion facing) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: 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_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0169: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: 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_01f2: Unknown result type (might be due to invalid IL or missing references) at = default(Vector3); facing = default(Quaternion); RaycastHit val = default(RaycastHit); if (!Physics.Raycast(from + Vector3.up * 1.2f, dir, ref val, 4f, -1, (QueryTriggerInteraction)1) || !Solid(((RaycastHit)(ref val)).collider)) { return false; } Vector3 normal = ((RaycastHit)(ref val)).normal; if (Mathf.Abs(normal.y) > 0.08f) { return false; } normal.y = 0f; ((Vector3)(ref normal)).Normalize(); RaycastHit val2 = default(RaycastHit); if (!Physics.Raycast(((RaycastHit)(ref val)).point + normal * 0.5f, Vector3.down, ref val2, 2.5f, -1, (QueryTriggerInteraction)1) || !Solid(((RaycastHit)(ref val2)).collider)) { return false; } if (((RaycastHit)(ref val2)).normal.y < 0.9f) { return false; } RaycastHit val3 = default(RaycastHit); float num = (Physics.Raycast(from + Vector3.up * 0.5f, Vector3.down, ref val3, 3f, -1, (QueryTriggerInteraction)1) ? ((RaycastHit)(ref val3)).point.y : from.y); if (Mathf.Abs(((RaycastHit)(ref val2)).point.y - num) > 0.2f) { return false; } Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(((RaycastHit)(ref val)).point.x, ((RaycastHit)(ref val2)).point.y, ((RaycastHit)(ref val)).point.z); Vector3 val5 = Vector3.Cross(Vector3.up, normal); RaycastHit val6 = default(RaycastHit); for (int i = -1; i <= 1; i++) { for (int j = 0; j < 4; j++) { if (!Physics.Raycast(val4 + val5 * ((float)i * 0.85f) + Vector3.up * (0.15f + (float)j * 0.85f) + normal * 0.5f, -normal, ref val6, 0.7f, -1, (QueryTriggerInteraction)1) || !Solid(((RaycastHit)(ref val6)).collider)) { return false; } if (Mathf.Abs(((RaycastHit)(ref val6)).distance - 0.5f) > 0.05f || Vector3.Dot(((RaycastHit)(ref val6)).normal, normal) < 0.97f) { return false; } } } Collider[] array = Physics.OverlapBox(val4 + normal * 1.1f + Vector3.up * 1.5f, new Vector3(1.2f, 1.45f, 1.05f), Quaternion.LookRotation(normal), -1, (QueryTriggerInteraction)1); for (int k = 0; k < array.Length; k++) { if (Object.op_Implicit((Object)(object)array[k])) { return false; } } at = val4 + normal * 0.01f; facing = Quaternion.LookRotation(normal); return true; } private void Start() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) grab = ((Component)this).GetComponent<PhysGrabObject>(); view = ((Component)this).GetComponent<PhotonView>(); mine = ((Component)this).GetComponentsInChildren<Collider>(true); anchor = ((Component)this).transform.position; anchorRot = ((Component)this).transform.rotation; try { TrainRun.Warm(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not load the train ahead of time: " + ex.Message)); } for (int i = 0; i < 4; i++) { Transform obj = ((Component)this).transform.Find("Booth Model/Lamp " + (i + 1)); MeshRenderer val = ((obj != null) ? ((Component)obj).GetComponent<MeshRenderer>() : null); if (Object.op_Implicit((Object)(object)val)) { lampMats[i] = ((Renderer)val).material; } } Transform obj2 = ((Component)this).transform.Find("Lamp Glow"); glow = ((obj2 != null) ? ((Component)obj2).GetComponent<Light>() : null); lampTimer = Plugin.LampSeconds.Value; ShowLamps(); } private void Send(string rpc, RpcTarget to, params object[] args) { //IL_0078: 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) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMultiplayer() && Object.op_Implicit((Object)(object)view)) { view.RPC(rpc, to, args); return; } switch (rpc) { case "LampsRPC": LampsRPC((int)args[0], (bool)args[1]); break; case "SeenRPC": SeenRPC(); break; case "TicketRPC": TicketRPC((int)args[0]); break; case "SoldRPC": SoldRPC((int)args[0], (int)args[1]); break; case "TrainRPC": TrainRPC((Vector3)args[0], (Vector3)args[1], (bool)args[2]); break; } } private void Update() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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) //IL_0093: Unknown result type (might be due to invalid IL or missing references) Tell.Tick(); if (Object.op_Implicit((Object)(object)grab)) { grab.OverrideGrabDisable(0.2f); if (IsHost) { grab.OverrideKinematic(0.2f); grab.OverrideIndestructible(0.2f); if (Object.op_Implicit((Object)(object)grab.rb) && !grab.rb.isKinematic) { grab.rb.linearVelocity = Vector3.zero; grab.rb.angularVelocity = Vector3.zero; grab.rb.isKinematic = true; } Vector3 val = ((Component)this).transform.position - anchor; if (((Vector3)(ref val)).sqrMagnitude > 1E-06f || Quaternion.Angle(((Component)this).transform.rotation, anchorRot) > 0.1f) { ((Component)this).transform.SetPositionAndRotation(anchor, anchorRot); } } } if (SemiFunc.RunIsLevel()) { if (IsHost) { HostTick(); } Look(); AtWindow(); Flicker(); } } private void HostTick() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if ((lampTimer -= Time.deltaTime) > 0f) { return; } lampTimer = Plugin.LampSeconds.Value; if (lamps >= 4) { (Vector3, Vector3)? tuple = Track.Choose(found); Send("LampsRPC", (RpcTarget)0, 0, found); if (tuple.HasValue) { Send("TrainRPC", (RpcTarget)0, tuple.Value.Item1, tuple.Value.Item2, found); } else { Plugin.Log.LogInfo((object)"Express Train to Hell: no straight run for the train this time."); } } else { Send("LampsRPC", (RpcTarget)0, lamps + 1, found); } } [PunRPC] public void LampsRPC(int lit, bool isFound, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMultiplayer() || SemiFunc.MasterOnlyRPC(info)) { lamps = Mathf.Clamp(lit, 0, 4); found |= isFound; ShowLamps(); } } [PunRPC] public void SeenRPC(PhotonMessageInfo info = default(PhotonMessageInfo)) { if (IsHost && !found) { found = true; Plugin.Log.LogInfo((object)"Express Train to Hell: the booth has been found."); Send("LampsRPC", (RpcTarget)0, lamps, true); } } [PunRPC] public void TicketRPC(int playerViewID, PhotonMessageInfo info = default(PhotonMessageInfo)) { if (IsHost && lamps > 0) { int num = lamps; lampTimer = Plugin.LampSeconds.Value; Send("LampsRPC", (RpcTarget)0, 0, true); Send("SoldRPC", (RpcTarget)0, num, playerViewID); } } [PunRPC] public void TrainRPC(Vector3 a, Vector3 b, bool isFound, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0011: 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_0007: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMultiplayer() || SemiFunc.MasterOnlyRPC(info)) { TrainRun.Start(a, b, isFound); } } private void Look() { //IL_0074: 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) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) if (found || reportedSeen || (lookTimer -= Time.deltaTime) > 0f) { return; } lookTimer = 0.3f; PlayerAvatar instance = PlayerAvatar.instance; Transform cameraT = CameraT; if (!Object.op_Implicit((Object)(object)instance) || instance.isDisabled || !Object.op_Implicit((Object)(object)cameraT)) { return; } Vector3 val = ((Component)this).transform.TransformPoint(new Vector3(-0.0086f, 1.3932f, 0.85f) * 1.1f); Vector3 position = cameraT.position; Vector3 val2 = val - position; if (((Vector3)(ref val2)).magnitude > 14f || !SemiFunc.OnScreen(val, 0f, 0f)) { return; } RaycastHit[] array = Physics.RaycastAll(position, val2, ((Vector3)(ref val2)).magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val3 = array[i]; if (!((RaycastHit)(ref val3)).transform.IsChildOf(((Component)this).transform) && !((RaycastHit)(ref val3)).transform.IsChildOf(((Component)instance).transform)) { return; } } reportedSeen = true; Send("SeenRPC", (RpcTarget)2); } private void AtWindow() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar instance = PlayerAvatar.instance; Transform cameraT = CameraT; if (!Object.op_Implicit((Object)(object)instance) || instance.isDisabled || !Object.op_Implicit((Object)(object)cameraT)) { return; } PhysGrabber instance2 = PhysGrabber.instance; if (Object.op_Implicit((Object)(object)instance2) && (instance2.grabbed || Object.op_Implicit((Object)(object)instance2.grabbedPhysGrabObject) || Object.op_Implicit((Object)(object)instance2.grabbedObjectTransform) || Object.op_Implicit((Object)(object)instance2.grabbedStaticGrabObject))) { heldAt = Time.time; } RaycastHit val = default(RaycastHit); if (!(Time.time - heldAt < 0.5f) && Physics.Raycast(cameraT.position, cameraT.forward, ref val, 2.6f, -1, (QueryTriggerInteraction)1) && Array.IndexOf(mine, ((RaycastHit)(ref val)).collider) >= 0) { if (Object.op_Implicit((Object)(object)ItemInfoUI.instance) && Tell.ShowingNow == null) { ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, (lamps > 0) ? ("Take a ticket " + Key) : "The clerk stares back. The lamps are out.", false); } if (lamps > 0 && SemiFunc.InputDown((InputKey)2) && Time.time - lastAsk > 1f && Object.op_Implicit((Object)(object)instance.photonView)) { lastAsk = Time.time; Send("TicketRPC", (RpcTarget)2, instance.photonView.ViewID); } } } [PunRPC] public void SoldRPC(int lit, int playerViewID, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMultiplayer() && !SemiFunc.MasterOnlyRPC(info)) { return; } Assets.Play(Assets.LoadSound("train_sell"), ((Component)this).transform, 0.9f * Plugin.Volume.Value, 12f); PlayerAvatar instance = PlayerAvatar.instance; if (Object.op_Implicit((Object)(object)instance) && !instance.isDisabled && Object.op_Implicit((Object)(object)instance.playerHealth) && Object.op_Implicit((Object)(object)instance.photonView)) { bool flag = instance.photonView.ViewID == playerViewID; int num = 0; if (lit == 1 && flag) { num = Plugin.Heal1.Value; } else if (lit == 2 && flag) { num = Plugin.Heal2.Value; } else if (lit == 3 && (flag || Vector3.Distance(((Component)instance).transform.position, ((Component)this).transform.position) <= Plugin.NearbyRange.Value)) { num = Plugin.HealShared.Value; } else if (lit >= 4) { num = Plugin.HealShared.Value; } if (num > 0) { instance.playerHealth.Heal(num, true); } if (flag) { Tell.Local((lit >= 4) ? "Far off, a train's horn. Everyone feels better." : "A ticket for a train with no final destination.", 3.5f); } else if (num > 0 && lit >= 4) { Tell.Local("Far off, a train's horn. You feel better.", 3.5f); } } } private void ShowLamps() { //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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 4; i++) { Material val = lampMats[i]; if (Object.op_Implicit((Object)(object)val)) { bool flag = i < lamps; val.color = (Color)(flag ? (LampLit * 0.5f) : new Color(0.12f, 0.09f, 0.05f)); val.SetColor("_EmissionColor", flag ? (LampLit * 2.4f) : Color.black); } } if (Object.op_Implicit((Object)(object)glow)) { glow.intensity = (float)lamps * 0.35f; } } private void Flicker() { //IL_008b: 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_009b: Unknown result type (might be due to invalid IL or missing references) if (lamps < 4 || !Object.op_Implicit((Object)(object)glow)) { return; } flicker += Time.deltaTime; float num = 0.75f + 0.25f * Mathf.Sin(flicker * 9f) * Mathf.Sin(flicker * 2.3f); glow.intensity = 1.4f * num; for (int i = 0; i < 4; i++) { if (Object.op_Implicit((Object)(object)lampMats[i])) { lampMats[i].SetColor("_EmissionColor", LampLit * 2.4f * num); } } } private void OnDestroy() { Material[] array = lampMats; foreach (Material val in array) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } } } internal static class Fx { private static readonly Dictionary<string, Material> mats = new Dictionary<string, Material>(); private static readonly string[] TexProps = new string[4] { "_MainTex", "_BaseMap", "_BaseTexture", "_AlbedoTexture" }; private static Material template; private static bool templateTried; private static Material Template { get { if (templateTried) { return template; } templateTried = true; List<Material> list = new List<Material>(); string[] array = new string[4] { "Items/Item Gun Laser", "Items/Item Gun Handgun", "Items/Item Gun Shotgun", "Items/Item Melee Stun Baton" }; for (int i = 0; i < array.Length; i++) { GameObject val = Resources.Load<GameObject>(array[i]); if (!Object.op_Implicit((Object)(object)val)) { continue; } ItemGun component = val.GetComponent<ItemGun>(); List<GameObject> list2 = new List<GameObject> { val }; if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.muzzleFlashPrefab)) { list2.Add(component.muzzleFlashPrefab); } if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.bulletPrefab)) { list2.Add(component.bulletPrefab); } foreach (GameObject item in list2) { ParticleSystemRenderer[] componentsInChildren = item.GetComponentsInChildren<ParticleSystemRenderer>(true); for (int j = 0; j < componentsInChildren.Length; j++) { Material sharedMaterial = ((Renderer)componentsInChildren[j]).sharedMaterial; if (Object.op_Implicit((Object)(object)sharedMaterial) && Object.op_Implicit((Object)(object)sharedMaterial.shader) && sharedMaterial.shader.isSupported && HasTex(sharedMaterial) && !list.Contains(sharedMaterial)) { list.Add(sharedMaterial); } } } } if (list.Count == 0) { Plugin.Log.LogWarning((object)"No REPO particle material found, building one."); return null; } list.Sort((Material a, Material b) => Score(b).CompareTo(Score(a))); template = list[0]; Plugin.Log.LogDebug((object)("Effects draw with REPO's \"" + ((Object)template).name + "\" (shader " + ((Object)template.shader).name + ").")); return template; static int Score(Material m) { int num = 0; if (((Object)m.shader).name.Contains("Unlit")) { num += 4; } if (m.HasProperty("_DstBlend") && Mathf.Approximately(m.GetFloat("_DstBlend"), 1f)) { num += 2; } if (((Object)m.shader).name.Contains("Surface")) { num -= 4; } return num; } } } private static bool HasTex(Material m) { string[] texProps = TexProps; foreach (string text in texProps) { if (m.HasProperty(text)) { return true; } } return false; } internal static Material Mat(string tex) { //IL_0034: 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_004b: Expected O, but got Unknown //IL_01de: 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_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown //IL_0072: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) if (mats.TryGetValue(tex, out var value) && Object.op_Implicit((Object)(object)value)) { return value; } Texture2D val = Assets.LoadTexture(tex); if (Object.op_Implicit((Object)(object)Template)) { value = new Material(Template) { name = "LobCorp FX " + tex }; string[] texProps = TexProps; foreach (string text in texProps) { if (value.HasProperty(text)) { value.SetTexture(text, (Texture)(object)val); value.SetTextureScale(text, Vector2.one); value.SetTextureOffset(text, Vector2.zero); } } Shader shader = value.shader; for (int j = 0; j < shader.GetPropertyCount(); j++) { if ((int)shader.GetPropertyType(j) == 0) { string propertyName = shader.GetPropertyName(j); if (!propertyName.Contains("Emission")) { Color color = value.GetColor(propertyName); float num = Mathf.Max(color.r, Mathf.Max(color.g, color.b)); value.SetColor(propertyName, new Color(num, num, num, color.a)); } } } if (value.HasProperty("_TilingX")) { value.SetFloat("_TilingX", 1f); value.SetFloat("_TilingY", 1f); } if (value.HasProperty("_OffsetX")) { value.SetFloat("_OffsetX", 0f); value.SetFloat("_OffsetY", 0f); } if (value.HasProperty("_EmissionColor")) { value.SetColor("_EmissionColor", Color.black); } if (value.HasProperty("_EmissionMap")) { value.SetTexture("_EmissionMap", (Texture)null); } value.DisableKeyword("_EMISSION"); return mats[tex] = value; } value = new Material(Shader.Find("Particles/Standard Unlit") ?? Shader.Find("Sprites/Default")) { name = "LobCorp FX " + tex, mainTexture = (Texture)(object)val }; if (value.HasProperty("_Mode")) { value.SetFloat("_Mode", 4f); value.SetFloat("_SrcBlend", 5f); value.SetFloat("_DstBlend", 1f); value.SetFloat("_ZWrite", 0f); value.EnableKeyword("_ALPHABLEND_ON"); value.SetOverrideTag("RenderType", "Transparent"); } value.renderQueue = 3100; return mats[tex] = value; } } internal static class Loot { internal static readonly string[] Small = new string[2] { "Valuables/02 Small/Valuable Wizard Love Potion", "Valuables/02 Small/Valuable Museum Car" }; internal static readonly string[] Big = new string[2] { "Valuables/04 Big/Valuable Manor Television", "Valuables/04 Big/Valuable Museum Boombox" }; private static readonly HashSet<string> Keep = new HashSet<string> { "PhotonView", "PhotonTransformView", "PhotonRigidbodyView", "ValuableObject", "PhysGrabObject", "PhysGrabObjectImpactDetector", "RoomVolumeCheck", "PhysGrabObjectBoxCollider", "PhysGrabObjectCollider", "PhysGrabObjectMeshCollider", "NotValuableObject" }; internal const string SolidSmall = "Valuables/02 Small/Valuable Museum Car"; private static Dictionary<string, Object> presets; internal static void FrameIcon(GameObject root, Bounds local, float pitch = 0f, float margin = 1.15f) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_0174: Unknown result type (might be due to invalid IL or missing references) Transform val = root.transform.Find("SemiIcon Maker"); if (Object.op_Implicit((Object)(object)val)) { SemiIconMaker component = ((Component)val).GetComponent<SemiIconMaker>(); Camera val2 = ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.iconCamera)) ? component.iconCamera : ((Component)val).GetComponentInChildren<Camera>(true)); Transform val3 = (Object.op_Implicit((Object)(object)val2) ? ((Component)val2).transform : val); if (pitch != 0f) { val.rotation = Quaternion.AngleAxis(pitch, val3.right) * val.rotation; } float num = Mathf.Tan((Object.op_Implicit((Object)(object)val2) ? val2.fieldOfView : 30f) * 0.5f * (MathF.PI / 180f)); float num2 = ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.renderTexture)) ? ((float)((Texture)component.renderTexture).width / (float)((Texture)component.renderTexture).height) : 1f); float num3 = num * num2; Transform transform = root.transform; Vector3 val4 = transform.InverseTransformDirection(val3.forward); Vector3 val5 = transform.InverseTransformDirection(val3.right); Vector3 val6 = transform.InverseTransformDirection(val3.up); float num4 = 0f; float num5 = 0f; for (int i = 0; i < 8; i++) { Vector3 val7 = Vector3.Scale(((Bounds)(ref local)).extents, new Vector3((float)(((i & 1) != 0) ? 1 : (-1)), (float)(((i & 2) != 0) ? 1 : (-1)), (float)(((i & 4) != 0) ? 1 : (-1)))); float num6 = Vector3.Dot(val7, val5); float num7 = Vector3.Dot(val7, val6); float num8 = Vector3.Dot(val7, val4); num4 = Mathf.Max(new float[3] { num4, margin * Mathf.Abs(num6) / num3 - num8, margin * Mathf.Abs(num7) / num - num8 }); num5 = Mathf.Max(num5, 0f - num8); } if (Object.op_Implicit((Object)(object)val2)) { num4 = Mathf.Max(num4, num5 + val2.nearClipPlane + 0.02f); } Vector3 val8 = transform.TransformPoint(((Bounds)(ref local)).center - val4 * num4); val.position += val8 - val3.position; } } internal static GameObject Holder(string name) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown GameObject val = new GameObject("ExpressTrain Prefabs " + name); val.SetActive(false); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)val); return val; } internal static GameObject CloneValuable(string[] bases, string name, out Material baseMat, out BoxCollider box) { //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: 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_01e8: Unknown result type (might be due to invalid IL or missing references) GameObject val = null; for (int i = 0; i < bases.Length; i++) { val = Resources.Load<GameObject>(bases[i]); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.GetComponent<ValuableObject>()) && Object.op_Implicit((Object)(object)val.GetComponentInChildren<BoxCollider>(true))) { break; } val = null; } if (!Object.op_Implicit((Object)(object)val)) { throw new Exception("No vanilla valuable to build on (looked for " + string.Join(", ", bases) + ")."); } GameObject val2 = Object.Instantiate<GameObject>(val, Holder(name).transform); ((Object)val2).name = name; MonoBehaviour[] componentsInChildren = val2.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val3 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val3) && !Keep.Contains(((object)val3).GetType().Name)) { Object.DestroyImmediate((Object)(object)val3); } } AudioSource[] componentsInChildren2 = val2.GetComponentsInChildren<AudioSource>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } baseMat = null; Renderer[] componentsInChildren3 = val2.GetComponentsInChildren<Renderer>(true); foreach (Renderer val4 in componentsInChildren3) { if (!Object.op_Implicit((Object)(object)baseMat) && val4 is MeshRenderer) { baseMat = val4.sharedMaterial; } val4.enabled = false; } Light[] componentsInChildren4 = val2.GetComponentsInChildren<Light>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { ((Behaviour)componentsInChildren4[i]).enabled = false; } box = null; Collider[] componentsInChildren5 = val2.GetComponentsInChildren<Collider>(true); foreach (Collider val5 in componentsInChildren5) { if (!Object.op_Implicit((Object)(object)box)) { BoxCollider val6 = (BoxCollider)(object)((val5 is BoxCollider) ? val5 : null); if (val6 != null) { box = val6; continue; } } val5.enabled = false; } if (!Object.op_Implicit((Object)(object)box)) { throw new Exception("\"" + ((Object)val).name + "\" has no box collider to reuse."); } if ((Object)(object)((Component)box).gameObject == (Object)(object)val2) { GameObject val7 = new GameObject("Valuable Box Collider") { layer = val2.layer, tag = val2.tag }; val7.transform.SetParent(val2.transform, false); BoxCollider val8 = val7.AddComponent<BoxCollider>(); ((Collider)val8).sharedMaterial = ((Collider)box).sharedMaterial; ((Collider)box).enabled = false; box = val8; } else { ((Component)box).transform.SetParent(val2.transform, false); } return val2; } internal static void LookLike(GameObject go, string path, ref Material baseMat) { GameObject val = Resources.Load<GameObject>(path); if (!Object.op_Implicit((Object)(object)val)) { Plugin.Log.LogWarning((object)(((Object)go).name + ": no \"" + path + "\" to borrow a look from.")); return; } MeshRenderer[] componentsInChildren = val.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val2 in componentsInChildren) { if (Object.op_Implicit((Object)(object)((Renderer)val2).sharedMaterial) && ((Renderer)val2).sharedMaterial.renderQueue < 2500) { baseMat = ((Renderer)val2).sharedMaterial; break; } } ValuableObject component = val.GetComponent<ValuableObject>(); ValuableObject component2 = go.GetComponent<ValuableObject>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component.audioPreset)) { component2.audioPreset = component.audioPreset; } } internal static void FitBox(BoxCollider box, Bounds b) { //IL_0007: 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_001c: 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_0036: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)box).transform; transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; box.center = ((Bounds)(ref b)).center; box.size = ((Bounds)(ref b)).size; } internal static BoxCollider AddBox(BoxCollider like, Bounds b) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Object.Instantiate<GameObject>(((Component)like).gameObject, ((Component)like).transform.parent, false); ((Object)obj).name = ((Object)((Component)like).gameObject).name + " (extra)"; BoxCollider component = obj.GetComponent<BoxCollider>(); FitBox(component, b); return component; } internal static void SetValue(GameObject go, Type volume, int min, int max, string label) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) ValuableObject component = go.GetComponent<ValuableObject>(); component.volumeType = volume; Value val = ScriptableObject.CreateInstance<Value>(); ((Object)val).name = "Value - " + label; val.valueMin = min; val.valueMax = Mathf.Max(min, max); Object.DontDestroyOnLoad((Object)(object)val); component.valuePreset = val; } internal static void Feel(GameObject go, string mass, string durability, string sound) { ValuableObject component = go.GetComponent<ValuableObject>(); if (!Object.op_Implicit((Object)(object)component)) { return; } if (presets == null) { presets = new Dictionary<string, Object>(); Resources.LoadAll<GameObject>("Valuables"); PhysAttribute[] array = Resources.FindObjectsOfTypeAll<PhysAttribute>(); foreach (PhysAttribute val in array) { presets["PhysAttribute " + ((Object)val).name.Replace("PhysAttribute ", "")] = (Object)(object)val; } Durability[] array2 = Resources.FindObjectsOfTypeAll<Durability>(); foreach (Durability val2 in array2) { presets["Durability " + ((Object)val2).name.Replace("Durability ", "").Trim()] = (Object)(object)val2; } PhysAudio[] array3 = Resources.FindObjectsOfTypeAll<PhysAudio>(); foreach (PhysAudio val3 in array3) { presets["PhysAudio " + ((Object)val3).name.Replace("PhysAudio - ", "")] = (Object)(object)val3; } } if (mass != null) { PhysAttribute val4 = Find<PhysAttribute>("PhysAttribute " + mass); if (Object.op_Implicit((Object)(object)val4)) { component.physAttributePreset = val4; } } if (durability != null) { Durability val5 = Find<Durability>("Durability " + durability); if (Object.op_Implicit((Object)(object)val5)) { component.durabilityPreset = val5; } } if (sound != null) { PhysAudio val6 = Find<PhysAudio>("PhysAudio " + sound); if (Object.op_Implicit((Object)(object)val6)) { component.audioPreset = val6; } } T Find<T>(string key) where T : Object { if (presets.TryGetValue(key, out var value)) { T val7 = (T)(object)((value is T) ? value : null); if (val7 != null) { return val7; } } Plugin.Log.LogWarning((object)(((Object)go).name + ": no vanilla preset \"" + key + "\" (kept the base valuable's).")); return default(T); } } internal static PrefabRef Register(GameObject loot, bool inLevels) { PrefabRef result = (inLevels ? Valuables.RegisterValuable(loot) : NetworkPrefabs.RegisterNetworkPrefab("Valuables/" + ((Object)loot).name, loot)) ?? throw new Exception("REPOLib refused to register " + ((Object)loot).name + "."); Plugin.Log.LogInfo((object)("Registered " + ((Object)loot).name + (inLevels ? " (level loot)." : " (spawned only)."))); return result; } internal static void HoldUpright(PhysGrabObject pgo, float torque = 6f, float massWhileHeld = -1f) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)pgo) || !pgo.grabbed) { return; } bool flag = false; foreach (PhysGrabber item in pgo.playerGrabbing) { if (!Object.op_Implicit((Object)(object)item) || !Object.op_Implicit((Object)(object)item.playerAvatar) || !Object.op_Implicit((Object)(object)item.playerAvatar.localCamera)) { continue; } if (item.isRotating) { flag = true; continue; } Transform overrideTransform = item.playerAvatar.localCamera.GetOverrideTransform(); if (Object.op_Implicit((Object)(object)overrideTransform)) { Vector3 val = overrideTransform.forward; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.001f) { val = overrideTransform.up; } val.y = 0f; val = -((Vector3)(ref val)).normalized; Quaternion val2 = Quaternion.Inverse(item.physRotation); item.cameraRelativeGrabbedForward = val2 * overrideTransform.InverseTransformDirection(val); item.cameraRelativeGrabbedUp = val2 * overrideTransform.InverseTransformDirection(Vector3.up); } } pgo.OverrideTorqueStrength(flag ? 2f : torque, 0.1f); pgo.OverrideAngularDrag(20f, 0.1f); if (massWhileHeld > 0f) { pgo.OverrideMass(massWhileHeld, 0.1f); } } } [HarmonyPatch] internal static class Patches { [HarmonyPatch(typeof(ItemInfoUI), "ItemInfoText")] [HarmonyPrefix] private static bool HoldToldText(string message) { string showingNow = Tell.ShowingNow; if (showingNow != null) { return message == showingNow; } return true; } [HarmonyPatch(typeof(LevelGenerator), "GenerateDoneApply")] [HarmonyPostfix] private static void LevelReady() { try { Booth.LevelReady(); } catch (Exception ex) { Plugin.Log.LogError((object)("Booth: " + ex)); } } } internal static class Tell { private static string showing; private static float until; internal static string ShowingNow { get { if (showing == null || !(Time.time < until)) { return null; } return showing; } } internal static void Local(string text, float seconds = 3f) { if (Object.op_Implicit((Object)(object)ItemInfoUI.instance)) { showing = text; until = Time.time + seconds; ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, text, false); } } internal static void Tick() { string showingNow = ShowingNow; if (showingNow != null && Object.op_Implicit((Object)(object)ItemInfoUI.instance)) { ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, showingNow, false); } } } [BepInPlugin("bigbootyteam.expresstraintohell", "ExpressTrainToHell", "0.9.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "bigbootyteam.expresstraintohell"; public const string Name = "ExpressTrainToHell"; public const string Version = "0.9.0"; internal static ManualLogSource Log; internal static ConfigEntry<float> Chance; internal static ConfigEntry<float> LampSeconds; internal static ConfigEntry<float> WarningSeconds; internal static ConfigEntry<float> Speed; internal static ConfigEntry<float> NearbyRange; internal static ConfigEntry<float> Volume; internal static ConfigEntry<int> Cars; internal static ConfigEntry<int> PlayerDamage; internal static ConfigEntry<int> MonsterDamage; internal static ConfigEntry<int> Heal1; internal static ConfigEntry<int> Heal2; internal static ConfigEntry<int> HealShared; internal static ConfigEntry<bool> BreaksValuables; internal static ConfigEntry<KeyboardShortcut> PreviewKey; internal static ConfigEntry<KeyboardShortcut> SummonKey; private void Awake() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Expected O, but got Unknown //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Chance = ((BaseUnityPlugin)this).Config.Bind<float>("Booth", "ChancePerLevel", 0.35f, new ConfigDescription("Chance the ticket booth turns up in a level, in one of the first rooms past the truck.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); LampSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Booth", "LampSeconds", 30f, "Seconds between its lamps lighting (Lob Corp: 30). Four lit, and the next time the train comes instead."); Heal1 = ((BaseUnityPlugin)this).Config.Bind<int>("Tickets", "HealOneLamp", 20, "Health a ticket gives the one who takes it, with one lamp lit."); Heal2 = ((BaseUnityPlugin)this).Config.Bind<int>("Tickets", "HealTwoLamps", 40, "Health a ticket gives the one who takes it, with two lamps lit."); HealShared = ((BaseUnityPlugin)this).Config.Bind<int>("Tickets", "HealThreeOrFourLamps", 25, "Health a ticket gives, with three lamps lit, to everyone near the booth; with four, to every player."); NearbyRange = ((BaseUnityPlugin)this).Config.Bind<float>("Tickets", "NearbyRange", 15f, "How near the booth counts as near, for three lamps."); Cars = ((BaseUnityPlugin)this).Config.Bind<int>("Train", "Cars", 4, new ConfigDescription("Cars behind the engine (Lob Corp: four, five pieces in all).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 8), Array.Empty<object>())); Speed = ((BaseUnityPlugin)this).Config.Bind<float>("Train", "Speed", 16f, "How fast it runs, in metres a second."); WarningSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Train", "WarningSeconds", 4f, "Seconds between its horn and the train itself."); PlayerDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Train", "PlayerDamage", 100, "Damage to a player it runs through."); MonsterDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Train", "MonsterDamage", 150, "Damage to a monster it runs through."); BreaksValuables = ((BaseUnityPlugin)this).Config.Bind<bool>("Train", "BreaksValuables", true, "Whether it smashes valuables it runs through (never before anyone has found the booth)."); Volume = ((BaseUnityPlugin)this).Config.Bind<float>("Train", "Volume", 1f, new ConfigDescription("Loudness of its sounds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); PreviewKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Testing", "PreviewModelKey", new KeyboardShortcut((KeyCode)285, Array.Empty<KeyCode>()), "Stands a still copy of the train in front of you, its eye towards you (nothing runs, nothing is hurt). Shift removes them."); SummonKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Testing", "SummonTrainKey", new KeyboardShortcut((KeyCode)284, Array.Empty<KeyCode>()), "Debug: a train right now, wall to wall through where you stand, along the way you face (after the usual horn and warning). It hurts like a real one."); new Harmony("bigbootyteam.expresstraintohell").PatchAll(typeof(Patches)); try { Booth.BuildAndRegister(); } catch (Exception ex) { Log.LogError((object)("Could not add the ticket booth: " + ex)); } } private void Update() { //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_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) KeyboardShortcut value = SummonKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { try { Booth.SummonForTest(); } catch (Exception ex) { Log.LogError((object)("Could not summon the train: " + ex)); } } value = PreviewKey.Value; if (!((KeyboardShortcut)(ref value)).IsDown()) { return; } try { TrainRun.TogglePreview(Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)); } catch (Exception ex2) { Log.LogError((object)("Could not show the train: " + ex2)); } } } internal static class Track { internal static (Vector3 a, Vector3 b)? Choose(bool found) { //IL_006d: 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_0303: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) List<LevelPoint> list = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? LevelGenerator.Instance.LevelPathPoints : null); if (list == null || list.Count < 2) { return null; } List<Vector3> list2 = new List<Vector3>(); foreach (LevelPoint item in list) { if (Object.op_Implicit((Object)(object)item) && (!Usable(item) || item.inStartRoom)) { list2.Add(((Component)item).transform.position); } } ExtractionPoint[] array = Object.FindObjectsByType<ExtractionPoint>((FindObjectsSortMode)0); foreach (ExtractionPoint val in array) { if (Object.op_Implicit((Object)(object)val)) { list2.Add(((Component)val).transform.position); } } List<(Vector3, Vector3, float)> list3 = new List<(Vector3, Vector3, float)>(); for (int j = 0; j < 400; j++) { if (list3.Count >= 40) { break; } LevelPoint val2 = list[Random.Range(0, list.Count)]; if (!Usable(val2) || val2.ConnectedPoints == null || val2.ConnectedPoints.Count == 0) { continue; } LevelPoint val3 = val2.ConnectedPoints[Random.Range(0, val2.ConnectedPoints.Count)]; if (!Usable(val3)) { continue; } (Vector3, Vector3, float)? tuple = Straight(val2, val3); if (!tuple.HasValue || tuple.Value.Item3 < 10f) { continue; } bool flag = false; foreach (Vector3 item2 in list2) { if (Gap(item2, tuple.Value.Item1, tuple.Value.Item2) < 6f) { flag = true; break; } } if (!flag) { list3.Add(tuple.Value); } } if (list3.Count == 0) { return null; } if (!found) { (Vector3, Vector3, float) tuple2 = list3[0]; float num = -1f; foreach (var item3 in list3) { float num2 = float.MaxValue; if (Object.op_Implicit((Object)(object)GameDirector.instance)) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (Object.op_Implicit((Object)(object)player) && !player.isDisabled) { num2 = Mathf.Min(num2, Gap(((Component)player).transform.position, item3.Item1, item3.Item2)); } } } if (num2 > 14f) { return (item3.Item1, item3.Item2); } if (num2 > num) { num = num2; tuple2 = item3; } } return (tuple2.Item1, tuple2.Item2); } float num3 = 0f; foreach (var item4 in list3) { num3 += item4.Item3; } float num4 = Random.value * num3; foreach (var item5 in list3) { num4 -= item5.Item3; if (num4 <= 0f) { return (item5.Item1, item5.Item2); } } return (list3[0].Item1, list3[0].Item2); } private static bool Usable(LevelPoint p) { if (Object.op_Implicit((Object)(object)p) && !p.Truck) { if (Object.op_Implicit((Object)(object)p.Room)) { return !p.Room.Truck; } return true; } return false; } private static Vector3 Flat(Vector3 v) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) v.y = 0f; return v; } private static float Gap(Vector3 p, Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Vector3 val = b - a; float num = Mathf.Clamp01(Vector3.Dot(p - a, val) / Mathf.Max(0.0001f, ((Vector3)(ref val)).sqrMagnitude)); return Vector3.Distance(p, a + val * num); } private static (Vector3 a, Vector3 b, float len)? Straight(LevelPoint p, LevelPoint q) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_001d: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing r