Decompiled source of P Rank Token v1.0.0
PirateToken.dll
Decompiled an hour ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace PirateToken; public class PirateChest : MonoBehaviour { private Transform root; private bool revealing; private static Material wood; private static Material iron; private static Material gold; private static GameObject cratePrefab; public static void Create(Transform parent, Vector3 pos, Quaternion rot) { //IL_00a8: 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_00c3: 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_00e2: 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_0102: 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_0141: 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_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_008e: 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_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0203: 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_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_033e: 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_037d: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: 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_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Expected O, but got Unknown //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_0542: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_05d9: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_0607: Unknown result type (might be due to invalid IL or missing references) //IL_060c: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_0589: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05a0: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) //IL_05b7: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)wood == (Object)null) { wood = A.Tinted("Assets/Materials/Dev/Wood/Crate.mat", new Color(0.45f, 0.3f, 0.2f)); iron = A.Tinted("Assets/Materials/Dev/Wood/Crate.mat", new Color(0.16f, 0.16f, 0.18f)); Material val = A.Load<Material>("Assets/Models/Objects/Coin.mat"); gold = (Material)((!((Object)(object)val != (Object)null)) ? ((object)A.Tinted("Assets/Materials/Dev/Wood/Crate.mat", Art.Gold)) : ((object)new Material(val))); } float value = Plugin.ChestScale.Value; Transform transform = new GameObject("PirateChest").transform; transform.SetParent(parent, false); transform.position = pos; transform.rotation = rot; Transform transform2 = new GameObject("Visual").transform; transform2.SetParent(transform, false); transform2.localScale = Vector3.one * value; A.Box(transform2, new Vector3(0f, 0.47f, 0f), new Vector3(1.6f, 0.84f, 1f), wood, (PrimitiveType)3); A.Box(transform2, new Vector3(0f, 0.9f, 0f), new Vector3(0.72f, 0.8f, 1f), wood, (PrimitiveType)2, Quaternion.Euler(0f, 0f, 90f)); float[] array = new float[2] { -0.55f, 0.55f }; foreach (float num in array) { A.Box(transform2, new Vector3(num, 0.47f, 0f), new Vector3(0.12f, 0.86f, 1.04f), iron, (PrimitiveType)3); A.Box(transform2, new Vector3(num, 0.9f, 0f), new Vector3(0.75f, 0.065f, 1.04f), iron, (PrimitiveType)2, Quaternion.Euler(0f, 0f, 90f)); } array = new float[2] { -0.78f, 0.78f }; foreach (float num2 in array) { float[] array2 = new float[2] { -0.48f, 0.48f }; foreach (float num3 in array2) { A.Box(transform2, new Vector3(num2, 0.47f, num3), new Vector3(0.1f, 0.9f, 0.1f), gold, (PrimitiveType)3); } } A.Box(transform2, new Vector3(0f, 0.06f, 0f), new Vector3(1.68f, 0.12f, 1.08f), gold, (PrimitiveType)3); A.Box(transform2, new Vector3(0f, 0.88f, 0f), new Vector3(1.64f, 0.06f, 1.04f), gold, (PrimitiveType)3); A.Box(transform2, new Vector3(0f, 0.78f, -0.52f), new Vector3(0.3f, 0.34f, 0.06f), gold, (PrimitiveType)3); A.Box(transform2, new Vector3(0f, 0.74f, -0.555f), new Vector3(0.06f, 0.12f, 0.02f), iron, (PrimitiveType)3); if ((Object)(object)cratePrefab == (Object)null) { cratePrefab = A.Load<GameObject>("Assets/Prefabs/Levels/Interactive/Crate.prefab"); } if ((Object)(object)cratePrefab == (Object)null) { Plugin.Log.LogWarning((object)"No crate prefab; chest can't be hit."); return; } GameObject val2 = new GameObject("h"); val2.SetActive(false); GameObject val3 = Object.Instantiate<GameObject>(cratePrefab, val2.transform); Breakable val4 = val3.GetComponent<Breakable>() ?? val3.GetComponentInChildren<Breakable>(); if ((Object)(object)val4 != (Object)null) { val4.crate = false; val4.coinAmount = 0; val4.crateCoin = null; val4.unbreakable = false; val4.weak = true; val4.precisionOnly = false; val4.specialCaseOnly = false; val4.playerOnly = false; val4.durability = 0f; } Renderer[] componentsInChildren = val3.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } Collider componentInChildren = val3.GetComponentInChildren<Collider>(true); val3.transform.SetParent(transform, false); val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; if ((Object)(object)componentInChildren != (Object)null) { Bounds bounds = componentInChildren.bounds; Vector3 size = ((Bounds)(ref bounds)).size; Vector3 val5 = new Vector3(1.68f, 1.3f, 1.08f) * value; Vector3 localScale = val3.transform.localScale; if (size.x > 0.01f && size.y > 0.01f && size.z > 0.01f) { val3.transform.localScale = new Vector3(localScale.x * val5.x / size.x, localScale.y * val5.y / size.y, localScale.z * val5.z / size.z); } bounds = componentInChildren.bounds; Vector3 center = ((Bounds)(ref bounds)).center; val3.transform.localPosition = new Vector3(0f, 0.65f * value, 0f) - transform.InverseTransformVector(center - val3.transform.position); } Object.Destroy((Object)(object)val2); (((Object)(object)val4 != (Object)null) ? ((Component)val4).gameObject : val3).AddComponent<PirateChest>().root = transform; } public bool OnHit() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (revealing) { return false; } if (Random.Range(0, 137500) != 0) { if ((Object)(object)root != (Object)null) { Object.Destroy((Object)(object)((Component)root).gameObject, 0.01f); } return true; } revealing = true; Plugin.Log.LogInfo((object)"P-RANK TOKEN rolled!"); new GameObject("PirateTokenReveal").AddComponent<TokenReveal>().Begin(root); return false; } } public class TokenReveal : MonoBehaviour { private Transform chest; public void Begin(Transform chestRoot) { chest = chestRoot; ((MonoBehaviour)this).StartCoroutine(Run()); } private IEnumerator Run() { if ((Object)(object)PirateLevel.Instance != (Object)null) { PirateLevel.Instance.Finishing = false; } NewMovement nm = default(NewMovement); MonoSingleton<NewMovement>.TryGetInstance(ref nm); Vector3 center = chest.position + Vector3.up * 1.1f * Plugin.ChestScale.Value; AudioSource val = ((Component)this).gameObject.AddComponent<AudioSource>(); val.spatialBlend = 0f; val.volume = 1f; val.priority = 0; if ((Object)(object)nm != (Object)null) { AudioSource[] componentsInChildren = ((Component)nm).GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val2 in componentsInChildren) { if ((Object)(object)val2.outputAudioMixerGroup != (Object)null) { val.outputAudioMixerGroup = val2.outputAudioMixerGroup; break; } } } if ((Object)(object)Plugin.TokenSound != (Object)null) { val.clip = Plugin.TokenSound; val.Play(); } else { A.PlayAt("Assets/Sounds/Environment/BellBig.ogg", center); A.PlayAt("Assets/Sounds/Enemies/FerrymanChimes.wav", center); } GameObject lightGo = new GameObject("ChestGlow"); lightGo.transform.position = center; Light light = lightGo.AddComponent<Light>(); light.type = (LightType)2; light.color = Art.Gold; light.range = 14f; light.intensity = 0f; Material glowMat = A.Load<Material>("Assets/Models/Objects/CoinUnlit.mat"); List<Renderer> renderers = new List<Renderer>(); Renderer[] componentsInChildren2 = ((Component)chest).GetComponentsInChildren<Renderer>(); foreach (Renderer val3 in componentsInChildren2) { if (val3.enabled) { renderers.Add(val3); } } Dictionary<Renderer, Material[]> original = new Dictionary<Renderer, Material[]>(); foreach (Renderer item in renderers) { original[item] = item.sharedMaterials; } A.Spawn("Assets/Particles/CoinCharge.prefab", center, Quaternion.identity, null, 3f); float t = 0f; while (t < 1.6f) { t += Time.deltaTime; bool flag = t > 0.9f || Mathf.Repeat(t * 6f, 1f) < 0.5f; foreach (Renderer item2 in renderers) { if ((Object)(object)item2 == (Object)null) { continue; } if (flag && (Object)(object)glowMat != (Object)null) { Material[] array = (Material[])(object)new Material[item2.sharedMaterials.Length]; for (int j = 0; j < array.Length; j++) { array[j] = glowMat; } item2.sharedMaterials = array; } else { item2.sharedMaterials = original[item2]; } } light.intensity = Mathf.Lerp(0f, 6f, t / 1.6f); Transform obj = chest; obj.position += Random.insideUnitSphere * 0.02f * (t / 1.6f); if (Random.value < 0.25f) { A.Spawn("Assets/Particles/Flashes/CoinFlash.prefab", center + Random.insideUnitSphere * 1.2f, Quaternion.identity, null, 1f); } yield return null; } A.Spawn("Assets/Particles/Breaks/BreakParticleCrate.prefab", center, Quaternion.identity, null, 4f); A.Spawn("Assets/Particles/CoinGet.prefab", center, Quaternion.identity, null, 3f); if ((Object)(object)nm != (Object)null && (Object)(object)nm.cc != (Object)null) { nm.cc.CameraShake(1.2f); } Object.Destroy((Object)(object)((Component)chest).gameObject); GameObject token = GameObject.CreatePrimitive((PrimitiveType)3); Object.Destroy((Object)(object)token.GetComponent<Collider>()); token.transform.position = center; token.transform.localScale = new Vector3(1.3f, 1.3f, 0.14f); Material val4 = (((Object)(object)glowMat != (Object)null) ? new Material(glowMat) : new Material(Shader.Find("Sprites/Default"))); val4.mainTexture = (Texture)(object)Art.Token(); A.SetColor(val4, Color.white); token.GetComponent<Renderer>().sharedMaterial = val4; lightGo.transform.SetParent(token.transform, true); t = 0f; while (t < 1.2f) { t += Time.deltaTime; float num = 1f - Mathf.Pow(1f - Mathf.Clamp01(t / 1.2f), 3f); token.transform.position = center + Vector3.up * 2.6f * num; float num2; if (!((Object)(object)nm != (Object)null) || !((Object)(object)nm.cc != (Object)null)) { num2 = 0f; } else { Quaternion val5 = Quaternion.LookRotation(token.transform.position - ((Component)nm.cc).transform.position); num2 = ((Quaternion)(ref val5)).eulerAngles.y; } float num3 = num2; token.transform.rotation = Quaternion.Euler(0f, num3 + (1f - num) * 720f, 0f); token.transform.localScale = new Vector3(1.3f, 1.3f, 0.14f) * (1f + Mathf.Sin(t * 12f) * 0.05f); light.intensity = 6f + Mathf.Sin(t * 20f) * 2f; yield return null; } A.PlayAt("Assets/Sounds/UI/CleanSuccessBig.wav", center, 0.8f); yield return Banner.Show(); Object.Destroy((Object)(object)token); if ((Object)(object)PirateLevel.Instance != (Object)null) { PirateLevel.Instance.Finishing = true; } Plugin.TokenWonThisRun = true; Plugin.FinishSecretLevel(); Object.Destroy((Object)(object)((Component)this).gameObject, 2f); } } public static class Banner { public static IEnumerator Show() { GameObject cgo = new GameObject("PirateTokenBanner"); Canvas obj = cgo.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 900; CanvasScaler obj2 = cgo.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.matchWidthOrHeight = 1f; CanvasGroup group = cgo.AddComponent<CanvasGroup>(); group.alpha = 0f; TMP_FontAsset font = null; LevelNamePopup val = default(LevelNamePopup); if (MonoSingleton<LevelNamePopup>.TryGetInstance(ref val) && (Object)(object)val.nameText != (Object)null) { font = val.nameText.font; } RectTransform main = Rect(cgo.transform, "Main", Vector2.zero, new Vector2(1920f, 1080f)); Image glow = Img((Transform)(object)main, "Glow", new Vector2(0f, 60f), new Vector2(1400f, 900f), Art.ToSprite(Art.Glow()), new Color(1f, 0.75f, 0.25f, 0.55f)); TextMeshProUGUI bgText = Txt((Transform)(object)main, "Back", new Vector2(0f, 150f), "P-RANK LEVEL ACCESS", 190f, new Color(1f, 0.78f, 0.2f, 0.28f), font); Graphic token = RankIconP((Transform)(object)main, new Vector2(0f, 150f), 230f); Txt((Transform)(object)main, "YouFound", new Vector2(0f, -20f), "YOU FOUND", 56f, Color.white, font); TextMeshProUGUI obj3 = Txt((Transform)(object)main, "Name", new Vector2(0f, -110f), "P-RANK LEVEL ACCESS", 100f, new Color(1f, 0.82f, 0.25f), font); ((TMP_Text)obj3).outlineWidth = 0.18f; ((TMP_Text)obj3).outlineColor = new Color32((byte)90, (byte)50, (byte)5, byte.MaxValue); Sprite s = Art.ToSprite(Art.Chevron()); ((Transform)((Graphic)Img((Transform)(object)main, "ChevL", new Vector2(-560f, -70f), new Vector2(300f, 225f), s, Color.white)).rectTransform).localScale = new Vector3(-1f, 1f, 1f); Img((Transform)(object)main, "ChevR", new Vector2(560f, -70f), new Vector2(300f, 225f), s, Color.white); Sprite s2 = Art.ToSprite(Art.Confetti()); List<Image> bits = new List<Image>(); List<Vector2> vel = new List<Vector2>(); List<float> spin = new List<float>(); for (int i = 0; i < 120; i++) { Image val2 = Img((Transform)(object)main, "c", new Vector2(Random.Range(-200f, 200f), Random.Range(0f, 200f)), Vector2.one * Random.Range(14f, 30f), s2, Color.Lerp(Art.Gold, Art.GoldLight, Random.value)); ((Transform)((Graphic)val2).rectTransform).localRotation = Quaternion.Euler(0f, 0f, Random.Range(0f, 360f)); bits.Add(val2); float num = Random.Range(0f, (float)Math.PI * 2f); vel.Add(new Vector2(Mathf.Cos(num), Mathf.Sin(num) * 0.7f + 0.5f) * Random.Range(500f, 1500f)); spin.Add(Random.Range(-720f, 720f)); } float t = 0f; float total = 4.2f; while (t < total) { float unscaledDeltaTime = Time.unscaledDeltaTime; t += unscaledDeltaTime; group.alpha = ((t < 0.2f) ? (t / 0.2f) : ((t > total - 0.7f) ? ((total - t) / 0.7f) : 1f)); float num2 = ((t < 0.25f) ? Mathf.Lerp(1.6f, 1f, t / 0.25f) : 1f); ((Transform)main).localScale = Vector3.one * num2; ((Transform)((TMP_Text)bgText).rectTransform).localScale = Vector3.one * (1f + t * 0.03f); ((Transform)token.rectTransform).parent.localRotation = Quaternion.Euler(0f, 0f, Mathf.Sin(t * 3f) * 4f); ((Graphic)glow).color = new Color(1f, 0.75f, 0.25f, 0.45f + Mathf.Sin(t * 6f) * 0.1f); for (int j = 0; j < bits.Count; j++) { vel[j] = new Vector2(vel[j].x * (1f - unscaledDeltaTime * 1.2f), vel[j].y - 900f * unscaledDeltaTime); RectTransform rectTransform = ((Graphic)bits[j]).rectTransform; rectTransform.anchoredPosition += vel[j] * unscaledDeltaTime; RectTransform rectTransform2 = ((Graphic)bits[j]).rectTransform; ((Transform)rectTransform2).localRotation = ((Transform)rectTransform2).localRotation * Quaternion.Euler(0f, 0f, spin[j] * unscaledDeltaTime); } yield return null; } Object.Destroy((Object)(object)cgo); } private static Graphic RankIconP(Transform parent, Vector2 pos, float size) { //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_001d: 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_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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) GameObject val = A.Load<GameObject>("Assets/Prefabs/UI/Rank Icon.prefab"); if ((Object)(object)val != (Object)null) { try { RectTransform val2 = Rect(parent, "PRankIcon", pos, new Vector2(size, size)); GameObject val3 = Object.Instantiate<GameObject>(val, (Transform)(object)val2, false); Transform transform = val3.transform; RectTransform val4 = (RectTransform)(object)((transform is RectTransform) ? transform : null); if ((Object)(object)val4 != (Object)null) { Vector2 anchorMin = (val4.anchorMax = new Vector2(0.5f, 0.5f)); val4.anchorMin = anchorMin; val4.anchoredPosition = Vector2.zero; Rect rect = val4.rect; float width = ((Rect)(ref rect)).width; rect = val4.rect; float num = Mathf.Max(1f, Mathf.Max(width, ((Rect)(ref rect)).height)); ((Transform)val4).localScale = Vector3.one * (size / num); } RankIcon val6 = val3.GetComponent<RankIcon>() ?? val3.GetComponentInChildren<RankIcon>(true); if ((Object)(object)val6 != (Object)null) { val6.SetRank(12); } Graphic componentInChildren = val3.GetComponentInChildren<Graphic>(true); if ((Object)(object)componentInChildren != (Object)null) { return componentInChildren; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("rank icon: " + ex.Message)); } } return (Graphic)(object)Img(parent, "Token", pos, new Vector2(size, size), Art.ToSprite(Art.Token()), Color.white); } private static RectTransform Rect(Transform parent, string n, Vector2 pos, Vector2 size) { //IL_0014: 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_002b: 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_003e: 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_004a: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown RectTransform val = (RectTransform)new GameObject(n, new Type[1] { typeof(RectTransform) }).transform; ((Transform)val).SetParent(parent, false); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); val.anchorMax = val2; val.anchorMin = val2; val.anchoredPosition = pos; val.sizeDelta = size; return val; } private static Image Img(Transform parent, string n, Vector2 pos, Vector2 size, Sprite s, Color c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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) Image obj = ((Component)Rect(parent, n, pos, size)).gameObject.AddComponent<Image>(); obj.sprite = s; ((Graphic)obj).color = c; ((Graphic)obj).raycastTarget = false; return obj; } private static TextMeshProUGUI Txt(Transform parent, string n, Vector2 pos, string text, float size, Color c, TMP_FontAsset font) { //IL_0002: 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_0047: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = ((Component)Rect(parent, n, pos, new Vector2(1900f, size * 1.3f))).gameObject.AddComponent<TextMeshProUGUI>(); if ((Object)(object)font != (Object)null) { ((TMP_Text)val).font = font; } ((TMP_Text)val).text = text; ((TMP_Text)val).fontSize = size; ((Graphic)val).color = c; ((TMP_Text)val).alignment = (TextAlignmentOptions)514; ((TMP_Text)val).enableWordWrapping = false; ((Graphic)val).raycastTarget = false; return val; } } public class PirateLevel : MonoBehaviour { private class TemplateInfo : MonoBehaviour { public float bottomOffset; } public static PirateLevel Instance; public bool Finishing; private const float ChunkSize = 40f; private const int Radius = 3; private Vector3 origin; private Vector3 outDir; private float groundY; private Bounds roomBounds; private Material groundMat; private readonly List<GameObject> crossTemplates = new List<GameObject>(); private readonly List<GameObject> treeTemplates = new List<GameObject>(); private readonly List<GameObject> grassTemplates = new List<GameObject>(); private Transform templateRoot; private Transform worldRoot; private readonly Dictionary<long, GameObject> chunks = new Dictionary<long, GameObject>(); private NewMovement nm; public const string LevelTitle = "P-T: P-RANK TOKEN"; private bool titleShown; private float nextRename; private static Material stone; public static IEnumerator Setup() { NewMovement nm = null; for (int i = 0; i < 600; i++) { if (MonoSingleton<NewMovement>.TryGetInstance(ref nm)) { break; } yield return null; } yield return null; yield return null; if ((Object)(object)nm == (Object)null) { Plugin.Log.LogError((object)"P-T: no player"); yield break; } Instance = new GameObject("PirateTokenLevel").AddComponent<PirateLevel>(); try { Instance.Build(nm); } catch (Exception ex) { Plugin.Log.LogError((object)("P-T setup failed: " + ex)); } } private unsafe void Build(NewMovement player) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00a0: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_027d: 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_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0306: 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_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) nm = player; FirstRoomPrefab val = Object.FindObjectOfType<FirstRoomPrefab>(); Transform val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform : null); Vector3 val3 = ((Component)nm).transform.position + ((Component)nm).transform.forward * 10f; if ((Object)(object)val != (Object)null && (Object)(object)val.mainDoor != (Object)null) { val3 = ((Component)val.mainDoor).transform.position; } outDir = (((Object)(object)val != (Object)null) ? Vector3.ProjectOnPlane(val3 - ((Component)val).transform.position, Vector3.up) : ((Component)nm).transform.forward); if (((Vector3)(ref outDir)).sqrMagnitude < 0.01f) { outDir = Vector3.ProjectOnPlane(((Component)nm.cc).transform.forward, Vector3.up); } ((Vector3)(ref outDir)).Normalize(); LayerMask val4 = LayerMaskDefaults.Get((LMD)1); groundY = val3.y - 2f; RaycastHit val5 = default(RaycastHit); if (Physics.Raycast(val3 + Vector3.up * 2f, Vector3.down, ref val5, 30f, LayerMask.op_Implicit(val4), (QueryTriggerInteraction)1)) { groundY = ((RaycastHit)(ref val5)).point.y; } origin = new Vector3(val3.x, groundY, val3.z) + outDir * 4f; if (Physics.Raycast(origin + outDir * 8f + Vector3.up * 10f, Vector3.down, ref val5, 60f, LayerMask.op_Implicit(val4), (QueryTriggerInteraction)1)) { Renderer val6 = ((Component)((RaycastHit)(ref val5)).collider).GetComponent<Renderer>() ?? ((Component)((RaycastHit)(ref val5)).collider).GetComponentInParent<Renderer>(); if ((Object)(object)val6 != (Object)null) { groundMat = val6.sharedMaterial; } Plugin.Log.LogInfo((object)("P-T ground from " + ((Object)((RaycastHit)(ref val5)).collider).name + " mat=" + (((Object)(object)groundMat != (Object)null) ? ((Object)groundMat).name : "none"))); } if ((Object)(object)groundMat == (Object)null) { groundMat = A.Tinted("Assets/Materials/Environment/Metal/CrackedWall.mat", new Color(0.85f, 0.85f, 0.85f), 10f); } roomBounds = new Bounds(val3, Vector3.one * 4f); if ((Object)(object)val2 != (Object)null) { Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Renderer>(); foreach (Renderer val7 in componentsInChildren) { ((Bounds)(ref roomBounds)).Encapsulate(val7.bounds); } } ((Bounds)(ref roomBounds)).Expand(6f); CollectTemplates(); Prune(val2); if ((Object)(object)val2 != (Object)null) { Greyify(val2); } worldRoot = new GameObject("PT_World").transform; RenameLevel(); ManualLogSource log = Plugin.Log; string[] obj = new string[10] { "P-T built. origin=", null, null, null, null, null, null, null, null, null }; Vector3 val8 = origin; obj[1] = ((object)(*(Vector3*)(&val8))/*cast due to .constrained prefix*/).ToString(); obj[2] = " dir="; val8 = outDir; obj[3] = ((object)(*(Vector3*)(&val8))/*cast due to .constrained prefix*/).ToString(); obj[4] = " crosses="; obj[5] = crossTemplates.Count.ToString(); obj[6] = " trees="; obj[7] = treeTemplates.Count.ToString(); obj[8] = " grass="; obj[9] = grassTemplates.Count.ToString(); log.LogInfo((object)string.Concat(obj)); } private void CollectTemplates() { //IL_0006: 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_00c7: 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_0166: 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_016f: 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_01a3: Expected O, but got Unknown //IL_01c4: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: 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_024e: Unknown result type (might be due to invalid IL or missing references) templateRoot = new GameObject("PT_Templates").transform; ((Component)templateRoot).gameObject.SetActive(false); HashSet<Mesh> hashSet = new HashSet<Mesh>(); HashSet<string> hashSet2 = new HashSet<string>(); MeshFilter[] array = Object.FindObjectsOfType<MeshFilter>(); foreach (MeshFilter val in array) { Mesh sharedMesh = val.sharedMesh; if ((Object)(object)sharedMesh == (Object)null || hashSet.Contains(sharedMesh)) { continue; } MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>(); if ((Object)(object)component == (Object)null || !((Renderer)component).enabled) { continue; } string text = (((Object)sharedMesh).name + " " + ((Object)((Component)val).gameObject).name).ToLowerInvariant(); if (hashSet2.Count < 400 && Vector3.Distance(((Component)val).transform.position, origin) < 250f) { hashSet2.Add(((Object)sharedMesh).name); } List<GameObject> list = null; if (text.Contains("cross") || text.Contains("grave") || text.Contains("tomb")) { list = crossTemplates; } else if (text.Contains("tree")) { list = treeTemplates; } else if (text.Contains("grass")) { list = grassTemplates; } if (list == null || list.Count >= 6) { continue; } Bounds bounds = ((Renderer)component).bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!(((Vector3)(ref size)).magnitude > 60f)) { hashSet.Add(sharedMesh); GameObject val2 = new GameObject("T_" + ((Object)sharedMesh).name); val2.transform.SetParent(templateRoot, false); val2.transform.localScale = ((Component)val).transform.lossyScale; val2.transform.rotation = ((Component)val).transform.rotation; val2.AddComponent<MeshFilter>().sharedMesh = sharedMesh; ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterials = ((Renderer)component).sharedMaterials; if (list != grassTemplates) { val2.AddComponent<MeshCollider>().sharedMesh = sharedMesh; val2.layer = A.EnvLayer; } Bounds bounds2 = ((Renderer)component).bounds; val2.AddComponent<TemplateInfo>().bottomOffset = ((Component)val).transform.position.y - ((Bounds)(ref bounds2)).min.y; list.Add(val2); } } Plugin.Log.LogInfo((object)("P-T meshes near start: " + string.Join(", ", new List<string>(hashSet2).ToArray()))); } private void Prune(Transform room) { //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) HashSet<Transform> hashSet = new HashSet<Transform>(); if ((Object)(object)room != (Object)null) { hashSet.Add(room); } hashSet.Add(((Component)nm).transform); Camera[] array = Object.FindObjectsOfType<Camera>(); foreach (Camera val in array) { hashSet.Add(((Component)val).transform); } Canvas[] array2 = Object.FindObjectsOfType<Canvas>(); foreach (Canvas val2 in array2) { if (val2.isRootCanvas) { hashSet.Add(((Component)val2).transform); } } hashSet.Add(templateRoot); MonoBehaviour[] array3 = Object.FindObjectsOfType<MonoBehaviour>(); foreach (MonoBehaviour val3 in array3) { if (val3 is StatsManager || val3 is MusicManager || val3 is FinalRank || val3 is LevelNamePopup || val3 is TimeController || val3 is OptionsManager) { hashSet.Add(((Component)val3).transform); } } HashSet<Transform> hashSet2 = new HashSet<Transform>(); foreach (Transform item in hashSet) { Transform parent = item.parent; while ((Object)(object)parent != (Object)null) { hashSet2.Add(parent); parent = parent.parent; } } int num = 0; Scene activeScene = SceneManager.GetActiveScene(); GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects(); foreach (GameObject val4 in rootGameObjects) { num += PruneRec(val4.transform, hashSet, hashSet2); } Plugin.Log.LogInfo((object)("P-T pruned " + num + " objects from 7-1.")); } private int PruneRec(Transform t, HashSet<Transform> keep, HashSet<Transform> ancestors) { if (keep.Contains(t)) { return 0; } if (ancestors.Contains(t)) { int num = 0; for (int i = 0; i < t.childCount; i++) { num += PruneRec(t.GetChild(i), keep, ancestors); } return num; } if ((Object)(object)((Component)t).GetComponentInChildren<Renderer>(true) != (Object)null || (Object)(object)((Component)t).GetComponentInChildren<Collider>(true) != (Object)null) { ((Component)t).gameObject.SetActive(false); return 1; } return 0; } private static void Greyify(Transform room) { //IL_01ab: 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_0093: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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) Renderer[] componentsInChildren = ((Component)room).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (val is ParticleSystemRenderer) { continue; } Material[] materials = val.materials; foreach (Material val2 in materials) { if ((Object)(object)val2 == (Object)null) { continue; } if (val2.HasProperty("_MainTex") && (Object)(object)val2.mainTexture != (Object)null) { Texture2D val3 = A.Greyscale(val2.mainTexture); if ((Object)(object)val3 != (Object)null) { val2.mainTexture = (Texture)(object)val3; } } if (val2.HasProperty("_Color")) { Color color = val2.color; float num = color.r * 0.3f + color.g * 0.59f + color.b * 0.11f; val2.color = new Color(num, num, num, color.a); } string[] array = new string[2] { "_EmissiveColor", "_EmissionColor" }; foreach (string text in array) { if (val2.HasProperty(text)) { Color color2 = val2.GetColor(text); float num2 = color2.r * 0.3f + color2.g * 0.59f + color2.b * 0.11f; val2.SetColor(text, new Color(num2, num2, num2, color2.a)); } } } val.materials = materials; } Light[] componentsInChildren2 = ((Component)room).GetComponentsInChildren<Light>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].color = new Color(0.85f, 0.85f, 0.88f); } } private void RenameLevel() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) try { StockMapInfo instance = StockMapInfo.Instance; if ((Object)(object)instance != (Object)null) { SerializedActivityAssets assets = instance.assets; assets.LargeText = "P-T: P-RANK TOKEN"; instance.assets = assets; } LevelStats[] array = Resources.FindObjectsOfTypeAll<LevelStats>(); Scene scene; foreach (LevelStats val in array) { if ((Object)(object)val != (Object)null) { scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid() && (Object)(object)val.levelName != (Object)null && !val.cyberGrind) { val.levelName.text = "P-T: P-RANK TOKEN"; } } } TMP_Text[] array2 = Resources.FindObjectsOfTypeAll<TMP_Text>(); foreach (TMP_Text val2 in array2) { if ((Object)(object)val2 == (Object)null) { continue; } scene = ((Component)val2).gameObject.scene; if (!((Scene)(ref scene)).IsValid() || string.IsNullOrEmpty(val2.text)) { continue; } string text = val2.text; if (text.IndexOf("GARDEN OF FORKING", StringComparison.OrdinalIgnoreCase) >= 0 || text.Contains("7-1")) { text = Regex.Replace(text, "GARDEN OF FORKING\\s*PATHS", "P-RANK TOKEN", RegexOptions.IgnoreCase); text = text.Replace("7-1", "P-T"); if (text != val2.text) { val2.text = text; } } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("rename: " + ex.Message)); } } private void Update() { //IL_00b2: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0253: 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_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)nm == (Object)null || (Object)(object)worldRoot == (Object)null || Finishing) { return; } Vector3 position = ((Component)nm).transform.position; if (Time.unscaledTime > nextRename) { nextRename = Time.unscaledTime + 0.5f; RenameLevel(); } if (!titleShown && !((Bounds)(ref roomBounds)).Contains(position)) { titleShown = true; LevelNamePopup val = default(LevelNamePopup); if (MonoSingleton<LevelNamePopup>.TryGetInstance(ref val)) { try { val.CustomNameAppear("SECRET LEVEL", "P-T: P-RANK TOKEN"); } catch (Exception ex) { Plugin.Log.LogWarning((object)("title: " + ex.Message)); } } } int num = Mathf.FloorToInt((position.x - origin.x) / 40f + 0.5f); int num2 = Mathf.FloorToInt((position.z - origin.z) / 40f + 0.5f); for (int i = num - 3; i <= num + 3; i++) { for (int j = num2 - 3; j <= num2 + 3; j++) { long key = Key(i, j); if (!chunks.ContainsKey(key)) { chunks[key] = MakeChunk(i, j); } } } List<long> list = new List<long>(); foreach (KeyValuePair<long, GameObject> chunk in chunks) { int num3 = (int)(chunk.Key >> 32); int num4 = (int)(chunk.Key & 0xFFFFFFFFu); if (Mathf.Abs(num3 - num) > 4 || Mathf.Abs(num4 - num2) > 4) { list.Add(chunk.Key); } } foreach (long item in list) { if ((Object)(object)chunks[item] != (Object)null) { Object.Destroy((Object)(object)chunks[item]); } chunks.Remove(item); } if (position.y < groundY - 40f && !nm.dead) { ((Component)nm).transform.position = origin + Vector3.up * 3f; nm.rb.velocity = Vector3.zero; } } private static long Key(int x, int z) { return ((long)x << 32) | (uint)z; } private GameObject MakeChunk(int cx, int cz) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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) //IL_00cb: 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_00fc: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_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_01a0: 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_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_01ee: 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_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_0299: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("PT_Chunk_" + cx + "_" + cz); val.transform.SetParent(worldRoot, false); Vector3 center = origin + new Vector3((float)cx * 40f, 0f, (float)cz * 40f); GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val2).name = "Ground"; val2.transform.SetParent(val.transform, false); val2.transform.position = center + Vector3.down * 1.02f; val2.transform.localScale = new Vector3(40f, 2f, 40f); val2.layer = A.EnvLayer; try { val2.tag = "Floor"; } catch { } Material val3 = new Material(groundMat); val3.mainTextureScale = new Vector2(5f, 5f); val3.mainTextureOffset = new Vector2((float)cx * 40f / 8f, (float)cz * 40f / 8f); val2.GetComponent<Renderer>().sharedMaterial = val3; Random rng = new Random((cx * 73856093) ^ (cz * 19349663) ^ 0x5EED); Func<Vector3> func = () => center + new Vector3((float)(rng.NextDouble() - 0.5) * 40f, 0f, (float)(rng.NextDouble() - 0.5) * 40f); Func<Vector3, bool> func2 = (Vector3 pos) => !((Bounds)(ref roomBounds)).Contains(new Vector3(pos.x, ((Bounds)(ref roomBounds)).center.y, pos.z)) && Vector3.Distance(pos, origin) > 10f; int num = 4 + rng.Next(4); for (int num2 = 0; num2 < num; num2++) { Vector3 val4 = func(); if (func2(val4)) { Prop(val.transform, crossTemplates, val4, rng, primitiveCrossFallback: true); } } int num3 = rng.Next(3); for (int num4 = 0; num4 < num3; num4++) { Vector3 val5 = func(); if (func2(val5)) { Prop(val.transform, treeTemplates, val5, rng, primitiveCrossFallback: false); } } if (grassTemplates.Count > 0) { int num5 = 10 + rng.Next(8); for (int num6 = 0; num6 < num5; num6++) { Vector3 val6 = func(); if (func2(val6)) { Prop(val.transform, grassTemplates, val6, rng, primitiveCrossFallback: false); } } } int value = Plugin.ChestsPerChunk.Value; for (int num7 = 0; num7 < value; num7++) { Vector3 val7 = func(); if (func2(val7)) { PirateChest.Create(val.transform, val7, Quaternion.Euler(0f, (float)rng.NextDouble() * 360f, 0f)); } } return val; } private void Prop(Transform parent, List<GameObject> templates, Vector3 pos, Random rng, bool primitiveCrossFallback) { //IL_000e: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_00a1: 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) if (templates.Count == 0) { if (primitiveCrossFallback) { StoneCross(parent, pos, rng); } return; } GameObject val = templates[rng.Next(templates.Count)]; GameObject obj = Object.Instantiate<GameObject>(val, parent); obj.SetActive(true); TemplateInfo component = val.GetComponent<TemplateInfo>(); float num = (((Object)(object)component != (Object)null) ? component.bottomOffset : 0f); obj.transform.position = pos + Vector3.up * (num - 0.1f); obj.transform.rotation = Quaternion.Euler(0f, (float)rng.NextDouble() * 360f, 0f) * val.transform.rotation; } private void StoneCross(Transform parent, Vector3 pos, Random rng) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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) if ((Object)(object)stone == (Object)null) { stone = A.Tinted("Assets/Materials/Environment/Metal/CrackedWall.mat", new Color(0.7f, 0.7f, 0.7f)); } GameObject val = new GameObject("Cross"); val.transform.SetParent(parent, false); val.transform.position = pos; val.transform.rotation = Quaternion.Euler((float)(rng.NextDouble() - 0.5) * 16f, (float)rng.NextDouble() * 360f, (float)(rng.NextDouble() - 0.5) * 16f); float num = 1f + (float)rng.NextDouble() * 1.5f; GameObject val2 = A.Box(val.transform, new Vector3(0f, 2.2f * num, 0f), new Vector3(0.5f * num, 4.4f * num, 0.5f * num), stone, (PrimitiveType)3); A.Box(val.transform, new Vector3(0f, 3.1f * num, 0f), new Vector3(2.4f * num, 0.5f * num, 0.5f * num), stone, (PrimitiveType)3); val2.AddComponent<BoxCollider>(); val2.layer = A.EnvLayer; } } [BepInPlugin("local.piratetoken", "Pirate Token", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "local.piratetoken"; public const string Version = "1.0.0"; public const string Scene71 = "Level 7-1"; internal static Plugin Inst; internal static ManualLogSource Log; internal static bool SecretRun; internal static bool PirateActive; internal static bool TokenWonThisRun; internal const int TokenOdds = 137500; internal static ConfigEntry<float> ChestScale; internal static ConfigEntry<int> ChestsPerChunk; internal static AudioClip TokenSound; internal static bool BlockSaves { get { if (!SecretRun) { return PirateActive; } return true; } } private void Awake() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) Inst = this; Log = ((BaseUnityPlugin)this).Logger; ChestsPerChunk = ((BaseUnityPlugin)this).Config.Bind<int>("P-T", "ChestsPerChunk", 3, "Chests per 40x40 area of the endless graveyard."); ChestScale = ((BaseUnityPlugin)this).Config.Bind<float>("P-T", "ChestScale", 1.7f, "Chest size."); Progress.Init(); ((Component)this).gameObject.AddComponent<TokenEffect>(); new Harmony("local.piratetoken").PatchAll(Assembly.GetExecutingAssembly()); SceneManager.sceneLoaded += OnSceneLoaded; ((MonoBehaviour)this).StartCoroutine(LoadSound()); Log.LogInfo((object)"Pirate Token loaded."); } private IEnumerator LoadSound() { string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "PirateTokenSound.mp3"); if (!File.Exists(text)) { Log.LogWarning((object)"No PirateTokenSound.mp3 next to the DLL; using a game sound instead."); yield break; } UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip("file:///" + text.Replace('\\', '/'), (AudioType)13); try { yield return req.SendWebRequest(); if ((int)req.result != 1) { Log.LogWarning((object)("Sound load failed: " + req.error)); yield break; } TokenSound = DownloadHandlerAudioClip.GetContent(req); Log.LogInfo((object)("Pirate token sound loaded (" + (((Object)(object)TokenSound != (Object)null) ? TokenSound.length.ToString("F1") : "?") + " s).")); } finally { ((IDisposable)req)?.Dispose(); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0000: 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) if ((int)mode == 0) { ((MonoBehaviour)this).StartCoroutine(AfterLoad(scene)); } } private IEnumerator AfterLoad(Scene scene) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) yield return null; string text = null; try { text = SceneHelper.CurrentScene; } catch { } if (string.IsNullOrEmpty(text)) { text = ((Scene)(ref scene)).name; } Log.LogInfo((object)("Scene loaded: " + text + " [" + ((Scene)(ref scene)).name + "] (secretRun=" + SecretRun + ", pirate=" + PirateActive + ")")); TokenWonThisRun = false; if (text == "Main Menu") { new GameObject("PRankTokenMenu").AddComponent<MenuButton>(); } if (text == "Level 7-1") { SecretRun = false; if (PirateActive) { ((MonoBehaviour)this).StartCoroutine(PirateLevel.Setup()); } else { ((MonoBehaviour)this).StartCoroutine(SecretWall.SpawnWhenReady()); } } else { SecretRun = false; PirateActive = false; } } internal static void StartPirateLevel() { SecretRun = false; PirateActive = true; SceneHelper.LoadScene("Level 7-1", false); } internal static void FinishSecretLevel() { //IL_0062: 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_011d: Unknown result type (might be due to invalid IL or missing references) try { MakeSecretEndScreen(); } catch (Exception ex) { Log.LogWarning((object)("secret end screen: " + ex)); } GameObject val = null; FinalRoom val2 = null; try { GameObject val3 = A.Load<GameObject>("Assets/Prefabs/Levels/Special Rooms/FinalRoom SecretExit.prefab"); if ((Object)(object)val3 != (Object)null) { val = Object.Instantiate<GameObject>(val3); val.transform.position = new Vector3(50000f, -1000f, 50000f); val2 = val.GetComponentInChildren<FinalRoom>(true); } } catch (Exception ex2) { Log.LogWarning((object)("Secret exit room failed: " + ex2.Message)); } if ((Object)(object)val2 == (Object)null || (Object)(object)val2.dropPoint == (Object)null) { Log.LogWarning((object)"No secret exit room; using the regular final pit."); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } SceneHelper.SpawnFinalPitAndFinish(); return; } if ((Object)(object)val2.doorOpener != (Object)null) { val2.doorOpener.SetActive(true); } NewMovement val4 = default(NewMovement); if (MonoSingleton<NewMovement>.TryGetInstance(ref val4)) { ((Component)val4).transform.position = val2.dropPoint.position; Rigidbody component = ((Component)val4).GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { component.velocity = Vector3.zero; } } Log.LogInfo((object)"P-T finished through the secret exit room."); } internal unsafe static void MakeSecretEndScreen() { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0249: 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_026e: 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_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Expected O, but got Unknown //IL_0346: Unknown result type (might be due to invalid IL or missing references) FinalRank val = null; StatsManager val2 = default(StatsManager); if (MonoSingleton<StatsManager>.TryGetInstance(ref val2) && (Object)(object)val2 != (Object)null) { val = val2.fr; } if ((Object)(object)val == (Object)null) { val = Object.FindObjectOfType<FinalRank>(true); } if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"No end screen found to convert."); return; } Transform transform = ((Component)val).transform; Transform val3 = transform.Find("Title"); Transform val4 = transform.Find("ff"); if ((Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null) { Log.LogWarning((object)"End screen layout not recognised; leaving it as is."); return; } val.casual = true; foreach (Transform item in transform) { ((Component)item).gameObject.SetActive(false); } KeepTexts keepTexts = ((Component)transform).gameObject.AddComponent<KeepTexts>(); RectTransform rt = (RectTransform)val4; Rect val5 = LocalRect((RectTransform)val3); Rect val6 = LocalRect(rt); float width = ((Rect)(ref val6)).width; float height = ((Rect)(ref val6)).height; float num = width * 0.12f; float num2 = (width - num) / 2f; float x = ((Rect)(ref val5)).center.x; float y = ((Rect)(ref val6)).center.y; ManualLogSource log = Log; Rect val7 = val5; string? text = ((object)(*(Rect*)(&val7))/*cast due to .constrained prefix*/).ToString(); val7 = val6; log.LogInfo((object)("End screen layout: title " + text + ", row " + ((object)(*(Rect*)(&val7))/*cast due to .constrained prefix*/).ToString())); TMP_Text[] componentsInChildren = ((Component)val4).GetComponentsInChildren<TMP_Text>(true); for (int i = 1; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.SetActive(false); } float num3 = ((componentsInChildren.Length != 0) ? componentsInChildren[0].fontSize : 36f); Transform obj = transform.Find("Time - Rank"); RectTransform val8 = (RectTransform)(object)((obj is RectTransform) ? obj : null); if ((Object)(object)val8 == (Object)null) { if (componentsInChildren.Length != 0) { keepTexts.Add(componentsInChildren[0], "MISSION:"); } if (componentsInChildren.Length > 1) { ((Component)componentsInChildren[1]).gameObject.SetActive(true); keepTexts.Add(componentsInChildren[1], "COMPLETE"); } val.toAppear = (GameObject[])(object)new GameObject[1] { ((Component)val4).gameObject }; Log.LogInfo((object)"End screen switched to the secret-level version (single box)."); return; } Place(rt, new Vector2(x - (num2 + num) / 2f, y), new Vector2(num2, height)); Place(val8, new Vector2(x + (num2 + num) / 2f, y), new Vector2(num2, height)); if (componentsInChildren.Length != 0) { Fill(componentsInChildren[0].rectTransform); componentsInChildren[0].alignment = (TextAlignmentOptions)514; keepTexts.Add(componentsInChildren[0], "MISSION:"); } foreach (Transform item2 in (Transform)val8) { object obj2 = (object)item2; RectTransform val9 = (RectTransform)((obj2 is RectTransform) ? obj2 : null); if ((Object)(object)val9 != (Object)null) { Fill(val9); } } TMP_Text componentInChildren = ((Component)val8).GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.enableAutoSizing = true; componentInChildren.fontSizeMin = 8f; componentInChildren.fontSizeMax = num3 * 1.3f; componentInChildren.alignment = (TextAlignmentOptions)514; ((Graphic)componentInChildren).color = Color.white; keepTexts.Add(componentInChildren, "COMPLETE"); } val.toAppear = (GameObject[])(object)new GameObject[2] { ((Component)val4).gameObject, ((Component)val8).gameObject }; Log.LogInfo((object)"End screen switched to the secret-level version."); } private static Rect LocalRect(RectTransform rt) { //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_0009: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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) Rect rect = rt.rect; Vector2 size = ((Rect)(ref rect)).size; return new Rect(Vector2.op_Implicit(((Transform)rt).localPosition) + Vector2.Scale(new Vector2(0.5f, 0.5f) - rt.pivot, size) - size / 2f, size); } private static void Place(RectTransform rt, Vector2 center, Vector2 size) { //IL_0013: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); rt.anchorMax = val; rt.anchorMin = val; rt.pivot = new Vector2(0.5f, 0.5f); rt.sizeDelta = size; ((Transform)rt).localPosition = new Vector3(center.x, center.y, ((Transform)rt).localPosition.z); } private static void Fill(RectTransform rt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; Vector2 offsetMin = (rt.offsetMax = Vector2.zero); rt.offsetMin = offsetMin; } internal static void Hud(string msg) { HudMessageReceiver val = default(HudMessageReceiver); if (MonoSingleton<HudMessageReceiver>.TryGetInstance(ref val)) { try { val.SendHudMessage(msg, "", "", 0, false, false, true); } catch { } } } internal static Vector3? ParseVec(string s) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(s)) { return null; } string[] array = s.Split(','); if (array.Length != 3) { return null; } CultureInfo invariantCulture = CultureInfo.InvariantCulture; if (!float.TryParse(array[0], NumberStyles.Float, invariantCulture, out var result) || !float.TryParse(array[1], NumberStyles.Float, invariantCulture, out var result2) || !float.TryParse(array[2], NumberStyles.Float, invariantCulture, out var result3)) { return null; } return new Vector3(result, result2, result3); } internal static string VecStr(Vector3 v) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; return v.x.ToString("F3", invariantCulture) + "," + v.y.ToString("F3", invariantCulture) + "," + v.z.ToString("F3", invariantCulture); } } public class KeepTexts : MonoBehaviour { private readonly List<TMP_Text> texts = new List<TMP_Text>(); private readonly List<string> values = new List<string>(); private readonly HashSet<int> reported = new HashSet<int>(); public void Add(TMP_Text t, string v) { if (!((Object)(object)t == (Object)null)) { texts.Add(t); values.Add(v); Apply(texts.Count - 1, report: false); } } private void LateUpdate() { for (int i = 0; i < texts.Count; i++) { Apply(i, report: true); } } private void Apply(int i, bool report) { //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) TMP_Text val = texts[i]; if ((Object)(object)val == (Object)null) { return; } if (val.text != values[i]) { if (report && reported.Add(i)) { Plugin.Log.LogInfo((object)("End screen text '" + ((Object)val).name + "' was changed to \"" + val.text + "\"; putting \"" + values[i] + "\" back.")); } val.text = values[i]; } if (!((Component)val).gameObject.activeSelf && (Object)(object)val.transform.parent != (Object)null && ((Component)val.transform.parent).gameObject.activeInHierarchy) { ((Component)val).gameObject.SetActive(true); if (report) { Plugin.Log.LogInfo((object)("End screen text '" + ((Object)val).name + "' switched on.")); } } val.maxVisibleCharacters = 99999; ((Behaviour)val).enabled = true; Color color = ((Graphic)val).color; if (color.a < 1f) { color.a = 1f; ((Graphic)val).color = color; } } } [HarmonyPatch] internal static class BlockProgressSaves { private static IEnumerable<MethodBase> TargetMethods() { MethodInfo[] methods = typeof(GameProgressSaver).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public); foreach (MethodInfo methodInfo in methods) { if (!(methodInfo.Name == "SetSlot") && !methodInfo.IsGenericMethodDefinition && (methodInfo.Name.StartsWith("Save") || methodInfo.Name.StartsWith("Set") || methodInfo.Name.StartsWith("Add"))) { yield return methodInfo; } } } private static bool Prefix(MethodBase __originalMethod) { if (!Plugin.BlockSaves) { return true; } Plugin.Log.LogInfo((object)("Blocked save: " + __originalMethod.Name)); return false; } } [HarmonyPatch(typeof(LeaderboardController), "SubmitLevelScore")] internal static class BlockLeaderboard { private static bool Prefix() { return !Plugin.BlockSaves; } } [HarmonyPatch(typeof(CrateCounter), "SaveStuff")] internal static class BlockCrateSave { private static bool Prefix() { return !Plugin.BlockSaves; } } [HarmonyPatch(typeof(FinalRank), "LevelChange")] internal static class WinScreenContinue { private static bool Prefix() { if (Plugin.SecretRun) { Plugin.Log.LogInfo((object)"Secret exit complete -> P-T"); Plugin.StartPirateLevel(); return false; } if (Plugin.PirateActive) { Plugin.Log.LogInfo((object)"P-T complete -> main menu"); Plugin.PirateActive = false; SceneHelper.LoadScene("Main Menu", false); return false; } return true; } } [HarmonyPatch(typeof(StatsManager), "SendInfo")] internal static class EarnToken { private static void Postfix() { if (Plugin.PirateActive && Plugin.TokenWonThisRun) { int difficulty = Progress.Difficulty; Progress.SetEarned(difficulty); Plugin.Log.LogInfo((object)("P-RANK TOKEN earned on difficulty " + difficulty)); } } } [HarmonyPatch(typeof(Explosion), "Start")] internal static class ExplosionBreaksWall { private static void Postfix(Explosion __instance) { try { SecretWall.OnExplosion(__instance); } catch (Exception ex) { Plugin.Log.LogWarning((object)ex); } } } [HarmonyPatch(typeof(Breakable), "Break", new Type[] { typeof(float) })] internal static class ChestBreak { private static bool Prefix(Breakable __instance) { if ((Object)(object)__instance == (Object)null || __instance.broken) { return true; } PirateChest component = ((Component)__instance).GetComponent<PirateChest>(); if ((Object)(object)component == (Object)null) { return true; } return component.OnHit(); } } [HarmonyPatch(typeof(LevelNamePopup), "Start")] internal static class TitleCard { private static void Postfix(LevelNamePopup __instance) { if (Plugin.PirateActive) { Traverse obj = Traverse.Create((object)__instance); obj.Field("layerString").SetValue((object)"SECRET LEVEL"); obj.Field("nameString").SetValue((object)"P-T: P-RANK TOKEN"); } } } internal static class Progress { private static ConfigFile file; private static readonly ConfigEntry<bool>[] earned = new ConfigEntry<bool>[6]; private static readonly ConfigEntry<bool>[] activated = new ConfigEntry<bool>[6]; public static int Difficulty { get { int num = 2; PrefsManager val = default(PrefsManager); if (MonoSingleton<PrefsManager>.TryGetInstance(ref val)) { try { num = val.GetInt("difficulty", 2); } catch { } } return Mathf.Clamp(num, 0, 5); } } public static void Init() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown file = new ConfigFile(Path.Combine(Paths.ConfigPath, "local.piratetoken.progress.cfg"), true); for (int i = 0; i < 6; i++) { earned[i] = file.Bind<bool>("Difficulty " + i, "TokenEarned", false, "Got the P-RANK TOKEN and beat P-T on this difficulty."); activated[i] = file.Bind<bool>("Difficulty " + i, "TokenActivated", false, "Clicked the P-RANK TOKEN button on this difficulty."); if (activated[i].Value) { activated[i].Value = false; earned[i].Value = false; Plugin.Log.LogInfo((object)("P-RANK TOKEN on difficulty " + i + " expired (game restarted).")); } } file.Save(); } public static bool Earned(int d) { return earned[Mathf.Clamp(d, 0, 5)].Value; } public static bool Activated(int d) { return activated[Mathf.Clamp(d, 0, 5)].Value; } public static void SetEarned(int d) { earned[Mathf.Clamp(d, 0, 5)].Value = true; file.Save(); } public static void SetActivated(int d) { activated[Mathf.Clamp(d, 0, 5)].Value = true; file.Save(); } } public class MenuButton : MonoBehaviour { private Button cyber; private Button sandbox; private Button token; private RectTransform sandboxRT; private Vector2 sandboxOrig; private bool usedLayout; private float nextCheck; private static readonly Color PGold = new Color(1f, 0.686f, 0f); private void Update() { if (Time.unscaledTime < nextCheck) { return; } nextCheck = Time.unscaledTime + 0.4f; if ((Object)(object)cyber == (Object)null || (Object)(object)sandbox == (Object)null) { FindButtons(); if ((Object)(object)cyber == (Object)null || (Object)(object)sandbox == (Object)null) { return; } } int difficulty = Progress.Difficulty; bool flag = Progress.Earned(difficulty) && !Progress.Activated(difficulty); if (flag && (Object)(object)token == (Object)null) { Inject(); } else if (!flag && (Object)(object)token != (Object)null) { Remove(); } } private static string Plain(string s) { return Regex.Replace(s ?? "", "<.*?>", "").ToUpperInvariant(); } private void FindButtons() { //IL_0027: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown Button val = null; Button val2 = null; TMP_Text[] array = Resources.FindObjectsOfTypeAll<TMP_Text>(); foreach (TMP_Text val3 in array) { if ((Object)(object)val3 == (Object)null) { continue; } Scene scene = ((Component)val3).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { continue; } string text = Plain(val3.text); Button componentInParent = ((Component)val3).GetComponentInParent<Button>(true); if (!((Object)(object)componentInParent == (Object)null)) { if ((Object)(object)val == (Object)null && text.Contains("CYBER")) { val = componentInParent; } else if ((Object)(object)val2 == (Object)null && text.Contains("SANDBOX")) { val2 = componentInParent; } } } cyber = val; sandbox = val2; if ((Object)(object)cyber != (Object)null && (Object)(object)sandbox != (Object)null) { sandboxRT = (RectTransform)((Component)sandbox).transform; Plugin.Log.LogInfo((object)("Menu: found '" + ((Object)cyber).name + "' and '" + ((Object)sandbox).name + "' (same parent: " + ((Object)(object)((Component)cyber).transform.parent == (Object)(object)((Component)sandbox).transform.parent) + ")")); } } private void Inject() { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016f: 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_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Expected O, but got Unknown //IL_022b: 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: Expected O, but got Unknown //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) Transform parent = ((Component)cyber).transform.parent; GameObject val = Object.Instantiate<GameObject>(((Component)cyber).gameObject, parent); ((Object)val).name = "PRankTokenButton"; val.SetActive(true); for (int i = 0; i < 3; i++) { MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && !(val2 is Graphic) && !(val2 is Selectable) && !(val2 is LayoutElement) && !(val2 is LayoutGroup) && !(val2 is ContentSizeFitter) && !(val2 is BaseMeshEffect) && !(val2 is Mask) && !(val2 is RectMask2D) && !(val2 is AspectRatioFitter)) { Object.DestroyImmediate((Object)(object)val2); } } } EventTrigger[] componentsInChildren2 = val.GetComponentsInChildren<EventTrigger>(true); for (int j = 0; j < componentsInChildren2.Length; j++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[j]); } token = val.GetComponent<Button>(); token.onClick = new ButtonClickedEvent(); ((UnityEvent)token.onClick).AddListener(new UnityAction(Activate)); ColorBlock colors = ((Selectable)token).colors; ((ColorBlock)(ref colors)).normalColor = Color.white; ((ColorBlock)(ref colors)).highlightedColor = new Color(1f, 0.95f, 0.75f); ((ColorBlock)(ref colors)).pressedColor = Color.white; ((ColorBlock)(ref colors)).selectedColor = Color.white; ((Selectable)token).colors = colors; if ((Object)(object)((Selectable)token).targetGraphic != (Object)null) { ((Selectable)token).targetGraphic.color = PGold; } Image[] componentsInChildren3 = val.GetComponentsInChildren<Image>(true); foreach (Image val3 in componentsInChildren3) { if ((Object)(object)val3 != (Object)(object)((Selectable)token).targetGraphic) { ((Graphic)val3).color = Color.Lerp(((Graphic)val3).color, PGold, 0.8f); } } bool flag = true; TMP_Text[] componentsInChildren4 = val.GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text obj in componentsInChildren4) { obj.text = (flag ? "P-RANK TOKEN" : ""); ((Graphic)obj).color = Color.white; flag = false; } RectTransform val4 = (RectTransform)val.transform; ((Transform)val4).SetSiblingIndex(((Component)cyber).transform.GetSiblingIndex() + 1); usedLayout = (Object)(object)((Component)parent).GetComponent<LayoutGroup>() != (Object)null && (Object)(object)((Component)cyber).transform.parent == (Object)(object)((Component)sandbox).transform.parent; if (!usedLayout) { RectTransform val5 = (RectTransform)((Component)cyber).transform; sandboxOrig = sandboxRT.anchoredPosition; val4.anchoredPosition = sandboxOrig; sandboxRT.anchoredPosition = sandboxOrig + (sandboxOrig - val5.anchoredPosition); } Plugin.Log.LogInfo((object)("Menu: P-RANK TOKEN button added (layout=" + usedLayout + ")")); } private void Remove() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)token != (Object)null) { Object.Destroy((Object)(object)((Component)token).gameObject); } token = null; if (!usedLayout && (Object)(object)sandboxRT != (Object)null) { sandboxRT.anchoredPosition = sandboxOrig; } } private void Activate() { //IL_004e: 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) Progress.SetActivated(Progress.Difficulty); Plugin.Log.LogInfo((object)("P-RANK TOKEN activated on difficulty " + Progress.Difficulty)); A.PlayAt("Assets/Sounds/UI/CleanSuccessBig.wav", ((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : Vector3.zero); ((MonoBehaviour)this).StartCoroutine(Flash()); } private IEnumerator Flash() { if ((Object)(object)token != (Object)null) { Graphic[] componentsInChildren = ((Component)token).GetComponentsInChildren<Graphic>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].color = Color.white; } ((Selectable)token).interactable = false; } GameObject cgo = new GameObject("PRankFlash"); Canvas obj = cgo.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 1000; Image img = new GameObject("White", new Type[1] { typeof(RectTransform) }).AddComponent<Image>(); ((Component)img).transform.SetParent(cgo.transform, false); RectTransform rectTransform = ((Graphic)img).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; Vector2 offsetMin = (rectTransform.offsetMax = Vector2.zero); rectTransform.offsetMin = offsetMin; ((Graphic)img).raycastTarget = false; float t = 0f; bool removed = false; while (t < 0.7f) { t += Time.unscaledDeltaTime; ((Graphic)img).color = new Color(1f, 1f, 1f, (t < 0.08f) ? (t / 0.08f) : Mathf.Clamp01(1f - (t - 0.08f) / 0.62f)); if (!removed && t > 0.1f) { removed = true; Remove(); } yield return null; } Object.Destroy((Object)(object)cgo); } } public class TokenEffect : MonoBehaviour { private StatsManager current; private bool on; private bool decided; private float nextCheck; private float sceneStart; private void Update() { StatsManager val = default(StatsManager); if (!MonoSingleton<StatsManager>.TryGetInstance(ref val) || (Object)(object)val == (Object)null) { current = null; return; } if ((Object)(object)val != (Object)(object)current) { current = val; on = false; decided = false; sceneStart = Time.unscaledTime; } if (!decided && Time.unscaledTime >= nextCheck) { nextCheck = Time.unscaledTime + 0.5f; on = ShouldApply(val, out var why); if (on || Time.unscaledTime - sceneStart > 15f || why == "token not active") { decided = true; Plugin.Log.LogInfo((object)("P-RANK TOKEN in level " + LevelNum(val) + ": " + (on ? "ACTIVE" : ("off (" + why + ")")))); if (on) { ((MonoBehaviour)this).StartCoroutine(Announce()); } } } if (on) { val.kills = 99999999; val.stylePoints = 99999999; float num = Mathf.Max(0f, (float)val.timeRanks[3] - 1f); if (val.seconds > num) { val.seconds = num; } val.restarts = 0; val.majorUsed = false; } } private static int LevelNum(StatsManager sm) { int num = sm.levelNumber; if (num <= 0) { try { num = SceneHelper.CurrentLevelNumber; } catch { } } return num; } private static bool ShouldApply(StatsManager sm, out string why) { why = ""; int difficulty = Progress.Difficulty; if (!Progress.Activated(difficulty)) { why = "token not active"; return false; } if (Plugin.PirateActive) { why = "in P-T"; return false; } if (sm.endlessMode) { why = "endless"; return false; } int num = LevelNum(sm); if (num <= 0) { why = "no level number yet"; return false; } if (sm.timeRanks == null || sm.timeRanks.Length < 4) { why = "no rank thresholds"; return false; } try { RankData rank = GameProgressSaver.GetRank(num, true); if (rank != null && rank.ranks != null && difficulty < rank.ranks.Length && rank.ranks[difficulty] == 12) { Plugin.Log.LogInfo((object)"(level already P-ranked; token applies anyway)"); } } catch { } return true; } private IEnumerator Announce() { yield return (object)new WaitForSeconds(1.5f); Plugin.Hud("<color=#ffaf00>P-RANK TOKEN</color> ACTIVE"); } } public class SecretWall : MonoBehaviour { public static SecretWall Instance; private BoxCollider col; private bool broken; private bool exiting; private Transform hole; private Vector3 normal; private static readonly Vector3 WallPosition = new Vector3(0.236f, 8.915f, 300f); private static readonly Vector3 WallNormal = new Vector3(0f, 0f, 1f); private const float WallWidth = 7f; private const float WallHeight = 7f; public static IEnumerator SpawnWhenReady() { NewMovement val = default(NewMovement); for (int i = 0; i < 300; i++) { if (MonoSingleton<NewMovement>.TryGetInstance(ref val)) { break; } yield return null; } Spawn(); } private static void Spawn() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Instance != (Object)null) { Object.Destroy((Object)(object)((Component)Instance).gameObject); } Instance = new GameObject("PirateCrackedWall").AddComponent<SecretWall>(); Instance.Build(WallPosition, WallNormal); Plugin.Log.LogInfo((object)("Cracked wall spawned at " + ((object)WallPosition/*cast due to .constrained prefix*/).ToString())); } private void Build(Vector3 point, Vector3 n) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_002a: 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) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) normal = n; float num = 7f; float num2 = 7f; Vector3 val = ((Mathf.Abs(Vector3.Dot(n, Vector3.up)) > 0.95f) ? Vector3.forward : Vector3.up); ((Component)this).transform.position = point + n * 0.15f; ((Component)this).transform.rotation = Quaternion.LookRotation(-n, val); GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val2).name = "CrackedPanel"; val2.transform.SetParent(((Component)this).transform, false); val2.transform.localScale = new Vector3(num, num2, 0.3f); val2.layer = A.EnvLayer; try { val2.tag = "Wall"; } catch { } Material val3 = A.Load<Material>("Assets/Materials/Environment/Metal/CrackedWall.mat"); Renderer component = val2.GetComponent<Renderer>(); if ((Object)(object)val3 != (Object)null) { component.sharedMaterial = new Material(val3); component.sharedMaterial.mainTextureScale = new Vector2(num / 4f, num2 / 4f); } col = val2.GetComponent<BoxCollider>(); } public static void OnExplosion(Explosion ex) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Instance == (Object)null) && !Instance.broken && !((Object)(object)ex == (Object)null)) { Vector3 position = ((Component)ex).transform.position; Vector3 val = ((Collider)Instance.col).ClosestPoint(position); float num = Mathf.Clamp(ex.maxSize * 0.6f, 3f, 12f); if (Vector3.Distance(val, position) <= num) { Instance.Break(position); } } } private unsafe void Break(Vector3 from) { //IL_002f: 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_00a5: 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_00c5: 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_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_0206: 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) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0272: 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_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0319: 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_0361: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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) broken = true; float num = 7f; float num2 = 7f; Material sharedMaterial = ((Component)col).GetComponent<Renderer>().sharedMaterial; A.PlayAt("Assets/Sounds/Environment/bigRockBreak.wav", ((Component)this).transform.position); NewMovement val = default(NewMovement); if (MonoSingleton<NewMovement>.TryGetInstance(ref val) && (Object)(object)val.cc != (Object)null) { val.cc.CameraShake(1f); } for (int i = 0; i < 18; i++) { GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); obj.transform.position = ((Component)this).transform.TransformPoint(new Vector3(Random.Range(0f - num, num) * 0.45f, Random.Range(0f - num2, num2) * 0.45f, -0.3f)); obj.transform.rotation = Random.rotation; obj.transform.localScale = Vector3.one * Random.Range(0.4f, 1.3f); obj.GetComponent<Renderer>().sharedMaterial = sharedMaterial; obj.layer = ((LayerMask.NameToLayer("Gib") >= 0) ? LayerMask.NameToLayer("Gib") : 0); Rigidbody obj2 = obj.AddComponent<Rigidbody>(); obj2.velocity = normal * Random.Range(6f, 16f) + Random.insideUnitSphere * 6f + Vector3.up * 4f; obj2.angularVelocity = Random.insideUnitSphere * 10f; Object.Destroy((Object)(object)obj, 8f); } Object.Destroy((Object)(object)((Component)col).gameObject); hole = new GameObject("SecretHole").transform; hole.SetParent(((Component)this).transform, false); Material val2 = A.Tinted("Assets/Materials/Dev/Wood/Crate.mat", Color.black); if (val2.HasProperty("_MainTex")) { val2.mainTexture = (Texture)(object)Texture2D.blackTexture; } A.Box(hole, new Vector3(0f, 0f, 0.05f), new Vector3(num * 0.85f, num2 * 0.85f, 0.05f), val2, (PrimitiveType)3); Material mat = A.Tinted("Assets/Materials/Environment/Metal/CrackedWall.mat", new Color(0.35f, 0.35f, 0.35f)); A.Box(hole, new Vector3(0f, num2 * 0.45f, -0.1f), new Vector3(num * 0.95f, num2 * 0.1f, 0.4f), mat, (PrimitiveType)3); A.Box(hole, new Vector3(0f, (0f - num2) * 0.45f, -0.1f), new Vector3(num * 0.95f, num2 * 0.1f, 0.4f), mat, (PrimitiveType)3); A.Box(hole, new Vector3(num * 0.45f, 0f, -0.1f), new Vector3(num * 0.1f, num2 * 0.9f, 0.4f), mat, (PrimitiveType)3); A.Box(hole, new Vector3((0f - num) * 0.45f, 0f, -0.1f), new Vector3(num * 0.1f, num2 * 0.9f, 0.4f), mat, (PrimitiveType)3); GameObject val3 = new GameObject("HoleLight"); val3.transform.SetParent(hole, false); val3.transform.localPosition = new Vector3(0f, 0f, -1.5f); Light obj3 = val3.AddComponent<Light>(); obj3.type = (LightType)2; obj3.range = 8f; obj3.intensity = 2f; obj3.color = new Color(0.8f, 0.8f, 0.85f); ManualLogSource log = Plugin.Log; Vector3 val4 = from; log.LogInfo((object)("Cracked wall broken by explosion at " + ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString()));