Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of OrbCart v1.0.6
OrbCart.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Photon.Pun; using REPOLib.Modules; using TMPro; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: AssemblyCompany("OrbCart")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.6.0")] [assembly: AssemblyInformationalVersion("1.0.6")] [assembly: AssemblyProduct("OrbCart")] [assembly: AssemblyTitle("OrbCart")] [assembly: AssemblyVersion("1.0.6.0")] namespace OrbCart; internal static class EmbeddedAssets { private static Sprite icon; private static Texture2D emblem; internal static Sprite Icon { get { //IL_0043: 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) if ((Object)(object)icon != (Object)null) { return icon; } Texture2D val = Load("icon.png", mipmaps: false); if ((Object)(object)val == (Object)null) { return null; } icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); ((Object)icon).name = "Orb Cart Icon"; return icon; } } internal static Texture2D Emblem { get { if (!((Object)(object)emblem != (Object)null)) { return emblem = Load("emblem.png", mipmaps: true); } return emblem; } } internal static Texture2D HatchOverlay => Load("hatch_overlay.png", mipmaps: false); private static Texture2D Load(string file, bool mipmaps) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown string text = "OrbCart.Assets." + file; using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text); if (stream == null) { Plugin.Log.LogWarning((object)("Embedded asset '" + text + "' is missing.")); return null; } byte[] array = new byte[stream.Length]; int num; for (int i = 0; i < array.Length; i += num) { num = stream.Read(array, i, array.Length - i); if (num <= 0) { break; } } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, mipmaps) { name = Path.GetFileNameWithoutExtension(file), wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)32 }; if (!ImageConversion.LoadImage(val, array)) { Plugin.Log.LogWarning((object)("Could not decode embedded asset '" + text + "'.")); return null; } return val; } } internal static class IconComposer { private const string KnownPocketIconFile = "a13809b12dec3e54d6e320802e6797d4.png"; private const int OverlaySize = 512; internal static Sprite Build(Item pocketItem, GameObject pocketPrefab) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown try { Texture2D val = LoadPocketIcon(pocketItem, pocketPrefab); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"Pocket C.A.R.T. icon not found; using the built-in Orb C.A.R.T. icon."); return null; } if (((Texture)val).width != 512 || ((Texture)val).height != 512) { Plugin.Log.LogWarning((object)$"Pocket C.A.R.T. icon is {((Texture)val).width}x{((Texture)val).height}, expected {512}; using the built-in icon."); return null; } Color32[] pixels = val.GetPixels32(); Over(pixels, EmbeddedAssets.HatchOverlay); Texture2D val2 = new Texture2D(512, 512, (TextureFormat)4, false) { name = "Orb Cart Icon", wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)32 }; val2.SetPixels32(pixels); val2.Apply(false, false); Object.Destroy((Object)(object)val); Sprite obj = Sprite.Create(val2, new Rect(0f, 0f, 512f, 512f), new Vector2(0.5f, 0.5f), 100f); ((Object)obj).name = "Orb Cart Icon"; return obj; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not compose the Orb C.A.R.T. icon (" + ex.Message + "); using the built-in icon.")); return null; } } private static Texture2D LoadPocketIcon(Item pocketItem, GameObject pocketPrefab) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown string path = Application.streamingAssetsPath.TrimEnd('/', '\\'); List<string> list = new List<string>(); if ((Object)(object)pocketItem != (Object)null) { list.Add(SemiIconMaker.BakedIconPath("Items", ((Object)pocketItem).name + "|" + ((Object)pocketPrefab).name)); } list.Add(SemiIconMaker.BakedIconPath("Items", ((Object)pocketPrefab).name + "|" + ((Object)pocketPrefab).name)); list.Add("BakedIcons/Items/a13809b12dec3e54d6e320802e6797d4.png"); foreach (string item in list) { string path2 = Path.Combine(path, item); if (File.Exists(path2)) { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (ImageConversion.LoadImage(val, File.ReadAllBytes(path2), false)) { return val; } Object.Destroy((Object)(object)val); } } return null; } private static void Over(Color32[] dst, Texture2D overlay) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)overlay == (Object)null || ((Texture)overlay).width != 512 || ((Texture)overlay).height != 512) { return; } Color32[] pixels = overlay.GetPixels32(); for (int i = 0; i < dst.Length; i++) { int a = pixels[i].a; switch (a) { case 255: dst[i] = pixels[i]; continue; case 0: continue; } int a2 = dst[i].a; int num = a + a2 * (255 - a) / 255; if (num == 0) { dst[i] = default(Color32); } else { dst[i] = new Color32((byte)((pixels[i].r * a + dst[i].r * a2 * (255 - a) / 255) / num), (byte)((pixels[i].g * a + dst[i].g * a2 * (255 - a) / 255) / num), (byte)((pixels[i].b * a + dst[i].b * a2 * (255 - a) / 255) / num), (byte)num); } } } } internal static class OrbCartBuilder { internal const string PrefabName = "Item Cart Orb"; internal const string DisplayName = "Orb C.A.R.T."; private const string PocketCartPath = "Items/Item Cart Small"; private const string HaulerPath = "Items/Item Vehicle Semiscooter"; private const float BasketCenterX = 0.02f; private static GameObject holder; internal static GameObject Build() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) GameObject val = Resources.Load<GameObject>("Items/Item Cart Small"); GameObject val2 = Resources.Load<GameObject>("Items/Item Vehicle Semiscooter"); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { Plugin.Log.LogError((object)$"Vanilla prefabs not found (pocket cart: {(Object)(object)val != (Object)null}, hauler: {(Object)(object)val2 != (Object)null}). Has the game changed its resource paths?"); return null; } ItemAttributes component = val.GetComponent<ItemAttributes>(); ItemValuableBox componentInChildren = val2.GetComponentInChildren<ItemValuableBox>(true); if ((Object)(object)component == (Object)null || (Object)(object)component.item == (Object)null || (Object)(object)componentInChildren == (Object)null) { Plugin.Log.LogError((object)"Vanilla prefabs are missing expected components (ItemAttributes / ItemValuableBox)."); return null; } holder = new GameObject("OrbCart.PrefabHolder"); holder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)holder); ((Object)holder).hideFlags = (HideFlags)61; GameObject val3 = Object.Instantiate<GameObject>(val, holder.transform); ((Object)val3).name = "Item Cart Orb"; SetupItem(val3, component.item, val); ItemValuableBox val4 = GraftBox(val3, componentInChildren); SetupScreen(val3); if (Plugin.TryGetTint(out var tint)) { TintBody(val3, tint); } if (Plugin.Decals) { AddDecals(val3); } Plugin.Log.LogInfo((object)string.Format("Built {0} prefab (box limit ${1:N0}).", "Orb C.A.R.T.", val4.valueLimit)); return val3; } private static void SetupItem(GameObject cart, Item source, GameObject pocketPrefab) { Item val = Object.Instantiate<Item>(source); ((Object)val).name = "Item Cart Orb"; val.itemName = "Orb C.A.R.T."; val.itemNameLocalized = null; val.description = "A pocketable C.A.R.T. with a hatch that only swallows enemy orbs. Screen shows how full it is."; if ((Object)(object)source.value != (Object)null) { Value val2 = Object.Instantiate<Value>(source.value); ((Object)val2).name = "Item Cart Orb Value"; val2.valueMin *= Plugin.PriceMultiplier; val2.valueMax *= Plugin.PriceMultiplier; val.value = val2; } ItemAttributes component = cart.GetComponent<ItemAttributes>(); component.item = val; Sprite val3 = IconComposer.Build(source, pocketPrefab) ?? EmbeddedAssets.Icon; if ((Object)(object)val3 != (Object)null) { component.icon = val3; } } private static ItemValuableBox GraftBox(GameObject cart, ItemValuableBox srcBox) { //IL_0026: 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_003c: 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) GameObject val = Object.Instantiate<GameObject>(((Component)srcBox).gameObject, cart.transform, false); ((Object)val).name = "Orb Box"; Transform transform = val.transform; transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; ItemValuableBox component = val.GetComponent<ItemValuableBox>(); component.valueLimit = Plugin.Capacity.Value; component.typeLimit = (Type)6; if ((Object)(object)component.boxChecker != (Object)null) { ((Component)component.boxChecker).gameObject.AddComponent<OrbCartChecker>(); } Collider[] componentsInChildren = val.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].isTrigger = true; } if ((Object)(object)component.textScreenAnimatorTransform != (Object)null) { HideVisuals(component.textScreenAnimatorTransform); } else if ((Object)(object)component.textScreen != (Object)null) { HideVisuals(((Component)component.textScreen).transform); } Transform val2 = transform.Find("Railing"); if ((Object)(object)val2 != (Object)null) { HideVisuals(val2); } FitBoxToBasket(cart, component); val.AddComponent<OrbCartBox>(); return component; } private static void FitBoxToBasket(GameObject cart, ItemValuableBox box) { //IL_0037: 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_0068: 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_012c: 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_007d: 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_014e: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00a5: 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_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0280: 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_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_037c: 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_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_0397: 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_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) Transform transform = cart.transform; Transform transform2 = ((Component)box).transform; if (!TryGetBasketBounds(cart, out var bounds)) { Plugin.Log.LogWarning((object)"Could not measure the basket; using fallback hatch placement."); ((Bounds)(ref bounds))..ctor(new Vector3(0.02f, 0.1f, 0f), new Vector3(0.72f, 0.56f, 0.72f)); } string text = "in-cart volume"; if (TryGetRimHeight(cart, out var rim) && rim > ((Bounds)(ref bounds)).min.y + 0.1f && rim < ((Bounds)(ref bounds)).max.y) { Vector3 min = ((Bounds)(ref bounds)).min; Vector3 max = ((Bounds)(ref bounds)).max; max.y = rim; ((Bounds)(ref bounds)).SetMinMax(min, max); text = "cart walls"; } if (!TryGetVisibleMeshBounds(transform2, transform, out var bounds2) || ((Bounds)(ref bounds2)).size.x < 0.01f || ((Bounds)(ref bounds2)).size.y < 0.01f || ((Bounds)(ref bounds2)).size.z < 0.01f) { Plugin.Log.LogWarning((object)"Could not measure the hatch box; using fallback hatch placement."); ((Bounds)(ref bounds2))..ctor(new Vector3(0f, 0.17f, 0f), new Vector3(0.55f, 0.34f, 0.55f)); } float hatchFill = Plugin.HatchFill; float num = ((Bounds)(ref bounds)).size.x * hatchFill / ((Bounds)(ref bounds2)).size.x; float num2 = ((Bounds)(ref bounds)).size.z * hatchFill / ((Bounds)(ref bounds2)).size.z; float num3 = Mathf.Min(num, num2); float num4 = Mathf.Min(num3, ((Bounds)(ref bounds)).size.y * 0.98f / ((Bounds)(ref bounds2)).size.y); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(num, num4, num2); if (!Plugin.HatchStretch) { ((Vector3)(ref val))..ctor(num3, num4, num3); } transform2.localScale = val; float num5 = ((Bounds)(ref bounds)).max.y + Plugin.HatchOffset; transform2.localPosition = new Vector3(((Bounds)(ref bounds)).center.x - ((Bounds)(ref bounds2)).center.x * val.x, num5 - ((Bounds)(ref bounds2)).max.y * val.y, ((Bounds)(ref bounds)).center.z - ((Bounds)(ref bounds2)).center.z * val.z); GameObject obj = CreateGrabbableCollider(cart, "Orb Hatch Lid"); obj.transform.SetParent(transform, false); obj.transform.localPosition = new Vector3(((Bounds)(ref bounds)).center.x, num5 - 0.015f, ((Bounds)(ref bounds)).center.z); obj.transform.localRotation = Quaternion.identity; obj.transform.localScale = Vector3.one; BoxCollider component = obj.GetComponent<BoxCollider>(); ((Collider)component).isTrigger = false; component.center = Vector3.zero; component.size = new Vector3(((Bounds)(ref bounds)).size.x, 0.03f, ((Bounds)(ref bounds)).size.z); if ((Object)(object)box.boxChecker != (Object)null) { Transform transform3 = ((Component)box.boxChecker).transform; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(((Bounds)(ref bounds)).center.x, num5 + 0.225f - 0.02f, ((Bounds)(ref bounds)).center.z); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(((Bounds)(ref bounds)).size.x * 0.98f, 0.48999998f, ((Bounds)(ref bounds)).size.z * 0.98f); transform3.localRotation = Quaternion.identity; transform3.position = transform.TransformPoint(val2); Vector3 val4 = (((Object)(object)transform3.parent != (Object)null) ? transform3.parent.lossyScale : Vector3.one); Vector3 lossyScale = transform.lossyScale; transform3.localScale = new Vector3(val3.x * lossyScale.x / val4.x, val3.y * lossyScale.y / val4.y, val3.z * lossyScale.z / val4.z); } Plugin.Log.LogInfo((object)$"Hatch fitted: basket {((Bounds)(ref bounds)).size}, box scale {val}, rim at y={num5:F3} (from {text})."); } private static bool TryGetRimHeight(GameObject cart, out float rim) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0065: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) rim = 0f; List<float> list = new List<float>(); foreach (Transform item in cart.transform) { Transform val = item; if (!(((Object)val).name != "Cart Wall Collider")) { MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.sharedMesh == (Object)null)) { Bounds val2 = TransformBounds(component.sharedMesh.bounds, val, cart.transform); list.Add(((Bounds)(ref val2)).max.y); } } } if (list.Count >= 2) { int num = 0; float num2 = 0f; foreach (float item2 in list) { int num3 = 0; float num4 = 0f; foreach (float item3 in list) { if (Mathf.Abs(item3 - item2) <= 0.02f) { num3++; num4 += item3; } } if (num3 > num) { num = num3; num2 = num4; } } if (num >= 2) { rim = num2 / (float)num; return true; } } Transform val3 = cart.transform.Find("Cart Mesh"); if ((Object)(object)val3 == (Object)null || !TryGetVisibleMeshBounds(val3, cart.transform, out var bounds)) { return false; } rim = ((Bounds)(ref bounds)).max.y; return true; } private static bool TryGetBasketBounds(GameObject cart, out Bounds bounds) { //IL_0001: 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_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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_007a: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); PhysGrabInCart componentInChildren = cart.GetComponentInChildren<PhysGrabInCart>(true); BoxCollider val = (((Object)(object)componentInChildren != (Object)null) ? ((Component)componentInChildren).GetComponent<BoxCollider>() : null); if ((Object)(object)val == (Object)null) { return false; } bounds = TransformBounds(new Bounds(val.center, val.size), ((Component)val).transform, cart.transform); if (((Bounds)(ref bounds)).size.x > 0.05f && ((Bounds)(ref bounds)).size.y > 0.05f) { return ((Bounds)(ref bounds)).size.z > 0.05f; } return false; } private static bool TryGetVisibleMeshBounds(Transform root, Transform space, out Bounds bounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_006b: 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_0061: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); bool flag = false; MeshFilter[] componentsInChildren = ((Component)root).GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val in componentsInChildren) { MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>(); if (!((Object)(object)component == (Object)null) && ((Renderer)component).enabled && !((Object)(object)val.sharedMesh == (Object)null)) { Bounds val2 = TransformBounds(val.sharedMesh.bounds, ((Component)val).transform, space); if (!flag) { bounds = val2; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val2); } } } return flag; } private static Bounds TransformBounds(Bounds local, Transform from, Transform to) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_0022: 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_0036: 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_004a: 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_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_0067: 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) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_007c: Unknown result type (might be due to invalid IL or missing references) Vector3 center = ((Bounds)(ref local)).center; Vector3 extents = ((Bounds)(ref local)).extents; Bounds result = default(Bounds); for (int i = 0; i < 8; i++) { Vector3 val = center + new Vector3(((i & 1) == 0) ? (0f - extents.x) : extents.x, ((i & 2) == 0) ? (0f - extents.y) : extents.y, ((i & 4) == 0) ? (0f - extents.z) : extents.z); Vector3 val2 = to.InverseTransformPoint(from.TransformPoint(val)); if (i == 0) { ((Bounds)(ref result))..ctor(val2, Vector3.zero); } else { ((Bounds)(ref result)).Encapsulate(val2); } } return result; } private static GameObject CreateGrabbableCollider(GameObject cart, string name) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown PhysGrabObjectCollider val = null; PhysGrabObjectCollider[] componentsInChildren = cart.GetComponentsInChildren<PhysGrabObjectCollider>(true); foreach (PhysGrabObjectCollider val2 in componentsInChildren) { BoxCollider component = ((Component)val2).GetComponent<BoxCollider>(); if ((Object)(object)component != (Object)null && !((Collider)component).isTrigger && ((Component)val2).transform.childCount == 0) { val = val2; break; } } GameObject val3; if ((Object)(object)val != (Object)null) { val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, cart.transform, false); Component[] components = val3.GetComponents<Component>(); foreach (Component val4 in components) { if (!(val4 is Transform) && !(val4 is BoxCollider) && !(val4 is PhysGrabObjectCollider) && !(val4 is PhysGrabObjectBoxCollider)) { Object.DestroyImmediate((Object)(object)val4); } } } else { Plugin.Log.LogWarning((object)"No grabbable collider found to copy; the hatch may not be grabbable."); val3 = new GameObject(); val3.layer = ReferenceColliderLayer(cart); val3.tag = "Phys Grab Object"; val3.AddComponent<BoxCollider>(); val3.AddComponent<PhysGrabObjectCollider>(); } ((Object)val3).name = name; return val3; } private static int ReferenceColliderLayer(GameObject cart) { BoxCollider[] componentsInChildren = cart.GetComponentsInChildren<BoxCollider>(true); foreach (BoxCollider val in componentsInChildren) { if (!((Collider)val).isTrigger && (Object)(object)((Component)val).GetComponent<PhysGrabObjectBoxCollider>() != (Object)null) { return ((Component)val).gameObject.layer; } } return cart.layer; } private static void SetupScreen(GameObject cart) { ValueScreen componentInChildren = cart.GetComponentInChildren<ValueScreen>(true); if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.displayText == (Object)null) { Plugin.Log.LogWarning((object)"Pocket C.A.R.T. value screen not found; the Orb C.A.R.T. will have no fill readout."); return; } ((Behaviour)componentInChildren).enabled = false; cart.AddComponent<OrbCartScreen>().text = componentInChildren.displayText; } private static void TintBody(GameObject cart, Color tint) { //IL_0053: 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_0074: Expected O, but got Unknown //IL_0090: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) Transform val = cart.transform.Find("Cart Mesh"); if ((Object)(object)val == (Object)null) { return; } Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { Material[] sharedMaterials = val2.sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { if (!((Object)(object)sharedMaterials[j] == (Object)null)) { Material val3 = new Material(sharedMaterials[j]) { name = ((Object)sharedMaterials[j]).name + " (Orb Tint)" }; if (val3.HasProperty("_BaseColor")) { val3.SetColor("_BaseColor", val3.GetColor("_BaseColor") * tint); } if (val3.HasProperty("_Color")) { val3.SetColor("_Color", val3.GetColor("_Color") * tint); } sharedMaterials[j] = val3; } } val2.sharedMaterials = sharedMaterials; } } private static void AddDecals(GameObject cart) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) Texture2D emblem = EmbeddedAssets.Emblem; Transform val = cart.transform.Find("Cart Mesh"); Renderer val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponentInChildren<Renderer>(true) : null); if (!((Object)(object)emblem == (Object)null) && !((Object)(object)val2 == (Object)null) && !((Object)(object)val2.sharedMaterial == (Object)null)) { Material val3 = new Material(val2.sharedMaterial) { name = "Orb Emblem", mainTexture = (Texture)(object)emblem }; if (val3.HasProperty("_BaseColor")) { val3.SetColor("_BaseColor", Color.white); } if (val3.HasProperty("_Color")) { val3.SetColor("_Color", Color.white); } if (val3.HasProperty("_MainTex")) { val3.SetTexture("_MainTex", (Texture)(object)emblem); } if (val3.HasProperty("_BaseMap")) { val3.SetTexture("_BaseMap", (Texture)(object)emblem); } AddDecal(cart.transform, val3, "Orb Decal Left", new Vector3(-0.375f, 0.07f, 0f), new Vector3(0f, 90f, 0f), 0.26f); AddDecal(cart.transform, val3, "Orb Decal Right", new Vector3(0.415f, 0.07f, 0f), new Vector3(0f, -90f, 0f), 0.26f); AddDecal(cart.transform, val3, "Orb Decal Front", new Vector3(0.02f, 0.07f, 0.405f), new Vector3(0f, 180f, 0f), 0.26f); } } private static void AddDecal(Transform parent, Material material, string name, Vector3 position, Vector3 euler, float size) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5); Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>()); ((Object)obj).name = name; obj.transform.SetParent(parent, false); obj.transform.localPosition = position; obj.transform.localEulerAngles = euler; obj.transform.localScale = new Vector3(size, size, 1f); MeshRenderer component = obj.GetComponent<MeshRenderer>(); ((Renderer)component).sharedMaterial = material; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; } private static void HideVisuals(Transform root) { Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } Light[] componentsInChildren2 = ((Component)root).GetComponentsInChildren<Light>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { ((Behaviour)componentsInChildren2[i]).enabled = false; } } } public class OrbCartChecker : MonoBehaviour { } public class OrbCartBox : MonoBehaviour { private PhotonView photonView; internal ItemValuableBox Box { get; private set; } internal float Fill { get { if (!((Object)(object)Box != (Object)null) || !(Box.valueLimit > 0f)) { return 0f; } return Mathf.Clamp01(Box.CurrentValue / Box.valueLimit); } } internal bool IsFull { get { if ((Object)(object)Box != (Object)null) { return Box.CurrentValue >= Box.valueLimit - 0.5f; } return false; } } private void Awake() { Box = ((Component)this).GetComponent<ItemValuableBox>(); photonView = ((Component)this).GetComponent<PhotonView>(); if ((Object)(object)Box != (Object)null) { Box.valueLimit = Plugin.Capacity.Value; } } private void Start() { if ((Object)(object)Box != (Object)null && (Object)(object)photonView != (Object)null && SemiFunc.IsMultiplayer() && SemiFunc.IsMasterClient()) { photonView.RPC("OrbCartSetLimitRPC", (RpcTarget)4, new object[1] { Box.valueLimit }); } } [PunRPC] private void OrbCartSetLimitRPC(float limit, PhotonMessageInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if ((info.Sender == null || info.Sender.IsMasterClient) && (Object)(object)Box != (Object)null && limit > 0f) { Box.valueLimit = limit; } } } public class OrbCartScreen : MonoBehaviour { public TextMeshPro text; private OrbCartBox orbBox; private string shown; private void Start() { orbBox = ((Component)this).GetComponentInChildren<OrbCartBox>(true); } private void LateUpdate() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)this.text == (Object)null) && !((Object)(object)orbBox == (Object)null) && !((Object)(object)orbBox.Box == (Object)null)) { int num = Mathf.Clamp(Mathf.FloorToInt(orbBox.Fill * 100f + 0.001f), 0, 100); string text = (orbBox.IsFull ? "FULL" : (num + "%")); if (!(text == shown) || !(((TMP_Text)this.text).text == text)) { shown = text; ((TMP_Text)this.text).text = text; ((Graphic)this.text).color = SemiFunc.ColorDifficultyGet(0f, 100f, (float)num); } } } } [HarmonyPatch] internal static class Patches { [HarmonyPostfix] [HarmonyPatch(typeof(PhysGrabObjectComponentInsideBoxChecker), "Start")] private static void InsideBoxCheckerStart(PhysGrabObjectComponentInsideBoxChecker __instance, List<Type> ___cachedTypes) { if (!((Object)(object)((Component)__instance).GetComponent<OrbCartChecker>() == (Object)null) && ___cachedTypes != null) { ___cachedTypes.Clear(); ___cachedTypes.Add(typeof(EnemyValuable)); __instance.checkForValuableTypes = false; } } } [BepInPlugin("OrbCart", "OrbCart", "1.0.6")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "OrbCart"; public const string Name = "OrbCart"; public const string Version = "1.0.6"; internal static readonly float PriceMultiplier = 1.5f; internal static readonly bool Decals = true; internal static readonly float HatchFill = 1f; internal static readonly float HatchOffset = -0.15f; internal static readonly bool HatchStretch = true; private const string DefaultTint = "B88CFFFF"; internal static ConfigEntry<float> Capacity; private static ConfigEntry<string> TintColor; internal static Plugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; BindConfig(); new Harmony("OrbCart").PatchAll(typeof(Plugin).Assembly); GameObject val = OrbCartBuilder.Build(); if ((Object)(object)val == (Object)null) { Log.LogError((object)"Orb C.A.R.T. could not be built; the item will not be available."); } else if (Items.RegisterItem(val.GetComponent<ItemAttributes>()) == null) { Log.LogError((object)"REPOLib refused to register the Orb C.A.R.T."); } else { Log.LogInfo((object)string.Format("{0} {1} loaded. Orb C.A.R.T. registered (capacity ${2:N0}).", "OrbCart", "1.0.6", Capacity.Value)); } } private void BindConfig() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown Capacity = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Capacity", 100000f, new ConfigDescription("Total orb value (in $) the Orb C.A.R.T. holds before it is full. The screen shows stored value as a percentage of this. The host's value is used and synced to everyone; it applies to carts spawned after the change.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1000f, 10000000f), Array.Empty<object>())); TintColor = ((BaseUnityPlugin)this).Config.Bind<string>("Visuals", "TintColor", "B88CFFFF", "Tint colour for the cart body as a hex colour (RRGGBB or RRGGBBAA, e.g. B88CFFFF). Leave empty to keep the same colours as the Pocket C.A.R.T. Requires a restart."); RemoveOldSettings(); } private void RemoveOldSettings() { if (typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(((BaseUnityPlugin)this).Config) is Dictionary<ConfigDefinition, string> { Count: >0 } dictionary) { dictionary.Clear(); ((BaseUnityPlugin)this).Config.Save(); } } internal static bool TryGetTint(out Color tint) { //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) tint = Color.white; string text = (TintColor?.Value ?? "").Trim().TrimStart('#'); if (text.Length == 0) { return false; } if (ColorUtility.TryParseHtmlString("#" + text, ref tint)) { return true; } Log.LogWarning((object)("TintColor '" + TintColor.Value + "' isn't a valid hex colour; keeping the Pocket C.A.R.T.'s colours.")); return false; } }