Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of HomesteadPack v1.0.13
HomesteadPack.dll
Decompiled 2 weeks 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.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Extensions; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: AssemblyCompany("HomesteadPack")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.13.0")] [assembly: AssemblyInformationalVersion("1.0.13")] [assembly: AssemblyProduct("HomesteadPack")] [assembly: AssemblyTitle("HomesteadPack")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.13.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace HomesteadPack { internal sealed class Canvas2D { public readonly int W; public readonly int H; private readonly Color[] _px; public Color[] Pixels => _px; public Canvas2D(int w, int h, Color? fill = null) { //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) W = w; H = h; _px = (Color[])(object)new Color[w * h]; if (fill.HasValue) { for (int i = 0; i < _px.Length; i++) { _px[i] = fill.Value; } } } public static Canvas2D FromPixels(int w, int h, Color[] px) { Canvas2D canvas2D = new Canvas2D(w, h); Array.Copy(px, canvas2D._px, Math.Min(px.Length, canvas2D._px.Length)); return canvas2D; } public Color Get(int x, int y) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) return _px[y * W + x]; } public void Set(int x, int y, Color c) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (x >= 0 && y >= 0 && x < W && y < H) { _px[y * W + x] = c; } } private void Blend(int x, int y, Color c, float cover) { //IL_001b: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) if (x < 0 || y < 0 || x >= W || y >= H) { return; } float num = Mathf.Clamp01(c.a * cover); if (!(num <= 0f)) { Color val = _px[y * W + x]; float num2 = num + val.a * (1f - num); if (!(num2 <= 0f)) { _px[y * W + x] = new Color((c.r * num + val.r * val.a * (1f - num)) / num2, (c.g * num + val.g * val.a * (1f - num)) / num2, (c.b * num + val.b * val.a * (1f - num)) / num2, num2); } } } public void FillRect(float x0, float y0, float x1, float y1, Color c) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) for (int i = Mathf.Max(0, Mathf.FloorToInt(y0)); i < Mathf.Min(H, Mathf.CeilToInt(y1)); i++) { for (int j = Mathf.Max(0, Mathf.FloorToInt(x0)); j < Mathf.Min(W, Mathf.CeilToInt(x1)); j++) { float num = Mathf.Clamp01(Mathf.Min((float)(j + 1), x1) - Mathf.Max((float)j, x0)); float num2 = Mathf.Clamp01(Mathf.Min((float)(i + 1), y1) - Mathf.Max((float)i, y0)); Blend(j, i, c, num * num2); } } } public void FillEllipse(float cx, float cy, float rx, float ry, Color c) { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(0, Mathf.FloorToInt(cx - rx - 1f)); int num2 = Mathf.Min(W - 1, Mathf.CeilToInt(cx + rx + 1f)); int num3 = Mathf.Max(0, Mathf.FloorToInt(cy - ry - 1f)); int num4 = Mathf.Min(H - 1, Mathf.CeilToInt(cy + ry + 1f)); for (int i = num3; i <= num4; i++) { for (int j = num; j <= num2; j++) { float num5 = ((float)j + 0.5f - cx) / rx; float num6 = ((float)i + 0.5f - cy) / ry; float num7 = Mathf.Sqrt(num5 * num5 + num6 * num6); float num8 = 1f / Mathf.Min(rx, ry); float num9 = Mathf.Clamp01((1f - num7) / num8 + 0.5f); if (num9 > 0f) { Blend(j, i, c, num9); } } } } public void FillCircle(float cx, float cy, float r, Color c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) FillEllipse(cx, cy, r, r, c); } public void Line(float ax, float ay, float bx, float by, float width, Color c) { //IL_012a: Unknown result type (might be due to invalid IL or missing references) float num = width * 0.5f; int num2 = Mathf.Max(0, Mathf.FloorToInt(Mathf.Min(ax, bx) - num - 1f)); int num3 = Mathf.Min(W - 1, Mathf.CeilToInt(Mathf.Max(ax, bx) + num + 1f)); int num4 = Mathf.Max(0, Mathf.FloorToInt(Mathf.Min(ay, by) - num - 1f)); int num5 = Mathf.Min(H - 1, Mathf.CeilToInt(Mathf.Max(ay, by) + num + 1f)); float num6 = bx - ax; float num7 = by - ay; float num8 = num6 * num6 + num7 * num7; for (int i = num4; i <= num5; i++) { for (int j = num2; j <= num3; j++) { float num9 = (float)j + 0.5f - ax; float num10 = (float)i + 0.5f - ay; float num11 = ((num8 > 0f) ? Mathf.Clamp01((num9 * num6 + num10 * num7) / num8) : 0f); float num12 = num9 - num6 * num11; float num13 = num10 - num7 * num11; float num14 = Mathf.Sqrt(num12 * num12 + num13 * num13); float num15 = Mathf.Clamp01(num - num14 + 0.5f); if (num15 > 0f) { Blend(j, i, c, num15); } } } } public void FillTriangle(Vector2 a, Vector2 b, Vector2 c, Color col) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(0, Mathf.FloorToInt(Mathf.Min(a.x, Mathf.Min(b.x, c.x)))); int num2 = Mathf.Min(W - 1, Mathf.CeilToInt(Mathf.Max(a.x, Mathf.Max(b.x, c.x)))); int num3 = Mathf.Max(0, Mathf.FloorToInt(Mathf.Min(a.y, Mathf.Min(b.y, c.y)))); int num4 = Mathf.Min(H - 1, Mathf.CeilToInt(Mathf.Max(a.y, Mathf.Max(b.y, c.y)))); for (int i = num3; i <= num4; i++) { for (int j = num; j <= num2; j++) { int num5 = 0; for (int k = 0; k < 4; k++) { for (int l = 0; l < 4; l++) { if (Inside(new Vector2((float)j + ((float)l + 0.5f) / 4f, (float)i + ((float)k + 0.5f) / 4f), a, b, c)) { num5++; } } } if (num5 > 0) { Blend(j, i, col, (float)num5 / 16f); } } } } private static bool Inside(Vector2 p, Vector2 a, Vector2 b, Vector2 c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_006f: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) float num = (p.x - b.x) * (a.y - b.y) - (a.x - b.x) * (p.y - b.y); float num2 = (p.x - c.x) * (b.y - c.y) - (b.x - c.x) * (p.y - c.y); float num3 = (p.x - a.x) * (c.y - a.y) - (c.x - a.x) * (p.y - a.y); bool flag = num < 0f || num2 < 0f || num3 < 0f; bool flag2 = num > 0f || num2 > 0f || num3 > 0f; return !(flag && flag2); } public void Foreach(Func<int, int, Color, Color> f) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { _px[i * W + j] = f(j, i, _px[i * W + j]); } } } public Texture2D ToTexture(bool mipmaps = false, TextureWrapMode wrap = (TextureWrapMode)1, FilterMode filter = (FilterMode)1) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown Texture2D val = new Texture2D(W, H, (TextureFormat)4, mipmaps) { wrapMode = wrap, filterMode = filter }; val.SetPixels(_px); val.Apply(mipmaps, false); return val; } public Sprite ToSprite(Vector4? border = null, float pixelsPerUnit = 100f) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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) return Sprite.Create(ToTexture(mipmaps: false, (TextureWrapMode)1, (FilterMode)1), new Rect(0f, 0f, (float)W, (float)H), new Vector2(0.5f, 0.5f), pixelsPerUnit, 0u, (SpriteMeshType)0, (Vector4)(((??)border) ?? Vector4.zero)); } } internal static class ClockArt { private static readonly Color Gold = new Color(0.86f, 0.69f, 0.38f, 1f); private static readonly Color GoldDark = new Color(0.5f, 0.37f, 0.19f, 1f); private static readonly Color Clear = new Color(0f, 0f, 0f, 0f); private static readonly float[] KeyHours = new float[12] { 0f, 4f, 5.5f, 7f, 10f, 12.5f, 15.5f, 17.5f, 19f, 20.5f, 22f, 24f }; private static readonly Color[] KeyColors = (Color[])(object)new Color[12] { new Color(0.55f, 0.62f, 1f), new Color(0.52f, 0.6f, 0.98f), new Color(1f, 0.58f, 0.34f), new Color(1f, 0.82f, 0.46f), new Color(1f, 0.9f, 0.52f), new Color(1f, 0.96f, 0.66f), new Color(1f, 0.8f, 0.42f), new Color(1f, 0.54f, 0.3f), new Color(0.92f, 0.42f, 0.52f), new Color(0.62f, 0.46f, 0.86f), new Color(0.5f, 0.58f, 0.98f), new Color(0.55f, 0.62f, 1f) }; public const int SunIcons = 5; public const int MoonIcons = 8; public const int IconCount = 13; private static readonly float[] SegStart = new float[6] { 5f, 7f, 11f, 14f, 17f, 19.5f }; public static Canvas2D PaintFrame() { //IL_0004: 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_00a1: 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_00be: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: 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_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_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_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: 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_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: 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_02f0: 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_031c: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) Canvas2D canvas2D = new Canvas2D(24, 24, Clear); for (int i = 0; i < 24; i++) { for (int j = 0; j < 24; j++) { float num = 0.5f + 0.5f * Mathf.Sin((float)j * 2.1f + Mathf.Sin((float)i * 0.7f) * 1.3f); float num2 = 0.075f + num * 0.03f; canvas2D.Set(j, i, new Color(num2 * 1.15f, num2 * 0.92f, num2 * 0.72f, 1f)); } } for (int k = 0; k < 24; k++) { canvas2D.Set(k, 0, Gold); canvas2D.Set(k, 23, Gold); canvas2D.Set(0, k, Gold); canvas2D.Set(23, k, Gold); canvas2D.Set(k, 1, new Color(0.04f, 0.03f, 0.02f, 1f)); canvas2D.Set(k, 22, new Color(0.04f, 0.03f, 0.02f, 1f)); canvas2D.Set(1, k, new Color(0.04f, 0.03f, 0.02f, 1f)); canvas2D.Set(22, k, new Color(0.04f, 0.03f, 0.02f, 1f)); } for (int l = 2; l < 22; l++) { canvas2D.Set(l, 3, GoldDark); canvas2D.Set(l, 20, GoldDark); canvas2D.Set(3, l, GoldDark); canvas2D.Set(20, l, GoldDark); } Vector2[] array = (Vector2[])(object)new Vector2[4] { new Vector2(5f, 5f), new Vector2(19f, 5f), new Vector2(5f, 19f), new Vector2(19f, 19f) }; foreach (Vector2 val in array) { canvas2D.FillTriangle(val + new Vector2(0f, 2.6f), val + new Vector2(2.6f, 0f), val + new Vector2(0f, -2.6f), Gold); canvas2D.FillTriangle(val + new Vector2(0f, 2.6f), val + new Vector2(-2.6f, 0f), val + new Vector2(0f, -2.6f), Gold); canvas2D.FillCircle(val.x, val.y, 0.9f, new Color(0.2f, 0.13f, 0.06f, 1f)); } canvas2D.Set(0, 0, Clear); canvas2D.Set(23, 0, Clear); canvas2D.Set(0, 23, Clear); canvas2D.Set(23, 23, Clear); return canvas2D; } public static Canvas2D PaintSun() { return PaintSunState(2); } public static Canvas2D PaintMoon() { return PaintMoonPhase(1); } public static Canvas2D PaintStrip() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) Canvas2D canvas2D = new Canvas2D(256, 8, Clear); Color val = default(Color); ((Color)(ref val))..ctor(0.04f, 0.06f, 0.17f, 1f); Color val2 = default(Color); ((Color)(ref val2))..ctor(1f, 0.92f, 0.52f, 1f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.96f, 0.44f, 0.2f, 1f); Random random = new Random(5); for (int i = 0; i < 256; i++) { float num = Mathf.Sin((((float)i + 0.5f) / 256f - 0.25f) * (float)Math.PI * 2f); float num2 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(-0.25f, 0.45f, num)); Color val4 = Color.Lerp(val, val2, num2); float num3 = Mathf.Clamp01(1f - Mathf.Abs(num) / 0.32f); val4 = Color.Lerp(val4, val3, num3 * 0.8f); for (int j = 0; j < 8; j++) { float num4; switch (j) { default: num4 = 1f; break; case 1: num4 = 1.08f; break; case 0: case 7: num4 = 0.7f; break; } float num5 = num4; canvas2D.Set(i, j, new Color(val4.r * num5, val4.g * num5, val4.b * num5, 1f)); } if (num2 < 0.15f && random.NextDouble() < 0.05) { canvas2D.Set(i, 2 + random.Next(4), new Color(0.9f, 0.93f, 1f, 1f)); } } int[] array = new int[3] { 6, 12, 18 }; for (int k = 0; k < array.Length; k++) { int x = Mathf.RoundToInt((float)array[k] / 24f * 256f); for (int l = 0; l < 8; l++) { canvas2D.Set(x, l, new Color(0.96f, 0.78f, 0.42f, 0.9f)); } } for (int m = 0; m < 256; m++) { canvas2D.Set(m, 0, GoldDark); canvas2D.Set(m, 7, GoldDark); } for (int n = 0; n < 8; n++) { canvas2D.Set(0, n, GoldDark); canvas2D.Set(255, n, GoldDark); } return canvas2D; } private static float Hash2(int x, int y) { int num = x * 374761393 + y * 668265263; int num2 = (num ^ (num >>> 13)) * 1274126177; return (float)(uint)((num2 ^ (num2 >>> 16)) & 0xFFFF) / 65535f; } private static float VNoise(float x, float y) { int num = Mathf.FloorToInt(x); int num2 = Mathf.FloorToInt(y); float num3 = x - (float)num; float num4 = y - (float)num2; num3 = num3 * num3 * (3f - 2f * num3); num4 = num4 * num4 * (3f - 2f * num4); return Mathf.Lerp(Mathf.Lerp(Hash2(num, num2), Hash2(num + 1, num2), num3), Mathf.Lerp(Hash2(num, num2 + 1), Hash2(num + 1, num2 + 1), num3), num4); } private static void Glow(Canvas2D c, float cx, float cy, float r0, float r1, Color col, float peak) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) for (int i = 0; i < 14; i++) { float num = (float)i / 13f; c.FillCircle(cx, cy, Mathf.Lerp(r1, r0, num), new Color(col.r, col.g, col.b, peak / 14f * (0.6f + num))); } } public static Canvas2D PaintSunState(int k) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: 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_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) Canvas2D canvas2D = new Canvas2D(64, 64, Clear); float m = 32f; bool flag = k == 0 || k == 4; Color body = (Color)(k switch { 2 => new Color(1f, 0.86f, 0.55f), 1 => new Color(0.97f, 0.78f, 0.44f), 4 => new Color(0.92f, 0.42f, 0.26f), 0 => new Color(0.95f, 0.6f, 0.32f), _ => new Color(0.96f, 0.72f, 0.38f), }); Color core = Color.Lerp(body, new Color(1f, 0.93f, 0.72f), 0.55f); Color rim = new Color(body.r * 0.74f, body.g * 0.58f, body.b * 0.4f); float cy = (flag ? 25f : m); float R = (flag ? 15.5f : 14.5f); Glow(canvas2D, m, cy, R, R + 16f, body, 0.3f); int num = (flag ? 9 : 12); Vector2 val = default(Vector2); Vector2 val2 = default(Vector2); Vector2 val3 = default(Vector2); for (int i = 0; i < num; i++) { float num2 = (flag ? ((float)Math.PI * ((float)i + 0.5f) / (float)num) : ((float)i * (float)Math.PI * 2f / (float)num + 0.13f)); bool flag2 = i % 2 == 0; float num3 = R + 3f; float num4 = R + (flag2 ? 12.5f : 8.5f); float num5 = (flag2 ? 0.13f : 0.1f); ((Vector2)(ref val))..ctor(m + Mathf.Cos(num2 - num5) * num3, cy + Mathf.Sin(num2 - num5) * num3); ((Vector2)(ref val2))..ctor(m + Mathf.Cos(num2 + num5) * num3, cy + Mathf.Sin(num2 + num5) * num3); ((Vector2)(ref val3))..ctor(m + Mathf.Cos(num2) * num4, cy + Mathf.Sin(num2) * num4); canvas2D.FillTriangle(val, val2, val3, new Color(core.r, core.g, core.b, 0.26f)); Vector2 a = Vector2.Lerp(val, val3, 0.18f); Vector2 b = Vector2.Lerp(val2, val3, 0.18f); canvas2D.FillTriangle(a, b, Vector2.Lerp(val, val3, 0.72f) * 0.5f + Vector2.Lerp(val2, val3, 0.72f) * 0.5f, new Color(core.r, core.g, core.b, 0.5f)); } canvas2D.Foreach(delegate(int x, int y, Color col) { //IL_0058: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00e4: 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_0107: 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_011b: 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_012d: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: 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) float num8 = (float)x + 0.5f - m; float num9 = (float)y + 0.5f - cy; float num10 = Mathf.Sqrt(num8 * num8 + num9 * num9); float num11 = Mathf.Clamp01(R + 0.5f - num10); if (num11 <= 0f) { return col; } float num12 = Mathf.Clamp01(num10 / R); Color val4 = Color.Lerp(core, body, Mathf.SmoothStep(0f, 1f, num12 * 1.05f)); val4 = Color.Lerp(val4, rim, Mathf.SmoothStep(0.8f, 1f, num12) * 0.85f); float num13 = (VNoise((float)x * 0.35f, (float)y * 0.35f) - 0.5f) * 0.1f; ((Color)(ref val4))..ctor(val4.r + num13, val4.g + num13 * 0.8f, val4.b + num13 * 0.5f, 1f); Color val5 = default(Color); ((Color)(ref val5))..ctor(val4.r, val4.g, val4.b, num11); float num14 = val5.a + col.a * (1f - val5.a); return new Color((val5.r * val5.a + col.r * col.a * (1f - val5.a)) / num14, (val5.g * val5.a + col.g * col.a * (1f - val5.a)) / num14, (val5.b * val5.a + col.b * col.a * (1f - val5.a)) / num14, num14); }); if (flag) { for (int num6 = 0; num6 < 25; num6++) { for (int num7 = 0; num7 < 64; num7++) { canvas2D.Set(num7, num6, Clear); } } canvas2D.FillRect(8f, 24f, 56f, 26f, new Color(body.r, body.g, body.b, 0.8f)); canvas2D.FillRect(16f, 20.5f, 48f, 22f, new Color(body.r, body.g, body.b, 0.42f)); canvas2D.FillRect(24f, 17f, 40f, 18.2f, new Color(body.r, body.g, body.b, 0.22f)); } return canvas2D; } public static Canvas2D PaintMoonPhase(int k) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019f: 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_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) Canvas2D canvas2D = new Canvas2D(64, 64, Clear); float m = 32f; float R = 21f; float num = (float)(k & 7) / 8f * (float)Math.PI * 2f; Vector3 L = new Vector3(Mathf.Sin(num), 0f, 0f - Mathf.Cos(num)); Glow(canvas2D, m, m, R, R + 12f, new Color(0.55f, 0.65f, 0.9f), (k == 4) ? 0.26f : 0.14f); canvas2D.Foreach(delegate(int x, int y, Color col) { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0199: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0207: 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_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) float num3 = ((float)x + 0.5f - m) / R; float num4 = ((float)y + 0.5f - m) / R; float num5 = num3 * num3 + num4 * num4; float num6 = Mathf.Clamp01((1f - Mathf.Sqrt(num5)) * R + 0.5f); if (num6 <= 0f) { return col; } float num7 = Mathf.Sqrt(Mathf.Max(0f, 1f - num5)); float num8 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((num3 * L.x + num7 * L.z + 0.04f) / 0.22f)); float num9 = VNoise((float)x * 0.22f, (float)y * 0.22f) * 0.6f + VNoise((float)x * 0.6f, (float)y * 0.6f) * 0.4f; Color val2 = Color.Lerp(new Color(0.9f, 0.91f, 0.94f), new Color(0.6f, 0.65f, 0.78f), Mathf.Clamp01((Mathf.Sqrt(num5) - 0.45f) * 1.7f)); val2 = Color.Lerp(val2, new Color(0.62f, 0.67f, 0.78f), Mathf.Clamp01((num9 - 0.5f) * 1.6f) * 0.55f); Color val3 = Color.Lerp(new Color(0.1f, 0.13f, 0.22f), val2, num8); Color val4 = default(Color); ((Color)(ref val4))..ctor(val3.r, val3.g, val3.b, num6); float num10 = val4.a + col.a * (1f - val4.a); return new Color((val4.r * val4.a + col.r * col.a * (1f - val4.a)) / num10, (val4.g * val4.a + col.g * col.a * (1f - val4.a)) / num10, (val4.b * val4.a + col.b * col.a * (1f - val4.a)) / num10, num10); }); Vector3[] array = (Vector3[])(object)new Vector3[4] { new Vector3(52f, 52f, 2f), new Vector3(10f, 54f, 1.4f), new Vector3(55f, 14f, 1.4f), new Vector3(9f, 12f, 1.1f) }; Color c = default(Color); foreach (Vector3 val in array) { ((Color)(ref c))..ctor(0.85f, 0.89f, 0.97f, 0.7f); canvas2D.Line(val.x - val.z, val.y, val.x + val.z, val.y, 0.9f, c); canvas2D.Line(val.x, val.y - val.z, val.x, val.y + val.z, 0.9f, c); } return canvas2D; } public static Canvas2D PaintGlow() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) Canvas2D canvas2D = new Canvas2D(64, 64, Clear); canvas2D.Foreach(delegate(int x, int y, Color col) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Sqrt(((float)x + 0.5f - 32f) * ((float)x + 0.5f - 32f) + ((float)y + 0.5f - 32f) * ((float)y + 0.5f - 32f)) / 32f; float num2 = Mathf.Pow(Mathf.Clamp01(1f - num), 2f); return new Color(1f, 1f, 1f, num2); }); return canvas2D; } public static Color AccentAt(float hour) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) hour = Mathf.Repeat(hour, 24f); for (int i = 0; i < KeyHours.Length - 1; i++) { if (hour >= KeyHours[i] && hour <= KeyHours[i + 1]) { return Color.Lerp(KeyColors[i], KeyColors[i + 1], Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(KeyHours[i], KeyHours[i + 1], hour))); } } return KeyColors[0]; } public static void IconAt(float hour, int day, out int a, out int b, out float t) { hour = Mathf.Repeat(hour, 24f); if (hour >= 23.6f || hour < 0.4f) { a = Moon((hour >= 12f) ? day : (day - 1)); b = Moon((hour >= 12f) ? (day + 1) : day); t = Mathf.SmoothStep(0f, 1f, (hour >= 12f) ? ((hour - 23.6f) / 0.8f) : ((hour + 0.4f) / 0.8f)); return; } int num = Seg(hour); a = ((num < 0) ? Moon(day) : num); b = a; t = 0f; for (int i = 0; i < SegStart.Length; i++) { float num2 = SegStart[i]; if (Mathf.Abs(hour - num2) < 0.4f) { int num3 = ((i == 0) ? Moon(day) : (i - 1)); int num4 = ((i == 5) ? Moon(day) : i); a = num3; b = num4; t = Mathf.SmoothStep(0f, 1f, (hour - (num2 - 0.4f)) / 0.8f); break; } } static int Moon(int d) { return 5 + (d % 8 + 8) % 8; } static int Seg(float h) { if (h < SegStart[0] || h >= SegStart[5]) { return -1; } for (int j = 0; j < 5; j++) { if (h < SegStart[j + 1]) { return j; } } return 4; } } public static Canvas2D PaintMarker() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00d4: 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) Canvas2D canvas2D = new Canvas2D(32, 32, Clear); canvas2D.FillTriangle(new Vector2(1f, 29f), new Vector2(31f, 29f), new Vector2(16f, 1f), new Color(0.1f, 0.06f, 0.03f, 1f)); canvas2D.FillTriangle(new Vector2(5f, 26f), new Vector2(27f, 26f), new Vector2(16f, 7f), new Color(1f, 0.85f, 0.42f, 1f)); canvas2D.FillTriangle(new Vector2(9f, 24f), new Vector2(23f, 24f), new Vector2(16f, 12f), new Color(1f, 0.95f, 0.72f, 1f)); return canvas2D; } } internal sealed class ClockHud : MonoBehaviour { private static readonly Color Gold = new Color(0.96f, 0.78f, 0.42f, 1f); private static readonly Color GoldDim = new Color(0.78f, 0.64f, 0.38f, 1f); private static readonly Color Soft = new Color(0.92f, 0.88f, 0.8f, 1f); private static Sprite _frame; private static Sprite _stripSprite; private static Sprite _marker; private static Sprite _glowSprite; private static Sprite[] _icons; private RectTransform _root; private RectTransform _parentRt; private CanvasGroup _group; private Image _bg; private Image _icon; private Image _icon2; private Image _glow; private Image _strip; private Image _marker1; private float _nextVisual; private RectTransform _markerRt; private RectTransform _stripRt; private TMP_Text _time; private TMP_Text _phase; private TMP_Text _day; private bool _built; private int _lastMinute = -1; private int _layoutVersion = -1; private Vector2 _statusBase; private bool _statusBaseKnown; private bool _statusShifted; private RectTransform _statusTarget; private Vector2 _statusSet; private readonly Vector3[] _corners = (Vector3[])(object)new Vector3[4]; private static int _cfgVersion; private string _builtAnchor; private static readonly Vector2 TL = new Vector2(0f, 1f); private static readonly Vector2 TR = new Vector2(1f, 1f); internal static void MarkDirty() { _cfgVersion++; } private void Update() { try { if (!_built) { TryBuild(); } if (_built) { UpdateVisibilityAndText(); } } catch (Exception ex) { HomesteadPlugin.Log.LogWarning((object)("Clock: " + ex.Message)); ((Behaviour)this).enabled = false; } } private void LateUpdate() { if (!_built || !((Component)_root).gameObject.activeSelf) { return; } try { Position(); } catch { } } private void OnDisable() { RestoreStatusEffects(); } private void OnDestroy() { RestoreStatusEffects(); if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)((Component)_root).gameObject); } } private void TryBuild() { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown Minimap instance = Minimap.instance; Hud instance2 = Hud.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance2 == (Object)null) && !((Object)(object)instance.m_smallRoot == (Object)null) && !((Object)(object)instance.m_biomeNameSmall == (Object)null)) { EnsureSprites(); Transform val = ((HomesteadPlugin.ClockAnchor.Value == "ScreenTopRight" && (Object)(object)instance2.m_rootObject != (Object)null) ? instance2.m_rootObject.transform : instance.m_smallRoot.transform.parent); if ((Object)(object)val == (Object)null) { val = ((Component)instance2).transform; } _parentRt = (RectTransform)(object)((val is RectTransform) ? val : null); if ((Object)(object)_parentRt == (Object)null) { HomesteadPlugin.Log.LogWarning((object)"Clock: parent is not a RectTransform, clock disabled"); ((Behaviour)this).enabled = false; return; } GameObject val2 = new GameObject("HomesteadClock", new Type[2] { typeof(RectTransform), typeof(CanvasGroup) }); val2.layer = ((Component)val).gameObject.layer; _root = (RectTransform)val2.transform; ((Transform)_root).SetParent(val, false); ((Transform)_root).SetAsLastSibling(); _group = val2.GetComponent<CanvasGroup>(); _group.blocksRaycasts = false; _group.interactable = false; _bg = NewImage("Bg", (Transform)(object)_root); _glow = NewImage("IconGlow", (Transform)(object)_root); _icon = NewImage("Icon", (Transform)(object)_root); _icon2 = NewImage("IconNext", (Transform)(object)_root); _strip = NewImage("Strip", (Transform)(object)_root); _stripRt = ((Graphic)_strip).rectTransform; _marker1 = NewImage("Marker", (Transform)(object)_root); _markerRt = ((Graphic)_marker1).rectTransform; _time = NewText("Time", (Transform)(object)_root, instance.m_biomeNameSmall, (TextAlignmentOptions)4097); _phase = NewText("Phase", (Transform)(object)_root, instance.m_biomeNameSmall, (TextAlignmentOptions)4100); _day = NewText("Day", (Transform)(object)_root, instance.m_biomeNameSmall, (TextAlignmentOptions)4100); _built = true; _builtAnchor = HomesteadPlugin.ClockAnchor.Value; _layoutVersion = -1; ManualLogSource log = HomesteadPlugin.Log; string[] obj = new string[7] { "Clock built under '", ((Object)val).name, "' (anchor: ", HomesteadPlugin.ClockAnchor.Value, ", font: ", null, null }; TMP_FontAsset font = instance.m_biomeNameSmall.font; obj[5] = ((font != null) ? ((Object)font).name : null); obj[6] = ")"; log.LogInfo((object)string.Concat(obj)); } } private static Image NewImage(string name, Transform parent) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(Image) }) { layer = ((Component)parent).gameObject.layer }; val.transform.SetParent(parent, false); Image component = val.GetComponent<Image>(); ((Graphic)component).raycastTarget = false; return component; } private static TMP_Text NewText(string name, Transform parent, TMP_Text template, TextAlignmentOptions align) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }) { layer = ((Component)parent).gameObject.layer }; val.transform.SetParent(parent, false); TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj).font = template.font; ((TMP_Text)obj).fontSharedMaterial = template.fontSharedMaterial; ((TMP_Text)obj).fontStyle = template.fontStyle; ((TMP_Text)obj).alignment = align; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj).overflowMode = (TextOverflowModes)0; ((Graphic)obj).raycastTarget = false; ((TMP_Text)obj).richText = false; return (TMP_Text)(object)obj; } private void ApplyLayout() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00d2: 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_01f1: 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_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: 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_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0235: 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_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0305: 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_032e: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: 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_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_05b0: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Unknown result type (might be due to invalid IL or missing references) //IL_05ce: Unknown result type (might be due to invalid IL or missing references) //IL_05d3: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) _layoutVersion = _cfgVersion; _lastMinute = -1; float value = HomesteadPlugin.ClockWidth.Value; float value2 = HomesteadPlugin.ClockHeight.Value; float value3 = HomesteadPlugin.ClockScale.Value; bool flag = HomesteadPlugin.ClockAnchor.Value == "ScreenTopRight"; RectTransform root = _root; Vector2 anchorMin = (_root.anchorMax = (flag ? new Vector2(1f, 1f) : new Vector2(0.5f, 0.5f))); root.anchorMin = anchorMin; _root.pivot = (flag ? new Vector2(1f, 1f) : new Vector2(0.5f, 1f)); _root.sizeDelta = new Vector2(value, value2); ((Transform)_root).localScale = Vector3.one * value3; Stretch(((Graphic)_bg).rectTransform); _bg.sprite = _frame; _bg.type = (Type)1; ((Graphic)_bg).color = new Color(1f, 1f, 1f, HomesteadPlugin.ClockBackgroundOpacity.Value); bool value4 = HomesteadPlugin.ClockShowStrip.Value; float num = 6f; float num2 = -5f; float num3 = value2 - (value4 ? (num + 14f) : 10f); if (num3 < 14f) { num3 = 14f; } float num4 = num2 - num3 * 0.5f; float num5 = Mathf.Min(num3, 38f); bool value5 = HomesteadPlugin.ClockShowIcon.Value; ((Component)_icon).gameObject.SetActive(value5); ((Component)_icon2).gameObject.SetActive(value5); ((Component)_glow).gameObject.SetActive(value5); Vector2 pos = default(Vector2); ((Vector2)(ref pos))..ctor(8f + num5 * 0.5f, num4); Place(((Graphic)_icon).rectTransform, pos, new Vector2(num5, num5), new Vector2(0.5f, 0.5f), TL); Place(((Graphic)_icon2).rectTransform, pos, new Vector2(num5, num5), new Vector2(0.5f, 0.5f), TL); Place(((Graphic)_glow).rectTransform, pos, new Vector2(num5 * 1.7f, num5 * 1.7f), new Vector2(0.5f, 0.5f), TL); _glow.sprite = _glowSprite; _icon.sprite = _icons[0]; _icon2.sprite = _icons[0]; _nextVisual = 0f; float num6 = 8f + (value5 ? (num5 + 6f) : 0f); int value6 = HomesteadPlugin.ClockTimeFontSize.Value; int value7 = HomesteadPlugin.ClockInfoFontSize.Value; _time.fontSize = value6; ((Graphic)_time).color = Gold; Place(_time.rectTransform, new Vector2(num6, num4), new Vector2((float)value6 * 3.2f, num3), new Vector2(0f, 0.5f), TL); bool value8 = HomesteadPlugin.ClockShowPhase.Value; bool value9 = HomesteadPlugin.ClockShowDay.Value; float num7 = value - num6 - (float)value6 * 3.2f - 8f; if (num7 < 30f) { num7 = 30f; } _phase.fontSize = value7; ((Graphic)_phase).color = Soft; _day.fontSize = Mathf.Max(6, value7 - 2); ((Graphic)_day).color = GoldDim; ((Component)_phase).gameObject.SetActive(value8); ((Component)_day).gameObject.SetActive(value9); if (value8 && value9) { Place(_phase.rectTransform, new Vector2(-8f, num2 - num3 * 0.28f), new Vector2(num7, num3 * 0.5f), new Vector2(1f, 0.5f), TR); Place(_day.rectTransform, new Vector2(-8f, num2 - num3 * 0.74f), new Vector2(num7, num3 * 0.5f), new Vector2(1f, 0.5f), TR); } else { Place(_phase.rectTransform, new Vector2(-8f, num4), new Vector2(num7, num3), new Vector2(1f, 0.5f), TR); Place(_day.rectTransform, new Vector2(-8f, num4), new Vector2(num7, num3), new Vector2(1f, 0.5f), TR); } ((Component)_strip).gameObject.SetActive(value4); ((Component)_marker1).gameObject.SetActive(value4); if (value4) { float num8 = value - 16f; Place(_stripRt, new Vector2(8f, 0f - (value2 - 7f)), new Vector2(num8, num), new Vector2(0f, 0.5f), TL); _strip.sprite = _stripSprite; ((Graphic)_strip).color = Color.white; Place(_markerRt, new Vector2(8f, 0f - (value2 - 7f) + num * 0.5f + 3f), new Vector2(9f, 7f), new Vector2(0.5f, 0.5f), TL); _marker1.sprite = _marker; ((Graphic)_marker1).color = Color.white; } } private static void Stretch(RectTransform rt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; Vector2 offsetMin = (rt.offsetMax = Vector2.zero); rt.offsetMin = offsetMin; } private static void Place(RectTransform rt, Vector2 pos, Vector2 size, Vector2 pivot, Vector2 anchor) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Vector2 anchorMin = (rt.anchorMax = anchor); rt.anchorMin = anchorMin; rt.pivot = pivot; rt.anchoredPosition = pos; rt.sizeDelta = size; } private void Position() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00cb: 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) float value = HomesteadPlugin.ClockOffsetX.Value; float value2 = HomesteadPlugin.ClockOffsetY.Value; if (HomesteadPlugin.ClockAnchor.Value == "ScreenTopRight") { _root.anchoredPosition = new Vector2(-8f + value, -8f + value2); return; } Minimap instance = Minimap.instance; RectTransform val = (RectTransform)(((Object)(object)instance != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); if (!((Object)(object)val == (Object)null)) { val.GetWorldCorners(_corners); Vector3 val2 = (_corners[0] + _corners[3]) * 0.5f; Vector3 val3 = ((Transform)_parentRt).InverseTransformPoint(val2); ((Transform)_root).localPosition = new Vector3(val3.x + value, val3.y + value2, 0f); } } private void UpdateVisibilityAndText() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: 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_03d8: 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_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: 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_0362: 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) Hud instance = Hud.instance; Minimap instance2 = Minimap.instance; EnvMan instance3 = EnvMan.instance; bool flag = HomesteadPlugin.ClockEnabled.Value && (Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)instance != (Object)null && instance.IsVisible() && !instance.m_userHidden && (Object)(object)instance2 != (Object)null && (int)instance2.m_mode == 1 && !Minimap.IsOpen() && (Object)(object)instance3 != (Object)null && (Object)(object)ZNet.instance != (Object)null; if (((Component)_root).gameObject.activeSelf != flag) { ((Component)_root).gameObject.SetActive(flag); } ShiftStatusEffects(flag); if (!flag) { return; } if (_builtAnchor != HomesteadPlugin.ClockAnchor.Value) { Object.Destroy((Object)(object)((Component)_root).gameObject); _built = false; return; } if (_layoutVersion != _cfgVersion) { ApplyLayout(); } float dayFraction = instance3.GetDayFraction(); int num = Mathf.Clamp(Mathf.FloorToInt(dayFraction * 24f * 60f), 0, 1439); if (num != _lastMinute) { _lastMinute = num; int hour = num / 60; int num2 = num % 60; _time.text = hour.ToString("00") + ":" + num2.ToString("00"); bool flag2 = UseUkrainian(); _phase.text = (flag2 ? Strings.PhasesUk : Strings.PhasesEn)[PhaseIndex(hour)]; _day.text = string.Format(flag2 ? "День {0}" : "Day {0}", instance3.GetDay()); } if (Time.unscaledTime >= _nextVisual) { _nextVisual = Time.unscaledTime + 0.066f; float hour2 = dayFraction * 24f; Color val = ClockArt.AccentAt(hour2); ((Graphic)_phase).color = Color.Lerp(Soft, val, 0.85f); ((Graphic)_time).color = Color.Lerp(Gold, val, 0.3f); ((Graphic)_day).color = Color.Lerp(GoldDim, val, 0.25f); ((Graphic)_bg).color = new Color(Mathf.Lerp(1f, val.r, 0.22f), Mathf.Lerp(1f, val.g, 0.22f), Mathf.Lerp(1f, val.b, 0.22f), HomesteadPlugin.ClockBackgroundOpacity.Value); ((Graphic)_glow).color = new Color(val.r, val.g, val.b, 0.3f); if (((Component)_marker1).gameObject.activeSelf) { ((Graphic)_marker1).color = Color.Lerp(Color.white, val, 0.5f); } ClockArt.IconAt(hour2, instance3.GetDay(), out var a, out var b, out var t); if (((Component)_icon).gameObject.activeSelf) { _icon.sprite = _icons[a]; _icon2.sprite = _icons[b]; ((Graphic)_icon).color = new Color(1f, 1f, 1f, (a == b) ? 1f : (1f - t)); ((Graphic)_icon2).color = new Color(1f, 1f, 1f, (a == b) ? 0f : t); ((Behaviour)_icon2).enabled = a != b; } } if (((Component)_marker1).gameObject.activeSelf) { float x = _stripRt.sizeDelta.x; Vector2 anchoredPosition = _markerRt.anchoredPosition; anchoredPosition.x = _stripRt.anchoredPosition.x + dayFraction * x; _markerRt.anchoredPosition = anchoredPosition; } } private void ShiftStatusEffects(bool clockVisible) { //IL_0051: 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_0061: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) Hud instance = Hud.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_statusEffectListRoot == (Object)null) { return; } RectTransform statusEffectListRoot = instance.m_statusEffectListRoot; if ((Object)(object)_statusTarget != (Object)(object)statusEffectListRoot) { _statusTarget = statusEffectListRoot; _statusBaseKnown = false; _statusShifted = false; } Vector2 val; if (_statusShifted) { val = statusEffectListRoot.anchoredPosition - _statusSet; if (((Vector2)(ref val)).sqrMagnitude > 0.01f) { _statusShifted = false; _statusBaseKnown = false; } } if (!_statusShifted && !_statusBaseKnown) { _statusBase = statusEffectListRoot.anchoredPosition; _statusBaseKnown = true; } if (clockVisible && HomesteadPlugin.ClockShiftStatusEffects.Value) { float num = HomesteadPlugin.ClockHeight.Value * HomesteadPlugin.ClockScale.Value + HomesteadPlugin.ClockStatusEffectGap.Value; _statusSet = _statusBase + new Vector2(0f, 0f - num); val = statusEffectListRoot.anchoredPosition - _statusSet; if (((Vector2)(ref val)).sqrMagnitude > 0.0001f) { statusEffectListRoot.anchoredPosition = _statusSet; } _statusShifted = true; } else { RestoreStatusEffects(); } } private void RestoreStatusEffects() { //IL_001c: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (_statusShifted && (Object)(object)_statusTarget != (Object)null) { Vector2 val = _statusTarget.anchoredPosition - _statusSet; if (((Vector2)(ref val)).sqrMagnitude <= 0.01f) { _statusTarget.anchoredPosition = _statusBase; } } _statusShifted = false; _statusBaseKnown = false; } private static bool UseUkrainian() { string value = HomesteadPlugin.ClockLanguage.Value; if (value == "Ukrainian") { return true; } if (value == "English") { return false; } try { return Localization.instance != null && Localization.instance.GetSelectedLanguage() == "Ukrainian"; } catch { return false; } } internal static int PhaseIndex(int hour) { switch (hour) { default: return 0; case 1: case 2: case 3: case 4: return 1; case 5: case 6: return 2; case 7: case 8: case 9: case 10: return 3; case 11: case 12: case 13: return 4; case 14: case 15: case 16: return 5; case 17: case 18: return 6; case 19: case 20: return 7; case 21: case 22: return 1; } } private static void EnsureSprites() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if (_icons == null) { _icons = (Sprite[])(object)new Sprite[13]; for (int i = 0; i < 5; i++) { _icons[i] = ClockArt.PaintSunState(i).ToSprite(); } for (int j = 0; j < 8; j++) { _icons[5 + j] = ClockArt.PaintMoonPhase(j).ToSprite(); } _glowSprite = ClockArt.PaintGlow().ToSprite(); _frame = ClockArt.PaintFrame().ToSprite((Vector4?)new Vector4(9f, 9f, 9f, 9f), 100f); _stripSprite = ClockArt.PaintStrip().ToSprite(); _marker = ClockArt.PaintMarker().ToSprite(); } } } [HarmonyPatch(typeof(Hud), "Awake")] internal static class Hud_Awake_Clock_Patch { private static void Postfix(Hud __instance) { if ((Object)(object)((Component)__instance).GetComponent<ClockHud>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<ClockHud>(); } } } internal static class CraftCredit { private static readonly HashSet<string> Needed = new HashSet<string>(); private static float _nextRebuild; private static Achievements _cachedFor; private static bool _tableLogged; private static HashSet<string> _excluded = new HashSet<string>(); private static string _excludedSpec; public static void Check() { if (!HomesteadPlugin.CraftCreditEnabled.Value) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)Game.instance == (Object)null || (Object)(object)Achievements.m_instance == (Object)null || (Object)(object)ObjectDB.instance == (Object)null || localPlayer.m_isLoading) { return; } PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); if (playerProfile == null) { return; } Rebuild(); if (Needed.Count == 0) { return; } List<ItemData> allItems = ((Humanoid)localPlayer).GetInventory().GetAllItems(); int currentAchievementDifficultyIndex = Achievements.GetCurrentAchievementDifficultyIndex(); Dictionary<string, float> itemCraftStats = playerProfile.m_playerStats[1].m_itemCraftStats; Dictionary<string, float> dictionary = ((currentAchievementDifficultyIndex >= 0 && currentAchievementDifficultyIndex < playerProfile.m_playerStats.Length) ? playerProfile.m_playerStats[currentAchievementDifficultyIndex].m_itemCraftStats : itemCraftStats); foreach (ItemData item in allItems) { if (item?.m_shared == null) { continue; } string name = item.m_shared.m_name; if (Needed.Contains(name) && !_excluded.Contains(name) && (!itemCraftStats.TryGetValue(name, out var value) || !(value >= 1f) || !dictionary.TryGetValue(name, out var value2) || !(value2 >= 1f)) && Achievements.CanGetAchievements(item.m_cheated)) { playerProfile.IncrementStatItemCraft(name, 1f, item.m_cheated); if (HomesteadPlugin.CraftCreditLog.Value) { HomesteadPlugin.Log.LogInfo((object)("[CraftCredit] counted '" + name + "' as crafted (found in inventory)")); } } } } private static void Rebuild() { //IL_011b: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_014c: Unknown result type (might be due to invalid IL or missing references) string text = HomesteadPlugin.CraftCreditExclude.Value ?? ""; if (text != _excludedSpec) { _excludedSpec = text; _excluded = new HashSet<string>(); string[] array = text.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text2 in array) { _excluded.Add(text2.Trim()); } } if ((Object)(object)_cachedFor == (Object)(object)Achievements.m_instance && Time.unscaledTime < _nextRebuild) { return; } _cachedFor = Achievements.m_instance; _nextRebuild = Time.unscaledTime + 10f; Needed.Clear(); foreach (AchievementList achievementList in Achievements.m_instance.m_achievementLists) { foreach (Achievement achievement in achievementList.m_achievements) { if ((Object)(object)achievement == (Object)null || achievement.m_unlocked || achievement.m_itemCraftTriggers.Count == 0) { continue; } foreach (DictStatRequirement itemCraftTrigger in achievement.m_itemCraftTriggers) { if ((int)itemCraftTrigger.m_operator == 0 && itemCraftTrigger.m_amount <= 1f && !string.IsNullOrEmpty(itemCraftTrigger.m_stat)) { Needed.Add(itemCraftTrigger.m_stat); } } } } if (_tableLogged || Needed.Count <= 0) { return; } _tableLogged = true; foreach (AchievementList achievementList2 in Achievements.m_instance.m_achievementLists) { foreach (Achievement achievement2 in achievementList2.m_achievements) { if ((Object)(object)achievement2 != (Object)null && achievement2.m_itemCraftTriggers.Count > 0) { HomesteadPlugin.Log.LogInfo((object)$"[CraftCredit] achievement '{achievement2.m_id}' counts crafted items: {achievement2.m_itemCraftTriggers.Count} (unlocked: {achievement2.m_unlocked})"); } } } } } [HarmonyPatch(typeof(Player), "OnInventoryChanged")] internal static class Player_OnInventoryChanged_Patch { private static void Postfix(Player __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } try { CraftCredit.Check(); } catch (Exception ex) { HomesteadPlugin.Log.LogWarning((object)("CraftCredit (inventory): " + ex.Message)); } } } [BepInPlugin("yura.valheim.homesteadpack", "Homestead Pack", "1.0.13")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class HomesteadPlugin : BaseUnityPlugin { public const string ModGuid = "yura.valheim.homesteadpack"; public const string ModName = "Homestead Pack"; public const string ModVersion = "1.0.13"; internal static ManualLogSource Log; internal static HomesteadPlugin Instance; internal static ConfigEntry<bool> PortalsEnabled; internal static ConfigEntry<string> StonePortalRecipe; internal static ConfigEntry<string> WoodPortalRecipe; internal static ConfigEntry<bool> ClockEnabled; internal static ConfigEntry<string> ClockLanguage; internal static ConfigEntry<string> ClockAnchor; internal static ConfigEntry<float> ClockOffsetX; internal static ConfigEntry<float> ClockOffsetY; internal static ConfigEntry<float> ClockScale; internal static ConfigEntry<float> ClockWidth; internal static ConfigEntry<float> ClockHeight; internal static ConfigEntry<int> ClockTimeFontSize; internal static ConfigEntry<int> ClockInfoFontSize; internal static ConfigEntry<float> ClockBackgroundOpacity; internal static ConfigEntry<bool> ClockShowIcon; internal static ConfigEntry<bool> ClockShowPhase; internal static ConfigEntry<bool> ClockShowDay; internal static ConfigEntry<bool> ClockShowStrip; internal static ConfigEntry<bool> ClockShiftStatusEffects; internal static ConfigEntry<float> ClockStatusEffectGap; internal static ConfigEntry<bool> CraftCreditEnabled; internal static ConfigEntry<string> CraftCreditExclude; internal static ConfigEntry<bool> CraftCreditLog; internal static ConfigEntry<bool> SakuraEnabled; internal static ConfigEntry<string> CostLarge; internal static ConfigEntry<string> CostYoung; internal static ConfigEntry<string> CostWeeping; internal static ConfigEntry<string> CostBonsai; internal static ConfigEntry<string> CostBush; internal static ConfigEntry<bool> SakuraCards; internal static ConfigEntry<string> SakuraBarkTint; internal static ConfigEntry<bool> SakuraSway; internal static ConfigEntry<float> SakuraSwayStrength; internal static ConfigEntry<bool> SakuraPetals; internal static ConfigEntry<float> SakuraPetalRate; internal static ConfigEntry<float> SakuraEffectRange; private float _creditTimer; private void Awake() { //IL_0236: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; BindConfig(); Migrate(StonePortalRecipe, "SurtlingCore:5,GreydwarfEye:20,Grausten:30", "MoltenCore:5,GreydwarfEye:20,Grausten:30"); Migrate(CostLarge, "FineWood:10,Wood:10,Resin:6,Dandelion:4", "BeechSeeds:5"); Migrate(CostYoung, "Wood:8,Resin:3,Dandelion:2", "BeechSeeds:2"); Migrate(CostWeeping, "FineWood:8,Resin:5,Dandelion:4,Honey:1", "BeechSeeds:4"); Migrate(CostBonsai, "Stone:4,Wood:2,Resin:2,Dandelion:2", "BeechSeeds:3"); Migrate(CostBush, "Wood:4,Resin:2,Dandelion:3", "BeechSeeds:1"); Strings.Register(); PrefabManager.OnVanillaPrefabsAvailable += SakuraPieces.Register; PrefabManager.OnPrefabsRegistered += ReapplyRecipes; PrefabManager.OnPrefabsRegistered += SakuraPieces.RenderIcons; SynchronizationManager.OnConfigurationSynchronized += delegate { ReapplyRecipes(); }; ConfigEntry<string>[] array = new ConfigEntry<string>[7] { StonePortalRecipe, WoodPortalRecipe, CostLarge, CostYoung, CostWeeping, CostBonsai, CostBush }; for (int num = 0; num < array.Length; num++) { array[num].SettingChanged += delegate { ReapplyRecipes(); }; } PortalsEnabled.SettingChanged += delegate { ReapplyRecipes(); }; SakuraSway.SettingChanged += delegate { SakuraPieces.ApplyWindConfig(); }; SakuraSwayStrength.SettingChanged += delegate { SakuraPieces.ApplyWindConfig(); }; ((BaseUnityPlugin)this).Config.SettingChanged += delegate { ClockHud.MarkDirty(); }; new Harmony("yura.valheim.homesteadpack").PatchAll(typeof(HomesteadPlugin).Assembly); Log.LogInfo((object)"Homestead Pack 1.0.13 loaded"); } private static void Migrate(ConfigEntry<string> entry, string oldDefault, string newValue) { if (entry.Value == oldDefault) { entry.Value = newValue; Log.LogInfo((object)("Config " + ((ConfigEntryBase)entry).Definition.Section + "/" + ((ConfigEntryBase)entry).Definition.Key + " upgraded from the old default to '" + newValue + "'")); } } private void Update() { _creditTimer -= Time.unscaledDeltaTime; if (_creditTimer <= 0f) { _creditTimer = 3f; try { CraftCredit.Check(); } catch (Exception ex) { Log.LogWarning((object)("CraftCredit: " + ex.Message)); } } } internal static void ReapplyRecipes() { try { PortalRecipes.ClearCache(); PortalRecipes.Apply(); SakuraPieces.ApplyCosts(); } catch (Exception ex) { Log.LogWarning((object)("ReapplyRecipes: " + ex)); } } private void BindConfig() { PortalsEnabled = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "1. Portals", "Enabled", true, "Change portal recipes. Server-controlled: only the server admin's value is used in multiplayer.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); StonePortalRecipe = ConfigFileExtensions.BindConfig<string>(((BaseUnityPlugin)this).Config, "1. Portals", "StonePortalRecipe", "MoltenCore:5,GreydwarfEye:20,Grausten:30", "Recipe for every portal prefab with 'stone' in its name (portal_stone). Format: ItemPrefab:Amount,ItemPrefab:Amount. Server-controlled.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); WoodPortalRecipe = ConfigFileExtensions.BindConfig<string>(((BaseUnityPlugin)this).Config, "1. Portals", "WoodPortalRecipe", "FineWood:40,GreydwarfEye:20,SurtlingCore:4", "Recipe for every other TeleportWorld prefab (portal_wood and the legacy 'portal' prefab). Server-controlled.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ClockEnabled = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "2. Clock", "Enabled", true, "Show the clock under the minimap.", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ConfigFile config = ((BaseUnityPlugin)this).Config; AcceptableValueBase val = (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Auto", "Ukrainian", "English" }); ClockLanguage = ConfigFileExtensions.BindConfig<string>(config, "2. Clock", "Language", "Auto", "Clock language: Auto (Ukrainian if the game is Ukrainian, otherwise English), Ukrainian, English.", false, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ConfigFile config2 = ((BaseUnityPlugin)this).Config; val = (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Minimap", "ScreenTopRight" }); ClockAnchor = ConfigFileExtensions.BindConfig<string>(config2, "2. Clock", "Anchor", "Minimap", "Minimap = under the small map (follows it). ScreenTopRight = fixed to the screen's top-right corner (fallback if the layout looks wrong).", false, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ClockOffsetX = ConfigFileExtensions.BindConfig<float>(((BaseUnityPlugin)this).Config, "2. Clock", "OffsetX", 0f, "Horizontal offset in pixels (positive = right).", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ClockOffsetY = ConfigFileExtensions.BindConfig<float>(((BaseUnityPlugin)this).Config, "2. Clock", "OffsetY", -4f, "Vertical offset in pixels (negative = lower).", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ConfigFile config3 = ((BaseUnityPlugin)this).Config; val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.4f, 3f); ClockScale = ConfigFileExtensions.BindConfig<float>(config3, "2. Clock", "Scale", 1f, "Overall scale of the clock panel.", false, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ConfigFile config4 = ((BaseUnityPlugin)this).Config; val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(120f, 500f); ClockWidth = ConfigFileExtensions.BindConfig<float>(config4, "2. Clock", "Width", 200f, "Panel width in pixels (before Scale).", false, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ConfigFile config5 = ((BaseUnityPlugin)this).Config; val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 160f); ClockHeight = ConfigFileExtensions.BindConfig<float>(config5, "2. Clock", "Height", 58f, "Panel height in pixels (before Scale).", false, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ConfigFile config6 = ((BaseUnityPlugin)this).Config; val = (AcceptableValueBase)(object)new AcceptableValueRange<int>(8, 64); ClockTimeFontSize = ConfigFileExtensions.BindConfig<int>(config6, "2. Clock", "TimeFontSize", 24, "Font size of the HH:MM text.", false, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ConfigFile config7 = ((BaseUnityPlugin)this).Config; val = (AcceptableValueBase)(object)new AcceptableValueRange<int>(6, 48); ClockInfoFontSize = ConfigFileExtensions.BindConfig<int>(config7, "2. Clock", "InfoFontSize", 16, "Font size of the phase / day text.", false, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ConfigFile config8 = ((BaseUnityPlugin)this).Config; val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f); ClockBackgroundOpacity = ConfigFileExtensions.BindConfig<float>(config8, "2. Clock", "BackgroundOpacity", 0.6f, "Opacity of the dark panel background.", false, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ClockShowIcon = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "2. Clock", "ShowIcon", true, "Show the sun / moon icon.", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ClockShowPhase = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "2. Clock", "ShowPhase", true, "Show the time-of-day name (dawn, morning, noon...).", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ClockShowDay = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "2. Clock", "ShowDay", true, "Show the day number.", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ClockShowStrip = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "2. Clock", "ShowStrip", true, "Show the thin 24-hour strip with the current-time marker.", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ClockShiftStatusEffects = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "2. Clock", "ShiftStatusEffects", true, "Move the status-effect icons down so the clock does not cover them.", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ClockStatusEffectGap = ConfigFileExtensions.BindConfig<float>(((BaseUnityPlugin)this).Config, "2. Clock", "StatusEffectGap", 6f, "Extra gap (pixels) between the clock and the status effects.", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); CraftCreditEnabled = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "3. Craft achievements", "Enabled", true, "Count an item for the 'craft everything' achievements as soon as it is in your inventory (picked up, received from a friend). Cheated items and cheat-marked profiles are still blocked by the game.", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); CraftCreditExclude = ConfigFileExtensions.BindConfig<string>(((BaseUnityPlugin)this).Config, "3. Craft achievements", "ExcludeItems", "", "Comma separated shared-names (e.g. $item_sword_dyrnwyn) that must still be crafted for real.", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); CraftCreditLog = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "3. Craft achievements", "LogCredits", true, "Write every credited item to the BepInEx log.", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); SakuraEnabled = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "4. Sakura", "Enabled", true, "Add the five sakura trees; they are planted with the Cultivator using Beech Seeds. Must match on all players. Needs a game restart.", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); CostLarge = ConfigFileExtensions.BindConfig<string>(((BaseUnityPlugin)this).Config, "4. Sakura", "CostLarge", "BeechSeeds:5", "Cost of the Great Sakura. Server-controlled.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); CostYoung = ConfigFileExtensions.BindConfig<string>(((BaseUnityPlugin)this).Config, "4. Sakura", "CostYoung", "BeechSeeds:2", "Cost of the Young Sakura. Server-controlled.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); CostWeeping = ConfigFileExtensions.BindConfig<string>(((BaseUnityPlugin)this).Config, "4. Sakura", "CostWeeping", "BeechSeeds:4", "Cost of the Weeping Sakura. Server-controlled.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); CostBonsai = ConfigFileExtensions.BindConfig<string>(((BaseUnityPlugin)this).Config, "4. Sakura", "CostBonsai", "BeechSeeds:3", "Cost of the Potted Sakura Bonsai. Server-controlled.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); CostBush = ConfigFileExtensions.BindConfig<string>(((BaseUnityPlugin)this).Config, "4. Sakura", "CostBush", "BeechSeeds:1", "Cost of the Flowering Sakura Bush. Server-controlled.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); SakuraCards = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "4. Sakura", "FoliageCards", true, "Visual quality only: true = two LOD levels with full flower cards, false = one cheaper LOD level. Never changes colliders, variants or saved identity. Needs a game restart.", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); SakuraBarkTint = ConfigFileExtensions.BindConfig<string>(((BaseUnityPlugin)this).Config, "4. Sakura", "BarkTint", "1.00,1.00,1.00", "Multiplicative tint of the sakura bark texture, R,G,B 0..1. 1,1,1 = as painted. Needs a game restart.", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); SakuraSway = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "4. Sakura", "Sway", true, "Gently sway the crowns (only when you are nearby).", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ConfigFile config9 = ((BaseUnityPlugin)this).Config; val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 4f); SakuraSwayStrength = ConfigFileExtensions.BindConfig<float>(config9, "4. Sakura", "SwayStrength", 1f, "Sway amplitude multiplier.", false, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); SakuraPetals = ConfigFileExtensions.BindConfig<bool>(((BaseUnityPlugin)this).Config, "4. Sakura", "FallingPetals", true, "Falling petal particles (only when you are nearby).", false, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ConfigFile config10 = ((BaseUnityPlugin)this).Config; val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 4f); SakuraPetalRate = ConfigFileExtensions.BindConfig<float>(config10, "4. Sakura", "PetalRate", 1f, "Petal emission multiplier (0 = off).", false, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ConfigFile config11 = ((BaseUnityPlugin)this).Config; val = (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 120f); SakuraEffectRange = ConfigFileExtensions.BindConfig<float>(config11, "4. Sakura", "EffectRange", 35f, "Sway and petals only run within this distance (meters) of the local player.", false, (int?)null, val, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); } } internal static class PortalRecipes { private enum Kind { Stone, Wood } private static readonly Dictionary<int, Requirement[]> Originals = new Dictionary<int, Requirement[]>(); private static readonly Dictionary<int, Kind> KindCache = new Dictionary<int, Kind>(); private static readonly HashSet<int> NotPortal = new HashSet<int>(); private static readonly Dictionary<string, Requirement[]> Cache = new Dictionary<string, Requirement[]>(); private static readonly Dictionary<Kind, Requirement[]> LastGood = new Dictionary<Kind, Requirement[]>(); private static ObjectDB _cacheDb; private static readonly HashSet<string> Logged = new HashSet<string>(); public static void ClearCache() { Cache.Clear(); } public static void ClearSceneState() { Cache.Clear(); LastGood.Clear(); KindCache.Clear(); NotPortal.Clear(); Logged.Clear(); _cacheDb = null; } private static bool TryGetKind(Piece piece, out Kind kind) { int instanceID = ((Object)piece).GetInstanceID(); if (KindCache.TryGetValue(instanceID, out kind)) { return true; } if (NotPortal.Contains(instanceID)) { return false; } if ((Object)(object)((Component)piece).GetComponent<TeleportWorld>() == (Object)null) { NotPortal.Add(instanceID); return false; } string text = ((Object)((Component)piece).gameObject).name.Replace("(Clone)", "").Trim(); string text2 = text.ToLowerInvariant(); string arg; switch (text2) { case "portal_stone": kind = Kind.Stone; arg = "known vanilla stone portal"; break; case "portal_wood": case "portal": kind = Kind.Wood; arg = "known vanilla wood/legacy portal"; break; default: if (text2.Contains("stone")) { kind = Kind.Stone; arg = "third-party prefab, name contains 'stone'"; } else { kind = Kind.Wood; arg = "third-party prefab, default wood recipe"; } break; } KindCache[instanceID] = kind; HomesteadPlugin.Log.LogInfo((object)$"[Portals] '{text}' -> {kind} recipe ({arg})"); return true; } private static Requirement[] Desired(Kind kind) { if ((Object)(object)ObjectDB.instance == (Object)null || ObjectDB.instance.m_items.Count == 0) { return null; } if ((Object)(object)_cacheDb != (Object)(object)ObjectDB.instance) { Cache.Clear(); _cacheDb = ObjectDB.instance; } string text = ((kind == Kind.Stone) ? HomesteadPlugin.StonePortalRecipe.Value : HomesteadPlugin.WoodPortalRecipe.V