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 Hearth and Blossom v1.0.20
HomesteadPack.dll
Decompiled 14 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using HomesteadPack.Tracker; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Extensions; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using SoftReferenceableAssets; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; 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.20.0")] [assembly: AssemblyInformationalVersion("1.0.20")] [assembly: AssemblyProduct("HomesteadPack")] [assembly: AssemblyTitle("HomesteadPack")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.20.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 static class AchievementFilter { private static readonly HashSet<string> Logged = new HashSet<string>(); private static int _items; private static int _pieces; private static int _creatures; private static HashSet<string> _noSource; private static int _noSourceFor; private static readonly HashSet<string> VerifiedNoSource = new HashSet<string> { "MushroomBlue" }; private static HashSet<string> NoSourceItems() { if ((Object)(object)ZNetScene.instance == (Object)null || (Object)(object)ZoneSystem.instance == (Object)null || ZoneSystem.instance.m_vegetation == null || ZoneSystem.instance.m_vegetation.Count == 0) { return null; } int instanceID = ((Object)ZNetScene.instance).GetInstanceID(); if (_noSource != null && _noSourceFor == instanceID) { return _noSource; } HashSet<string> hashSet = new HashSet<string>(); HashSet<string> sources = new HashSet<string>(); Action<DropTable> action = delegate(DropTable dt) { //IL_001b: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (dt != null && dt.m_drops != null) { foreach (DropData drop in dt.m_drops) { if ((Object)(object)drop.m_item != (Object)null) { sources.Add(((Object)drop.m_item).name); } } } }; foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if ((Object)(object)prefab == (Object)null) { continue; } Pickable component = prefab.GetComponent<Pickable>(); if ((Object)(object)component != (Object)null && (Object)(object)component.m_itemPrefab != (Object)null) { hashSet.Add(((Object)component.m_itemPrefab).name); } CharacterDrop component2 = prefab.GetComponent<CharacterDrop>(); if ((Object)(object)component2 != (Object)null && component2.m_drops != null) { foreach (Drop drop2 in component2.m_drops) { if (drop2 != null && (Object)(object)drop2.m_prefab != (Object)null) { sources.Add(((Object)drop2.m_prefab).name); } } } DropOnDestroyed component3 = prefab.GetComponent<DropOnDestroyed>(); if ((Object)(object)component3 != (Object)null) { action(component3.m_dropWhenDestroyed); } Container component4 = prefab.GetComponent<Container>(); if ((Object)(object)component4 != (Object)null) { action(component4.m_defaultItems); } MineRock component5 = prefab.GetComponent<MineRock>(); if ((Object)(object)component5 != (Object)null) { action(component5.m_dropItems); } MineRock5 component6 = prefab.GetComponent<MineRock5>(); if ((Object)(object)component6 != (Object)null) { action(component6.m_dropItems); } TreeBase component7 = prefab.GetComponent<TreeBase>(); if ((Object)(object)component7 != (Object)null) { action(component7.m_dropWhenDestroyed); } Trader component8 = prefab.GetComponent<Trader>(); if (!((Object)(object)component8 != (Object)null) || component8.m_items == null) { continue; } foreach (TradeItem item in component8.m_items) { if (item != null && (Object)(object)item.m_prefab != (Object)null) { sources.Add(((Object)item.m_prefab).name); } } } foreach (ZoneVegetation item2 in ZoneSystem.instance.m_vegetation) { if (item2 == null || (Object)(object)item2.m_prefab == (Object)null || !item2.m_enable) { continue; } Pickable component9 = item2.m_prefab.GetComponent<Pickable>(); if ((Object)(object)component9 != (Object)null && (Object)(object)component9.m_itemPrefab != (Object)null) { sources.Add(((Object)component9.m_itemPrefab).name); } CharacterDrop component10 = item2.m_prefab.GetComponent<CharacterDrop>(); if (!((Object)(object)component10 != (Object)null) || component10.m_drops == null) { continue; } foreach (Drop drop3 in component10.m_drops) { if (drop3 != null && (Object)(object)drop3.m_prefab != (Object)null) { sources.Add(((Object)drop3.m_prefab).name); } } } HashSet<string> hashSet2 = new HashSet<string>(); foreach (string item3 in hashSet) { if (VerifiedNoSource.Contains(item3) && !sources.Contains(item3)) { hashSet2.Add(item3); } } foreach (Recipe recipe in ObjectDB.instance.m_recipes) { if ((Object)(object)recipe != (Object)null && (Object)(object)recipe.m_item != (Object)null) { hashSet2.Remove(((Object)recipe.m_item).name); } } _noSource = hashSet2; _noSourceFor = instanceID; HomesteadPlugin.Log.LogInfo((object)("[Achievements] pickable items with no source in the world: " + ((hashSet2.Count == 0) ? "none" : string.Join(", ", new List<string>(hashSet2).ToArray())))); return hashSet2; } private static bool NeedsUnobtainable(Requirement[] reqs, HashSet<string> noSource) { if (noSource == null || noSource.Count == 0 || reqs == null) { return false; } foreach (Requirement val in reqs) { if (val != null && (Object)(object)val.m_resItem != (Object)null && noSource.Contains(((Object)val.m_resItem).name)) { return true; } } return false; } private static bool RecipeUsable(Recipe r) { if ((Object)(object)r == (Object)null || !r.m_enabled || (Object)(object)r.m_item == (Object)null) { return false; } Requirement[] resources = r.m_resources; foreach (Requirement val in resources) { if (val == null || (Object)(object)val.m_resItem == (Object)null) { return false; } } if (NeedsUnobtainable(r.m_resources, NoSourceItems())) { return false; } return true; } private static HashSet<string> SeasonalPieceNames(Player p) { HashSet<string> hashSet = new HashSet<string>(); try { FieldInfo fieldInfo = AccessTools.Field(typeof(Player), "m_seasonalItemGroups"); IEnumerable enumerable = (((Object)(object)p != (Object)null) ? (fieldInfo?.GetValue(p) as IEnumerable) : null); if (enumerable != null) { foreach (object item in enumerable) { if (!(item.GetType().GetField("Pieces")?.GetValue(item) is IEnumerable enumerable2)) { continue; } foreach (object item2 in enumerable2) { GameObject val = (GameObject)((item2 is GameObject) ? item2 : null); if ((Object)(object)val != (Object)null) { hashSet.Add(((Object)val).name); } } } } } catch { } return hashSet; } private static HashSet<Recipe> SeasonalRecipes() { HashSet<Recipe> hashSet = new HashSet<Recipe>(); try { GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("Player") : null); FieldInfo fieldInfo = AccessTools.Field(typeof(Player), "m_seasonalItemGroups"); IEnumerable enumerable = (((Object)(object)val != (Object)null) ? (fieldInfo?.GetValue(val.GetComponent<Player>()) as IEnumerable) : null); if (enumerable != null) { foreach (object item in enumerable) { if (!(item.GetType().GetField("Recipes")?.GetValue(item) is IEnumerable enumerable2)) { continue; } foreach (object item2 in enumerable2) { Recipe val2 = (Recipe)((item2 is Recipe) ? item2 : null); if ((Object)(object)val2 != (Object)null) { hashSet.Add(val2); } } } } } catch { } return hashSet; } public static void Prepare(Achievements ach) { //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Invalid comparison between Unknown and I4 //IL_01e4: 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_0282: Invalid comparison between Unknown and I4 //IL_0287: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ach == (Object)null || !HomesteadPlugin.AchievementFilter.Value || (Object)(object)ObjectDB.instance == (Object)null) { return; } _items = (_pieces = (_creatures = 0)); HashSet<Recipe> hashSet = SeasonalRecipes(); Dictionary<ItemDrop, bool> dictionary = new Dictionary<ItemDrop, bool>(); foreach (Recipe recipe in ObjectDB.instance.m_recipes) { if (!((Object)(object)recipe == (Object)null) && !((Object)(object)recipe.m_item == (Object)null) && !((Object)(object)recipe.m_craftingStation == (Object)null)) { dictionary.TryGetValue(recipe.m_item, out var value); dictionary[recipe.m_item] = value || RecipeUsable(recipe) || hashSet.Contains(recipe); } } foreach (KeyValuePair<ItemDrop, bool> item in dictionary) { if (!item.Value) { GameObject gameObject = ((Component)item.Key).gameObject; if (!ach.m_itemsExcluded.Contains(gameObject)) { ach.m_itemsExcluded.Add(gameObject); _items++; Note("item", item.Key.m_itemData?.m_shared?.m_name ?? ((Object)gameObject).name); } } } if (!((Object)(object)ZNetScene.instance != (Object)null)) { return; } foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { Character val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<Character>() : null); if ((Object)(object)val == (Object)null) { continue; } if (string.IsNullOrWhiteSpace(val.m_name)) { if ((int)val.m_killedForAchievements == 1) { val.m_killedForAchievements = (AchievementInclusion)2; _creatures++; Note("creature", "(no name) prefab " + ((Object)prefab).name); } continue; } string text = val.m_name.ToLowerInvariant(); string text2 = ((Object)prefab).name.ToLowerInvariant(); if ((text.Contains("_summon") || text2.Contains("friendly") || text2.Contains("skellies")) && !text.StartsWith("$enemy_") && !text.StartsWith("$spiritcaller") && (int)val.m_killedForAchievements != 2) { val.m_killedForAchievements = (AchievementInclusion)2; _creatures++; Note("creature", val.m_name); } } } public static void FilterPieces(List<Piece> list) { if (list == null || !HomesteadPlugin.AchievementFilter.Value) { return; } GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("Player") : null); Player val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Player>() : Player.m_localPlayer); if ((Object)(object)val2 == (Object)null) { return; } HashSet<string> hashSet = SeasonalPieceNames(val2); if (hashSet.Count == 0) { return; } for (int num = list.Count - 1; num >= 0; num--) { Piece val3 = list[num]; if ((Object)(object)val3 == (Object)null) { list.RemoveAt(num); } else { bool flag = false; if (val3.m_resources != null) { Requirement[] resources = val3.m_resources; foreach (Requirement val4 in resources) { if (val4 == null || (Object)(object)val4.m_resItem == (Object)null) { flag = true; break; } } } if (!flag && NeedsUnobtainable(val3.m_resources, NoSourceItems())) { flag = true; } bool flag2 = (!val3.m_enabled && !hashSet.Contains(((Object)((Component)val3).gameObject).name)) || string.IsNullOrWhiteSpace(val3.m_name); if (flag || flag2) { list.RemoveAt(num); _pieces++; Note("piece", val3.m_name); } } } } private static void Note(string kind, string name) { if (Logged.Add(kind + name) && Logged.Count < 80) { HomesteadPlugin.Log.LogInfo((object)("[Achievements] not counted (" + kind + ", cannot be obtained): " + name)); } } public static void Summary() { if (_items + _pieces + _creatures > 0) { HomesteadPlugin.Log.LogInfo((object)$"[Achievements] left out of 'do everything' lists: {_items} item(s), {_pieces} piece(s), {_creatures} creature(s)"); } } } [HarmonyPatch(typeof(Achievements), "Initialize")] internal static class Achievements_Initialize_Patch { [HarmonyPriority(800)] private static void Prefix(Achievements __instance) { try { AchievementFilter.Prepare(__instance); } catch (Exception ex) { HomesteadPlugin.Log.LogWarning((object)("[Achievements] prepare failed: " + ex.Message)); } } private static void Postfix() { try { AchievementFilter.Summary(); } catch { } } } [HarmonyPatch(typeof(ObjectDB), "GetAllBuildPieces")] internal static class ObjectDB_GetAllBuildPieces_Patch { private static void Postfix(List<Piece> __result) { try { AchievementFilter.FilterPieces(__result); } catch (Exception ex) { HomesteadPlugin.Log.LogWarning((object)("[Achievements] piece filter failed: " + ex.Message)); } } } 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); private readonly Vector3[] _statusCorners = (Vector3[])(object)new Vector3[4]; 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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) 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; } bool flag = clockVisible && HomesteadPlugin.ClockShiftStatusEffects.Value; if (flag && !_statusShifted && !StatusOverlapsClock(statusEffectListRoot)) { flag = false; } if (flag) { 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 bool StatusOverlapsClock(RectTransform list) { //IL_014f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_root == (Object)null || !((Component)_root).gameObject.activeInHierarchy) { return false; } _root.GetWorldCorners(_corners); Rect val = default(Rect); ((Rect)(ref val))..ctor(_corners[0].x, _corners[0].y, _corners[2].x - _corners[0].x, _corners[2].y - _corners[0].y); Rect val3 = default(Rect); for (int i = 0; i < ((Transform)list).childCount; i++) { Transform child = ((Transform)list).GetChild(i); RectTransform val2 = (RectTransform)(object)((child is RectTransform) ? child : null); if (!((Object)(object)val2 == (Object)null) && ((Component)val2).gameObject.activeInHierarchy) { val2.GetWorldCorners(_statusCorners); ((Rect)(ref val3))..ctor(_statusCorners[0].x, _statusCorners[0].y, _statusCorners[2].x - _statusCorners[0].x, _statusCorners[2].y - _statusCorners[0].y); if (((Rect)(ref val3)).Overlaps(val)) { return true; } } } return false; } 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)); } } } internal static class CraftFilter { private sealed class Source { public string Id; public string Name; public Sprite Icon; public int Count; public GameObject Button; public Image Ring; public Image Disc; public Image IconImg; } [CompilerGenerated] private static class <>O { public static UnityAction <0>__ClearAll; } internal const string VanillaId = "valheim"; internal const string OtherId = "other"; private static readonly Dictionary<string, Source> Sources = new Dictionary<string, Source>(); private static readonly HashSet<string> VanillaItems = new HashSet<string>(); private static readonly HashSet<string> VanillaRecipes = new HashSet<string>(); private static readonly Dictionary<Recipe, string> SourceCache = new Dictionary<Recipe, string>(); private static readonly ConditionalWeakTable<Recipe, string> Creators = new ConditionalWeakTable<Recipe, string>(); private static readonly HashSet<string> Selected = new HashSet<string>(); private static string _search = ""; private static bool _loadedSelection; private static string _lastKey = ""; private static int _lastShown; private static int _lastTotal; private static GameObject _root; private static InputField _input; private static Text _hover; private static Font _font; private static InventoryGui _builtFor; private static bool _rebuilding; private static string _hoverText; private static Dictionary<string, string> _asmToGuid; private static Dictionary<string, string> _dirToGuid; private static readonly string[] Skipped = new string[13] { "mscorlib", "System", "UnityEngine", "0Harmony", "MonoMod", "BepInEx", "Jotunn", "assembly_valheim", "assembly_utils", "assembly_guiutils", "Anonymously Hosted", "Mono.", "Unity." }; private static Dictionary<string, string> _helperMap; private static Sprite _vanillaIcon; private static Sprite _otherIcon; private static Sprite _disc; private static Sprite _ring; private const float Cell = 30f; private const float Gap = 5f; private const float SearchH = 28f; private const float LabelH = 38f; private const float Pad = 4f; private static readonly Color Gold = new Color(0.95f, 0.78f, 0.3f, 1f); private static readonly Color GoldDim = new Color(0.62f, 0.5f, 0.26f, 0.55f); private static readonly Color DiscCol = new Color(0.13f, 0.1f, 0.08f, 0.95f); private static bool Uk() { try { return Localization.instance != null && Localization.instance.GetSelectedLanguage() == "Ukrainian"; } catch { return false; } } private static string T(string en, string uk) { if (!Uk()) { return en; } return uk; } public static void RecordVanilla(ObjectDB db) { if ((Object)(object)db == (Object)null || VanillaRecipes.Count > 0 || db.m_items == null || db.m_items.Count == 0 || db.m_recipes == null || db.m_recipes.Count == 0) { return; } foreach (GameObject item in db.m_items) { if ((Object)(object)item != (Object)null) { VanillaItems.Add(((Object)item).name); } } foreach (Recipe recipe in db.m_recipes) { if ((Object)(object)recipe != (Object)null) { VanillaRecipes.Add(((Object)recipe).name); } } HomesteadPlugin.Log.LogInfo((object)$"[CraftFilter] recorded {VanillaItems.Count} vanilla items and {VanillaRecipes.Count} vanilla recipes"); } private static void BuildAssemblyMap() { _asmToGuid = new Dictionary<string, string>(); _dirToGuid = new Dictionary<string, string>(); foreach (PluginInfo value in Chainloader.PluginInfos.Values) { if (value == null) { continue; } try { if ((Object)(object)value.Instance != (Object)null) { _asmToGuid[((object)value.Instance).GetType().Assembly.FullName] = value.Metadata.GUID; } string text = Path.GetFullPath(Path.GetDirectoryName(value.Location)).TrimEnd(new char[1] { '\\' }); if (!string.Equals(text, Path.GetFullPath(Paths.PluginPath).TrimEnd(new char[1] { '\\' }), StringComparison.OrdinalIgnoreCase)) { _dirToGuid[text] = value.Metadata.GUID; } } catch { } } } private static string GuidOfAssembly(Assembly a) { if (_asmToGuid == null || _asmToGuid.Count != Chainloader.PluginInfos.Count) { BuildAssemblyMap(); } if (_asmToGuid.TryGetValue(a.FullName, out var value)) { return value; } try { string text = (a.IsDynamic ? null : a.Location); if (!string.IsNullOrEmpty(text)) { string key = Path.GetFullPath(Path.GetDirectoryName(text)).TrimEnd(new char[1] { '\\' }); if (_dirToGuid.TryGetValue(key, out value)) { return value; } } } catch { } return null; } internal static void NoteCreated(ScriptableObject so) { Recipe val = (Recipe)(object)((so is Recipe) ? so : null); if ((Object)(object)val == (Object)null) { return; } try { StackFrame[] array = new StackTrace(2, fNeedFileInfo: false).GetFrames() ?? new StackFrame[0]; foreach (StackFrame obj in array) { MethodBase method = obj.GetMethod(); Type type = ((method != null) ? method.DeclaringType : null); Assembly assembly = ((type != null) ? type.Assembly : null); if (assembly == nul