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 Stjarna v0.1.0
plugins/Stjarna.dll
Decompiled a day agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GBV.Shared; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Guys Being Vikings")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+71eadc83c57b0679777ea2b3c8c4b80aa1d4ff35")] [assembly: AssemblyProduct("Stjarna")] [assembly: AssemblyTitle("Stjarna")] [assembly: AssemblyVersion("0.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace GBV.Shared { internal static class Theme { public static readonly Color StoneDeep = Hex("0A0B0D"); public static readonly Color Stone = Hex("14161A"); public static readonly Color StoneHi = Hex("1F2329"); public static readonly Color StoneLit = Hex("2D323A"); public static readonly Color Carve = Hex("060708"); public static readonly Color Brass = Hex("C9A45C"); public static readonly Color BrassHi = Hex("F2D9A0"); public static readonly Color BrassDim = Hex("6B5630"); public static readonly Color BrassInk = Hex("17110478"); public static readonly Color TextHi = Hex("F7F4EE"); public static readonly Color Text = Hex("D8D4CC"); public static readonly Color Muted = Hex("9FA0A2"); public static readonly Color Faint = Hex("74767A"); public static readonly Color Good = Hex("A6C978"); public static readonly Color Bad = Hex("DD6A57"); public static readonly Color Warn = Hex("E8B25C"); public const float Pad = 30f; public const float Inlay = 9f; public const float TabH = 46f; public const float RowH = 30f; public const float FooterH = 44f; public static GUIStyle Blank; public static GUIStyle Wordmark; public static GUIStyle TabOn; public static GUIStyle TabOff; public static GUIStyle Heading; public static GUIStyle Body; public static GUIStyle BodyHi; public static GUIStyle Dim; public static GUIStyle Small; public static GUIStyle SmallRight; public static GUIStyle Mono; public static GUIStyle MonoDim; public static GUIStyle MonoEcho; public static GUIStyle Search; public static GUIStyle Field; public static GUIStyle FieldText; public static GUIStyle FieldArea; public static GUIStyle Console_; public static GUIStyle Link; public static GUIStyle LinkOn; public static GUIStyle Chip; public static GUIStyle ChipOn; public static GUIStyle Row; public static GUIStyle Action; public static GUIStyle ActionKey; public static GUIStyle Danger; public static GUIStyle Btn; public static GUIStyle BtnOn; public static GUIStyle BtnPrimary; public static GUIStyle BtnDanger; public static GUIStyle BtnSmall; public static GUIStyle BtnSmallOn; public static GUIStyle DropItem; public static GUIStyle TileName; public static GUIStyle TileNameHot; public static GUIStyle Glyph; public static GUIStyle ScrollbarV; public static GUIStyle ScrollbarThumb; public static GUIStyle Scroll; public static Texture2D Grain; public static Texture2D Px; private static bool _built; public static void EnsureBuilt() { //IL_000e: 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_0036: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_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_00a5: 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_00d4: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_016c: 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_019e: 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_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Expected O, but got Unknown //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_024a: 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_0271: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: 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_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: 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_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0329: 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_0338: 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_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: 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_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_0529: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Expected O, but got Unknown //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_05ac: Unknown result type (might be due to invalid IL or missing references) //IL_05b6: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_05d1: Unknown result type (might be due to invalid IL or missing references) //IL_05db: Unknown result type (might be due to invalid IL or missing references) //IL_05e0: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Expected O, but got Unknown //IL_05ea: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Expected O, but got Unknown //IL_05fb: Unknown result type (might be due to invalid IL or missing references) //IL_0600: Unknown result type (might be due to invalid IL or missing references) //IL_060a: Expected O, but got Unknown //IL_060a: Unknown result type (might be due to invalid IL or missing references) //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_061d: Unknown result type (might be due to invalid IL or missing references) //IL_0629: Expected O, but got Unknown //IL_062e: Unknown result type (might be due to invalid IL or missing references) //IL_0633: Unknown result type (might be due to invalid IL or missing references) //IL_063b: Unknown result type (might be due to invalid IL or missing references) //IL_0646: Unknown result type (might be due to invalid IL or missing references) //IL_064d: Unknown result type (might be due to invalid IL or missing references) //IL_0652: Unknown result type (might be due to invalid IL or missing references) //IL_065c: Expected O, but got Unknown //IL_0661: Expected O, but got Unknown //IL_0666: Unknown result type (might be due to invalid IL or missing references) //IL_066b: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_067e: Unknown result type (might be due to invalid IL or missing references) //IL_0685: Unknown result type (might be due to invalid IL or missing references) //IL_068a: Unknown result type (might be due to invalid IL or missing references) //IL_0694: Expected O, but got Unknown //IL_0699: Expected O, but got Unknown //IL_069e: Unknown result type (might be due to invalid IL or missing references) //IL_06a3: Unknown result type (might be due to invalid IL or missing references) //IL_06ab: Unknown result type (might be due to invalid IL or missing references) //IL_06b6: Unknown result type (might be due to invalid IL or missing references) //IL_06bd: Unknown result type (might be due to invalid IL or missing references) //IL_06c4: Unknown result type (might be due to invalid IL or missing references) //IL_06ce: Expected O, but got Unknown //IL_06ce: Unknown result type (might be due to invalid IL or missing references) //IL_06da: Expected O, but got Unknown //IL_06df: Unknown result type (might be due to invalid IL or missing references) //IL_06e4: Unknown result type (might be due to invalid IL or missing references) //IL_06ec: Unknown result type (might be due to invalid IL or missing references) //IL_06f7: Unknown result type (might be due to invalid IL or missing references) //IL_06fe: Unknown result type (might be due to invalid IL or missing references) //IL_0703: Unknown result type (might be due to invalid IL or missing references) //IL_070d: Expected O, but got Unknown //IL_0712: Expected O, but got Unknown //IL_071c: Unknown result type (might be due to invalid IL or missing references) //IL_0730: Unknown result type (might be due to invalid IL or missing references) //IL_0744: Unknown result type (might be due to invalid IL or missing references) //IL_0762: Unknown result type (might be due to invalid IL or missing references) //IL_07b0: Unknown result type (might be due to invalid IL or missing references) //IL_07e3: Unknown result type (might be due to invalid IL or missing references) //IL_081b: Unknown result type (might be due to invalid IL or missing references) //IL_0835: Unknown result type (might be due to invalid IL or missing references) //IL_083f: Expected O, but got Unknown //IL_0849: Unknown result type (might be due to invalid IL or missing references) //IL_084e: Unknown result type (might be due to invalid IL or missing references) //IL_0859: Unknown result type (might be due to invalid IL or missing references) //IL_0868: Unknown result type (might be due to invalid IL or missing references) //IL_086d: Unknown result type (might be due to invalid IL or missing references) //IL_0877: Expected O, but got Unknown //IL_0877: Unknown result type (might be due to invalid IL or missing references) //IL_0882: Unknown result type (might be due to invalid IL or missing references) //IL_0888: Unknown result type (might be due to invalid IL or missing references) //IL_0892: Expected O, but got Unknown //IL_0892: Unknown result type (might be due to invalid IL or missing references) //IL_0897: Unknown result type (might be due to invalid IL or missing references) //IL_08a1: Expected O, but got Unknown //IL_08a6: Expected O, but got Unknown //IL_08b0: Unknown result type (might be due to invalid IL or missing references) //IL_08b5: Unknown result type (might be due to invalid IL or missing references) //IL_08bb: Unknown result type (might be due to invalid IL or missing references) //IL_08ca: Unknown result type (might be due to invalid IL or missing references) //IL_08d0: Unknown result type (might be due to invalid IL or missing references) //IL_08df: Unknown result type (might be due to invalid IL or missing references) //IL_08e5: Unknown result type (might be due to invalid IL or missing references) //IL_08f4: Unknown result type (might be due to invalid IL or missing references) //IL_08f9: Unknown result type (might be due to invalid IL or missing references) //IL_0903: Expected O, but got Unknown //IL_0903: Unknown result type (might be due to invalid IL or missing references) //IL_090e: Unknown result type (might be due to invalid IL or missing references) //IL_0913: Unknown result type (might be due to invalid IL or missing references) //IL_091d: Expected O, but got Unknown //IL_091d: Unknown result type (might be due to invalid IL or missing references) //IL_0922: Unknown result type (might be due to invalid IL or missing references) //IL_092c: Expected O, but got Unknown //IL_0931: Expected O, but got Unknown //IL_09b8: Unknown result type (might be due to invalid IL or missing references) //IL_09cc: Unknown result type (might be due to invalid IL or missing references) if (!_built) { _built = true; Px = Solid(Color.white); Grain = StoneGrain(128); Blank = new GUIStyle(); Wordmark = Label(26, (FontStyle)1, TextHi); Heading = Label(11, (FontStyle)1, Brass); Body = Label(13, (FontStyle)0, Text); BodyHi = Label(13, (FontStyle)1, TextHi); Dim = Label(13, (FontStyle)0, Muted); Small = Label(11, (FontStyle)0, Muted); SmallRight = Label(11, (FontStyle)0, Muted); SmallRight.alignment = (TextAnchor)5; Mono = Label(12, (FontStyle)0, TextHi); MonoDim = Label(12, (FontStyle)0, Muted); MonoEcho = Label(12, (FontStyle)1, Brass); TabOff = Ghost(46f, 13, (FontStyle)0, Muted, TextHi); TabOn = Ghost(46f, 13, (FontStyle)1, BrassHi, BrassHi); TabOff.alignment = (TextAnchor)4; TabOn.alignment = (TextAnchor)4; Link = Ghost(30f, 13, (FontStyle)0, Text, BrassHi); LinkOn = Ghost(30f, 13, (FontStyle)1, BrassHi, BrassHi); Link.alignment = (TextAnchor)4; LinkOn.alignment = (TextAnchor)4; Chip = Ghost(26f, 12, (FontStyle)0, Muted, BrassHi); ChipOn = Ghost(26f, 12, (FontStyle)1, Brass, BrassHi); Chip.alignment = (TextAnchor)4; ChipOn.alignment = (TextAnchor)4; Row = Ghost(30f, 13, (FontStyle)0, Text, BrassHi); Row.alignment = (TextAnchor)3; Row.padding = new RectOffset(12, 12, 0, 0); Action = Ghost(34f, 13, (FontStyle)1, Brass, BrassHi); Action.alignment = (TextAnchor)4; ActionKey = Ghost(34f, 13, (FontStyle)1, BrassInk, BrassInk); ActionKey.alignment = (TextAnchor)4; Danger = Ghost(34f, 13, (FontStyle)1, Bad, Hex("FF8B78")); Danger.alignment = (TextAnchor)4; Btn = Plate(34, 4, Hex("1B1F25"), Hex("272D35"), Hex("3B434E"), Hex("262D36"), Hex("39424E"), Hex("6E5F3A"), Hex("14171C"), Hex("1B2027"), Brass, Text, 13); BtnOn = Plate(34, 4, Hex("312B18"), Hex("43391F"), Brass, Hex("3B3320"), Hex("4E4227"), BrassHi, Hex("2A2515"), Hex("352E1A"), BrassHi, BrassHi, 13); BtnPrimary = Plate(34, 4, Hex("A8873A"), Hex("D0A63A"), Hex("F2D9A0"), Hex("C09A38"), Hex("EBC97A"), Hex("F7E6BE"), Hex("8A6E2C"), Hex("A8873A"), Hex("F2D9A0"), Hex("151003"), 13); BtnPrimary.fontStyle = (FontStyle)1; BtnDanger = Plate(34, 4, Hex("5A2621"), Hex("7A332C"), Hex("A8453A"), Hex("7A332C"), Hex("9C4239"), Hex("DD6A57"), Hex("431B17"), Hex("5A2621"), Hex("DD6A57"), Hex("F3C8C0"), 13); BtnDanger.fontStyle = (FontStyle)1; BtnSmall = Plate(26, 3, Hex("1B1F25"), Hex("272D35"), Hex("3B434E"), Hex("262D36"), Hex("39424E"), Hex("6E5F3A"), Hex("14171C"), Hex("1B2027"), Brass, Text, 12); BtnSmallOn = Plate(26, 3, Hex("312B18"), Hex("43391F"), Brass, Hex("3B3320"), Hex("4E4227"), BrassHi, Hex("2A2515"), Hex("352E1A"), BrassHi, TextHi, 12); DropItem = Ghost(28f, 13, (FontStyle)0, Text, BrassHi); DropItem.alignment = (TextAnchor)3; DropItem.padding = new RectOffset(12, 12, 0, 0); GUIStyle val = new GUIStyle(GUI.skin.textField); val.normal.background = Solid(Carve); val.normal.textColor = TextHi; val.hover.background = Solid(Carve); val.hover.textColor = TextHi; val.focused.background = Solid(Carve); val.focused.textColor = TextHi; val.border = new RectOffset(0, 0, 0, 0); val.padding = new RectOffset(10, 10, 0, 0); val.margin = new RectOffset(0, 0, 0, 0); val.fontSize = 15; val.fixedHeight = 34f; val.alignment = (TextAnchor)3; Search = val; Field = new GUIStyle(Search) { fontSize = 13, fixedHeight = 26f, alignment = (TextAnchor)4, padding = new RectOffset(2, 2, 0, 0) }; FieldText = new GUIStyle(Search) { fontSize = 13, fixedHeight = 26f, alignment = (TextAnchor)3, padding = new RectOffset(8, 8, 0, 0) }; FieldArea = new GUIStyle(Search) { fontSize = 13, fixedHeight = 0f, alignment = (TextAnchor)0, padding = new RectOffset(10, 10, 8, 8), wordWrap = true }; Console_ = new GUIStyle(Search) { fontSize = 13, fixedHeight = 0f, alignment = (TextAnchor)3, padding = new RectOffset(4, 4, 0, 0) }; Console_.normal.textColor = TextHi; Console_.focused.textColor = TextHi; Console_.hover.textColor = TextHi; Texture2D background = Solid(new Color(0f, 0f, 0f, 0f)); Console_.normal.background = background; Console_.focused.background = background; Console_.hover.background = background; Console_.active.background = background; TileName = Label(11, (FontStyle)0, Text); TileName.alignment = (TextAnchor)1; TileName.wordWrap = true; TileName.clipping = (TextClipping)1; TileNameHot = Label(11, (FontStyle)1, TextHi); TileNameHot.alignment = (TextAnchor)1; TileNameHot.wordWrap = true; TileNameHot.clipping = (TextClipping)1; Glyph = Label(20, (FontStyle)0, Hex("4A3F33")); Glyph.alignment = (TextAnchor)4; Scroll = new GUIStyle(); GUIStyle val2 = new GUIStyle(GUI.skin.verticalScrollbar); val2.normal.background = Solid(Hex("0A0807")); val2.border = new RectOffset(0, 0, 0, 0); val2.fixedWidth = 3f; val2.margin = new RectOffset(10, 0, 0, 0); val2.padding = new RectOffset(0, 0, 0, 0); ScrollbarV = val2; GUIStyle val3 = new GUIStyle(GUI.skin.verticalScrollbarThumb); val3.normal.background = Solid(BrassDim); val3.hover.background = Solid(Brass); val3.active.background = Solid(BrassHi); val3.border = new RectOffset(0, 0, 0, 0); val3.fixedWidth = 3f; val3.margin = new RectOffset(0, 0, 0, 0); val3.padding = new RectOffset(0, 0, 0, 0); ScrollbarThumb = val3; GUI.skin.verticalScrollbarUpButton = GUIStyle.none; GUI.skin.verticalScrollbarDownButton = GUIStyle.none; GUI.skin.horizontalScrollbarLeftButton = GUIStyle.none; GUI.skin.horizontalScrollbarRightButton = GUIStyle.none; GUI.skin.verticalScrollbar = ScrollbarV; GUI.skin.verticalScrollbarThumb = ScrollbarThumb; GUI.skin.settings.selectionColor = new Color(Brass.r, Brass.g, Brass.b, 0.3f); GUI.skin.settings.cursorColor = BrassHi; } } public static void DrawSlab(Rect r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_0024: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00c2: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) Fill(r, Stone); Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, 0.95f); GUI.DrawTextureWithTexCoords(r, (Texture)(object)Grain, new Rect(0f, 0f, ((Rect)(ref r)).width / (float)((Texture)Grain).width, ((Rect)(ref r)).height / (float)((Texture)Grain).height)); GUI.color = color; FillFade(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 34f), Carve, 0.6f, topDown: true); FillFade(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - 34f, ((Rect)(ref r)).width, 34f), Carve, 0.6f, topDown: false); Outline(r, Hex("000000"), 1f); Fill(new Rect(((Rect)(ref r)).x + 1f, ((Rect)(ref r)).y + 1f, ((Rect)(ref r)).width - 2f, 1f), new Color(StoneLit.r, StoneLit.g, StoneLit.b, 0.9f)); Fill(new Rect(((Rect)(ref r)).x + 1f, ((Rect)(ref r)).y + 1f, 1f, ((Rect)(ref r)).height - 2f), new Color(StoneLit.r, StoneLit.g, StoneLit.b, 0.7f)); Fill(new Rect(((Rect)(ref r)).x + 1f, ((Rect)(ref r)).yMax - 2f, ((Rect)(ref r)).width - 2f, 1f), new Color(0f, 0f, 0f, 0.65f)); Fill(new Rect(((Rect)(ref r)).xMax - 2f, ((Rect)(ref r)).y + 1f, 1f, ((Rect)(ref r)).height - 2f), new Color(0f, 0f, 0f, 0.5f)); Rect r2 = default(Rect); ((Rect)(ref r2))..ctor(((Rect)(ref r)).x + 9f, ((Rect)(ref r)).y + 9f, ((Rect)(ref r)).width - 18f, ((Rect)(ref r)).height - 18f); Outline(r2, new Color(Brass.r, Brass.g, Brass.b, 0.75f), 1f); Outline(new Rect(((Rect)(ref r2)).x + 1f, ((Rect)(ref r2)).y + 1f, ((Rect)(ref r2)).width - 2f, ((Rect)(ref r2)).height - 2f), new Color(0f, 0f, 0f, 0.55f), 1f); Rivet(((Rect)(ref r2)).x, ((Rect)(ref r2)).y); Rivet(((Rect)(ref r2)).xMax, ((Rect)(ref r2)).y); Rivet(((Rect)(ref r2)).x, ((Rect)(ref r2)).yMax); Rivet(((Rect)(ref r2)).xMax, ((Rect)(ref r2)).yMax); } private static void Rivet(float cx, float cy) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) Rect r = default(Rect); ((Rect)(ref r))..ctor(cx - 3f, cy - 3f, 6f, 6f); Fill(new Rect(((Rect)(ref r)).x - 1f, ((Rect)(ref r)).y - 1f, ((Rect)(ref r)).width + 2f, ((Rect)(ref r)).height + 2f), new Color(0f, 0f, 0f, 0.6f)); Fill(r, BrassDim); Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 2f), Brass); Fill(new Rect(((Rect)(ref r)).x + 1f, ((Rect)(ref r)).y + 1f, 2f, 2f), BrassHi); } public static void Fill(Rect r, Color c) { //IL_0000: 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) Color color = GUI.color; GUI.color = c; GUI.DrawTexture(r, (Texture)(object)Px); GUI.color = color; } private static void FillFade(Rect r, Color c, float alpha, bool topDown) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) int num = 8; for (int i = 0; i < num; i++) { float num2 = (float)i / (float)num; float num3 = alpha * (topDown ? (1f - num2) : num2); float num4 = ((Rect)(ref r)).height / (float)num; Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + num4 * (float)i, ((Rect)(ref r)).width, num4 + 1f), new Color(c.r, c.g, c.b, num3)); } } public static void Outline(Rect r, Color c, float w) { //IL_0016: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_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_007d: 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) Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, w), c); Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - w, ((Rect)(ref r)).width, w), c); Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, w, ((Rect)(ref r)).height), c); Fill(new Rect(((Rect)(ref r)).xMax - w, ((Rect)(ref r)).y, w, ((Rect)(ref r)).height), c); } public static void Hairline(Rect r, float alpha = 0.28f) { //IL_001a: 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) Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 1f), new Color(Brass.r, Brass.g, Brass.b, alpha)); } public static void Groove(Rect r) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 1f), Carve); Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 1f, ((Rect)(ref r)).width, 1f), new Color(StoneLit.r, StoneLit.g, StoneLit.b, 0.8f)); } public static string Spaced(string s) { if (string.IsNullOrEmpty(s)) { return s; } StringBuilder stringBuilder = new StringBuilder(s.Length * 2); string text = s.ToUpperInvariant(); foreach (char value in text) { stringBuilder.Append(value).Append(' '); } return stringBuilder.ToString().TrimEnd(); } private static GUIStyle Label(int size, FontStyle style, Color colour) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0038: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = size, fontStyle = style }; val.normal.textColor = colour; val.margin = new RectOffset(0, 0, 0, 0); val.padding = new RectOffset(0, 0, 0, 0); val.alignment = (TextAnchor)3; val.wordWrap = false; return val; } private static GUIStyle Ghost(float h, int size, FontStyle style, Color normal, Color hover) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0084: 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_0091: 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) //IL_00a3: 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_00b6: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_00e1: 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_00f0: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown Texture2D background = Solid(new Color(0f, 0f, 0f, 0f)); GUIStyle val = new GUIStyle(GUI.skin.button); val.normal.background = background; val.normal.textColor = normal; val.hover.background = background; val.hover.textColor = hover; val.active.background = background; val.active.textColor = hover; val.onNormal.background = background; val.onNormal.textColor = hover; val.onHover.background = background; val.onHover.textColor = hover; val.onActive.background = background; val.onActive.textColor = hover; val.border = new RectOffset(0, 0, 0, 0); val.padding = new RectOffset(8, 8, 0, 0); val.margin = new RectOffset(0, 0, 0, 0); val.fixedHeight = h; val.fontSize = size; val.fontStyle = style; val.alignment = (TextAnchor)3; val.wordWrap = false; val.clipping = (TextClipping)1; return val; } private static GUIStyle Plate(int h, int radius, Color nBot, Color nTop, Color nEdge, Color hBot, Color hTop, Color hEdge, Color aBot, Color aTop, Color aEdge, Color text, int fontSize) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0084: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00a9: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00de: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //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_011e: Expected O, but got Unknown //IL_011e: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_0144: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.button); val.normal.background = PlateTex(h, radius, nBot, nTop, nEdge); val.normal.textColor = text; val.hover.background = PlateTex(h, radius, hBot, hTop, hEdge); val.hover.textColor = text; val.active.background = PlateTex(h, radius, aBot, aTop, aEdge); val.active.textColor = text; val.onNormal.background = PlateTex(h, radius, aBot, aTop, aEdge); val.onNormal.textColor = text; val.onHover.background = PlateTex(h, radius, aBot, aTop, aEdge); val.onHover.textColor = text; val.onActive.background = PlateTex(h, radius, aBot, aTop, aEdge); val.onActive.textColor = text; val.border = new RectOffset(radius + 3, radius + 3, 0, 0); val.padding = new RectOffset(10, 10, 0, 0); val.margin = new RectOffset(0, 0, 0, 0); val.fixedHeight = h; val.fontSize = fontSize; val.alignment = (TextAnchor)4; val.wordWrap = false; val.clipping = (TextClipping)1; return val; } private static Texture2D PlateTex(int h, int radius, Color bottom, Color top, Color edge) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //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) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) int num = radius * 2 + 8; Texture2D val = new Texture2D(num, h, (TextureFormat)5, false); for (int i = 0; i < h; i++) { float num2 = ((h <= 1) ? 0f : ((float)i / (float)(h - 1))); Color val2 = Color.Lerp(bottom, top, num2); if (i >= h - 1) { val2 = Color.Lerp(val2, Color.white, 0.12f); } for (int j = 0; j < num; j++) { float num3 = Sdf(j, i, num, h, radius); float num4 = Mathf.Clamp01(0.5f - num3); if (num4 <= 0f) { val.SetPixel(j, i, new Color(0f, 0f, 0f, 0f)); continue; } float num5 = Mathf.Clamp01(0.5f - (num3 + 1.15f)); Color val3 = Color.Lerp(edge, val2, num5); val.SetPixel(j, i, new Color(val3.r, val3.g, val3.b, num4)); } } return Finish(val); } private static float Sdf(float x, float y, int w, int h, int radius) { float num = Mathf.Min((float)radius, (float)Mathf.Min(w, h) * 0.5f); float num2 = x + 0.5f; float num3 = y + 0.5f; float num4 = Mathf.Clamp(num2, num, (float)w - num); float num5 = Mathf.Clamp(num3, num, (float)h - num); float num6 = num2 - num4; float num7 = num3 - num5; return Mathf.Sqrt(num6 * num6 + num7 * num7) - num; } private static Color Hex(string hex) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) int num = Convert.ToInt32(hex.Substring(0, 2), 16); int num2 = Convert.ToInt32(hex.Substring(2, 2), 16); int num3 = Convert.ToInt32(hex.Substring(4, 2), 16); float num4 = ((hex.Length >= 8) ? ((float)Convert.ToInt32(hex.Substring(6, 2), 16) / 255f) : 1f); return new Color((float)num / 255f, (float)num2 / 255f, (float)num3 / 255f, num4); } private static Texture2D Finish(Texture2D t) { ((Object)t).hideFlags = (HideFlags)61; ((Texture)t).filterMode = (FilterMode)1; ((Texture)t).wrapMode = (TextureWrapMode)0; t.Apply(); return t; } private static Texture2D Solid(Color c) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1, (TextureFormat)5, false); val.SetPixel(0, 0, c); ((Texture)val).wrapMode = (TextureWrapMode)1; return Finish(val); } private static Texture2D StoneGrain(int size) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_00c4: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)5, false); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num = (0f + Tileable(j, i, size, 8f) * 0.5f + Tileable(j, i, size, 19f) * 0.32f + Tileable(j, i, size, 43f) * 0.18f - 0.5f) * 2f; float num2 = Mathf.Abs(num) * 0.55f; Color val2 = ((num >= 0f) ? new Color(StoneHi.r, StoneHi.g, StoneHi.b, num2) : new Color(Carve.r, Carve.g, Carve.b, num2 * 1.5f)); val.SetPixel(j, i, val2); } } return Finish(val); } private static float Tileable(int x, int y, int size, float freq) { float num = (float)x / (float)size; float num2 = (float)y / (float)size; float num3 = Mathf.PerlinNoise(num * freq, num2 * freq); float num4 = Mathf.PerlinNoise((num - 1f) * freq, num2 * freq); float num5 = Mathf.PerlinNoise(num * freq, (num2 - 1f) * freq); float num6 = Mathf.PerlinNoise((num - 1f) * freq, (num2 - 1f) * freq); return Mathf.Lerp(Mathf.Lerp(num3, num4, num), Mathf.Lerp(num5, num6, num), num2); } } } namespace GBV.Stjarna { internal static class Client { private static bool _checked; private static bool _hasUi; internal static bool HasUi { get { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 if (_checked) { return _hasUi; } _checked = true; try { _hasUi = (int)SystemInfo.graphicsDeviceType != 4; } catch (Exception ex) { _hasUi = false; Safety.Failed("Client.HasUi", ex); } return _hasUi; } } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] public static class Commands { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__2_0; public static ConsoleEvent <>9__2_1; internal void <Register>b__2_0(ConsoleEventArgs args) { try { Terminal context = args.Context; if (context != null) { context.AddString(Report()); } } catch (Exception ex) { Safety.Failed("stjarna", ex); } } internal void <Register>b__2_1(ConsoleEventArgs args) { try { PipSprites.Rebuild(); Terminal context = args.Context; if (context != null) { context.AddString("Stjarna: redrawn. Open your inventory to see the new settings."); } } catch (Exception ex) { Safety.Failed("stjarna_reload", ex); } } } private static bool _registered; [HarmonyPostfix] public static void Postfix() { try { if (!_registered) { _registered = true; Register(); } } catch (Exception ex) { Safety.Failed("Terminal.InitTerminal command registration", ex); } } private static void Register() { //IL_0033: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_006c: 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_0062: Expected O, but got Unknown object obj = <>c.<>9__2_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { try { Terminal context = args.Context; if (context != null) { context.AddString(Report()); } } catch (Exception ex) { Safety.Failed("stjarna", ex); } }; <>c.<>9__2_0 = val; obj = (object)val; } new ConsoleCommand("stjarna", "stjarna - say whether the quality stars are working, and what they are set to.", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>c.<>9__2_1; if (obj2 == null) { ConsoleEvent val2 = delegate(ConsoleEventArgs args) { try { PipSprites.Rebuild(); Terminal context = args.Context; if (context != null) { context.AddString("Stjarna: redrawn. Open your inventory to see the new settings."); } } catch (Exception ex) { Safety.Failed("stjarna_reload", ex); } }; <>c.<>9__2_1 = val2; obj2 = (object)val2; } new ConsoleCommand("stjarna_reload", "stjarna_reload - redraw the stars from the current settings. Use after editing the config file by hand.", (ConsoleEvent)obj2, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } private static string Report() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Stjarna ").Append("0.1.0").AppendLine(); if (!StjarnaPlugin.Enabled.Value) { stringBuilder.AppendLine(" Off. The game is showing its own quality number."); return stringBuilder.ToString().TrimEnd(); } stringBuilder.Append(" Drawing on: "); bool any = false; any |= Append(stringBuilder, StjarnaPlugin.Inventory.Value, "inventory", ref any); any |= Append(stringBuilder, StjarnaPlugin.Hotbar.Value, "hotbar", ref any); if (!(any | Append(stringBuilder, StjarnaPlugin.CraftingList.Value, "crafting list", ref any))) { stringBuilder.Append("nothing - every Where setting is off"); } stringBuilder.AppendLine(); stringBuilder.Append(" Headroom: ").AppendLine(StjarnaPlugin.ShowHeadroom.Value ? "hollow stars for the upgrades still to come" : "off, only the stars you have"); stringBuilder.Append(" Quality 1: ").AppendLine(StjarnaPlugin.ShowQualityOne.Value ? "shown" : "not shown"); stringBuilder.Append(" Maxed items: ").AppendLine(StjarnaPlugin.MaxedTint.Value ? "turn gold" : "look the same as any other"); stringBuilder.Append(" Size: ").Append(StjarnaPlugin.ClampedScale().ToString("0.00", CultureInfo.InvariantCulture)).Append("x, offset ") .Append(StjarnaPlugin.VerticalOffset.Value.ToString("0.#", CultureInfo.InvariantCulture)) .AppendLine("%"); stringBuilder.Append(" Giving up above ").Append(StjarnaPlugin.ClampedMaxPips()).AppendLine(" stars, where the number reads better."); return stringBuilder.ToString().TrimEnd(); } private static bool Append(StringBuilder sb, bool on, string name, ref bool any) { if (!on) { return false; } if (any) { sb.Append(", "); } sb.Append(name); return true; } } internal static class Layout { public const int CellPixels = 24; public const int StripHeightPixels = 26; public const float OuterRadius = 0.78f; public const float InnerRatio = 0.44f; public const float OutlinePixels = 1.7f; public const float HaloPixels = 2.6f; public const float HaloAlpha = 0.55f; public const float HollowFillAlpha = 0.2f; public const float HollowOpacity = 0.62f; public const float HollowRimPixels = 2.3f; public const float HighlightOffsetX = -0.13f; public const float HighlightOffsetY = 0.15f; public const float HighlightRadius = 0.3f; public const float HighlightAlpha = 0.85f; public const float PipWidthFraction = 0.22f; public const float MaxRowWidthFraction = 0.9f; public const float TopInsetFraction = 0.055f; public const float FallbackSlotWidth = 70f; public const float DefaultBindingClearance = 28f; public const float RightInsetFraction = 0.04f; public const int DefaultMaxPips = 6; public static void RowSize(int pips, float slotWidth, out float width, out float height) { if (pips < 1) { pips = 1; } float num = slotWidth * 0.22f; width = num * (float)pips; float num2 = slotWidth * 0.9f; if (width > num2) { num *= num2 / width; width = num2; } height = num * 1.0833334f; } } internal static class Patches { private static FieldInfo _elementGo; private static bool _elementFieldsChecked; private static ItemData[] _byPosition = (ItemData[])(object)new ItemData[8]; public static void Apply(Harmony harmony) { Hook(harmony, "the inventory and chest grids", AccessTools.Method(typeof(InventoryGrid), "UpdateGui", new Type[2] { typeof(Player), typeof(ItemData) }, (Type[])null), "GridPostfix", 0, "quality will keep showing as a number in the inventory"); Hook(harmony, "the hotbar", AccessTools.Method(typeof(HotkeyBar), "UpdateIcons", new Type[1] { typeof(Player) }, (Type[])null), "HotbarPostfix", 400, "the hotbar will show no quality at all, which is what the game does on its own"); Hook(harmony, "the crafting list", AccessTools.Method(typeof(InventoryGui), "AddRecipeToList", new Type[4] { typeof(Player), typeof(Recipe), typeof(ItemData), typeof(bool) }, (Type[])null), "RecipePostfix", 400, "the crafting and upgrade rows will keep showing a number"); Hook(harmony, "the world unload cleanup", AccessTools.Method(typeof(ZNet), "OnDestroy", (Type[])null, (Type[])null), "ZNetOnDestroyPostfix", 400, "a few small textures will be held until the game is closed"); } private static void Hook(Harmony harmony, string what, MethodInfo target, string postfixName, int priority, string consequence) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown try { if (target == null) { Safety.Warn("hook:" + what, "the game's code for " + what + " is not where Stjarna expects it, so " + consequence + ". Everything else still works. This needs a new version of Stjarna."); return; } MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(Patches), postfixName, (Type[])null, (Type[])null); if (methodInfo == null) { Safety.Warn("hook:" + what, "Stjarna is built wrong: " + postfixName + " is missing. " + consequence + "."); } else { harmony.Patch((MethodBase)target, (HarmonyMethod)null, new HarmonyMethod(methodInfo) { priority = priority }, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch (Exception ex) { Safety.Failed("Patches.Hook(" + what + ")", ex); } } private static void GridPostfix(InventoryGrid __instance, List<InventoryElement> ___m_elements, Inventory ___m_inventory) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) try { if (___m_elements == null) { return; } bool flag = StjarnaPlugin.Enabled.Value && StjarnaPlugin.Inventory.Value; foreach (InventoryElement ___m_element in ___m_elements) { if ((Object)(object)___m_element == (Object)null) { continue; } int filled = 0; int total = 0; if (flag && ___m_inventory != null && ___m_element.m_used) { StjarnaPlugin.PipsFor(___m_inventory.GetItemAt(___m_element.Position.x, ___m_element.Position.y), out filled, out total); } StjarnaPips stjarnaPips = ((Component)___m_element).GetComponent<StjarnaPips>(); if ((Object)(object)stjarnaPips == (Object)null) { if (total < 1) { continue; } stjarnaPips = ((Component)___m_element).gameObject.AddComponent<StjarnaPips>(); } if (total < 1) { stjarnaPips.Clear(); } else if (stjarnaPips.Apply(filled, total, filled >= total && StjarnaPlugin.MaxedTint.Value, SlotWidth(((Component)___m_element).transform, ((Object)(object)__instance != (Object)null) ? __instance.m_elementSpace : 0f), StjarnaPlugin.ClearanceFor(stjarnaPips)) && (Object)(object)___m_element.m_quality != (Object)null) { ((Behaviour)___m_element.m_quality).enabled = false; } } } catch (Exception ex) { Safety.Failed("InventoryGrid.UpdateGui pip pass", ex); } } private static void HotbarPostfix(HotkeyBar __instance, IList ___m_elements, List<ItemData> ___m_items) { try { if (___m_elements == null || ___m_elements.Count == 0 || !ResolveElementFields(___m_elements[0])) { return; } bool num = StjarnaPlugin.Enabled.Value && StjarnaPlugin.Hotbar.Value; int count = ___m_elements.Count; if (_byPosition.Length < count) { _byPosition = (ItemData[])(object)new ItemData[count]; } Array.Clear(_byPosition, 0, count); if (num && ___m_items != null) { foreach (ItemData ___m_item in ___m_items) { if (___m_item != null) { int x = ___m_item.m_gridPos.x; if (x >= 0 && x < count) { _byPosition[x] = ___m_item; } } } } for (int i = 0; i < count; i++) { object? value = _elementGo.GetValue(___m_elements[i]); GameObject val = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val == (Object)null) { continue; } int filled = 0; int total = 0; StjarnaPlugin.PipsFor(_byPosition[i], out filled, out total); StjarnaPips stjarnaPips = val.GetComponent<StjarnaPips>(); if ((Object)(object)stjarnaPips == (Object)null) { if (total < 1) { continue; } stjarnaPips = val.AddComponent<StjarnaPips>(); } if (total < 1) { stjarnaPips.Clear(); } else { stjarnaPips.Apply(filled, total, filled >= total && StjarnaPlugin.MaxedTint.Value, SlotWidth(val.transform, ((Object)(object)__instance != (Object)null) ? __instance.m_elementSpace : 0f), StjarnaPlugin.ClearanceFor(stjarnaPips)); } } } catch (Exception ex) { Safety.Failed("HotkeyBar.UpdateIcons pip pass", ex); } } private static bool ResolveElementFields(object sample) { if (_elementFieldsChecked) { return _elementGo != null; } _elementFieldsChecked = true; if (sample == null) { return false; } _elementGo = AccessTools.Field(sample.GetType(), "m_go"); if (_elementGo == null) { Safety.Warn("hotbar fields", "the hotbar's slots are not shaped the way Stjarna expects, so the hotbar will show no quality stars. The inventory is unaffected. This needs a new version of Stjarna."); return false; } return true; } private static void RecipePostfix(InventoryGui __instance, ItemData item) { try { if ((Object)(object)__instance == (Object)null) { return; } RectTransform recipeListRoot = __instance.m_recipeListRoot; if ((Object)(object)recipeListRoot == (Object)null || !StjarnaPlugin.Enabled.Value || !StjarnaPlugin.CraftingList.Value || !StjarnaPlugin.PipsFor(item, out var filled, out var total)) { return; } int childCount = ((Transform)recipeListRoot).childCount; if (childCount == 0) { return; } Transform child = ((Transform)recipeListRoot).GetChild(childCount - 1); if ((Object)(object)child == (Object)null) { return; } Transform val = child.Find("QualityLevel"); if (!((Object)(object)val == (Object)null)) { StjarnaPips stjarnaPips = ((Component)child).gameObject.GetComponent<StjarnaPips>(); if ((Object)(object)stjarnaPips == (Object)null) { stjarnaPips = ((Component)child).gameObject.AddComponent<StjarnaPips>(); } if (stjarnaPips.ApplyOverLabel((RectTransform)(object)((val is RectTransform) ? val : null), filled, total, filled >= total && StjarnaPlugin.MaxedTint.Value)) { ((Component)val).gameObject.SetActive(false); } } } catch (Exception ex) { Safety.Failed("InventoryGui.AddRecipeToList pip pass", ex); } } private static void ZNetOnDestroyPostfix() { try { PipSprites.Rebuild(); } catch (Exception ex) { Safety.Failed("ZNet.OnDestroy pip cache reset", ex); } } private static float SlotWidth(Transform slot, float elementSpace) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)(object)((slot is RectTransform) ? slot : null); if ((Object)(object)val != (Object)null) { Rect rect = val.rect; float width = ((Rect)(ref rect)).width; if (width > 1f) { return width; } } if (elementSpace > 1f) { return elementSpace; } return 70f; } } public class StjarnaPips : MonoBehaviour { private Image _image; private int _filled = -1; private int _total = -1; private bool _maxed; private float _basis = -1f; private float _scale = -1f; private float _offset = float.NaN; private float _leftClear = float.NaN; private bool _overLabel; private TMP_Text _binding; private bool _bindingLookedUp; public bool HasVisibleBinding() { if (!_bindingLookedUp) { _bindingLookedUp = true; Transform val = ((Component)this).transform.Find("binding"); if ((Object)(object)val != (Object)null) { _binding = ((Component)val).GetComponent<TMP_Text>(); } } if ((Object)(object)_binding != (Object)null && ((Behaviour)_binding).enabled && ((Component)_binding).gameObject.activeSelf) { return !string.IsNullOrEmpty(_binding.text); } return false; } public bool Apply(int filled, int total, bool maxed, float slotWidth, float leftClear = 0f) { if (!Begin(filled, total, maxed, out var rowChanged)) { return false; } float num = StjarnaPlugin.ClampedScale(); float num2 = ((StjarnaPlugin.VerticalOffset != null) ? StjarnaPlugin.VerticalOffset.Value : 0f); if (leftClear < 0f) { leftClear = 0f; } if (leftClear > 0.75f) { leftClear = 0.75f; } if (_overLabel || !Mathf.Approximately(slotWidth, _basis) || !Mathf.Approximately(num, _scale) || !Mathf.Approximately(num2, _offset) || !Mathf.Approximately(leftClear, _leftClear) || rowChanged) { _overLabel = false; _basis = slotWidth; _scale = num; _offset = num2; _leftClear = leftClear; Place(total, slotWidth, num, num2, leftClear); } ((Behaviour)_image).enabled = true; return true; } private void Place(int total, float slotWidth, float scale, float offset, float leftClear) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_002c: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)((Component)_image).transform; float num = slotWidth * (1f - leftClear); Layout.RowSize(total, num * scale, out var width, out var height); val.sizeDelta = new Vector2(width, height); float num2 = slotWidth * 0.055f; float num3 = slotWidth * (offset / 100f); float num4 = 0f - (num2 + num3); if (leftClear <= 0f) { val.anchorMin = new Vector2(0.5f, 1f); val.anchorMax = new Vector2(0.5f, 1f); val.pivot = new Vector2(0.5f, 1f); val.anchoredPosition = new Vector2(0f, num4); } else { val.anchorMin = new Vector2(1f, 1f); val.anchorMax = new Vector2(1f, 1f); val.pivot = new Vector2(1f, 1f); val.anchoredPosition = new Vector2((0f - slotWidth) * 0.04f, num4); } } public bool ApplyOverLabel(RectTransform label, int filled, int total, bool maxed) { //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_0098: 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) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00c3: 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) if ((Object)(object)label == (Object)null) { return false; } if (!Begin(filled, total, maxed, out var rowChanged)) { return false; } float num = StjarnaPlugin.ClampedScale(); Rect rect = label.rect; float num2 = ((Rect)(ref rect)).height; if (num2 <= 1f) { num2 = 18f; } if (!_overLabel || !Mathf.Approximately(num2, _basis) || !Mathf.Approximately(num, _scale) || rowChanged) { _overLabel = true; _basis = num2; _scale = num; _offset = 0f; RectTransform val = (RectTransform)((Component)_image).transform; val.anchorMin = label.anchorMin; val.anchorMax = label.anchorMax; val.pivot = label.pivot; val.anchoredPosition = label.anchoredPosition; float num3 = num2 * num * 0.82f; float num4 = num3 * (float)total; float num5 = num3 * 1.0833334f; val.sizeDelta = new Vector2(num4, num5); } ((Behaviour)_image).enabled = true; return true; } private bool Begin(int filled, int total, bool maxed, out bool rowChanged) { rowChanged = filled != _filled || total != _total || maxed != _maxed; if (total < 1) { _filled = filled; _total = total; _maxed = maxed; if ((Object)(object)_image != (Object)null) { ((Behaviour)_image).enabled = false; } return false; } if (!EnsureImage()) { return false; } if (rowChanged) { _filled = filled; _total = total; _maxed = maxed; Sprite val = PipSprites.For(filled, total, maxed); if ((Object)(object)val == (Object)null) { ((Behaviour)_image).enabled = false; return false; } _image.sprite = val; } return true; } public void Clear() { _filled = 0; _total = 0; if ((Object)(object)_image != (Object)null) { ((Behaviour)_image).enabled = false; } } private bool EnsureImage() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_image != (Object)null) { return true; } GameObject val = new GameObject("StjarnaPips", new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent(((Component)this).transform, false); ((Transform)val2).localScale = Vector3.one; _image = val.AddComponent<Image>(); ((Graphic)_image).raycastTarget = false; _image.type = (Type)0; _image.preserveAspect = false; ((Transform)val2).SetAsLastSibling(); return true; } public void Forget() { _filled = -1; _total = -1; _basis = -1f; _scale = -1f; _offset = float.NaN; if ((Object)(object)_image != (Object)null) { ((Behaviour)_image).enabled = false; _image.sprite = null; } } } internal static class PipSprites { private static readonly Dictionary<int, Sprite> Cache = new Dictionary<int, Sprite>(); public static Sprite For(int filled, int total, bool maxed) { if (total < 1) { return null; } if (filled < 0) { filled = 0; } if (filled > total) { filled = total; } int key = Key(filled, total, maxed); if (Cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } Sprite val = Build(filled, total, maxed); Cache[key] = val; return val; } private static int Key(int filled, int total, bool maxed) { return (total << 6) | (filled << 1) | (maxed ? 1 : 0); } private static Sprite Build(int filled, int total, bool maxed) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) int num = StarArt.StripWidth(total); int num2 = StarArt.StripHeight(); float[] array = new float[num * num2 * 4]; StarArt.Row(filled, total, maxed ? MaxedPalette() : NormalPalette(), array); Texture2D val = new Texture2D(num, num2, (TextureFormat)5, true); ((Object)val).name = "StjarnaPips" + filled + "of" + total + (maxed ? "max" : ""); ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; ((Object)val).hideFlags = (HideFlags)61; Texture2D val2 = val; Color[] array2 = (Color[])(object)new Color[num * num2]; for (int i = 0; i < num2; i++) { int num3 = (num2 - 1 - i) * num; int num4 = i * num; for (int j = 0; j < num; j++) { int num5 = (num3 + j) * 4; array2[num4 + j] = new Color(array[num5], array[num5 + 1], array[num5 + 2], array[num5 + 3]); } } val2.SetPixels(array2); val2.Apply(true); Sprite obj = Sprite.Create(val2, new Rect(0f, 0f, (float)num, (float)num2), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); ((Object)obj).hideFlags = (HideFlags)61; return obj; } private static StarArt.Palette NormalPalette() { //IL_000a: 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_002c: 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) return new StarArt.Palette { Filled = Rgb(Theme.Brass), Highlight = Rgb(Theme.BrassHi), Hollow = Rgb(Theme.BrassDim), Outline = Rgb(Theme.Carve) }; } private static StarArt.Palette MaxedPalette() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) return new StarArt.Palette { Filled = new StarArt.Rgb(1f, 0.761f, 0.29f), Highlight = new StarArt.Rgb(1f, 0.929f, 0.745f), Hollow = Rgb(Theme.BrassDim), Outline = Rgb(Theme.Carve) }; } private static StarArt.Rgb Rgb(Color 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_000c: Unknown result type (might be due to invalid IL or missing references) return new StarArt.Rgb(c.r, c.g, c.b); } public static void Reset() { foreach (Sprite value in Cache.Values) { if (!((Object)(object)value == (Object)null)) { if ((Object)(object)value.texture != (Object)null) { Object.Destroy((Object)(object)value.texture); } Object.Destroy((Object)(object)value); } } Cache.Clear(); } public static void Rebuild() { Reset(); StjarnaPips[] array = Object.FindObjectsByType<StjarnaPips>((FindObjectsInactive)1, (FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { array[i].Forget(); } } } [BepInPlugin("gbv.valheim.stjarna", "Stjarna", "0.1.0")] public class StjarnaPlugin : BaseUnityPlugin { public const string PluginGuid = "gbv.valheim.stjarna"; public const string PluginName = "Stjarna"; public const string PluginVersion = "0.1.0"; internal static ManualLogSource Log; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> Inventory; internal static ConfigEntry<bool> Hotbar; internal static ConfigEntry<bool> CraftingList; internal static ConfigEntry<bool> ShowHeadroom; internal static ConfigEntry<bool> ShowQualityOne; internal static ConfigEntry<bool> MaxedTint; internal static ConfigEntry<float> Scale; internal static ConfigEntry<float> VerticalOffset; internal static ConfigEntry<int> MaxPips; internal static ConfigEntry<float> BindingClearance; private Harmony _harmony; private void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; if (!Client.HasUi) { Log.LogInfo((object)"Stjarna 0.1.0: no graphics device, so this is a dedicated server. Stjarna only ever draws on inventory slots, so it is standing down and patching nothing."); return; } Bind(); _harmony = new Harmony("gbv.valheim.stjarna"); Patches.Apply(_harmony); WarnAboutDuplicates(); Log.LogInfo((object)"Stjarna 0.1.0 loaded."); } private void Bind() { //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Expected O, but got Unknown Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Draw quality as stars. Turn this off and the game goes straight back to its own small number, with nothing left behind."); Inventory = ((BaseUnityPlugin)this).Config.Bind<bool>("Where", "Inventory", true, "Stars on inventory and chest slots."); Hotbar = ((BaseUnityPlugin)this).Config.Bind<bool>("Where", "Hotbar", true, "Stars on the hotbar. The game shows no quality at all there, so this adds something rather than replacing it."); CraftingList = ((BaseUnityPlugin)this).Config.Bind<bool>("Where", "CraftingList", true, "Stars on the rows of the crafting and upgrade list."); ShowHeadroom = ((BaseUnityPlugin)this).Config.Bind<bool>("Look", "ShowHeadroom", true, "Draw a hollow star for every upgrade an item can still take, as well as a filled one for each it already has. Turn this off to show only the stars you have."); ShowQualityOne = ((BaseUnityPlugin)this).Config.Bind<bool>("Look", "ShowQualityOne", false, "Draw a row on items still at quality 1. Off by default: everything you craft starts at 1, so a star on every item is clutter rather than news."); MaxedTint = ((BaseUnityPlugin)this).Config.Bind<bool>("Look", "MaxedTint", true, "Turn the row gold when an item is fully upgraded, so a finished piece is recognisable without counting stars."); Scale = ((BaseUnityPlugin)this).Config.Bind<float>("Look", "Scale", 1f, new ConfigDescription("Size of the stars, as a multiple of the normal size.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>())); VerticalOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Look", "VerticalOffset", 0f, new ConfigDescription("Nudge the row up or down, as a percentage of the slot's width. Positive moves it down. Useful if another mod draws something along the top edge of the slot.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-25f, 25f), Array.Empty<object>())); BindingClearance = ((BaseUnityPlugin)this).Config.Bind<float>("Look", "BindingClearance", 28f, new ConfigDescription("How much of the left of a slot to keep clear of stars, as a percentage of its width, on the slots that show a keybind number in the corner - the hotbar, and the top row of your inventory. The row is pushed right and shrinks to fit what is left. Set it to 0 to spread the stars across the whole slot; the number will be harder to read.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 60f), Array.Empty<object>())); MaxPips = ((BaseUnityPlugin)this).Config.Bind<int>("Look", "MaxPips", 6, new ConfigDescription("Most stars to draw on one item. Above this, Stjarna leaves the slot alone and the game's own number is shown instead - past six or so, a row of little stars stops being countable at a glance, which was the whole point.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 10), Array.Empty<object>())); } private void WarnAboutDuplicates() { try { if (Chainloader.PluginInfos.ContainsKey("zenox.betterui")) { Log.LogWarning((object)"Stjarna: BetterUI is installed, and it draws quality stars too. Stjarna's will be the ones you see. If you would rather have BetterUI's, either turn off Stjarna's Enabled setting, or set Enabled and HotbarEnabled to false under [ItemLevelStars] in zenox.betterui.cfg."); } } catch (Exception ex) { Safety.Failed("StjarnaPlugin.WarnAboutDuplicates", ex); } } private void OnDestroy() { if (Client.HasUi) { try { PipSprites.Rebuild(); } catch (Exception ex) { Safety.Failed("StjarnaPlugin.OnDestroy", ex); } Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal static float ClampedScale() { if (Scale == null) { return 1f; } return Mathf.Clamp(Scale.Value, 0.5f, 2f); } internal static int ClampedMaxPips() { if (MaxPips == null) { return 6; } return Mathf.Clamp(MaxPips.Value, 2, 10); } internal static float ClearanceFor(StjarnaPips pips) { if ((Object)(object)pips == (Object)null || !pips.HasVisibleBinding()) { return 0f; } return Mathf.Clamp((BindingClearance != null) ? BindingClearance.Value : 28f, 0f, 60f) / 100f; } internal static bool PipsFor(ItemData item, out int filled, out int total) { filled = 0; total = 0; if (item == null || item.m_shared == null) { return false; } if (Enabled == null || !Enabled.Value) { return false; } int num = item.m_quality; int num2 = item.m_shared.m_maxQuality; if (num2 <= 1) { return false; } if (num < 1) { num = 1; } if (num2 < num) { num2 = num; } if (!ShowQualityOne.Value && num <= 1) { return false; } total = (ShowHeadroom.Value ? num2 : num); filled = num; if (total > ClampedMaxPips()) { return false; } return total >= 1; } } internal static class Safety { private static readonly HashSet<string> Reported = new HashSet<string>(StringComparer.Ordinal); public static void Failed(string where, Exception ex) { if (Reported.Add(where)) { ManualLogSource log = StjarnaPlugin.Log; if (log != null) { log.LogError((object)("Stjarna: " + where + " threw and was ignored, so the game keeps its own quality number. This is a bug in Stjarna; please report it. It will not be reported again this session.\n" + ex)); } } } public static void Warn(string where, string message) { if (Reported.Add("warn:" + where)) { ManualLogSource log = StjarnaPlugin.Log; if (log != null) { log.LogWarning((object)("Stjarna: " + message)); } } } } internal static class StarArt { internal struct Rgb { public float R; public float G; public float B; public Rgb(float r, float g, float b) { R = r; G = g; B = b; } } internal struct Palette { public Rgb Filled; public Rgb Highlight; public Rgb Hollow; public Rgb Outline; } public static int StripWidth(int total) { if (total < 1) { total = 1; } return total * 24; } public static int StripHeight() { return 26; } public static void Row(int filled, int total, Palette palette, float[] rgba) { if (rgba == null) { throw new ArgumentNullException("rgba"); } if (total < 1) { total = 1; } if (filled < 0) { filled = 0; } if (filled > total) { filled = total; } int num = StripWidth(total); int num2 = StripHeight(); int num3 = num * num2 * 4; if (rgba.Length < num3) { throw new ArgumentException("buffer is " + rgba.Length + " floats, need " + num3 + " for " + total + " pips", "rgba"); } Array.Clear(rgba, 0, num3); for (int i = 0; i < total; i++) { Pip(rgba, num, num2, i, i < filled, palette); } } private static void Pip(float[] rgba, int width, int height, int index, bool isFilled, Palette palette) { float num = 24f; float num2 = num * 0.5f; float num3 = (float)index * num + num2; float num4 = (float)height * 0.5f; float num5 = num2 * 0.78f; float inner = num5 * 0.44f; float num6 = (isFilled ? 1f : 0.62f); int num7 = (int)Math.Ceiling(4.300000190734863) + 2; int num8 = Math.Max(0, (int)((float)index * num) - num7); int num9 = Math.Min(width - 1, (int)((float)(index + 1) * num) + num7); for (int i = 0; i < height; i++) { float num10 = num4 - ((float)i + 0.5f); for (int j = num8; j <= num9; j++) { float num11 = (float)j + 0.5f - num3; float num12 = StarSdf(num11, num10, num5, inner); float num13 = (num12 - 1.7f) / 2.6f; if (num13 < 0f) { num13 = 0f; } if (num13 > 1f) { num13 = 1f; } float num14 = 0.55f * (1f - num13); float num15 = Coverage(num12); float num16 = Coverage(num12 - 1.7f) - num15; if (num16 < 0f) { num16 = 0f; } int offset = (i * width + j) * 4; if (num14 > 0f) { Over(rgba, offset, palette.Outline, num14 * num6); } if (num16 > 0f) { Over(rgba, offset, palette.Outline, num16 * num6); } if (num15 <= 0f) { continue; } if (isFilled) { Over(rgba, offset, palette.Filled, num15); float num17 = num11 - -0.13f * num; float num18 = num10 - 0.15f * num; float num19 = 0.3f * num; float num20 = Coverage((float)Math.Sqrt(num17 * num17 + num18 * num18) - num19) * num15 * 0.85f; if (num20 > 0f) { Over(rgba, offset, palette.Highlight, num20); } } else { Over(rgba, offset, palette.Outline, num15 * 0.2f * num6); float num21 = num15 - Coverage(num12 + 2.3f); if (num21 > 0f) { Over(rgba, offset, palette.Hollow, num21 * num6); } } } } } public static void Icon(int size, Palette palette, Rgb background, float[] rgba) { if (rgba == null) { throw new ArgumentNullException("rgba"); } int num = size * size * 4; if (rgba.Length < num) { throw new ArgumentException("icon buffer too small", "rgba"); } for (int i = 0; i < size * size; i++) { int num2 = i * 4; rgba[num2] = background.R; rgba[num2 + 1] = background.G; rgba[num2 + 2] = background.B; rgba[num2 + 3] = 1f; } float num3 = (float)size * 0.225f; float num4 = 4f * num3; float num5 = ((float)size - num4) * 0.5f; float num6 = (float)size * 0.47f; float num7 = num3 * 0.5f; float num8 = num7 * 0.78f; float inner = num8 * 0.44f; float num9 = num3 / 24f; float num10 = 1.7f * num9; float num11 = 2.6f * num9; float num12 = 2.3f * num9; for (int j = 0; j < size; j++) { float num13 = num6 - ((float)j + 0.5f); for (int k = 0; k < size; k++) { for (int l = 0; l < 4; l++) { float num14 = num5 + (float)l * num3 + num7; float num15 = (float)k + 0.5f - num14; if (num15 < 0f - num7 - num11 - num10 || num15 > num7 + num11 + num10) { continue; } float num16 = StarSdf(num15, num13, num8, inner); float num17 = (num16 - num10) / num11; if (num17 < 0f) { num17 = 0f; } if (num17 > 1f) { num17 = 1f; } float num18 = 0.55f * (1f - num17); float num19 = Coverage(num16); float num20 = Coverage(num16 - num10) - num19; if (num20 < 0f) { num20 = 0f; } int offset = (j * size + k) * 4; float num21 = ((l < 3) ? 1f : 0.62f); if (num18 > 0f) { Over(rgba, offset, palette.Outline, num18 * num21); } if (num20 > 0f) { Over(rgba, offset, palette.Outline, num20 * num21); } if (num19 <= 0f) { continue; } if (l < 3) { Over(rgba, offset, palette.Filled, num19); float num22 = num15 - -0.13f * num3; float num23 = num13 - 0.15f * num3; float num24 = 0.3f * num3; float num25 = Coverage((float)Math.Sqrt(num22 * num22 + num23 * num23) - num24) * num19 * 0.85f; if (num25 > 0f) { Over(rgba, offset, palette.Highlight, num25); } } else { Over(rgba, offset, palette.Outline, num19 * 0.2f * num21); float num26 = num19 - Coverage(num16 + num12); if (num26 > 0f) { Over(rgba, offset, palette.Hollow, num26 * num21); } } } } } } public static float StarSdf(float x, float y, float outer, float inner) { float num = MathF.PI / 5f; float best = float.MaxValue; bool insideOdd = false; float num2 = 0f; float ax = num2; float ay = outer; for (int i = 1; i < 10; i++) { float num3 = ((i % 2 == 0) ? outer : inner); float num4 = (float)i * num; float num5 = num3 * (float)Math.Sin(num4); float num6 = num3 * (float)Math.Cos(num4); Edge(x, y, ax, ay, num5, num6, ref best, ref insideOdd); ax = num5; ay = num6; } Edge(x, y, ax, ay, num2, outer, ref best, ref insideOdd); float num7 = (float)Math.Sqrt(best); if (!insideOdd) { return num7; } return 0f - num7; } private static void Edge(float px, float py, float ax, float ay, float bx, float by, ref float best, ref bool insideOdd) { float num = bx - ax; float num2 = by - ay; float num3 = px - ax; float num4 = py - ay; float num5 = num * num + num2 * num2; float num6 = ((num5 > 0f) ? ((num3 * num + num4 * num2) / num5) : 0f); if (num6 < 0f) { num6 = 0f; } if (num6 > 1f) { num6 = 1f; } float num7 = num3 - num * num6; float num8 = num4 - num2 * num6; float num9 = num7 * num7 + num8 * num8; if (num9 < best) { best = num9; } if (ay > py != by > py) { float num10 = ax + (py - ay) / (by - ay) * num; if (px < num10) { insideOdd = !insideOdd; } } } private static float Coverage(float d) { float num = 0.5f - d; if (num <= 0f) { return 0f; } if (num >= 1f) { return 1f; } return num; } private static void Over(float[] rgba, int offset, Rgb colour, float alpha) { if (!(alpha <= 0f)) { if (alpha > 1f) { alpha = 1f; } float num = rgba[offset + 3]; float num2 = alpha + num * (1f - alpha); if (num2 <= 0f) { rgba[offset] = 0f; rgba[offset + 1] = 0f; rgba[offset + 2] = 0f; rgba[offset + 3] = 0f; } else { rgba[offset] = (colour.R * alpha + rgba[offset] * num * (1f - alpha)) / num2; rgba[offset + 1] = (colour.G * alpha + rgba[offset + 1] * num * (1f - alpha)) / num2; rgba[offset + 2] = (colour.B * alpha + rgba[offset + 2] * num * (1f - alpha)) / num2; rgba[offset + 3] = num2; } } } } }