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 InventorySlotsVisualToggle v0.1.4
BepInEx/plugins/InventorySlotsVisualToggle.dll
Decompiled 20 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace InventorySlotsVisualToggle { [BepInPlugin("dragonmotion.InventorySlotsVisualToggle", "InventorySlots Visual Toggle", "0.1.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class InventorySlotsVisualTogglePlugin : BaseUnityPlugin { private sealed class HiddenVisualState { public ItemData? Helmet; public ItemData? Shoulder; public bool HideHelmet; public bool HideCape; } private static class InventorySlotsUiPatch { public static void Postfix(object[] __args, bool __result) { object element = ((__args.Length != 0) ? __args[0] : null); string slotId = GetSlotId((__args.Length > 3) ? __args[3] : null); if (!IsTargetSlot(slotId)) { SetToggleActive(element, active: false); } else { EnsureToggle(element, slotId, __result); } } } private static class InventorySlotsBindingLabelPatch { public static void Postfix(object[] __args) { object element = ((__args.Length != 0) ? __args[0] : null); if (IsTargetSlot(GetSlotId((__args.Length > 1) ? __args[1] : null))) { BringToggleToFront(element); } } } [HarmonyPatch(typeof(Humanoid), "SetupVisEquipment")] private static class HumanoidSetupVisEquipmentPatch { private static void Prefix(Humanoid __instance, bool isRagdoll, ref HiddenVisualState? __state) { if (isRagdoll) { return; } Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val == null) { return; } bool flag = IsHidden(val, "helmet"); bool flag2 = IsHidden(val, "cape"); if (flag || flag2) { __state = new HiddenVisualState { Helmet = HelmetItemRef.Invoke(__instance), Shoulder = ShoulderItemRef.Invoke(__instance), HideHelmet = flag, HideCape = flag2 }; if (flag) { HelmetItemRef.Invoke(__instance) = null; } if (flag2) { ShoulderItemRef.Invoke(__instance) = null; } } } private static void Postfix(Humanoid __instance, HiddenVisualState? __state) { if (__state != null) { if (__state.HideHelmet) { HelmetItemRef.Invoke(__instance) = __state.Helmet; } if (__state.HideCape) { ShoulderItemRef.Invoke(__instance) = __state.Shoulder; } } } } [HarmonyPatch(typeof(Player), "Load")] private static class PlayerLoadPatch { private static void Postfix(Player __instance) { RestoreHiddenState(__instance); RefreshVisuals(__instance); } } [HarmonyPatch(typeof(Player), "Save")] private static class PlayerSavePatch { private static void Prefix(Player __instance) { RestoreHiddenState(__instance); } } [HarmonyPatch(typeof(Player), "OnSpawned")] private static class PlayerOnSpawnedPatch { private static void Postfix(Player __instance) { RestoreHiddenState(__instance); RefreshVisuals(__instance); } } private sealed class EyeToggleMarker : MonoBehaviour { public const string ChildName = "ObeliskVisualEyeToggle"; private string _slotId = ""; public void Configure(string slotId) { _slotId = slotId; } public void OnClick() { ToggleHidden(_slotId); } } public const string ModGuid = "dragonmotion.InventorySlotsVisualToggle"; public const string ModName = "InventorySlots Visual Toggle"; public const string ModVersion = "0.1.4"; private static readonly string HelmetHiddenKey = "dragonmotion.InventorySlotsVisualToggle.HideHelmet"; private static readonly string CapeHiddenKey = "dragonmotion.InventorySlotsVisualToggle.HideCape"; private static readonly string ItemHiddenSlotKey = "dragonmotion.InventorySlotsVisualToggle.HiddenSlot"; private static readonly Dictionary<Type, FieldInfo?> ElementGoFields = new Dictionary<Type, FieldInfo>(); private static readonly Dictionary<Type, PropertyInfo?> SlotIdProperties = new Dictionary<Type, PropertyInfo>(); private static readonly FieldRef<Humanoid, ItemData?> HelmetItemRef = AccessTools.FieldRefAccess<Humanoid, ItemData>("m_helmetItem"); private static readonly FieldRef<Humanoid, ItemData?> ShoulderItemRef = AccessTools.FieldRefAccess<Humanoid, ItemData>("m_shoulderItem"); private static Harmony? _harmony; private static ManualLogSource? _log; private static MethodInfo? _setupEquipmentMethod; private static MethodInfo? _inventoryGuiUpdateInventoryMethod; private static Sprite? _eyeSprite; private static Sprite? _hiddenEyeSprite; private static bool _loggedHelmetSlotSeen; private static bool _loggedCapeSlotSeen; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown _log = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("dragonmotion.InventorySlotsVisualToggle"); _setupEquipmentMethod = AccessTools.Method(typeof(Humanoid), "SetupEquipment", (Type[])null, (Type[])null); _inventoryGuiUpdateInventoryMethod = AccessTools.Method(typeof(InventoryGui), "UpdateInventory", new Type[1] { typeof(Player) }, (Type[])null); PatchInventorySlotsUi(); _harmony.PatchAll(typeof(InventorySlotsVisualTogglePlugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"InventorySlots Visual Toggle 0.1.4 loaded."); } private void OnDestroy() { Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private static void PatchInventorySlotsUi() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown Type type = AccessTools.TypeByName("InventorySlots.InventorySlotsPlugin"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "UpdateEquipmentSlotElementState", (Type[])null, (Type[])null)); MethodInfo methodInfo2 = AccessTools.Method(typeof(InventorySlotsUiPatch), "Postfix", (Type[])null, (Type[])null); if (methodInfo == null || methodInfo2 == null) { ManualLogSource? log = _log; if (log != null) { log.LogWarning((object)"InventorySlots equipment slot UI method was not found. Eye buttons are disabled."); } return; } Harmony? harmony = _harmony; if (harmony != null) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } ManualLogSource? log2 = _log; if (log2 != null) { log2.LogInfo((object)"InventorySlots equipment slot UI method patched."); } MethodInfo methodInfo3 = ((type == null) ? null : AccessTools.Method(type, "UpdateSlotBindingLabel", (Type[])null, (Type[])null)); MethodInfo methodInfo4 = AccessTools.Method(typeof(InventorySlotsBindingLabelPatch), "Postfix", (Type[])null, (Type[])null); if (methodInfo3 != null && methodInfo4 != null) { Harmony? harmony2 = _harmony; if (harmony2 != null) { harmony2.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } ManualLogSource? log3 = _log; if (log3 != null) { log3.LogInfo((object)"InventorySlots slot binding label method patched."); } } } private static bool IsTargetSlot(string? slotId) { if (!string.Equals(slotId, "helmet", StringComparison.OrdinalIgnoreCase)) { return string.Equals(slotId, "cape", StringComparison.OrdinalIgnoreCase); } return true; } private static string GetHiddenKey(string slotId) { if (!string.Equals(slotId, "helmet", StringComparison.OrdinalIgnoreCase)) { return CapeHiddenKey; } return HelmetHiddenKey; } internal static bool IsHidden(Player? player, string slotId) { if (player?.m_customData == null) { return false; } if (player.m_customData.TryGetValue(GetHiddenKey(slotId), out var value) && string.Equals(value, "1", StringComparison.Ordinal)) { return true; } return IsItemMarkedHidden(GetSlotItem(player, slotId), slotId); } private static void SetHidden(Player player, string slotId, bool hidden) { string hiddenKey = GetHiddenKey(slotId); if (hidden) { player.m_customData[hiddenKey] = "1"; } else { player.m_customData.Remove(hiddenKey); } SetItemHidden(GetSlotItem(player, slotId), slotId, hidden); } internal static void ToggleHidden(string slotId) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && IsTargetSlot(slotId)) { bool hidden = !IsHidden(localPlayer, slotId); SetHidden(localPlayer, slotId, hidden); RefreshVisuals(localPlayer); RefreshInventoryGui(localPlayer); } } private static ItemData? GetSlotItem(Player? player, string slotId) { if ((Object)(object)player == (Object)null) { return null; } if (!string.Equals(slotId, "helmet", StringComparison.OrdinalIgnoreCase)) { return ShoulderItemRef.Invoke((Humanoid)(object)player); } return HelmetItemRef.Invoke((Humanoid)(object)player); } private static bool IsItemMarkedHidden(ItemData? item, string slotId) { if (item?.m_customData != null && item.m_customData.TryGetValue(ItemHiddenSlotKey, out var value)) { return string.Equals(value, slotId, StringComparison.OrdinalIgnoreCase); } return false; } private static void SetItemHidden(ItemData? item, string slotId, bool hidden) { if (item != null) { if (item.m_customData == null) { item.m_customData = new Dictionary<string, string>(); } if (hidden) { item.m_customData[ItemHiddenSlotKey] = slotId.ToLowerInvariant(); } else if (IsItemMarkedHidden(item, slotId)) { item.m_customData.Remove(ItemHiddenSlotKey); } } } private static void RestoreHiddenState(Player player) { RestoreSlotHiddenState(player, "helmet"); RestoreSlotHiddenState(player, "cape"); } private static void RestoreSlotHiddenState(Player player, string slotId) { bool flag = IsHidden(player, slotId); string hiddenKey = GetHiddenKey(slotId); if (flag) { player.m_customData[hiddenKey] = "1"; } else { player.m_customData.Remove(hiddenKey); } SetItemHidden(GetSlotItem(player, slotId), slotId, flag); } private static void RefreshVisuals(Player player) { try { _setupEquipmentMethod?.Invoke(player, Array.Empty<object>()); } catch (Exception ex) { ManualLogSource? log = _log; if (log != null) { log.LogWarning((object)("Failed to refresh player equipment visuals: " + ex.Message)); } } } private static void RefreshInventoryGui(Player player) { try { InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance != (Object)null) { _inventoryGuiUpdateInventoryMethod?.Invoke(instance, new object[1] { player }); } } catch (Exception ex) { ManualLogSource? log = _log; if (log != null) { log.LogWarning((object)("Failed to refresh InventoryGui after visual toggle: " + ex.Message)); } } } private static string? GetSlotId(object? slot) { if (slot == null) { return null; } Type type = slot.GetType(); if (!SlotIdProperties.TryGetValue(type, out PropertyInfo value)) { value = AccessTools.Property(type, "Id"); SlotIdProperties[type] = value; } return value?.GetValue(slot) as string; } private static GameObject? GetElementGameObject(object? element) { if (element == null) { return null; } Type type = element.GetType(); if (!ElementGoFields.TryGetValue(type, out FieldInfo value)) { value = AccessTools.Field(type, "m_go"); ElementGoFields[type] = value; } object? obj = value?.GetValue(element); return (GameObject?)((obj is GameObject) ? obj : null); } private static void SetToggleActive(object? element, bool active) { GameObject? elementGameObject = GetElementGameObject(element); Transform val = ((elementGameObject != null) ? elementGameObject.transform.Find("ObeliskVisualEyeToggle") : null); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(active); } } private static void EnsureToggle(object? element, string slotId, bool hasItem) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b0: 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_00c5: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_011a: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_0167: 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_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: 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_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Expected O, but got Unknown //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) GameObject elementGameObject = GetElementGameObject(element); if ((Object)(object)elementGameObject == (Object)null) { return; } Transform val = elementGameObject.transform.Find("ObeliskVisualEyeToggle"); if (!hasItem) { if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } return; } Image val4; EyeToggleMarker eyeToggleMarker; if ((Object)(object)val == (Object)null) { GameObject val2 = new GameObject("ObeliskVisualEyeToggle", new Type[5] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image), typeof(Button), typeof(EyeToggleMarker) }); RectTransform val3 = (RectTransform)val2.transform; ((Transform)val3).SetParent(elementGameObject.transform, false); val3.anchorMin = new Vector2(0f, 1f); val3.anchorMax = new Vector2(0f, 1f); val3.pivot = new Vector2(0f, 1f); val3.sizeDelta = new Vector2(22f, 22f); val3.anchoredPosition = new Vector2(3f, -3f); ((Transform)val3).localScale = Vector3.one; ((Transform)val3).localRotation = Quaternion.identity; val4 = val2.GetComponent<Image>(); ((Graphic)val4).raycastTarget = true; val4.preserveAspect = true; Button component = val2.GetComponent<Button>(); ((Selectable)component).targetGraphic = (Graphic)(object)val4; ((Selectable)component).transition = (Transition)1; ColorBlock colors = default(ColorBlock); ((ColorBlock)(ref colors)).normalColor = Color.white; ((ColorBlock)(ref colors)).highlightedColor = new Color(1f, 0.92f, 0.62f, 1f); ((ColorBlock)(ref colors)).pressedColor = new Color(0.8f, 0.55f, 0.25f, 1f); ((ColorBlock)(ref colors)).selectedColor = Color.white; ((ColorBlock)(ref colors)).disabledColor = new Color(1f, 1f, 1f, 0.35f); ((ColorBlock)(ref colors)).colorMultiplier = 1f; ((ColorBlock)(ref colors)).fadeDuration = 0.08f; ((Selectable)component).colors = colors; eyeToggleMarker = val2.GetComponent<EyeToggleMarker>(); ((UnityEvent)component.onClick).AddListener(new UnityAction(eyeToggleMarker.OnClick)); val = val2.transform; } else { eyeToggleMarker = ((Component)val).GetComponent<EyeToggleMarker>() ?? ((Component)val).gameObject.AddComponent<EyeToggleMarker>(); val4 = ((Component)val).GetComponent<Image>() ?? ((Component)val).gameObject.AddComponent<Image>(); } ((Component)val).gameObject.SetActive(true); val.SetAsLastSibling(); eyeToggleMarker.Configure(slotId); bool flag = IsHidden(Player.m_localPlayer, slotId); val4.sprite = (flag ? GetHiddenEyeSprite() : GetEyeSprite()); ((Graphic)val4).color = (flag ? new Color(1f, 0.72f, 0.35f, 0.95f) : new Color(1f, 1f, 1f, 0.92f)); LogTargetSlotSeenOnce(slotId); } private static void BringToggleToFront(object? element) { GameObject? elementGameObject = GetElementGameObject(element); Transform val = ((elementGameObject != null) ? elementGameObject.transform.Find("ObeliskVisualEyeToggle") : null); if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf) { val.SetAsLastSibling(); } } private static void LogTargetSlotSeenOnce(string slotId) { if (string.Equals(slotId, "helmet", StringComparison.OrdinalIgnoreCase)) { if (_loggedHelmetSlotSeen) { return; } _loggedHelmetSlotSeen = true; } else if (string.Equals(slotId, "cape", StringComparison.OrdinalIgnoreCase)) { if (_loggedCapeSlotSeen) { return; } _loggedCapeSlotSeen = true; } ManualLogSource? log = _log; if (log != null) { log.LogInfo((object)("InventorySlots visual toggle attached to occupied '" + slotId + "' slot.")); } } private static Sprite GetEyeSprite() { return _eyeSprite ?? (_eyeSprite = CreateEyeSprite(hidden: false)); } private static Sprite GetHiddenEyeSprite() { return _hiddenEyeSprite ?? (_hiddenEyeSprite = CreateEyeSprite(hidden: true)); } private static Sprite CreateEyeSprite(bool hidden) { //IL_0006: 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_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_002f: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false) { name = (hidden ? "ObeliskHiddenEyeIcon" : "ObeliskEyeIcon"), filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; Color val2 = default(Color); ((Color)(ref val2))..ctor(0f, 0f, 0f, 0f); Color color = default(Color); ((Color)(ref color))..ctor(1f, 1f, 1f, 1f); Color color2 = default(Color); ((Color)(ref color2))..ctor(0f, 0f, 0f, 0.6f); Color color3 = default(Color); ((Color)(ref color3))..ctor(1f, 0.74f, 0.32f, 1f); Color[] array = (Color[])(object)new Color[1024]; for (int i = 0; i < array.Length; i++) { array[i] = val2; } DrawEye(array, 32, color2, 1); DrawEye(array, 32, color, 0); DrawCircle(array, 32, 16, 16, 4, color2, 1); DrawCircle(array, 32, 16, 16, 4, color, 0); DrawCircle(array, 32, 16, 16, 2, color, 0); if (hidden) { DrawLine(array, 32, 25, 6, 7, 26, color2, 3); DrawLine(array, 32, 25, 6, 7, 26, color3, 2); } val.SetPixels(array); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f), 32f); } private static void DrawEye(Color[] pixels, int size, Color color, int offset) { //IL_0011: 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_0041: 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_0072: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) DrawLine(pixels, size, 4 + offset, 16 - offset, 10 + offset, 10 - offset, color, 2); DrawLine(pixels, size, 10 + offset, 10 - offset, 16 + offset, 8 - offset, color, 2); DrawLine(pixels, size, 16 + offset, 8 - offset, 22 + offset, 10 - offset, color, 2); DrawLine(pixels, size, 22 + offset, 10 - offset, 28 + offset, 16 - offset, color, 2); DrawLine(pixels, size, 4 + offset, 16 + offset, 10 + offset, 22 + offset, color, 2); DrawLine(pixels, size, 10 + offset, 22 + offset, 16 + offset, 24 + offset, color, 2); DrawLine(pixels, size, 16 + offset, 24 + offset, 22 + offset, 22 + offset, color, 2); DrawLine(pixels, size, 22 + offset, 22 + offset, 28 + offset, 16 + offset, color, 2); } private static void DrawCircle(Color[] pixels, int size, int cx, int cy, int radius, Color color, int offset) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) int num = radius * radius; int num2 = Math.Max(0, radius - 1); int num3 = num2 * num2; for (int i = -radius; i <= radius; i++) { for (int j = -radius; j <= radius; j++) { int num4 = j * j + i * i; if (num4 <= num && num4 >= num3) { SetPixel(pixels, size, cx + j + offset, cy + i + offset, color); } } } } private static void DrawLine(Color[] pixels, int size, int x0, int y0, int x1, int y1, Color color, int thickness) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) int num = Math.Abs(x1 - x0); int num2 = -Math.Abs(y1 - y0); int num3 = ((x0 < x1) ? 1 : (-1)); int num4 = ((y0 < y1) ? 1 : (-1)); int num5 = num + num2; while (true) { for (int i = -thickness / 2; i <= thickness / 2; i++) { for (int j = -thickness / 2; j <= thickness / 2; j++) { SetPixel(pixels, size, x0 + j, y0 + i, color); } } if (x0 != x1 || y0 != y1) { int num6 = 2 * num5; if (num6 >= num2) { num5 += num2; x0 += num3; } if (num6 <= num) { num5 += num; y0 += num4; } continue; } break; } } private static void SetPixel(Color[] pixels, int size, int x, int y, Color color) { //IL_0017: 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) if (x >= 0 && y >= 0 && x < size && y < size) { pixels[y * size + x] = color; } } } }