Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of Schedule 1 Survival Mode v0.9.88
S1HungerThirst.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using HarmonyLib; using Il2CppFishNet.Object; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.AvatarFramework; using Il2CppScheduleOne.AvatarFramework.Emotions; using Il2CppScheduleOne.AvatarFramework.Equipping; using Il2CppScheduleOne.Cartel; using Il2CppScheduleOne.Casino; using Il2CppScheduleOne.Core.Items.Framework; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Dialogue; using Il2CppScheduleOne.Economy; using Il2CppScheduleOne.Effects; using Il2CppScheduleOne.Equipping; using Il2CppScheduleOne.GameTime; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.Money; using Il2CppScheduleOne.NPCs; using Il2CppScheduleOne.NPCs.Behaviour; using Il2CppScheduleOne.NPCs.Relation; using Il2CppScheduleOne.ObjectScripts; using Il2CppScheduleOne.Persistence; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.PlayerScripts.Health; using Il2CppScheduleOne.Product; using Il2CppScheduleOne.Property; using Il2CppScheduleOne.Storage; using Il2CppScheduleOne.TV; using Il2CppScheduleOne.Trash; using Il2CppScheduleOne.UI; using Il2CppScheduleOne.UI.Shop; using Il2CppScheduleOne.Vehicles; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using Il2CppTMPro; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using S1HungerThirst; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(Mod), "Schedule 1 Chillvival Mod", "0.9.88", "Schedule 1 Chillvival Mod", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: VerifyLoaderVersion("0.7.0", true)] [assembly: HarmonyDontPatchAll] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("Schedule 1 Chillvival Mod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.9.88.0")] [assembly: AssemblyInformationalVersion("0.9.88")] [assembly: AssemblyProduct("Schedule 1 Chillvival Mod")] [assembly: AssemblyTitle("Schedule 1 Chillvival Mod")] [assembly: AssemblyVersion("0.9.88.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace S1HungerThirst { public static class ArtDiag { private static bool _ran; public static void Run() { //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) if (_ran) { return; } _ran = true; try { Diag.Log("[Art] ===== PHASE 0 MATERIAL RECON ====="); Il2CppReferenceArray<Object> val = Resources.FindObjectsOfTypeAll(Il2CppType.Of<Material>()); Diag.Log($"[Art] {((Il2CppArrayBase<Object>)(object)val).Length} materials loaded; scanning URP/Lit..."); int num = 0; int num2 = 0; int num3 = 0; string text = null; string[] array = new string[5] { "_BaseMap", "_BumpMap", "_MetallicGlossMap", "_OcclusionMap", "_EmissionMap" }; for (int i = 0; i < ((Il2CppArrayBase<Object>)(object)val).Length; i++) { if (num >= 12) { break; } Material val2 = ((Il2CppObjectBase)((Il2CppArrayBase<Object>)(object)val)[i]).TryCast<Material>(); if ((Object)(object)val2 == (Object)null || (Object)(object)val2.shader == (Object)null || ((Object)val2.shader).name != "Universal Render Pipeline/Lit") { continue; } num2++; bool flag = val2.HasProperty("_BumpMap") && (Object)(object)val2.GetTexture("_BumpMap") != (Object)null; bool flag2 = val2.IsKeywordEnabled("_NORMALMAP"); if (flag && flag2) { num3++; if (text == null) { text = ((Object)val2).name; } } if ((Object)(object)val2.GetTexture("_BaseMap") == (Object)null && !flag) { continue; } StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(12, 1, stringBuilder2); handler.AppendLiteral("[Art] mat '"); handler.AppendFormatted(((Object)val2).name); handler.AppendLiteral("'"); stringBuilder3.Append(ref handler); try { stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(6, 1, stringBuilder2); handler.AppendLiteral(" kw=["); handler.AppendFormatted(string.Join(",", Il2CppArrayBase<string>.op_Implicit((Il2CppArrayBase<string>)(object)val2.shaderKeywords))); handler.AppendLiteral("]"); stringBuilder4.Append(ref handler); } catch { } Diag.Log(stringBuilder.ToString()); StringBuilder stringBuilder5 = new StringBuilder("[Art] maps:"); string[] array2 = array; foreach (string text2 in array2) { if (!val2.HasProperty(text2)) { stringBuilder2 = stringBuilder5; StringBuilder stringBuilder6 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(5, 1, stringBuilder2); handler.AppendLiteral(" "); handler.AppendFormatted(text2); handler.AppendLiteral("=n/a"); stringBuilder6.Append(ref handler); continue; } Texture texture = val2.GetTexture(text2); if ((Object)(object)texture == (Object)null) { stringBuilder2 = stringBuilder5; StringBuilder stringBuilder7 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(6, 1, stringBuilder2); handler.AppendLiteral(" "); handler.AppendFormatted(text2); handler.AppendLiteral("=null"); stringBuilder7.Append(ref handler); } else { Texture2D val3 = ((Il2CppObjectBase)texture).TryCast<Texture2D>(); stringBuilder5.Append(((Object)(object)val3 != (Object)null) ? $" {text2}={((Texture)val3).width}x{((Texture)val3).height}:{val3.format}" : (" " + text2 + "=tex")); } } Diag.Log(stringBuilder5.ToString()); StringBuilder stringBuilder8 = new StringBuilder("[Art] "); if (val2.HasProperty("_BaseMap_ST")) { Vector4 vector = val2.GetVector("_BaseMap_ST"); stringBuilder2 = stringBuilder8; StringBuilder stringBuilder9 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(10, 4, stringBuilder2); handler.AppendLiteral("_ST=("); handler.AppendFormatted(vector.x, "0.##"); handler.AppendLiteral(","); handler.AppendFormatted(vector.y, "0.##"); handler.AppendLiteral(","); handler.AppendFormatted(vector.z, "0.##"); handler.AppendLiteral(","); handler.AppendFormatted(vector.w, "0.##"); handler.AppendLiteral(") "); stringBuilder9.Append(ref handler); } if (val2.HasProperty("_BaseColor")) { Color color = val2.GetColor("_BaseColor"); stringBuilder2 = stringBuilder8; StringBuilder stringBuilder10 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(16, 3, stringBuilder2); handler.AppendLiteral("_BaseColor=("); handler.AppendFormatted(color.r, "0.##"); handler.AppendLiteral(","); handler.AppendFormatted(color.g, "0.##"); handler.AppendLiteral(","); handler.AppendFormatted(color.b, "0.##"); handler.AppendLiteral(") "); stringBuilder10.Append(ref handler); } if (val2.HasProperty("_Metallic")) { stringBuilder2 = stringBuilder8; StringBuilder stringBuilder11 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(11, 1, stringBuilder2); handler.AppendLiteral("_Metallic="); handler.AppendFormatted(val2.GetFloat("_Metallic"), "0.###"); handler.AppendLiteral(" "); stringBuilder11.Append(ref handler); } if (val2.HasProperty("_Smoothness")) { stringBuilder2 = stringBuilder8; StringBuilder stringBuilder12 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(13, 1, stringBuilder2); handler.AppendLiteral("_Smoothness="); handler.AppendFormatted(val2.GetFloat("_Smoothness"), "0.###"); handler.AppendLiteral(" "); stringBuilder12.Append(ref handler); } if (val2.HasProperty("_OcclusionStrength")) { stringBuilder2 = stringBuilder8; StringBuilder stringBuilder13 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(10, 1, stringBuilder2); handler.AppendLiteral("_OcclStr="); handler.AppendFormatted(val2.GetFloat("_OcclusionStrength"), "0.###"); handler.AppendLiteral(" "); stringBuilder13.Append(ref handler); } if (val2.HasProperty("_Surface")) { stringBuilder2 = stringBuilder8; StringBuilder stringBuilder14 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(10, 1, stringBuilder2); handler.AppendLiteral("_Surface="); handler.AppendFormatted(val2.GetFloat("_Surface"), "0"); handler.AppendLiteral(" "); stringBuilder14.Append(ref handler); } if (val2.HasProperty("_WorkflowMode")) { stringBuilder2 = stringBuilder8; StringBuilder stringBuilder15 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(10, 1, stringBuilder2); handler.AppendLiteral("_Workflow="); handler.AppendFormatted(val2.GetFloat("_WorkflowMode"), "0"); stringBuilder15.Append(ref handler); } Diag.Log(stringBuilder8.ToString()); num++; } Diag.Log($"[Art] URP/Lit total={num2}, normal-mapped w/ _NORMALMAP enabled={num3}"); Diag.Log((num3 > 0) ? ("[Art] NORMALMAP VARIANT EXISTS in the shipped game. Donor candidate: '" + text + "'") : "[Art] WARN: no normal-mapped URP/Lit material found, the _NORMALMAP variant may be stripped; PBR normals may be silently ignored."); Diag.Log("[Art] ===== END PHASE 0 RECON ====="); } catch (Exception ex) { Diag.Log("[Art] recon failed: " + ex.Message); } } } public static class FoodMaterial { private static readonly int ID_BaseMap = Shader.PropertyToID("_BaseMap"); private static readonly int ID_BaseMapST = Shader.PropertyToID("_BaseMap_ST"); private static readonly int ID_BaseColor = Shader.PropertyToID("_BaseColor"); private static readonly int ID_Color = Shader.PropertyToID("_Color"); private static readonly int ID_BumpMap = Shader.PropertyToID("_BumpMap"); private static readonly int ID_BumpScale = Shader.PropertyToID("_BumpScale"); private static readonly int ID_MetGloss = Shader.PropertyToID("_MetallicGlossMap"); private static readonly int ID_Metallic = Shader.PropertyToID("_Metallic"); private static readonly int ID_Smoothness = Shader.PropertyToID("_Smoothness"); private static readonly int ID_OcclMap = Shader.PropertyToID("_OcclusionMap"); private static readonly int ID_OcclStr = Shader.PropertyToID("_OcclusionStrength"); private static readonly Dictionary<string, TexGen.TexSet> _sets = new Dictionary<string, TexGen.TexSet>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<string, Texture2D[]> _uploaded = new Dictionary<string, Texture2D[]>(StringComparer.OrdinalIgnoreCase); private static Material _donor; private static int _donorTier; private static Material Donor(Renderer callSiteDonor) { //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown if ((Object)(object)_donor != (Object)null && Object.op_Implicit((Object)(object)_donor)) { return _donor; } try { Il2CppReferenceArray<Object> val = Resources.FindObjectsOfTypeAll(Il2CppType.Of<Material>()); for (int i = 0; i < ((Il2CppArrayBase<Object>)(object)val).Length; i++) { Material val2 = ((Il2CppObjectBase)((Il2CppArrayBase<Object>)(object)val)[i]).TryCast<Material>(); if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.shader == (Object)null) && !(((Object)val2.shader).name != "Universal Render Pipeline/Lit") && val2.HasProperty(ID_BumpMap) && !((Object)(object)val2.GetTexture(ID_BumpMap) == (Object)null) && val2.IsKeywordEnabled("_NORMALMAP")) { _donor = val2; _donorTier = 1; Diag.Log("[Art] donor tier 1 (normal-mapped): '" + ((Object)val2).name + "'"); return _donor; } } } catch (Exception ex) { MelonLogger.Warning("[Art] donor scan failed: " + ex.Message); } if ((Object)(object)callSiteDonor != (Object)null && (Object)(object)callSiteDonor.sharedMaterial != (Object)null) { _donor = callSiteDonor.sharedMaterial; _donorTier = 2; Diag.Log("[Art] donor tier 2 (call-site '" + ((Object)_donor).name + "'): no normal-mapped URP/Lit material found; _NORMALMAP variant may be stripped, normal map may be ignored."); return _donor; } Shader val3 = Shader.Find("Universal Render Pipeline/Lit"); if ((Object)(object)val3 == (Object)null) { val3 = Shader.Find("Universal Render Pipeline/Simple Lit"); } _donor = new Material(val3); _donorTier = 3; Diag.Log("[Art] donor tier 3 (bare shader): keywords unproven."); return _donor; } private static Texture2D Upload(byte[] rgba, int size, bool linear, string name) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //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) Texture2D val = new Texture2D(size, size, (TextureFormat)4, true, linear); ((Object)val).name = name; bool flag = false; try { GCHandle gCHandle = GCHandle.Alloc(rgba, GCHandleType.Pinned); try { val.LoadRawTextureData(gCHandle.AddrOfPinnedObject(), rgba.Length); flag = true; } finally { gCHandle.Free(); } } catch (Exception) { flag = false; } if (!flag) { Color32[] array = (Color32[])(object)new Color32[size * size]; for (int i = 0; i < array.Length; i++) { array[i] = new Color32(rgba[i * 4], rgba[i * 4 + 1], rgba[i * 4 + 2], rgba[i * 4 + 3]); } val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array)); } ((Texture)val).wrapMode = (TextureWrapMode)0; ((Texture)val).filterMode = (FilterMode)2; ((Texture)val).anisoLevel = 4; ((Object)val).hideFlags = (HideFlags)32; val.Apply(true, true); return val; } private static Texture2D[] GetTextures(string variantKey, Taco3D.FillingLook look) { if (_uploaded.TryGetValue(variantKey, out var value) && value != null && (Object)(object)value[0] != (Object)null && Object.op_Implicit((Object)(object)value[0])) { return value; } if (!_sets.TryGetValue(variantKey, out var value2) || value2 == null) { value2 = (string.Equals(variantKey, "burroito", StringComparison.OrdinalIgnoreCase) ? TexGen.BuildBurroitoSet() : (TacoItem.IsTacoId(variantKey) ? TexGen.BuildTacoSet(variantKey, look) : TexGen.BuildBandedSet(variantKey, look))); _sets[variantKey] = value2; Diag.Log($"[Art] texgen '{variantKey}': {value2.Size}x{value2.Size} x3 maps in {value2.GenMs} ms"); } Texture2D[] array = (Texture2D[])(object)new Texture2D[3] { Upload(value2.Albedo, value2.Size, linear: false, "S1HT_" + variantKey + "_albedo"), Upload(value2.Normal, value2.Size, linear: true, "S1HT_" + variantKey + "_normal"), Upload(value2.Mos, value2.Size, linear: true, "S1HT_" + variantKey + "_mos") }; _uploaded[variantKey] = array; _sets.Remove(variantKey); return array; } public static Material Build(Renderer callSiteDonor, string variantKey, Taco3D.FillingLook look) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) Texture2D[] textures = GetTextures(variantKey, look); Material val = Donor(callSiteDonor); Material val2; try { val2 = Object.Instantiate<Material>(val); } catch (Exception ex) { MelonLogger.Warning("[Art] donor clone failed (" + ex.Message + "); bare material."); val2 = new Material(Shader.Find("Universal Render Pipeline/Lit")); } ((Object)val2).name = "S1HT_Food_" + variantKey; ((Object)val2).hideFlags = (HideFlags)32; if (val2.HasProperty(ID_BaseMapST)) { val2.SetVector(ID_BaseMapST, new Vector4(1f, 1f, 0f, 0f)); } val2.mainTexture = (Texture)(object)textures[0]; if (val2.HasProperty(ID_BaseMap)) { val2.SetTexture(ID_BaseMap, (Texture)(object)textures[0]); } if (val2.HasProperty(ID_BaseColor)) { val2.SetColor(ID_BaseColor, Color.white); } if (val2.HasProperty(ID_Color)) { val2.SetColor(ID_Color, Color.white); } if (val2.HasProperty(ID_BumpMap)) { val2.SetTexture(ID_BumpMap, (Texture)(object)textures[1]); if (val2.HasProperty(ID_BumpScale)) { val2.SetFloat(ID_BumpScale, 1f); } val2.EnableKeyword("_NORMALMAP"); } if (val2.HasProperty(ID_MetGloss)) { val2.SetTexture(ID_MetGloss, (Texture)(object)textures[2]); val2.SetFloat(ID_Smoothness, 1f); val2.SetFloat(ID_Metallic, 0f); val2.EnableKeyword("_METALLICSPECGLOSSMAP"); val2.DisableKeyword("_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A"); val2.DisableKeyword("_SPECULAR_SETUP"); } if (val2.HasProperty(ID_OcclMap)) { val2.SetTexture(ID_OcclMap, (Texture)(object)textures[2]); if (val2.HasProperty(ID_OcclStr)) { val2.SetFloat(ID_OcclStr, 0.85f); } val2.EnableKeyword("_OCCLUSIONMAP"); } try { Diag.Log($"[Art] mat '{((Object)val2).name}' shader='{((Object)val2.shader).name}' donorTier={_donorTier} keywords=[{string.Join(",", Il2CppArrayBase<string>.op_Implicit((Il2CppArrayBase<string>)(object)val2.shaderKeywords))}]"); } catch { } return val2; } } public static class FoodShapes { public const float TAC_OUT_C = 5f / 32f; public const float TAC_OUT_H = 5f / 32f; public const float TAC_INN_C = 13f / 32f; public const float TAC_INN_H = 3f / 32f; public const float TAC_MEAT_C = 19f / 32f; public const float TAC_MEAT_H = 3f / 32f; public const float TAC_CHE_C = 47f / 64f; public const float TAC_CHE_H = 3f / 64f; public const float TAC_TOM_C = 53f / 64f; public const float TAC_TOM_H = 3f / 64f; public const float TAC_LET_C = 0.9375f; public const float TAC_LET_H = 0.0625f; public const float TacoTexels = 3.125f; private const float RD = 0.078f; private const float SHELL_TH = 0.0017f; private const float PHI_MAX = (float)Math.PI * 13f / 30f; private const float FLARE = (float)Math.PI / 12f; private const float U_TURN = 0.54f; private const int NX = 27; private const int NSIDE = 13; public static void AddGrid(List<int> tris, int start, int nx, int na, bool flip) { for (int i = 0; i < nx - 1; i++) { for (int j = 0; j < na - 1; j++) { int num = start + i * na + j; int item = num + 1; int num2 = num + na; int item2 = num2 + 1; if (!flip) { tris.Add(num); tris.Add(item); tris.Add(num2); tris.Add(item); tris.Add(item2); tris.Add(num2); } else { tris.Add(num); tris.Add(num2); tris.Add(item); tris.Add(item); tris.Add(num2); tris.Add(item2); } } } } public static void AddQuad(List<int> tris, int a, int b, int c, int d) { tris.Add(a); tris.Add(b); tris.Add(c); tris.Add(a); tris.Add(c); tris.Add(d); } public static float FoldV(float center, float half, float arcMeters) { float num = half * 0.82f; if (num < 1E-05f) { return center; } float t = Mathf.Abs(arcMeters) * 3.125f; float num2 = 2f * num; float num3 = Repeat(t, 2f * num2); float num4 = ((num3 <= num2) ? (num3 / num2) : (2f - num3 / num2)); return center - num + 2f * num * num4; } private static float Repeat(float t, float length) { if (length <= 1E-09f) { return 0f; } float num = t - (float)Math.Floor(t / length) * length; if (!(num < 0f)) { return num; } return num + length; } private static float Hash01(int x, int y, int seed) { int num = x * 374761393 + y * 668265263 + seed * 1274126177; int num2 = (num ^ (num >>> 13)) * 1103515245; return (float)(uint)((num2 ^ (num2 >>> 16)) & 0xFFFFFF) / 16777215f; } private static float Noise2(float u, float v, int seed) { float num = 0f; float num2 = 0.65f; float num3 = 0f; float num4 = u; float num5 = v; for (int i = 0; i < 2; i++) { int num6 = Mathf.FloorToInt(num4); int num7 = Mathf.FloorToInt(num5); float num8 = num4 - (float)num6; float num9 = num5 - (float)num7; num8 = num8 * num8 * (3f - 2f * num8); num9 = num9 * num9 * (3f - 2f * num9); float num10 = Hash01(num6, num7, seed + i * 101); float num11 = Hash01(num6 + 1, num7, seed + i * 101); float num12 = Hash01(num6, num7 + 1, seed + i * 101); float num13 = Hash01(num6 + 1, num7 + 1, seed + i * 101); float num14 = Mathf.Lerp(Mathf.Lerp(num10, num11, num8), Mathf.Lerp(num12, num13, num8), num9); num += num2 * num14; num3 += num2; num2 *= 0.5f; num4 *= 2.13f; num5 *= 2.13f; } return num / num3; } private static void HalfSection(float S, int n, float[] z, float[] y, float[] phi) { float num = S / (float)n; z[0] = 0f; y[0] = 0f; phi[0] = 0f; for (int i = 1; i <= n; i++) { float num2 = ((float)i - 0.5f) / (float)n; float num3 = Mathf.Clamp01(num2 / 0.54f); float num4 = (float)Math.PI * 13f / 30f * Mathf.Pow(num3 * num3 * (3f - 2f * num3), 0.85f); if (num2 > 0.84f) { float num5 = (num2 - 0.84f) / 0.16f; num4 -= (float)Math.PI / 12f * num5 * num5; } phi[i] = num4; z[i] = z[i - 1] + Mathf.Cos(num4) * num; y[i] = y[i - 1] + Mathf.Sin(num4) * num; } } private static float ChordAt(float t) { float num = (t * 2f - 1f) * 0.078f; return Mathf.Sqrt(Mathf.Max(1E-06f, 0.006084f - num * num)); } private static float RimWave(float t, int side) { return 0.0013f * Mathf.Sin(t * 17.3f + (float)side * 1.9f) + 0.0009f * Mathf.Sin(t * 31.7f + (float)side * 4.2f + 1.1f); } public static void Taco(List<Vector3> verts, List<Vector2> uvs, List<int> tris) { //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_05b3: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_0a65: Unknown result type (might be due to invalid IL or missing references) //IL_0ba9: Unknown result type (might be due to invalid IL or missing references) //IL_08c4: Unknown result type (might be due to invalid IL or missing references) //IL_08fa: Unknown result type (might be due to invalid IL or missing references) int num = 28; float[] array = new float[14]; float[] array2 = new float[14]; float[] array3 = new float[14]; Vector3[,] array4 = new Vector3[27, num]; Vector3[,] array5 = new Vector3[27, num]; float[,] array6 = new float[27, num]; float[,] array7 = new float[27, 2]; float[] array8 = new float[27]; for (int i = 0; i < 27; i++) { float num2 = (float)i / 26f; float num3 = (num2 * 2f - 1f) * 0.078f; float num4 = ChordAt(num2); for (int j = 0; j < 2; j++) { int num5 = ((j != 0) ? 1 : (-1)); float num6 = num4 * ((num5 > 0) ? 1.03f : 1f); HalfSection(num6, 13, array, array2, array3); float num7 = RimWave(num2, num5); for (int k = 0; k <= 13; k++) { float num8 = 1f + 0.01f * (Noise2(num2 * 5f + (float)j * 9f, (float)k * 0.55f, 733) - 0.5f) * 2f; float num9 = array[k] * (float)num5 * num8; float num10 = array2[k] * num8; float num11 = Mathf.Clamp01(((float)k / 13f - 0.78f) / 0.22f); num10 += num7 * num11 * num11; float num12 = Mathf.Sin(array3[k]) * (float)num5; float num13 = 0f - Mathf.Cos(array3[k]); int num14 = ((num5 < 0) ? (13 - k) : (14 + k)); array4[i, num14] = new Vector3(num3, num10, num9); array5[i, num14] = new Vector3(num3, num10 + 0.0017f * (0f - num13), num9 - 0.0017f * num12); array6[i, num14] = ((num5 < 0) ? (num6 - (float)k * (num6 / 13f)) : (num6 + 0.004f + (float)k * (num6 / 13f))); } array7[i, j] = array2[13] * 1f + num7; } float num15 = Mathf.Min(array7[i, 0], array7[i, 1]) * 0.56f; float num16 = 0.0015f; for (int l = 0; l <= 13; l++) { if (array2[l] <= num15) { num16 = Mathf.Max(num16, array[l] - 0.0017f); } } array8[i] = num16; } int count = verts.Count; for (int m = 0; m < 27; m++) { float num17 = (float)m / 26f; for (int n = 0; n < num; n++) { verts.Add(array4[m, n]); uvs.Add(new Vector2(num17 * 2f * 0.078f * 3.125f, FoldV(5f / 32f, 5f / 32f, array6[m, n]))); } } AddGrid(tris, count, 27, num, flip: true); int count2 = verts.Count; for (int num18 = 0; num18 < 27; num18++) { float num19 = (float)num18 / 26f; for (int num20 = 0; num20 < num; num20++) { verts.Add(array5[num18, num20]); uvs.Add(new Vector2(num19 * 2f * 0.078f * 3.125f, FoldV(13f / 32f, 3f / 32f, array6[num18, num20]))); } } AddGrid(tris, count2, 27, num, flip: false); for (int num21 = 0; num21 < 2; num21++) { int num22 = ((num21 != 0) ? (num - 1) : 0); int count3 = verts.Count; for (int num23 = 0; num23 < 27; num23++) { float num24 = (float)num23 / 26f * 2f * 0.078f * 3.125f; verts.Add(array4[num23, num22]); uvs.Add(new Vector2(num24, 17f / 64f)); verts.Add(array5[num23, num22]); uvs.Add(new Vector2(num24, 0.340625f)); } AddGrid(tris, count3, 27, 2, num21 == 1); } int count4 = verts.Count; for (int num25 = 0; num25 < 27; num25++) { float num26 = 0.02f + 0.96f * (float)num25 / 26f; float num27 = (num26 * 2f - 1f) * 0.078f; int num28 = Math.Min(Math.Max(Mathf.RoundToInt(num26 * 26f), 0), 26); float num29 = array8[num28] * 0.99f; float num30 = Mathf.Min(array7[num28, 0], array7[num28, 1]); float num31 = Mathf.Sin(Mathf.Clamp01(num26) * (float)Math.PI); float num32 = num30 * (0.46f + 0.14f * num31); for (int num33 = 0; num33 < 13; num33++) { float num34 = (float)num33 / 12f; float num35 = (num34 * 2f - 1f) * num29; float num36 = 1f - Mathf.Pow(Mathf.Abs(num34 * 2f - 1f), 2.6f); float num37 = Noise2(num26 * 9.5f, num34 * 4.2f, 512) - 0.42f; float num38 = 0.0018f * Mathf.Clamp01((num34 - 0.5f) * 2f); float num39 = num32 + (0.0035f * num37 * 2f + 0.0022f * num31) * num36 + num38 * num36; if (num25 == 0 || num25 == 26) { num39 = num32 - 0.0045f; } verts.Add(new Vector3(num27, num39, num35)); uvs.Add(new Vector2(num27 * 3.125f * 1.4f, FoldV(19f / 32f, 3f / 32f, num34 * 2f * num29 * 1.4f))); } } AddGrid(tris, count4, 27, 13, flip: false); for (int num40 = 0; num40 < 3; num40++) { float num41 = num40 switch { 1 => -0.52f, 0 => -0.24f, _ => -0.02f, }; float num42 = num40 switch { 1 => 0.8f, 0 => 1f, _ => 0.62f, }; float num43 = (float)num40 * 2.6f + 0.7f; float num44 = ((num40 == 2) ? 0.22f : 0.08f); float num45 = ((num40 == 2) ? 0.66f : 0.92f); int count5 = verts.Count; for (int num46 = 0; num46 < 29; num46++) { float num47 = num44 + (num45 - num44) * (float)num46 / 28f; float num48 = (num47 * 2f - 1f) * 0.078f; int num49 = Math.Min(Math.Max(Mathf.RoundToInt(num47 * 26f), 0), 26); float num50 = array8[num49]; float num51 = Mathf.Min(array7[num49, 0], array7[num49, 1]); float num52 = Mathf.Sin(Mathf.Clamp01(num47) * (float)Math.PI); float num53 = num51 * (0.51f + 0.15f * num52); float num54 = num50 * num41; float num55 = Mathf.Clamp01(Mathf.Min(num47 - num44 + 0.02f, num45 + 0.02f - num47) / 0.09f); float num56 = 0.35f + 1.15f * Noise2(num47 * 11f + (float)num40 * 7f, (float)num40 * 3f, 917); float num57 = (0.55f + 0.55f * Mathf.Abs(Mathf.Sin(num47 * 47f + num43))) * num56 + 0.14f * Mathf.Sin(num47 * 103f + num43 * 2.3f); float num58 = Mathf.Clamp01(num50 / 0.024f); float num59 = 0.0058f * num42 * num57 * num55 * num58; float num60 = 0.0036f * num42 * num57 * num55 * num58; for (int num61 = 0; num61 < 9; num61++) { float num62 = (float)num61 / 8f; float num63 = Mathf.Lerp(-2.05f, 2.05f, num62); float num64 = Mathf.Clamp01(1f - Mathf.Abs(num62 - 0.5f) * 2f); float num65 = 1f + 0.3f * num64 * (Noise2(num47 * 33f, num62 * 5f + (float)num40 * 11f, 411) - 0.5f) * 2f; float num66 = num53 + num60 * Mathf.Cos(num63) * num65; float num67 = num54 + num59 * Mathf.Sin(num63) * 1.35f * num65; verts.Add(new Vector3(num48, num66, num67)); uvs.Add(new Vector2(num48 * 3.125f * 2.2f, FoldV(0.9375f, 0.0625f, (num63 + 2.05f) * 0.004f))); } } AddGrid(tris, count5, 29, 9, flip: false); } Random random = new Random(7331); for (int num68 = 0; num68 < 16; num68++) { float num69 = 0.13f + 0.74f * (float)random.NextDouble(); int num70 = Math.Min(Math.Max(Mathf.RoundToInt(num69 * 26f), 0), 26); float num71 = array8[num70] * (-0.34f + 0.78f * (float)random.NextDouble()); float num72 = Mathf.Min(array7[num70, 0], array7[num70, 1]) * (0.56f + 0.16f * Mathf.Sin(Mathf.Clamp01(num69) * (float)Math.PI)) + 0.002f + 0.0012f * (float)random.NextDouble(); float yaw = (float)(random.NextDouble() * 1.5 - 0.75 + Math.PI / 2.0); float len = 0.014f + 0.014f * (float)random.NextDouble(); float roll = (float)(random.NextDouble() * 0.9 - 0.45); Strand(verts, uvs, tris, new Vector3((num69 * 2f - 1f) * 0.078f, num72, num71), yaw, roll, len, 0.0019f, 0.0013f, 47f / 64f, 3f / 64f); } for (int num73 = 0; num73 < 7; num73++) { float num74 = 0.17f + 0.66f * ((float)num73 + 0.5f) / 7f + 0.03f * ((float)random.NextDouble() - 0.5f); int num75 = Math.Min(Math.Max(Mathf.RoundToInt(num74 * 26f), 0), 26); float num76 = array8[num75]; float num77 = num76 * ((num73 % 2 == 0) ? 0.26f : 0.04f) + num76 * 0.1f * ((float)random.NextDouble() - 0.5f); float num78 = Mathf.Min(array7[num75, 0], array7[num75, 1]) * (0.52f + 0.15f * Mathf.Sin(Mathf.Clamp01(num74) * (float)Math.PI)) - 0.0012f; float size = 0.0052f + 0.0016f * (float)random.NextDouble(); float yaw2 = (float)(random.NextDouble() * Math.PI); Dice(verts, uvs, tris, new Vector3((num74 * 2f - 1f) * 0.078f, num78, num77), size, yaw2, 53f / 64f, 3f / 64f); } } private static void Strand(List<Vector3> verts, List<Vector2> uvs, List<int> tris, Vector3 center, float yaw, float roll, float len, float w, float h, float vC, float vH) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Cos(yaw), 0f, Mathf.Sin(yaw)); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0f - Mathf.Sin(yaw), 0f, Mathf.Cos(yaw)); float num = Mathf.Cos(roll); float num2 = Mathf.Sin(roll); Vector3 val3 = val2 * num + Vector3.up * num2; Vector3 val4 = Vector3.up * num - val2 * num2; int count = verts.Count; for (int i = 0; i <= 3; i++) { float num3 = (float)i / 3f; float num4 = (num3 - 0.5f) * len; float num5 = -0.0022f * Mathf.Pow(Mathf.Abs(num3 * 2f - 1f), 1.6f); Vector3 val5 = center + val * num4 + Vector3.up * num5; for (int j = 0; j <= 4; j++) { int num6 = j % 4; float num7 = ((num6 == 0 || num6 == 3) ? (-0.5f) : 0.5f); float num8 = ((num6 < 2) ? 0.5f : (-0.5f)); verts.Add(val5 + val3 * (num7 * w) + val4 * (num8 * h)); uvs.Add(new Vector2(num3 * len * 3.125f * 3f, FoldV(vC, vH, (float)j * (w + h) * 0.5f))); } } AddGrid(tris, count, 4, 5, flip: true); } private static void Dice(List<Vector3> verts, List<Vector2> uvs, List<int> tris, Vector3 center, float size, float yaw, float vC, float vH) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Cos(yaw); float num2 = Mathf.Sin(yaw); Vector3[] array = (Vector3[])(object)new Vector3[3] { new Vector3(num, 0f, num2), new Vector3(0f, 1f, 0f), new Vector3(0f - num2, 0f, num) }; for (int i = 0; i < 6; i++) { int num3 = i / 2; float num4 = ((i % 2 == 0) ? 1f : (-1f)); int num5 = (num3 + 1) % 3; int num6 = (num3 + 2) % 3; int count = verts.Count; for (int j = 0; j <= 2; j++) { for (int k = 0; k <= 2; k++) { float num7 = (float)k - 1f; float num8 = (float)j - 1f; Vector3 val = array[num3] * num4 + array[num5] * num7 + array[num6] * num8; Vector3 val2 = val; Vector3 val3 = ((Vector3)(ref val)).normalized * 1.62f; Vector3 val4 = val2 * 0.62f + val3 * 0.38f; verts.Add(center + val4 * (size * 0.5f)); uvs.Add(new Vector2((float)(k + i) * size * 3.125f * 2f, FoldV(vC, vH, (float)j * size))); } } AddGrid(tris, count, 3, 3, (num4 > 0f) ? (num3 != 1) : (num3 == 1)); } } } public static class MeshBuild { public sealed class MeshData { public string Name; public Vector3[] Vertices; public Vector3[] Normals; public Vector2[] Uvs; public Vector4[] Tangents; public int[] Triangles; public int VertexCount { get { if (Vertices == null) { return 0; } return Vertices.Length; } } public int TriangleCount { get { if (Triangles == null) { return 0; } return Triangles.Length / 3; } } } public sealed class Report { public int Verts; public int Tris; public int Welds; public int Splits; public int HardVerts; public float DensU; public float DensV; public float Aniso; public override string ToString() { return string.Format("verts={0} tris={1} welded={2} hardSplits={3} texel u={4:0}/m v={5:0}/m aniso={6:0.00}:1{7}", Verts, Tris, Welds, Splits, DensU, DensV, Aniso, (Aniso > 2f) ? " WARN >2:1" : ""); } } public const float FoodSmoothAngle = 68f; public const float WeldEps = 2E-05f; public static MeshData Solve(string name, List<Vector3> verts, List<Vector2> uvs, List<int> tris, float smoothAngleDeg = 68f, Report report = null) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (uvs == null) { uvs = new List<Vector2>(); } while (uvs.Count < verts.Count) { uvs.Add(Vector2.zero); } Vector3[] array = SolveNormals(verts, uvs, tris, smoothAngleDeg, report); Vector4[] tangents = SolveTangents(verts, array, uvs, tris); MeshData meshData = new MeshData { Name = name, Vertices = verts.ToArray(), Normals = array, Uvs = uvs.ToArray(), Tangents = tangents, Triangles = tris.ToArray() }; if (report != null) { report.Verts = meshData.VertexCount; report.Tris = meshData.TriangleCount; Measure(meshData, out report.DensU, out report.DensV, out report.Aniso); } return meshData; } public static int[] WeldByPosition(List<Vector3> v, float eps, out int groupCount) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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) Dictionary<long, List<int>> dictionary = new Dictionary<long, List<int>>(v.Count * 2); List<Vector3> list = new List<Vector3>(v.Count); int[] array = new int[v.Count]; float num = 1f / eps; float num2 = eps * eps; for (int i = 0; i < v.Count; i++) { Vector3 val = v[i]; int num3 = FloorI(val.x * num); int num4 = FloorI(val.y * num); int num5 = FloorI(val.z * num); int num6 = -1; for (int j = -1; j <= 1; j++) { if (num6 >= 0) { break; } for (int k = -1; k <= 1; k++) { if (num6 >= 0) { break; } for (int l = -1; l <= 1; l++) { if (num6 >= 0) { break; } if (!dictionary.TryGetValue(CellKey(num3 + l, num4 + k, num5 + j), out var value)) { continue; } for (int m = 0; m < value.Count; m++) { Vector3 val2 = list[value[m]] - val; if (val2.x * val2.x + val2.y * val2.y + val2.z * val2.z <= num2) { num6 = value[m]; break; } } } } } if (num6 < 0) { num6 = list.Count; list.Add(val); long key = CellKey(num3, num4, num5); if (!dictionary.TryGetValue(key, out var value2)) { value2 = (dictionary[key] = new List<int>(2)); } value2.Add(num6); } array[i] = num6; } groupCount = list.Count; return array; } private static int FloorI(float f) { int num = (int)f; if (!(f < (float)num)) { return num; } return num - 1; } private static long CellKey(int x, int y, int z) { long num = (long)(x + 1048576) & 0x1FFFFFL; long num2 = (long)(y + 1048576) & 0x1FFFFFL; long num3 = (long)(z + 1048576) & 0x1FFFFFL; return (num << 42) | (num2 << 21) | num3; } public static Vector3[] SolveNormals(List<Vector3> verts, List<Vector2> uvs, List<int> tris, float smoothAngleDeg, Report report = null) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: 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_03b1: 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_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) int num = tris.Count / 3; Vector3[] array = (Vector3[])(object)new Vector3[num]; for (int i = 0; i < num; i++) { Vector3 val = verts[tris[i * 3]]; Vector3 val2 = verts[tris[i * 3 + 1]]; Vector3 val3 = verts[tris[i * 3 + 2]]; Vector3 val4 = Vector3.Cross(val2 - val, val3 - val); float magnitude = ((Vector3)(ref val4)).magnitude; array[i] = ((magnitude > 1E-14f) ? (val4 / magnitude) : Vector3.up); } int groupCount; int[] array2 = WeldByPosition(verts, 2E-05f, out groupCount); if (report != null) { report.Welds = verts.Count - groupCount; } List<int>[] array3 = new List<int>[groupCount]; for (int j = 0; j < num; j++) { for (int k = 0; k < 3; k++) { int num2 = array2[tris[j * 3 + k]]; if (array3[num2] == null) { array3[num2] = new List<int>(6); } array3[num2].Add(j * 3 + k); } } float num3 = Mathf.Cos(Mathf.Clamp(smoothAngleDeg, 1f, 179f) * ((float)Math.PI / 180f)); List<Vector3> list = new List<Vector3>(verts.Count); for (int l = 0; l < verts.Count; l++) { list.Add(Vector3.up); } Dictionary<int, int> dictionary = new Dictionary<int, int>(verts.Count); Dictionary<long, int> dictionary2 = new Dictionary<long, int>(); int num4 = 0; int num5 = 0; List<int> list2 = new List<int>(); for (int m = 0; m < groupCount; m++) { List<int> list3 = array3[m]; if (list3 == null) { continue; } int count = list3.Count; list2.Clear(); for (int n = 0; n < count; n++) { list2.Add(n); } for (int num6 = 0; num6 < count; num6++) { for (int num7 = num6 + 1; num7 < count; num7++) { if (!(Vector3.Dot(array[list3[num6] / 3], array[list3[num7] / 3]) < num3)) { int num8 = Find(list2, num6); int num9 = Find(list2, num7); if (num8 != num9) { list2[num9] = num8; } } } } Dictionary<int, Vector3> dictionary3 = new Dictionary<int, Vector3>(); for (int num10 = 0; num10 < count; num10++) { int key = Find(list2, num10); int num11 = list3[num10]; int num12 = num11 / 3; int slot = num11 % 3; float num13 = CornerAngle(verts, tris, num12, slot); dictionary3.TryGetValue(key, out var value); dictionary3[key] = value + array[num12] * num13; } foreach (int item in new List<int>(dictionary3.Keys)) { Vector3 val5 = dictionary3[item]; float magnitude2 = ((Vector3)(ref val5)).magnitude; dictionary3[item] = ((magnitude2 > 1E-14f) ? (val5 / magnitude2) : array[list3[item] / 3]); } if (dictionary3.Count > 1) { num5++; } for (int num14 = 0; num14 < count; num14++) { int index = list3[num14]; int num15 = Find(list2, num14); int num16 = tris[index]; if (!dictionary.TryGetValue(num16, out var value2)) { dictionary[num16] = num15; list[num16] = dictionary3[num15]; } else if (value2 != num15) { long key2 = ((long)num16 << 20) | (uint)num15; if (!dictionary2.TryGetValue(key2, out var value3)) { value3 = verts.Count; verts.Add(verts[num16]); uvs.Add((num16 < uvs.Count) ? uvs[num16] : Vector2.zero); list.Add(dictionary3[num15]); dictionary2[key2] = value3; num4++; } tris[index] = value3; } } } if (report != null) { report.Splits = num4; report.HardVerts = num5; } return list.ToArray(); } private static int Find(List<int> parent, int i) { while (parent[i] != i) { parent[i] = parent[parent[i]]; i = parent[i]; } return i; } private static float CornerAngle(List<Vector3> verts, List<int> tris, int f, int slot) { //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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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) Vector3 val = verts[tris[f * 3 + slot]]; Vector3 val2 = verts[tris[f * 3 + (slot + 1) % 3]]; Vector3 val3 = verts[tris[f * 3 + (slot + 2) % 3]]; Vector3 val4 = val2 - val; Vector3 val5 = val3 - val; float magnitude = ((Vector3)(ref val4)).magnitude; float magnitude2 = ((Vector3)(ref val5)).magnitude; if (magnitude < 1E-12f || magnitude2 < 1E-12f) { return 0f; } return Mathf.Acos(Mathf.Clamp(Vector3.Dot(val4, val5) / (magnitude * magnitude2), -1f, 1f)); } public static Vector4[] SolveTangents(List<Vector3> v, Vector3[] n, List<Vector2> uv, List<int> tris) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00a0: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: 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_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: 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_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0234: 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_023b: 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_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0346: 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_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_02de: 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_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: 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_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) int count = v.Count; Vector3[] array = (Vector3[])(object)new Vector3[count]; Vector3[] array2 = (Vector3[])(object)new Vector3[count]; Vector3 val7 = default(Vector3); Vector3 val8 = default(Vector3); for (int i = 0; i + 2 < tris.Count; i += 3) { int num = tris[i]; int num2 = tris[i + 1]; int num3 = tris[i + 2]; Vector3 val = v[num]; Vector3 val2 = v[num2]; Vector3 val3 = v[num3]; Vector2 val4 = uv[num]; Vector2 val5 = uv[num2]; Vector2 val6 = uv[num3]; float num4 = val2.x - val.x; float num5 = val3.x - val.x; float num6 = val2.y - val.y; float num7 = val3.y - val.y; float num8 = val2.z - val.z; float num9 = val3.z - val.z; float num10 = val5.x - val4.x; float num11 = val6.x - val4.x; float num12 = val5.y - val4.y; float num13 = val6.y - val4.y; float num14 = num10 * num13 - num11 * num12; if (!(Mathf.Abs(num14) < 1E-12f)) { float num15 = 1f / num14; ((Vector3)(ref val7))..ctor((num13 * num4 - num12 * num5) * num15, (num13 * num6 - num12 * num7) * num15, (num13 * num8 - num12 * num9) * num15); ((Vector3)(ref val8))..ctor((num10 * num5 - num11 * num4) * num15, (num10 * num7 - num11 * num6) * num15, (num10 * num9 - num11 * num8) * num15); ref Vector3 reference = ref array[num]; reference += val7; ref Vector3 reference2 = ref array[num2]; reference2 += val7; ref Vector3 reference3 = ref array[num3]; reference3 += val7; ref Vector3 reference4 = ref array2[num]; reference4 += val8; ref Vector3 reference5 = ref array2[num2]; reference5 += val8; ref Vector3 reference6 = ref array2[num3]; reference6 += val8; } } Vector4[] array3 = (Vector4[])(object)new Vector4[count]; for (int j = 0; j < count; j++) { Vector3 val9 = n[j]; Vector3 val10 = array[j]; if (((Vector3)(ref val10)).sqrMagnitude < 1E-16f) { val10 = Vector3.Cross((Mathf.Abs(val9.y) < 0.9f) ? Vector3.up : Vector3.right, val9); } Vector3 val11 = val10 - val9 * Vector3.Dot(val9, val10); float magnitude = ((Vector3)(ref val11)).magnitude; if (magnitude < 1E-12f) { val11 = Vector3.Cross((Mathf.Abs(val9.y) < 0.9f) ? Vector3.up : Vector3.right, val9); magnitude = ((Vector3)(ref val11)).magnitude; if (magnitude < 1E-12f) { array3[j] = new Vector4(1f, 0f, 0f, 1f); continue; } } val11 /= magnitude; float num16 = ((Vector3.Dot(Vector3.Cross(val9, val11), array2[j]) < 0f) ? (-1f) : 1f); array3[j] = new Vector4(val11.x, val11.y, val11.z, num16); } return array3; } public static void Measure(MeshData m, out float densU, out float densV, out float aniso) { //IL_004f: 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_0067: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) densU = (densV = (aniso = 0f)); if (m == null || m.Triangles == null || m.Triangles.Length < 3) { return; } List<float> list = new List<float>(); List<float> list2 = new List<float>(); for (int i = 0; i + 2 < m.Triangles.Length; i += 3) { Vector3 val = m.Vertices[m.Triangles[i]]; Vector3 val2 = m.Vertices[m.Triangles[i + 1]]; Vector3 val3 = m.Vertices[m.Triangles[i + 2]]; Vector2 val4 = m.Uvs[m.Triangles[i]]; Vector2 val5 = m.Uvs[m.Triangles[i + 1]]; Vector2 val6 = m.Uvs[m.Triangles[i + 2]]; Vector3 val7 = val2 - val; Vector3 val8 = val3 - val; float magnitude = ((Vector3)(ref val7)).magnitude; if (magnitude < 1E-09f) { continue; } Vector3 val9 = val7 / magnitude; Vector3 val10 = val8 - val9 * Vector3.Dot(val8, val9); float magnitude2 = ((Vector3)(ref val10)).magnitude; if (!(magnitude2 < 1E-09f)) { float num = Vector3.Dot(val8, val9); Vector2 val11 = val5 - val4; Vector2 val12 = val6 - val4; Vector2 val13 = val11 / magnitude; Vector2 val14 = (val12 - val13 * num) / magnitude2; float x = val13.x; float x2 = val14.x; float y = val13.y; float y2 = val14.y; float num2 = (x * x + x2 * x2 + y * y + y2 * y2) * 0.5f; float num3 = x * y2 - x2 * y; float num4 = Mathf.Sqrt(Mathf.Max(0f, num2 * num2 - num3 * num3)); float num5 = Mathf.Sqrt(Mathf.Max(0f, num2 + num4)); float item = Mathf.Sqrt(Mathf.Max(0f, num2 - num4)); if (!(num5 < 1E-09f)) { list.Add(num5); list2.Add(item); } } } if (list.Count != 0) { list.Sort(); list2.Sort(); float num6 = list[list.Count / 2]; float num7 = list2[list2.Count / 2]; densU = num6; densV = num7; aniso = ((num7 > 1E-09f) ? (num6 / num7) : 999f); } } } public static class MeshUpload { public static Mesh Build(string name, List<Vector3> verts, List<Vector2> uvs, List<int> tris, float smoothAngleDeg = 68f, bool log = true) { MeshBuild.Report report = (log ? new MeshBuild.Report() : null); Mesh result = Upload(MeshBuild.Solve(name, verts, uvs, tris, smoothAngleDeg, report)); if (report != null) { try { Diag.Log($"[Art] mesh '{name}' {report}"); } catch { } } return result; } public static Mesh Upload(MeshBuild.MeshData d) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown Mesh val = new Mesh(); ((Object)val).name = d.Name; if (d.VertexCount > 65000) { try { val.indexFormat = (IndexFormat)1; } catch (Exception ex) { MelonLogger.Warning("[Art] 32-bit indices unavailable: " + ex.Message); } } val.SetVertices(Il2CppStructArray<Vector3>.op_Implicit(d.Vertices)); val.SetUVs(0, Il2CppStructArray<Vector2>.op_Implicit(d.Uvs)); val.normals = Il2CppStructArray<Vector3>.op_Implicit(d.Normals); val.triangles = Il2CppStructArray<int>.op_Implicit(d.Triangles); if (d.Tangents != null && d.Tangents.Length == d.VertexCount) { val.tangents = Il2CppStructArray<Vector4>.op_Implicit(d.Tangents); } else { val.RecalculateTangents(); } val.RecalculateBounds(); ((Object)val).hideFlags = (HideFlags)32; return val; } } public sealed class SurfaceRecipe { public string Key; public float GrainFreq; public float GrainAmp; public float CellFreq; public float CellAmp; public int FreckleCount; public float NormalStrength; public float SmoothMin; public float SmoothMax; public float AoStrength; public float AlbedoShadeAmp; public static readonly SurfaceRecipe TortillaOuter = new SurfaceRecipe("tortilla", 28f, 0.45f, 0f, 0f, 14, 1.25f, 0.06f, 0.42f, 0.75f, 0.16f); public static readonly SurfaceRecipe TortillaInner = new SurfaceRecipe("tortilla_inner", 36f, 0.4f, 0f, 0f, 6, 1f, 0.06f, 0.3f, 0.65f, 0.12f); public static readonly SurfaceRecipe Filling = new SurfaceRecipe("filling", 22f, 0.3f, 9f, 0.6f, 0, 1.6f, 0.3f, 0.58f, 0.9f, 0.14f); public static readonly SurfaceRecipe LiquidFill = new SurfaceRecipe("liquid", 30f, 0.05f, 0f, 0f, 0, 0.35f, 0.52f, 0.68f, 0.2f, 0.03f); public static readonly SurfaceRecipe Vessel = new SurfaceRecipe("vessel", 40f, 0.06f, 0f, 0f, 0, 0.4f, 0.38f, 0.48f, 0.25f, 0.04f); public static readonly SurfaceRecipe Topping = new SurfaceRecipe("topping", 18f, 0.45f, 12f, 0.35f, 0, 1.2f, 0.1f, 0.3f, 0.8f, 0.14f); public static readonly SurfaceRecipe BurroitoHero = new SurfaceRecipe("burroito", 24f, 0.2f, 0f, 0f, 0, 1.05f, 0.05f, 0.4f, 0.75f, 0.1f); public SurfaceRecipe(string key, float grainFreq, float grainAmp, float cellFreq, float cellAmp, int freckles, float normalStrength, float smoothMin, float smoothMax, float ao, float shadeAmp) { Key = key; GrainFreq = grainFreq; GrainAmp = grainAmp; CellFreq = cellFreq; CellAmp = cellAmp; FreckleCount = freckles; NormalStrength = normalStrength; SmoothMin = smoothMin; SmoothMax = smoothMax; AoStrength = ao; AlbedoShadeAmp = shadeAmp; } } public static class TexGen { public sealed class TexSet { public int Size; public byte[] Albedo; public byte[] Normal; public byte[] Mos; public long GenMs; } public static readonly HashSet<string> SmoothFillKeys = new HashSet<string>(StringComparer.OrdinalIgnoreCase); public static int StableHash(string s) { uint num = 2166136261u; if (s != null) { for (int i = 0; i < s.Length; i++) { num ^= char.ToLowerInvariant(s[i]); num *= 16777619; } } return (int)(num & 0x7FFFFFFF); } private static float Hash(int x, int y, int seed) { int num = x * 374761393 + y * 668265263 + seed * 1274126177; int num2 = (num ^ (num >>> 13)) * 1103515245; return (float)(uint)((num2 ^ (num2 >>> 16)) & 0xFFFFFF) / 16777215f; } private static int Mod(int a, int m) { int num = a % m; if (num >= 0) { return num; } return num + m; } private static float ValueNoise(float u, float v, int period, int seed) { float num = u * (float)period; float num2 = v * (float)period; int num3 = (int)Math.Floor(num); int num4 = (int)Math.Floor(num2); float num5 = num - (float)num3; float num6 = num2 - (float)num4; num5 = num5 * num5 * (3f - 2f * num5); num6 = num6 * num6 * (3f - 2f * num6); int x = Mod(num3, period); int x2 = Mod(num3 + 1, period); int y = Mod(num4, period); int y2 = Mod(num4 + 1, period); float num7 = Hash(x, y, seed); float num8 = Hash(x2, y, seed); float num9 = Hash(x, y2, seed); float num10 = Hash(x2, y2, seed); return num7 + (num8 - num7) * num5 + (num9 + (num10 - num9) * num5 - (num7 + (num8 - num7) * num5)) * num6; } private static float Fbm(float u, float v, float baseFreq, int seed) { float num = 0f; float num2 = 0.5f; float num3 = 0f; int num4 = Math.Max(2, (int)baseFreq); for (int i = 0; i < 4; i++) { num += num2 * ValueNoise(u, v, num4, seed + i * 101); num3 += num2; num2 *= 0.5f; num4 *= 2; } return num / num3; } private static float Worley(float u, float v, int cells, int seed) { float num = u * (float)cells; float num2 = v * (float)cells; int num3 = (int)Math.Floor(num); int num4 = (int)Math.Floor(num2); float num5 = 9f; for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { int num6 = num3 + j; int num7 = num4 + i; float num8 = (float)num6 + Hash(Mod(num6, cells), Mod(num7, cells), seed); float num9 = (float)num7 + Hash(Mod(num6, cells), Mod(num7, cells), seed + 7919); float num10 = num - num8; float num11 = num2 - num9; float num12 = num10 * num10 + num11 * num11; if (num12 < num5) { num5 = num12; } } } float num13 = (float)Math.Sqrt(num5); float num14 = 1f - Mathf.Clamp01(num13 * 1.4f); return num14 * num14 * (3f - 2f * num14); } private static void Blobs(float[] field, int w, int h, Random rng, int count, float rMin, float rMax, float iMin, float iMax, int yMin, int yMax) { for (int i = 0; i < count; i++) { float num = (float)(rng.NextDouble() * (double)w); float num2 = (float)yMin + (float)(rng.NextDouble() * (double)(yMax - yMin)); float num3 = rMin + (float)rng.NextDouble() * (rMax - rMin); float num4 = iMin + (float)rng.NextDouble() * (iMax - iMin); float num5 = (float)(rng.NextDouble() * 6.28); float num6 = (float)(rng.NextDouble() * 6.28); float num7 = 0.22f + 0.2f * (float)rng.NextDouble(); float num8 = 0.12f + 0.15f * (float)rng.NextDouble(); int num9 = Mathf.CeilToInt(num3 * 1.6f); for (int j = -num9; j <= num9; j++) { for (int k = -num9; k <= num9; k++) { float num10 = Mathf.Atan2((float)j, (float)k); float num11 = num3 * (1f + num7 * Mathf.Sin(3f * num10 + num5) + num8 * Mathf.Sin(5f * num10 + num6)); float num12 = Mathf.Sqrt((float)(k * k + j * j)) / Mathf.Max(1f, num11); if (!(num12 >= 1f)) { float num13 = (1f - num12) * (1f - num12) * (3f - 2f * (1f - num12)); int num14 = Mod((int)num + k, w); int num15 = (int)num2 + j; if (num15 >= yMin && num15 < yMax) { field[num15 * w + num14] += num4 * num13; } } } } } } private static float[] BoxBlur(float[] src, int w, int h, int r) { float[] array = new float[w * h]; float[] array2 = new float[w * h]; float num = 1f / (float)(2 * r + 1); for (int i = 0; i < h; i++) { int num2 = i * w; for (int j = 0; j < w; j++) { float num3 = 0f; for (int k = -r; k <= r; k++) { num3 += src[num2 + Mod(j + k, w)]; } array[num2 + j] = num3 * num; } } for (int l = 0; l < w; l++) { for (int m = 0; m < h; m++) { float num4 = 0f; for (int n = -r; n <= r; n++) { int num5 = m + n; if (num5 < 0) { num5 = 0; } else if (num5 >= h) { num5 = h - 1; } num4 += array[num5 * w + l]; } array2[m * w + l] = num4 * num; } } return array2; } private static float[] BakeAo(float[] height, int w, int h, float strength) { float[] array = BoxBlur(height, w, h, Math.Max(2, w / 128)); float[] array2 = BoxBlur(height, w, h, Math.Max(8, w / 32)); float[] array3 = new float[w * h]; for (int i = 0; i < array3.Length; i++) { float num = Mathf.Clamp01((array[i] - height[i]) * 2.4f) * 0.6f + Mathf.Clamp01((array2[i] - height[i]) * 1.6f) * 0.4f; array3[i] = Mathf.Clamp(1f - num * strength, 0.45f, 1f); } return array3; } private static void BakeNormal(float[] height, int w, int h, float[] strengthMap, byte[] outRgba) { for (int i = 0; i < h; i++) { int num = ((i > 0) ? (i - 1) : 0); int num2 = ((i < h - 1) ? (i + 1) : (h - 1)); for (int j = 0; j < w; j++) { int num3 = Mod(j - 1, w); int num4 = Mod(j + 1, w); float num5 = height[num * w + num4] + 2f * height[i * w + num4] + height[num2 * w + num4] - (height[num * w + num3] + 2f * height[i * w + num3] + height[num2 * w + num3]); float num6 = height[num2 * w + num3] + 2f * height[num2 * w + j] + height[num2 * w + num4] - (height[num * w + num3] + 2f * height[num * w + j] + height[num * w + num4]); float num7 = strengthMap[i * w + j]; float num8 = (0f - num5) * num7; float num9 = (0f - num6) * num7; float num10 = 1f; float num11 = Mathf.Sqrt(num8 * num8 + num9 * num9 + num10 * num10); num8 /= num11; num9 /= num11; num10 /= num11; int num12 = (i * w + j) * 4; outRgba[num12] = (byte)Mathf.Clamp((num8 * 0.5f + 0.5f) * 255f, 0f, 255f); outRgba[num12 + 1] = (byte)Mathf.Clamp((num9 * 0.5f + 0.5f) * 255f, 0f, 255f); outRgba[num12 + 2] = (byte)Mathf.Clamp((num10 * 0.5f + 0.5f) * 255f, 0f, 255f); outRgba[num12 + 3] = byte.MaxValue; } } } private static void WriteRgb(byte[] buf, int i, float r, float g, float b, byte a = byte.MaxValue) { buf[i] = (byte)Mathf.Clamp(r * 255f, 0f, 255f); buf[i + 1] = (byte)Mathf.Clamp(g * 255f, 0f, 255f); buf[i + 2] = (byte)Mathf.Clamp(b * 255f, 0f, 255f); buf[i + 3] = a; } public static TexSet BuildBurroitoSet() { //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0309: 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_033c: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_034d: 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_0393: Unknown result type (might be due to invalid IL or missing references) Stopwatch stopwatch = Stopwatch.StartNew(); SurfaceRecipe burroitoHero = SurfaceRecipe.BurroitoHero; Random rng = new Random(420069); float[] array = new float[262144]; Blobs(array, 512, 512, rng, 190, 4.8f, 10.4f, 0.22f, 0.5f, 0, 512); Blobs(array, 512, 512, rng, 72, 11f, 20f, 0.32f, 0.62f, 0, 512); Blobs(array, 512, 512, rng, 10, 24f, 36f, 0.42f, 0.72f, 0, 512); float[] array2 = new float[262144]; for (int i = 0; i < 512; i++) { float v = ((float)i + 0.5f) / 512f; for (int j = 0; j < 512; j++) { float u = ((float)j + 0.5f) / 512f; float num = Fbm(u, v, burroitoHero.GrainFreq, 11); float num2 = Fbm(u, v, 96f, 23); float num3 = Mathf.Clamp01(array[i * 512 + j]); float num4 = 0.3f + burroitoHero.GrainAmp * (num - 0.5f) + 0.06f * (num2 - 0.5f) + 0.45f * num3 * num3 * (3f - 2f * num3); if (i >= 192 && i < 240) { float num5 = ((float)i - 216f) / 20f; num4 -= 0.3f * Mathf.Exp((0f - num5) * num5); } array2[i * 512 + j] = Mathf.Clamp01(num4); } } TexSet texSet = new TexSet { Size = 512, Albedo = new byte[1048576], Normal = new byte[1048576], Mos = new byte[1048576] }; Color val = default(Color); ((Color)(ref val))..ctor(0.78f, 0.68f, 0.52f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.63f, 0.45f, 0.25f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.4f, 0.25f, 0.12f); Color val4 = default(Color); ((Color)(ref val4))..ctor(0.86f, 0.8f, 0.68f); float[] array3 = new float[262144]; for (int k = 0; k < 512; k++) { float num6 = ((k >= 256 && k < 480) ? 0.12f : 0f); for (int l = 0; l < 512; l++) { int num7 = k * 512 + l; float u2 = ((float)l + 0.5f) / 512f; float v2 = ((float)k + 0.5f) / 512f; float num8 = Mathf.Clamp01(array[num7] + num6); float num9 = num8 * num8; Color val5 = Color.Lerp(val2, val3, num9); Color val6 = Color.Lerp(val, val5, Mathf.Clamp01(num8 * 0.92f)); float num10 = Mathf.Clamp01((Fbm(u2, v2, 6f, 71) - 0.58f) / 0.12f) * (1f - num8); val6 = Color.Lerp(val6, val4, num10 * 0.55f); float num11 = 1f + burroitoHero.AlbedoShadeAmp * (Fbm(u2, v2, 10f, 37) - 0.5f); WriteRgb(texSet.Albedo, num7 * 4, val6.r * num11, val6.g * num11, val6.b * num11); float num12 = burroitoHero.SmoothMin + (burroitoHero.SmoothMax - burroitoHero.SmoothMin) * Mathf.Pow(num8, 1.6f) + 0.05f * (Fbm(u2, v2, 64f, 53) - 0.5f); num12 = Mathf.Lerp(num12, 0.04f, num10); texSet.Mos[num7 * 4] = 0; texSet.Mos[num7 * 4 + 3] = (byte)Mathf.Clamp(num12 * 255f, 0f, 255f); texSet.Mos[num7 * 4 + 2] = 0; array3[num7] = burroitoHero.NormalStrength; } } float[] array4 = BakeAo(array2, 512, 512, burroitoHero.AoStrength); for (int m = 0; m < 262144; m++) { texSet.Mos[m * 4 + 1] = (byte)Mathf.Clamp(array4[m] * 255f, 0f, 255f); } BakeNormal(array2, 512, 512, array3, texSet.Normal); stopwatch.Stop(); texSet.GenMs = stopwatch.ElapsedMilliseconds; return texSet; } public static TexSet BuildBandedSet(string variantKey, Taco3D.FillingLook look) { //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_026a: 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_0140: 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_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: 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_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: 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_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) Stopwatch stopwatch = Stopwatch.StartNew(); Random random = new Random(42 + StableHash(variantKey)); bool flag = SmoothFillKeys.Contains(variantKey); float[] array = new float[65536]; float[] array2 = new float[65536]; TexSet texSet = new TexSet { Size = 256, Albedo = new byte[262144], Normal = new byte[262144], Mos = new byte[262144] }; float[] array3 = new float[65536]; Blobs(array3, 256, 256, random, SurfaceRecipe.TortillaOuter.FreckleCount, 3f, 8f, 0.35f, 0.8f, 0, 32); Color val = default(Color); ((Color)(ref val))..ctor(0.74f, 0.61f, 0.34f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.64f, 0.46f, 0.22f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.66f, 0.51f, 0.27f); int num = 16; Color[,] array4 = new Color[num, num]; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { int num2 = i * 16 + 8; Color val4; if (num2 < 32) { val4 = ((random.NextDouble() < 0.06) ? val2 : val); } else if (num2 < 64) { val4 = val3; } else if (num2 < 128) { double num3 = random.NextDouble(); val4 = ((num3 < 0.72) ? look.Primary : ((num3 < 0.96) ? look.Secondary : look.Accent)); float num4 = 1f + 0.05f * ((float)random.NextDouble() - 0.5f); ((Color)(ref val4))..ctor(Mathf.Clamp01(val4.r * num4), Mathf.Clamp01(val4.g * num4), Mathf.Clamp01(val4.b * num4)); } else if (num2 < 224) { Color accent = look.Accent; val4 = (Color)((random.NextDouble() < 0.07) ? new Color(accent.r * 0.86f, accent.g * 0.86f, accent.b * 0.86f) : accent); } else { val4 = ((random.NextDouble() < 0.7) ? look.LettuceA : look.LettuceB); } array4[j, i] = val4; } } for (int k = 0; k < 256; k++) { SurfaceRecipe surfaceRecipe = ((k < 32) ? SurfaceRecipe.TortillaOuter : ((k < 64) ? SurfaceRecipe.TortillaInner : ((k >= 128) ? ((k < 224) ? SurfaceRecipe.Vessel : SurfaceRecipe.Topping) : (flag ? SurfaceRecipe.LiquidFill : SurfaceRecipe.Filling)))); for (int l = 0; l < 256; l++) { int num5 = k * 256 + l; float u = ((float)l + 0.5f) / 256f; float v = ((float)k + 0.5f) / 256f; float num6 = Fbm(u, v, surfaceRecipe.GrainFreq, 17); float num7 = ((surfaceRecipe.CellFreq > 0f) ? Worley(u, v, (int)surfaceRecipe.CellFreq, 29) : 0f); float num8 = 0.35f + surfaceRecipe.GrainAmp * (num6 - 0.5f) + surfaceRecipe.CellAmp * num7 + 0.5f * Mathf.Clamp01(array3[num5]); array[num5] = Mathf.Clamp01(num8); array2[num5] = surfaceRecipe.NormalStrength; Color val5 = array4[l / 16, k / 16]; float num9 = 1f + surfaceRecipe.AlbedoShadeAmp * (array[num5] - 0.45f); WriteRgb(texSet.Albedo, num5 * 4, val5.r * num9, val5.g * num9, val5.b * num9); float num10 = ((surfaceRecipe.CellFreq > 0f) ? Mathf.Max(num7, Mathf.Clamp01(array3[num5])) : Mathf.Clamp01(array3[num5] + 0.4f * (num6 - 0.5f))); float num11 = surfaceRecipe.SmoothMin + (surfaceRecipe.SmoothMax - surfaceRecipe.SmoothMin) * Mathf.Clamp01(num10) + 0.05f * (Fbm(u, v, 48f, 61) - 0.5f); texSet.Mos[num5 * 4] = 0; texSet.Mos[num5 * 4 + 2] = 0; texSet.Mos[num5 * 4 + 3] = (byte)Mathf.Clamp(num11 * 255f, 0f, 255f); } } float[] array5 = BakeAo(array, 256, 256, 0.8f); for (int m = 0; m < 65536; m++) { texSet.Mos[m * 4 + 1] = (byte)Mathf.Clamp(array5[m] * 255f, 0f, 255f); } BakeNormal(array, 256, 256, array2, texSet.Normal); stopwatch.Stop(); texSet.GenMs = stopwatch.ElapsedMilliseconds; return texSet; } public static TexSet BuildTacoSet(string variantKey, Taco3D.FillingLook look) { //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_033c: 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_02ef: 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) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_07ca: Unknown result type (might be due to invalid IL or missing references) //IL_07d4: Unknown result type (might be due to invalid IL or missing references) //IL_07de: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_05fc: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Unknown result type (might be due to invalid IL or missing references) //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_0607: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_05aa: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_0575: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_070f: Unknown result type (might be due to invalid IL or missing references) //IL_0715: Unknown result type (might be due to invalid IL or missing references) //IL_071c: Unknown result type (might be due to invalid IL or missing references) //IL_0721: Unknown result type (might be due to invalid IL or missing references) //IL_06cd: Unknown result type (might be due to invalid IL or missing references) //IL_06cf: Unknown result type (might be due to invalid IL or missing references) //IL_06d3: Unknown result type (might be due to invalid IL or missing references) //IL_06d8: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_0622: Unknown result type (might be due to invalid IL or missing references) //IL_072c: Unknown result type (might be due to invalid IL or missing references) //IL_073d: Unknown result type (might be due to invalid IL or missing references) //IL_0750: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Unknown result type (might be due to invalid IL or missing references) //IL_0760: Unknown result type (might be due to invalid IL or missing references) //IL_0771: Unknown result type (might be due to invalid IL or missing references) //IL_077b: Unknown result type (might be due to invalid IL or missing references) //IL_0780: Unknown result type (might be due to invalid IL or missing references) Stopwatch stopwatch = Stopwatch.StartNew(); Random rng = new Random(42 + StableHash(variantKey)); bool flag = string.Equals(variantKey, "tacokylespecial", StringComparison.OrdinalIgnoreCase); float[] array = new float[262144]; float[] array2 = new float[262144]; TexSet texSet = new TexSet { Size = 512, Albedo = new byte[1048576], Normal = new byte[1048576], Mos = new byte[1048576] }; float[] array3 = new float[262144]; Blobs(array3, 512, 512, rng, 150, 4f, 9f, 0.25f, 0.55f, 0, 160); Blobs(array3, 512, 512, rng, 40, 10f, 18f, 0.35f, 0.65f, 0, 160); float[] array4 = new float[262144]; Blobs(array4, 512, 512, rng, 60, 2.2f, 5f, 0.5f, 0.95f, 0, 160); Color val = default(Color); ((Color)(ref val))..ctor(0.93f, 0.72f, 0.34f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.72f, 0.46f, 0.16f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.34f, 0.21f, 0.1f); Color val4 = default(Color); ((Color)(ref val4))..ctor(0.93f, 0.8f, 0.51f); Color val5 = default(Color); ((Color)(ref val5))..ctor(0.83f, 0.68f, 0.4f); Color val6 = default(Color); ((Color)(ref val6))..ctor(0.97f, 0.67f, 0.2f); Color val7 = default(Color); ((Color)(ref val7))..ctor(0.87f, 0.53f, 0.14f); Color val8 = default(Color); ((Color)(ref val8))..ctor(0.76f, 0.17f, 0.12f); Color val9 = default(Color); ((Color)(ref val9))..ctor(0.58f, 0.1f, 0.08f); Color val10 = default(Color); ((Color)(ref val10))..ctor(0.94f, 0.86f, 0.62f); Color val11 = default(Color); ((Color)(ref val11))..ctor(0.96f, 0.95f, 0.9f); Color val12 = default(Color); ((Color)(ref val12))..ctor(0.86f, 0.84f, 0.76f); for (int i = 0; i < 512; i++) { for (int j = 0; j < 512; j++) { int num = i * 512 + j; float num2 = ((float)j + 0.5f) / 512f; float num3 = ((float)i + 0.5f) / 512f; float num7; Color val13; float num8; if (i < 160) { float num4 = Fbm(num2, num3, 34f, 11); float num5 = Mathf.Clamp01(array3[num]); float num6 = Mathf.Clamp01(array4[num]); num7 = 0.3f + 0.24f * (num4 - 0.5f) + 0.5f * num5 * num5 * (3f - 2f * num5); val13 = Color.Lerp(val, val2, Mathf.Clamp01(num5 * 1.6f)); if (num4 > 0.56f) { val13 = Color.Lerp(val13, new Color(0.95f, 0.82f, 0.5f), Mathf.Clamp01((num4 - 0.56f) * 3.2f) * 0.45f); } val13 = Color.Lerp(val13, val3, Mathf.Clamp01((num6 - 0.34f) * 1.5f)); if (Fbm(num2, num3, 90f, 43) > 0.64f) { val13 = Color.Lerp(val13, val2, 0.45f); } num8 = 0.16f + 0.36f * Mathf.Pow(num5, 1.4f) + 0.05f * (num4 - 0.5f); array2[num] = 1.35f; } else if (i < 256) { float num9 = Fbm(num2, num3, 44f, 19); num7 = 0.32f + 0.16f * (num9 - 0.5f); val13 = Color.Lerp(val5, val4, num9); num8 = 0.08f + 0.1f * num9; array2[num] = 0.9f; } else if (i < 352) { float num10 = Worley(num2, num3, 26, 29); float num11 = Fbm(num2, num3, 30f, 17); num7 = 0.26f + 0.52f * num10 + 0.12f * (num11 - 0.5f); float num12 = Fbm(num2, num3, 9f, 57); val13 = Color.Lerp(look.Primary, look.Secondary, Mathf.Clamp01((num12 - 0.35f) * 2.2f)); val13 = Color.Lerp(new Color(val13.r * 0.55f, val13.g * 0.5f, val13.b * 0.5f), val13, Mathf.Clamp01(0.25f + num10)); if (Fbm(num2, num3, 70f, 83) > 0.66f) { val13 = Color.Lerp(val13, look.Accent, 0.65f); } num8 = 0.24f + 0.32f * num10; array2[num] = 1.6f; } else if (i < 400) { float num13 = Fbm(num2 * 1f, num3 * 6f, 12f, 31); float num14 = Fbm(num2, num3, 60f, 37); num7 = 0.34f + 0.18f * (num13 - 0.5f) + 0.06f * (num14 - 0.5f);