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 TruckStorage v1.2.0
BepInEx\plugins\TruckStorage.dll
Decompiled 2 hours agousing 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.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TruckStorage")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d4ced266ab2b42a04bb8e421ad7dbe83d7e334e1")] [assembly: AssemblyProduct("TruckStorage")] [assembly: AssemblyTitle("TruckStorage")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TruckStorage { internal static class ObjModelLoader { public static GameObject? LoadEmbeddedTray(Transform? truckAnchor = null, string name = "TruckStorageTray3D") { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text = ReadEmbedded(executingAssembly, "truck_storage_tray.obj"); string text2 = ReadEmbedded(executingAssembly, "truck_storage_tray.mtl"); if (string.IsNullOrEmpty(text)) { return null; } Material nativeTruckMetal = FindNativeTruckMaterial(truckAnchor); Dictionary<string, Material> matMap = ((!string.IsNullOrEmpty(text2)) ? ParseMtl(text2, nativeTruckMetal) : new Dictionary<string, Material>()); return ParseObj(name, text, matMap); } private static Material? FindNativeTruckMaterial(Transform? truckAnchor) { List<Transform> list = new List<Transform>(); if ((Object)(object)TruckHealer.instance != (Object)null) { list.Add(((Component)TruckHealer.instance).transform); } if ((Object)(object)ChargingStation.instance != (Object)null) { list.Add(((Component)ChargingStation.instance).transform); } if ((Object)(object)truckAnchor != (Object)null) { list.Add(truckAnchor.root); } Material val = null; int num = -1; foreach (Transform item in list) { MeshRenderer[] componentsInChildren = ((Component)item).GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val2 in componentsInChildren) { if ((Object)(object)val2 == (Object)null) { continue; } Material[] sharedMaterials = ((Renderer)val2).sharedMaterials; foreach (Material val3 in sharedMaterials) { if ((Object)(object)val3 == (Object)null) { continue; } string text = ((Object)val3).name.ToLowerInvariant(); if (!text.Contains("emission") && !text.Contains("laser") && !text.Contains("screen") && !text.Contains("glow") && !text.Contains("glass") && !text.Contains("ui") && !text.Contains("text") && !text.Contains("font") && !text.Contains("light") && !((Object)(object)(val3.HasProperty("_MainTex") ? val3.GetTexture("_MainTex") : null) == (Object)null)) { int num2 = 1; if ((Object)(object)item != (Object)(object)((truckAnchor != null) ? truckAnchor.root : null)) { num2 += 10; } if (val3.HasProperty("_BumpMap") && (Object)(object)val3.GetTexture("_BumpMap") != (Object)null) { num2 += 3; } if (text.Contains("rust") || text.Contains("metal") || text.Contains("grime") || text.Contains("worn")) { num2 += 5; } if (num2 > num) { num = num2; val = val3; } } } } if ((Object)(object)val != (Object)null && num >= 11) { break; } } if ((Object)(object)val != (Object)null) { ManualLogSource log = Plugin.Log; string[] obj = new string[5] { "Cloned native rusty material '", ((Object)val).name, "' (tex='", null, null }; Texture mainTexture = val.mainTexture; obj[3] = ((mainTexture != null) ? ((Object)mainTexture).name : null); obj[4] = "')"; log.LogInfo((object)string.Concat(obj)); } return val; } private static string? ReadEmbedded(Assembly asm, string suffix) { string[] manifestResourceNames = asm.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (!text.EndsWith(suffix, StringComparison.OrdinalIgnoreCase)) { continue; } using Stream stream = asm.GetManifestResourceStream(text); if (stream == null) { return null; } using StreamReader streamReader = new StreamReader(stream); return streamReader.ReadToEnd(); } return null; } private static Texture2D CreateRustyTexture(Color baseColor, float rustAmount, float grimeAmount, int seed) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0162: 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_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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_0184: 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_01ed: 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_0230: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(128, 128, (TextureFormat)4, true) { wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1 }; Color val2 = default(Color); ((Color)(ref val2))..ctor(0.26f, 0.12f, 0.06f, 1f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.45f, 0.21f, 0.09f, 1f); Color val4 = default(Color); ((Color)(ref val4))..ctor(0.07f, 0.08f, 0.07f, 1f); float num = (float)seed * 37.1f % 100f; float num2 = (float)seed * 53.7f % 100f; Color[] array = (Color[])(object)new Color[16384]; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num3 = (float)j / 128f; float num4 = (float)i / 128f; float num5 = Mathf.PerlinNoise(num3 * 4.5f + num, num4 * 4.5f + num2); float num6 = Mathf.PerlinNoise(num3 * 11f + num * 1.7f, num4 * 11f + num2 * 1.3f); float num7 = Mathf.PerlinNoise(num3 * 24f + num * 2.3f, num4 * 24f + num2 * 2.1f); float num8 = num5 * 0.55f + num6 * 0.3f + num7 * 0.15f; float num9 = Mathf.PerlinNoise(num3 * 14f + num, num4 * 2.5f + num2); Color val5 = baseColor; float num10 = Mathf.Clamp01((num9 - 0.35f) * 1.6f) * grimeAmount; val5 = Color.Lerp(val5, val4, num10); if (rustAmount > 0.01f) { float num11 = Mathf.Clamp01((num8 - (0.58f - rustAmount * 0.28f)) * 4.2f) * rustAmount; Color val6 = Color.Lerp(val2, val3, num6); val5 = Color.Lerp(val5, val6, num11); } float num12 = (num7 - 0.5f) * 0.1f; val5.r = Mathf.Clamp01(val5.r + num12); val5.g = Mathf.Clamp01(val5.g + num12); val5.b = Mathf.Clamp01(val5.b + num12); val5.a = 1f; array[i * 128 + j] = val5; } } val.SetPixels(array); val.Apply(); return val; } private static Dictionary<string, Material> ParseMtl(string mtlText, Material? nativeTruckMetal) { //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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: 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_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029e: 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) Dictionary<string, Material> dictionary = new Dictionary<string, Material>(StringComparer.OrdinalIgnoreCase); Shader val = (((Object)(object)nativeTruckMetal != (Object)null) ? nativeTruckMetal.shader : (Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard") ?? Shader.Find("Sprites/Default"))); Material cur = null; string curName = ""; Color curKd = Color.gray; bool isEmissive = false; int matIdx = 0; string[] array = mtlText.Split('\n'); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length == 0 || text[0] == '#') { continue; } string[] array2 = text.Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); if (array2.Length < 2) { continue; } switch (array2[0].ToLowerInvariant()) { case "newmtl": FinalizeCurrent(); curName = array2[1]; curKd = Color.gray; isEmissive = false; cur = new Material(val) { name = curName }; dictionary[curName] = cur; break; case "kd": { if ((Object)(object)cur != (Object)null && array2.Length >= 4 && TryColor(array2, out var c)) { curKd = c; if (cur.HasProperty("_BaseColor")) { cur.SetColor("_BaseColor", c); } if (cur.HasProperty("_Color")) { cur.SetColor("_Color", c); } } break; } case "ke": { if ((Object)(object)cur != (Object)null && array2.Length >= 4 && TryColor(array2, out var c2) && (c2.r > 0.01f || c2.g > 0.01f || c2.b > 0.01f)) { isEmissive = true; cur.EnableKeyword("_EMISSION"); if (cur.HasProperty("_EmissionColor")) { cur.SetColor("_EmissionColor", c2 * 2f); } } break; } case "pm": { if ((Object)(object)cur != (Object)null && float.TryParse(array2[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && cur.HasProperty("_Metallic")) { cur.SetFloat("_Metallic", result2 * 0.7f); } break; } case "pr": { if ((Object)(object)cur != (Object)null && float.TryParse(array2[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { float num = Mathf.Clamp01((1f - result) * 0.65f); if (cur.HasProperty("_Smoothness")) { cur.SetFloat("_Smoothness", num); } if (cur.HasProperty("_Glossiness")) { cur.SetFloat("_Glossiness", num); } } break; } } } FinalizeCurrent(); return dictionary; void FinalizeCurrent() { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)cur == (Object)null || isEmissive)) { float num2 = 0.65f; float num3 = 0.55f; if (curName.Contains("Rubber")) { num2 = 0.2f; num3 = 0.6f; } else if (curName.Contains("HazardYellow")) { num2 = 0.45f; num3 = 0.5f; } else if (curName.Contains("HazardBlack")) { num2 = 0.35f; num3 = 0.55f; } else if (curName.Contains("ScreenBG")) { num2 = 0.15f; num3 = 0.45f; } else if (curName.Contains("Gunmetal")) { num2 = 0.75f; num3 = 0.6f; } else if (curName.Contains("Steel")) { num2 = 0.55f; num3 = 0.5f; } float rustAmount = Mathf.Clamp01(num2 * Plugin.RustIntensity.Value); float grimeAmount = Mathf.Clamp01(num3 * Plugin.GrimeIntensity.Value); Texture2D val2 = CreateRustyTexture(curKd, rustAmount, grimeAmount, ++matIdx); ((Texture)val2).filterMode = (FilterMode)(!Plugin.PixelatedTexture.Value); if (cur.HasProperty("_MainTex")) { cur.SetTexture("_MainTex", (Texture)(object)val2); } if (cur.HasProperty("_Color")) { cur.SetColor("_Color", Color.white); } if (cur.HasProperty("_Glossiness")) { cur.SetFloat("_Glossiness", Plugin.Glossiness.Value); } if (cur.HasProperty("_Metallic")) { cur.SetFloat("_Metallic", Plugin.Metallic.Value); } } } } private static bool TryColor(string[] p, out Color c) { //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_0056: 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) c = Color.white; if (float.TryParse(p[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(p[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(p[3], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3)) { c = new Color(result, result2, result3, 1f); return true; } return false; } private static GameObject ParseObj(string name, string objText, Dictionary<string, Material> matMap) { //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Expected O, but got Unknown //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Expected O, but got Unknown //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_030e: 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_0300: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); List<Vector2> list2 = new List<Vector2>(); List<Vector3> list3 = new List<Vector3>(); List<Vector3> list4 = new List<Vector3>(); List<Vector2> list5 = new List<Vector2>(); List<Vector3> list6 = new List<Vector3>(); Dictionary<string, List<int>> dictionary = new Dictionary<string, List<int>>(StringComparer.OrdinalIgnoreCase); List<string> list7 = new List<string>(); string text = "default"; string[] array = objText.Split('\n'); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.Length == 0 || text2[0] == '#') { continue; } string[] array2 = text2.Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); if (array2.Length < 2) { continue; } if (array2[0] == "v" && array2.Length >= 4) { float num = float.Parse(array2[1], CultureInfo.InvariantCulture); float num2 = float.Parse(array2[2], CultureInfo.InvariantCulture); float num3 = float.Parse(array2[3], CultureInfo.InvariantCulture); list.Add(new Vector3(0f - num, num2, num3)); } else if (array2[0] == "vt" && array2.Length >= 3) { float num4 = float.Parse(array2[1], CultureInfo.InvariantCulture); float num5 = float.Parse(array2[2], CultureInfo.InvariantCulture); list2.Add(new Vector2(num4, num5)); } else if (array2[0] == "vn" && array2.Length >= 4) { float num6 = float.Parse(array2[1], CultureInfo.InvariantCulture); float num7 = float.Parse(array2[2], CultureInfo.InvariantCulture); float num8 = float.Parse(array2[3], CultureInfo.InvariantCulture); list3.Add(new Vector3(0f - num6, num7, num8)); } else if (array2[0] == "usemtl") { text = array2[1]; if (!dictionary.ContainsKey(text)) { dictionary[text] = new List<int>(); list7.Add(text); } } else { if (!(array2[0] == "f") || array2.Length < 4) { continue; } if (!dictionary.ContainsKey(text)) { dictionary[text] = new List<int>(); list7.Add(text); } List<int> list8 = dictionary[text]; int count = list4.Count; int num9 = array2.Length - 1; for (int j = 1; j <= num9; j++) { string[] array3 = array2[j].Split('/'); int num10 = int.Parse(array3[0], CultureInfo.InvariantCulture) - 1; list4.Add((num10 >= 0 && num10 < list.Count) ? list[num10] : Vector3.zero); if (array3.Length >= 2 && int.TryParse(array3[1], out var result) && result - 1 >= 0 && result - 1 < list2.Count) { list5.Add(list2[result - 1]); } else { list5.Add(Vector2.zero); } if (array3.Length >= 3 && int.TryParse(array3[2], out var result2) && result2 - 1 >= 0 && result2 - 1 < list3.Count) { list6.Add(list3[result2 - 1]); } else { list6.Add(Vector3.up); } } for (int k = 1; k < num9 - 1; k++) { list8.Add(count); list8.Add(count + k + 1); list8.Add(count + k); } } } Mesh val = new Mesh { name = name }; val.SetVertices(list4); val.SetUVs(0, list5); val.SetNormals(list6); val.subMeshCount = list7.Count; Material[] array4 = (Material[])(object)new Material[list7.Count]; Shader val2 = Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard"); for (int l = 0; l < list7.Count; l++) { val.SetTriangles(dictionary[list7[l]], l); array4[l] = (Material)(matMap.TryGetValue(list7[l], out Material value) ? ((object)value) : ((object)new Material(val2))); } val.RecalculateBounds(); GameObject val3 = new GameObject(name); val3.AddComponent<MeshFilter>().sharedMesh = val; ((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterials = array4; return val3; } } [BepInPlugin("com.moongetsu.truckstorage", "TruckStorage", "1.2.0")] public class Plugin : BaseUnityPlugin { [Serializable] internal class SavedValuable { public string PrefabName = ""; public float PosX; public float PosY; public float PosZ; public float RotX; public float RotY; public float RotZ; public float RotW; public float DollarValue; public Vector3 LocalPos => new Vector3(PosX, PosY, PosZ); public Quaternion LocalRot => new Quaternion(RotX, RotY, RotZ, RotW); } [Serializable] private class StorageSaveData { public List<SavedValuable> Items = new List<SavedValuable>(); } internal static ManualLogSource Log = null; internal static Plugin Instance = null; internal static readonly List<SavedValuable> StoredValuables = new List<SavedValuable>(); private static bool _capturedThisLevel; internal static ConfigEntry<bool> EnableMod = null; internal static ConfigEntry<bool> ShowStorageZone = null; internal static ConfigEntry<bool> RequireStorageZone = null; internal static ConfigEntry<bool> PersistAcrossSaves = null; internal static ConfigEntry<bool> ClearOnGameOver = null; internal static ConfigEntry<int> MaxStoredItems = null; internal static ConfigEntry<bool> AllowOrbs = null; internal static ConfigEntry<bool> AllowValuables = null; internal static ConfigEntry<float> ValueRetentionMultiplier = null; internal static ConfigEntry<bool> IndestructibleInTray = null; internal static ConfigEntry<bool> IndestructibleInEntireTruck = null; internal static ConfigEntry<bool> ZeroVelocityOnSpawn = null; internal static ConfigEntry<float> SpawnHeightOffset = null; internal static ConfigEntry<float> SpawnDelaySeconds = null; internal static ConfigEntry<bool> ShowValueDisplay = null; internal static ConfigEntry<float> DisplayUpdateInterval = null; internal static ConfigEntry<bool> DisplayShowItemCount = null; internal static ConfigEntry<float> DisplayFontSizeMin = null; internal static ConfigEntry<float> DisplayFontSizeMax = null; internal static ConfigEntry<string> DisplayDollarColorHex = null; internal static ConfigEntry<float> RustIntensity = null; internal static ConfigEntry<float> GrimeIntensity = null; internal static ConfigEntry<float> Glossiness = null; internal static ConfigEntry<float> Metallic = null; internal static ConfigEntry<bool> PixelatedTexture = null; internal static ConfigEntry<bool> EnableSolidRails = null; internal static ConfigEntry<Vector3> ZoneLocalOffset = null; internal static ConfigEntry<float> ZoneLocalRotationY = null; internal static ConfigEntry<Vector3> ZoneVisualScale = null; internal static ConfigEntry<Vector3> ZoneSize = null; internal static ConfigEntry<bool> EnablePlacementHotkeys = null; internal static ConfigEntry<KeyCode> MoveTrayKey = null; internal static ConfigEntry<KeyCode> RotateTrayKey = null; internal static ConfigEntry<bool> EnableDevTestHotkeys = null; internal static ConfigEntry<KeyCode> SpawnTestOrbKey = null; internal static ConfigEntry<KeyCode> SkipLevelKey = null; private static TextMeshPro? _valueDisplayText; private static bool _displayStyledFromExtraction; private static float _displayUpdateTimer; private static readonly FieldInfo? FldRoomVolumeCheck = AccessTools.Field(typeof(ValuableObject), "roomVolumeCheck"); private static readonly FieldInfo? FldInTruck = AccessTools.Field(typeof(RoomVolumeCheck), "inTruck"); private static readonly FieldInfo? FldDollarValueCurrent = AccessTools.Field(typeof(ValuableObject), "dollarValueCurrent"); private static readonly FieldInfo? FldDollarValueOverride = AccessTools.Field(typeof(ValuableObject), "dollarValueOverride"); private static readonly FieldInfo? FldSaveFileCurrent = AccessTools.Field(typeof(StatsManager), "saveFileCurrent"); private static readonly string[] SearchFolders = new string[8] { "Valuables", "Valuables/01 Tiny", "Valuables/02 Small", "Valuables/03 Medium", "Valuables/04 Big", "Valuables/05 Wide", "Valuables/06 Tall", "Valuables/07 Very Tall" }; private void Awake() { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Expected O, but got Unknown //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Expected O, but got Unknown //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Expected O, but got Unknown //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Expected O, but got Unknown //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Expected O, but got Unknown //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Expected O, but got Unknown //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Expected O, but got Unknown //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Expected O, but got Unknown //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Expected O, but got Unknown //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_06a0: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableMod", true, "Master switch for TruckStorage."); ShowStorageZone = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowStorageZone", true, "Show the 3D storage tray inside the truck."); RequireStorageZone = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RequireStorageZone", false, "If true, only valuables placed inside the 3D storage tray are saved. If false, anything inside the truck is saved."); PersistAcrossSaves = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PersistAcrossSaves", true, "Save and load stored truck items to disk (truck_storage.json) per save slot."); ClearOnGameOver = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ClearOnGameOver", true, "Clear stored truck items when entering the Arena / Game Over."); MaxStoredItems = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxStoredItems", 0, new ConfigDescription("Maximum number of items saved per transition (0 = unlimited, keeps highest value first).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); AllowOrbs = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AllowOrbs", true, "Allow enemy orbs (Enemy Valuable) to be saved in the truck."); AllowValuables = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AllowValuables", true, "Allow regular map valuables to be saved in the truck."); ValueRetentionMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ValueRetentionMultiplier", 1f, new ConfigDescription("Multiplier applied to saved item values on restore (1.0 = 100%, <1.0 = storage tax, >1.0 = bonus).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), Array.Empty<object>())); IndestructibleInTray = ((BaseUnityPlugin)this).Config.Bind<bool>("Protection", "IndestructibleInTray", true, "Prevent valuables and orbs from breaking or losing value while inside the 3D storage tray."); IndestructibleInEntireTruck = ((BaseUnityPlugin)this).Config.Bind<bool>("Protection", "IndestructibleInEntireTruck", false, "Prevent valuables and orbs from breaking anywhere inside the truck."); ZeroVelocityOnSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Protection", "ZeroVelocityOnSpawn", true, "Zero out linear and angular velocity when restoring items so they settle cleanly."); SpawnHeightOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Protection", "SpawnHeightOffset", 0.05f, new ConfigDescription("Vertical height offset (meters) when restoring items onto the tray.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.5f), Array.Empty<object>())); SpawnDelaySeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Protection", "SpawnDelaySeconds", 0.6f, new ConfigDescription("Delay (seconds) after level generation before restoring stored items.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>())); ShowValueDisplay = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "ShowValueDisplay", true, "Show the live Extraction-style $ readout on the tray display."); DisplayUpdateInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "DisplayUpdateInterval", 0.25f, new ConfigDescription("How often (seconds) the live $ display refreshes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 2f), Array.Empty<object>())); DisplayShowItemCount = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "DisplayShowItemCount", false, "Also show the number of items in the tray on the display (e.g. $12,500 (5))."); DisplayFontSizeMin = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "DisplayFontSizeMin", 0.6f, new ConfigDescription("Minimum auto-size font scale for the $ display.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 2f), Array.Empty<object>())); DisplayFontSizeMax = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "DisplayFontSizeMax", 1.6f, new ConfigDescription("Maximum auto-size font scale for the $ display.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.4f, 3f), Array.Empty<object>())); DisplayDollarColorHex = ((BaseUnityPlugin)this).Config.Bind<string>("Display", "DisplayDollarColorHex", "#bd4300", "Hex color for the '$' symbol on the display (default #bd4300 matches ExtractionPoint)."); RustIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "RustIntensity", 1f, new ConfigDescription("Rust intensity on the 3D tray (0 = clean metal, 1.5 = heavy rust).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1.5f), Array.Empty<object>())); GrimeIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "GrimeIntensity", 1f, new ConfigDescription("Grime/dirt streak intensity on the 3D tray.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1.5f), Array.Empty<object>())); Glossiness = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "Glossiness", 0.2f, new ConfigDescription("Surface glossiness (0 = fully matte, 1 = glossy).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); Metallic = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "Metallic", 0.3f, new ConfigDescription("Surface metallic strength.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); PixelatedTexture = ((BaseUnityPlugin)this).Config.Bind<bool>("Appearance", "PixelatedTexture", true, "Use crisp pixelated Point filtering to match R.E.P.O.'s art style."); EnableSolidRails = ((BaseUnityPlugin)this).Config.Bind<bool>("Appearance", "EnableSolidRails", true, "Enable solid colliders on the 3 side guard rails so orbs cannot roll out."); ZoneLocalOffset = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Placement", "ZoneLocalOffset", new Vector3(-0.4367f, -1.5512f, -1.5808f), "Local offset of the 3D storage tray relative to TruckSafetySpawnPoint."); ZoneLocalRotationY = ((BaseUnityPlugin)this).Config.Bind<float>("Placement", "ZoneLocalRotationY", 0f, new ConfigDescription("Y rotation (degrees) of the 3D storage tray inside the truck.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 360f), Array.Empty<object>())); ZoneVisualScale = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Placement", "ZoneVisualScale", Vector3.one, "Scale (width, height, depth) of the 3D storage tray."); ZoneSize = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Placement", "ZoneSize", new Vector3(1.75f, 1.4f, 1.05f), "Size (width, height, depth) of the 3D storage zone."); EnablePlacementHotkeys = ((BaseUnityPlugin)this).Config.Bind<bool>("Hotkeys", "EnablePlacementHotkeys", false, "Enable in-game hotkeys to move and rotate the 3D tray."); MoveTrayKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Hotkeys", "MoveTrayKey", (KeyCode)289, "Hotkey to move the 3D tray to your current position."); RotateTrayKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Hotkeys", "RotateTrayKey", (KeyCode)290, "Hotkey to rotate the 3D tray by 90 degrees."); EnableDevTestHotkeys = ((BaseUnityPlugin)this).Config.Bind<bool>("Hotkeys", "EnableDevTestHotkeys", false, "Enable dev test hotkeys (spawn test orb / skip level)."); SpawnTestOrbKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Hotkeys", "SpawnTestOrbKey", (KeyCode)287, "Hotkey to spawn a test orb on the tray."); SkipLevelKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Hotkeys", "SkipLevelKey", (KeyCode)288, "Hotkey to skip to the next shop/level."); ZoneLocalOffset.SettingChanged += delegate { ApplyLiveTrayTransform(); }; ZoneLocalRotationY.SettingChanged += delegate { ApplyLiveTrayTransform(); }; ZoneVisualScale.SettingChanged += delegate { ApplyLiveTrayTransform(); }; new Harmony("com.moongetsu.truckstorage").PatchAll(); Log.LogInfo((object)"TruckStorage 1.2.0 loaded."); } private static void ApplyLiveTrayTransform() { //IL_0033: 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_0062: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)TruckSafetySpawnPoint.instance == (Object)null)) { Transform val = ((Component)TruckSafetySpawnPoint.instance).transform.Find("TruckStorageZoneVisual"); if (!((Object)(object)val == (Object)null)) { val.localPosition = ZoneLocalOffset.Value; val.localRotation = Quaternion.Euler(0f, ZoneLocalRotationY.Value, 0f); val.localScale = ZoneVisualScale.Value; } } } internal static void ResetCaptureFlag() { _capturedThisLevel = false; } private void Update() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: 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_0289: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) if (!EnableMod.Value) { return; } if (EnableDevTestHotkeys.Value && SemiFunc.IsMasterClientOrSingleplayer() && Input.GetKeyDown(SkipLevelKey.Value) && (Object)(object)RunManager.instance != (Object)null) { Log.LogInfo((object)"[DevTest] Triggering ChangeLevel(true, false, Normal)..."); RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)0); } else { if ((Object)(object)TruckSafetySpawnPoint.instance == (Object)null) { return; } Transform transform = ((Component)TruckSafetySpawnPoint.instance).transform; Transform val = transform.Find("TruckStorageZoneVisual"); if ((Object)(object)val == (Object)null) { return; } if (ShowValueDisplay.Value && (Object)(object)_valueDisplayText != (Object)null) { if (!_displayStyledFromExtraction) { TryApplyExtractionStyle(_valueDisplayText); } _displayUpdateTimer -= Time.deltaTime; if (_displayUpdateTimer <= 0f) { _displayUpdateTimer = DisplayUpdateInterval.Value; int num = 0; int num2 = 0; ValuableObject[] array = Object.FindObjectsByType<ValuableObject>((FindObjectsSortMode)0); foreach (ValuableObject val2 in array) { if (!((Object)(object)val2 == (Object)null) && ((Component)val2).gameObject.activeInHierarchy && IsInsideStorageZone(transform.InverseTransformPoint(((Component)val2).transform.position))) { float num3 = ((FldDollarValueCurrent != null) ? ((float)FldDollarValueCurrent.GetValue(val2)) : 0f); num += Mathf.RoundToInt(num3); num2++; } } string text = (string.IsNullOrWhiteSpace(DisplayDollarColorHex.Value) ? "#bd4300" : DisplayDollarColorHex.Value.Trim()); string text2 = "<color=" + text + ">$</color>" + SemiFunc.DollarGetString(Mathf.Max(0, num)); if (DisplayShowItemCount.Value) { text2 += $" ({num2})"; } ((TMP_Text)_valueDisplayText).fontSizeMin = Mathf.Min(DisplayFontSizeMin.Value, DisplayFontSizeMax.Value); ((TMP_Text)_valueDisplayText).fontSizeMax = DisplayFontSizeMax.Value; ((TMP_Text)_valueDisplayText).text = text2; } } if (EnablePlacementHotkeys.Value) { if (Input.GetKeyDown(MoveTrayKey.Value) && (Object)(object)PlayerAvatar.instance != (Object)null) { Vector3 val3 = transform.InverseTransformPoint(((Component)PlayerAvatar.instance).transform.position); val3.y = GetTruckFloorLocalY(transform, val3.y); val.localPosition = val3; ZoneLocalOffset.Value = val3; ((BaseUnityPlugin)this).Config.Save(); Log.LogInfo((object)$"Moved TruckStorage tray to local={val3} (saved to config)"); } else if (Input.GetKeyDown(RotateTrayKey.Value)) { float num4 = (ZoneLocalRotationY.Value + 90f) % 360f; val.localRotation = Quaternion.Euler(0f, num4, 0f); ZoneLocalRotationY.Value = num4; ((BaseUnityPlugin)this).Config.Save(); Log.LogInfo((object)$"Rotated TruckStorage tray to Y={num4} (saved to config)"); } } if (EnableDevTestHotkeys.Value && SemiFunc.IsMasterClientOrSingleplayer() && Input.GetKeyDown(SpawnTestOrbKey.Value) && (Object)(object)AssetManager.instance != (Object)null && (Object)(object)AssetManager.instance.enemyValuableSmall != (Object)null) { Vector3 val4 = val.position + Vector3.up * 0.25f; if (SemiFunc.IsMultiplayer()) { PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)AssetManager.instance.enemyValuableSmall).name, val4, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate<GameObject>(AssetManager.instance.enemyValuableSmall, val4, Quaternion.identity); } Log.LogInfo((object)$"[DevTest] Spawned test orb on tray at {val4}"); } } } private static bool IsPlayableLevel() { if ((Object)(object)RunManager.instance != (Object)null && SemiFunc.RunIsLevel() && !SemiFunc.RunIsShop() && !SemiFunc.RunIsLobby()) { return !SemiFunc.RunIsArena(); } return false; } internal static void CaptureTruckValuables() { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0221: 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_022b: Unknown result type (might be due to invalid IL or missing references) //IL_023c: 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_0256: 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) //IL_0270: 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_028a: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) if (!EnableMod.Value || _capturedThisLevel || !SemiFunc.IsMasterClientOrSingleplayer() || !IsPlayableLevel() || (Object)(object)TruckSafetySpawnPoint.instance == (Object)null) { return; } _capturedThisLevel = true; Transform transform = ((Component)TruckSafetySpawnPoint.instance).transform; List<SavedValuable> list = new List<SavedValuable>(); ValuableObject[] array = Object.FindObjectsByType<ValuableObject>((FindObjectsSortMode)0); RoomVolume val3 = default(RoomVolume); Vector3 val4 = default(Vector3); foreach (ValuableObject val in array) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null || !((Component)val).gameObject.activeInHierarchy) { continue; } string text = ((Object)((Component)val).gameObject).name.Replace("(Clone)", "").Trim(); bool flag = text.IndexOf("Enemy Valuable", StringComparison.OrdinalIgnoreCase) >= 0; if ((!flag || AllowOrbs.Value) && (flag || AllowValuables.Value)) { Vector3 val2 = transform.InverseTransformPoint(((Component)val).transform.position); bool flag2 = IsInsideStorageZone(val2); bool flag3; if (RequireStorageZone.Value) { flag3 = flag2; } else { bool num = SemiFunc.GetRoomVolumeAtPosition(((Component)val).transform.position, ref val3, ref val4) && (Object)(object)val3 != (Object)null && val3.Truck; object? obj = FldRoomVolumeCheck?.GetValue(val); RoomVolumeCheck val5 = (RoomVolumeCheck)((obj is RoomVolumeCheck) ? obj : null); bool flag4 = (Object)(object)val5 != (Object)null && FldInTruck != null && (bool)FldInTruck.GetValue(val5); bool flag5 = Mathf.Abs(val2.x) <= 3.5f && val2.y >= -2.5f && val2.y <= 3.5f && Mathf.Abs(val2.z) <= 6.5f; flag3 = num || flag4 || flag2 || flag5; } if (flag3) { float dollarValue = ((FldDollarValueCurrent != null) ? ((float)FldDollarValueCurrent.GetValue(val)) : 0f); Quaternion val6 = Quaternion.Inverse(transform.rotation) * ((Component)val).transform.rotation; list.Add(new SavedValuable { PrefabName = text, PosX = val2.x, PosY = val2.y, PosZ = val2.z, RotX = val6.x, RotY = val6.y, RotZ = val6.z, RotW = val6.w, DollarValue = dollarValue }); } } } if (MaxStoredItems.Value > 0 && list.Count > MaxStoredItems.Value) { list.Sort((SavedValuable a, SavedValuable b) => b.DollarValue.CompareTo(a.DollarValue)); list.RemoveRange(MaxStoredItems.Value, list.Count - MaxStoredItems.Value); } StoredValuables.Clear(); StoredValuables.AddRange(list); foreach (SavedValuable storedValuable in StoredValuables) { Log.LogInfo((object)$" + Captured {storedValuable.PrefabName} (${storedValuable.DollarValue:0})"); } Log.LogInfo((object)$"Captured {StoredValuables.Count} valuables/orbs inside the truck."); SaveToDisk(GetCurrentSaveFileName()); } internal static bool IsInsideStorageZone(Vector3 localPos) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_007e: Unknown result type (might be due to invalid IL or missing references) Vector3 value = ZoneLocalOffset.Value; Vector3 val = ZoneSize.Value * 0.5f; if (Mathf.Abs(localPos.x - value.x) <= val.x && localPos.y >= value.y - 0.3f && localPos.y <= value.y + ZoneSize.Value.y) { return Mathf.Abs(localPos.z - value.z) <= val.z; } return false; } internal static bool IsProtectedInTruck(Vector3 worldPos) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0068: Unknown result type (might be due to invalid IL or missing references) if (!EnableMod.Value || (Object)(object)TruckSafetySpawnPoint.instance == (Object)null) { return false; } if (!IndestructibleInTray.Value && !IndestructibleInEntireTruck.Value) { return false; } Vector3 localPos = ((Component)TruckSafetySpawnPoint.instance).transform.InverseTransformPoint(worldPos); if (IndestructibleInTray.Value && IsInsideStorageZone(localPos)) { return true; } RoomVolume val = default(RoomVolume); Vector3 val2 = default(Vector3); if (IndestructibleInEntireTruck.Value && SemiFunc.GetRoomVolumeAtPosition(worldPos, ref val, ref val2) && (Object)(object)val != (Object)null && val.Truck) { return true; } return false; } internal static void OnLevelReady() { if (!EnableMod.Value) { return; } if (ClearOnGameOver.Value && SemiFunc.RunIsArena()) { StoredValuables.Clear(); SaveToDisk(GetCurrentSaveFileName()); } else if (IsPlayableLevel()) { _capturedThisLevel = false; if (ShowStorageZone.Value) { CreateStorageZoneVisual(); } if (SemiFunc.IsMasterClientOrSingleplayer() && StoredValuables.Count != 0) { ((MonoBehaviour)Instance).StartCoroutine(SpawnRoutine()); } } } private static void CreateStorageZoneVisual() { //IL_0064: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00d2: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_016b: 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) if ((Object)(object)TruckSafetySpawnPoint.instance == (Object)null) { return; } Transform transform = ((Component)TruckSafetySpawnPoint.instance).transform; if ((Object)(object)transform.Find("TruckStorageZoneVisual") != (Object)null) { return; } GameObject val = ObjModelLoader.LoadEmbeddedTray(transform, "TruckStorageZoneVisual"); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"Failed to load embedded 3D tray model."); return; } val.transform.SetParent(transform, false); Vector3 value = ZoneLocalOffset.Value; value.y = GetTruckFloorLocalY(transform, value.y); val.transform.localPosition = value; val.transform.localRotation = Quaternion.Euler(0f, ZoneLocalRotationY.Value, 0f); val.transform.localScale = ZoneVisualScale.Value; AddBoxCollider(val, new Vector3(0f, 0.033f, 0f), new Vector3(1.75f, 0.067f, 1.05f)); if (EnableSolidRails.Value) { AddBoxCollider(val, new Vector3(0f, 0.18f, -0.47f), new Vector3(1.75f, 0.28f, 0.1f)); AddBoxCollider(val, new Vector3(-0.82f, 0.18f, 0f), new Vector3(0.1f, 0.28f, 1.05f)); AddBoxCollider(val, new Vector3(0.82f, 0.18f, 0f), new Vector3(0.1f, 0.28f, 1.05f)); } if (ShowValueDisplay.Value) { CreateValueDisplay(val); } } private static void CreateValueDisplay(GameObject tray) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_003b: 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_005a: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ValueDisplayText"); val.transform.SetParent(tray.transform, false); val.transform.localPosition = new Vector3(0f, 0.62f, -0.425f); val.transform.localRotation = Quaternion.Euler(0f, 180f, 0f); val.transform.localScale = Vector3.one; TextMeshPro obj = val.AddComponent<TextMeshPro>(); ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).fontSize = 1.45f; ((TMP_Text)obj).enableAutoSizing = true; ((TMP_Text)obj).fontSizeMin = Mathf.Min(DisplayFontSizeMin.Value, DisplayFontSizeMax.Value); ((TMP_Text)obj).fontSizeMax = DisplayFontSizeMax.Value; ((TMP_Text)obj).rectTransform.sizeDelta = new Vector2(0.6f, 0.18f); ((Graphic)obj).color = new Color(1f, 0.85f, 0.22f, 1f); string text = (string.IsNullOrWhiteSpace(DisplayDollarColorHex.Value) ? "#bd4300" : DisplayDollarColorHex.Value.Trim()); ((TMP_Text)obj).text = "<color=" + text + ">$</color>0"; _displayStyledFromExtraction = false; TryApplyExtractionStyle(obj); _valueDisplayText = obj; } private static void TryApplyExtractionStyle(TextMeshPro target) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) ExtractionPoint val = Object.FindFirstObjectByType<ExtractionPoint>((FindObjectsInactive)1); if ((Object)(object)val != (Object)null && (Object)(object)val.haulGoalScreen != (Object)null) { ((TMP_Text)target).font = ((TMP_Text)val.haulGoalScreen).font; ((TMP_Text)target).fontSharedMaterial = ((TMP_Text)val.haulGoalScreen).fontSharedMaterial; ((Graphic)target).color = ((Graphic)val.haulGoalScreen).color; _displayStyledFromExtraction = true; } } private static void AddBoxCollider(GameObject parent, Vector3 center, Vector3 size) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) BoxCollider obj = parent.AddComponent<BoxCollider>(); obj.center = center; obj.size = size; } private static float GetTruckFloorLocalY(Transform truck, float fallbackY) { //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_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_001a: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) RaycastHit[] array = Physics.RaycastAll(truck.position + Vector3.up * 0.2f, Vector3.down, 4f); float num = float.MaxValue; float result = fallbackY; RaycastHit[] array2 = array; for (int i = 0; i < array2.Length; i++) { RaycastHit val = array2[i]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && !((RaycastHit)(ref val)).collider.isTrigger) { string name = ((Object)((Component)((RaycastHit)(ref val)).collider).gameObject).name; if (!name.Contains("TruckStorageZoneVisual") && !name.Contains("Player") && ((RaycastHit)(ref val)).distance < num) { num = ((RaycastHit)(ref val)).distance; result = truck.InverseTransformPoint(((RaycastHit)(ref val)).point).y + 0.005f; } } } return result; } private static IEnumerator SpawnRoutine() { yield return (object)new WaitForSeconds(SpawnDelaySeconds.Value); if ((Object)(object)TruckSafetySpawnPoint.instance == (Object)null) { Log.LogWarning((object)"TruckSafetySpawnPoint not found on level load."); yield break; } Transform transform = ((Component)TruckSafetySpawnPoint.instance).transform; int num = 0; foreach (SavedValuable storedValuable in StoredValuables) { string text = FindResourcePath(storedValuable.PrefabName); if (text == null) { Log.LogWarning((object)("Could not find resource path for '" + storedValuable.PrefabName + "'.")); continue; } Vector3 val = transform.TransformPoint(storedValuable.LocalPos) + Vector3.up * SpawnHeightOffset.Value; Quaternion val2 = transform.rotation * storedValuable.LocalRot; GameObject val3 = null; if (SemiFunc.IsMultiplayer()) { val3 = PhotonNetwork.InstantiateRoomObject(text, val, val2, (byte)0, (object[])null); } else { GameObject val4 = Resources.Load<GameObject>(text); if ((Object)(object)val4 != (Object)null) { val3 = Object.Instantiate<GameObject>(val4, val, val2); } } if (!((Object)(object)val3 != (Object)null)) { continue; } ValuableObject component = val3.GetComponent<ValuableObject>(); if ((Object)(object)component != (Object)null) { int num2 = Mathf.Max(1, Mathf.RoundToInt(storedValuable.DollarValue * ValueRetentionMultiplier.Value)); FldDollarValueOverride?.SetValue(component, num2); } if (ZeroVelocityOnSpawn.Value) { Rigidbody component2 = val3.GetComponent<Rigidbody>(); if ((Object)(object)component2 != (Object)null) { component2.velocity = Vector3.zero; component2.angularVelocity = Vector3.zero; } } num++; } Log.LogInfo((object)$"Restored {num}/{StoredValuables.Count} valuables/orbs into the truck."); StoredValuables.Clear(); SaveToDisk(GetCurrentSaveFileName()); } internal static string? GetCurrentSaveFileName() { if ((Object)(object)StatsManager.instance == (Object)null || FldSaveFileCurrent == null) { return null; } return FldSaveFileCurrent.GetValue(StatsManager.instance) as string; } internal static void SaveToDisk(string? saveFileName) { if (!PersistAcrossSaves.Value || string.IsNullOrWhiteSpace(saveFileName)) { return; } try { string text = Path.Combine(Application.persistentDataPath, "saves", saveFileName); if (Directory.Exists(text)) { string path = Path.Combine(text, "truck_storage.json"); StorageSaveData storageSaveData = new StorageSaveData { Items = new List<SavedValuable>(StoredValuables) }; File.WriteAllText(path, JsonUtility.ToJson((object)storageSaveData, true)); } } catch (Exception ex) { Log.LogError((object)("SaveToDisk error: " + ex.Message)); } } internal static void LoadFromDisk(string? saveFileName) { StoredValuables.Clear(); if (!PersistAcrossSaves.Value || string.IsNullOrWhiteSpace(saveFileName)) { return; } try { string path = Path.Combine(Application.persistentDataPath, "saves", saveFileName, "truck_storage.json"); if (File.Exists(path)) { StorageSaveData storageSaveData = JsonUtility.FromJson<StorageSaveData>(File.ReadAllText(path)); if (storageSaveData?.Items != null) { StoredValuables.AddRange(storageSaveData.Items); Log.LogInfo((object)$"Loaded {StoredValuables.Count} stored truck valuables from {saveFileName}."); } } } catch (Exception ex) { Log.LogError((object)("LoadFromDisk error: " + ex.Message)); } } private static string? FindResourcePath(string prefabName) { string[] searchFolders = SearchFolders; for (int i = 0; i < searchFolders.Length; i++) { string text = searchFolders[i] + "/" + prefabName; if ((Object)(object)Resources.Load<GameObject>(text) != (Object)null) { return text; } } return null; } } [HarmonyPatch(typeof(GameDirector), "OutroStart")] internal static class GameDirectorOutroPatch { private static void Prefix() { try { Plugin.CaptureTruckValuables(); } catch (Exception arg) { Plugin.Log.LogError((object)$"CaptureTruckValuables error: {arg}"); } } } [HarmonyPatch(typeof(RunManager), "ChangeLevel")] internal static class RunManagerChangeLevelPatch { private static void Prefix() { try { Plugin.CaptureTruckValuables(); } catch (Exception arg) { Plugin.Log.LogError((object)$"ChangeLevel CaptureTruckValuables error: {arg}"); } } } [HarmonyPatch(typeof(SemiFunc), "OnLevelGenDone")] internal static class LevelGenDonePatch { private static void Postfix() { try { Plugin.OnLevelReady(); } catch (Exception arg) { Plugin.Log.LogError((object)$"OnLevelReady error: {arg}"); } } } [HarmonyPatch(typeof(StatsManager), "SaveFileSave")] internal static class SaveFileSavePatch { private static void Postfix() { try { Plugin.SaveToDisk(Plugin.GetCurrentSaveFileName()); } catch (Exception arg) { Plugin.Log.LogError((object)$"SaveFileSavePatch error: {arg}"); } } } [HarmonyPatch(typeof(StatsManager), "LoadGame")] internal static class LoadGamePatch { private static void Postfix(string fileName) { try { Plugin.LoadFromDisk(fileName); } catch (Exception arg) { Plugin.Log.LogError((object)$"LoadGamePatch error: {arg}"); } } } [HarmonyPatch(typeof(RunManager), "LeaveToMainMenu")] internal static class LeaveToMainMenuPatch { private static void Prefix() { Plugin.StoredValuables.Clear(); Plugin.ResetCaptureFlag(); } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "Break")] internal static class TrayIndestructiblePatch { private static bool Prefix(PhysGrabObjectImpactDetector __instance) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)null && Plugin.IsProtectedInTruck(((Component)__instance).transform.position)) { return false; } return true; } } }