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 Minecraft Blocks v1.1.1
EmpressMinecraft.dll
Decompiled 2 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c78724dd7713b3d310be1e81a00b271706b0f66d")] [assembly: AssemblyProduct("EmpressMinecraft")] [assembly: AssemblyTitle("EmpressMinecraft")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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 EmpressMinecraft { [BepInPlugin("Omniscye.EmpressMinecraft", "EmpressMinecraft", "1.0")] public class EmpressMinecraft : BaseUnityPlugin { internal static EmpressMinecraft Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //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_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { } } } namespace Empress.REPO.MinecraftLite { [BepInPlugin("empress.repo.minecraftlite", "Empress Minecraft-Lite", "1.3.1")] public class EmpressMinecraftLitePlugin : BaseUnityPlugin { [CompilerGenerated] private sealed class <LoadAudioClips>d__19 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string dir; public EmpressMinecraftLitePlugin <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadAudioClips>d__19(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.LoadOne(dir, "place.ogg", delegate(AudioClip c) { <>4__this._placeClip = c; })); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.LoadOne(dir, "break.ogg", delegate(AudioClip c) { <>4__this._breakClip = c; })); <>1__state = 2; return true; case 2: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadOne>d__20 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string dir; public string fileName; public Action<AudioClip> setter; public EmpressMinecraftLitePlugin <>4__this; private string <full>5__1; private string <uri>5__2; private UnityWebRequest <req>5__3; private bool <err>5__4; private AudioClip <clip>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadOne>d__20(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <full>5__1 = null; <uri>5__2 = null; <req>5__3 = null; <clip>5__5 = null; <>1__state = -2; } private bool MoveNext() { bool result; try { switch (<>1__state) { default: result = false; break; case 0: <>1__state = -1; <full>5__1 = Path.Combine(dir, fileName); if (!File.Exists(<full>5__1)) { ((BaseUnityPlugin)<>4__this).Logger.LogWarning((object)("[MinecraftLite] Audio missing: " + fileName + " (optional)")); result = false; break; } <uri>5__2 = new Uri(<full>5__1).AbsoluteUri; <req>5__3 = UnityWebRequestMultimedia.GetAudioClip(<uri>5__2, (AudioType)14); <>1__state = -3; <>2__current = <req>5__3.SendWebRequest(); <>1__state = 1; result = true; break; case 1: <>1__state = -3; <err>5__4 = <req>5__3.isNetworkError || <req>5__3.isHttpError; if (<err>5__4) { ((BaseUnityPlugin)<>4__this).Logger.LogWarning((object)("[MinecraftLite] Failed loading " + fileName + ": " + <req>5__3.error)); result = false; <>m__Finally1(); break; } <clip>5__5 = DownloadHandlerAudioClip.GetContent(<req>5__3); if ((Object)(object)<clip>5__5 != (Object)null) { ((Object)<clip>5__5).name = Path.GetFileNameWithoutExtension(fileName); setter?.Invoke(<clip>5__5); ((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)("[MinecraftLite] Audio OK: " + fileName)); } else { ((BaseUnityPlugin)<>4__this).Logger.LogWarning((object)("[MinecraftLite] " + fileName + " decoded to null clip.")); } <clip>5__5 = null; <>m__Finally1(); <req>5__3 = null; result = false; break; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<req>5__3 != null) { ((IDisposable)<req>5__3).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string PluginGuid = "empress.repo.minecraftlite"; public const string PluginName = "Empress Minecraft-Lite"; public const string PluginVersion = "1.3.1"; internal static ManualLogSource Log; internal static EmpressMinecraftLitePlugin Instance; private BlockSystem _blocks; private PlacementPreview _preview; private BlockUI _ui; private int _selectedIndex = -1; private float _scrollCooldown; private bool _placementEnabled = true; private int _lastSelectedIndexBeforeDisable = -1; private float _lastSelectionTime; private const float UI_AUTOHIDE_SEC = 5f; private AudioClip _placeClip; private AudioClip _breakClip; private void Awake() { //IL_0018: 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_0042: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; _blocks = new GameObject("Empress_BlockSystem").AddComponent<BlockSystem>(); _preview = new GameObject("Empress_PlacementPreview").AddComponent<PlacementPreview>(); _ui = new GameObject("Empress_BlockUI").AddComponent<BlockUI>(); string text = ResolveContentPath(); _blocks.Init(text); _preview.Init(_blocks); _ui.Init(GetSelectedKind, _blocks); ((MonoBehaviour)this).StartCoroutine(LoadAudioClips(text)); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Empress Minecraft-Lite 1.3.1 loaded. Content: " + text)); } private BlockKind GetSelectedKind() { int count = _blocks.Kinds.Count; if (count == 0) { return null; } if (_selectedIndex < 0) { return null; } _selectedIndex = Mathf.Clamp(_selectedIndex, 0, count - 1); return _blocks.Kinds[_selectedIndex]; } public string ResolveContentPath() { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); if (!string.IsNullOrEmpty(directoryName) && Directory.Exists(directoryName)) { return directoryName; } string text = Path.Combine(Paths.PluginPath, "EmpressMinecraftLite"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } return text; } [IteratorStateMachine(typeof(<LoadAudioClips>d__19))] private IEnumerator LoadAudioClips(string dir) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadAudioClips>d__19(0) { <>4__this = this, dir = dir }; } [IteratorStateMachine(typeof(<LoadOne>d__20))] private IEnumerator LoadOne(string dir, string fileName, Action<AudioClip> setter) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadOne>d__20(0) { <>4__this = this, dir = dir, fileName = fileName, setter = setter }; } internal void PlayClipAt(AudioClip clip, Vector3 worldPos, float volume = 0.9f) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)clip == (Object)null)) { GameObject val = new GameObject("Empress_AudioOneShot_" + ((Object)clip).name); val.transform.position = worldPos; AudioSource val2 = val.AddComponent<AudioSource>(); val2.spatialBlend = 1f; val2.rolloffMode = (AudioRolloffMode)1; val2.minDistance = 2f; val2.maxDistance = 20f; val2.playOnAwake = false; val2.clip = clip; val2.volume = Mathf.Clamp01(volume); val2.dopplerLevel = 0f; val2.spread = 0f; val2.priority = 128; val2.Play(); Object.Destroy((Object)(object)val, clip.length + 0.1f); } } private void Update() { //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return; } if (Input.GetKeyDown((KeyCode)287)) { _blocks.ReloadTextures(ResolveContentPath()); if (_selectedIndex >= 0) { _selectedIndex = Mathf.Clamp(_selectedIndex, 0, Mathf.Max(0, _blocks.Kinds.Count - 1)); } _ui.Refresh(pulse: true); _ui.ShowPanel(); _lastSelectionTime = Time.unscaledTime; Log.LogInfo((object)"[MinecraftLite] Reloaded textures."); } if (Input.GetKeyDown((KeyCode)120)) { if (_placementEnabled) { _lastSelectedIndexBeforeDisable = _selectedIndex; _placementEnabled = false; SetNoneAndHideUI(); Log.LogInfo((object)"[MinecraftLite] Disabled (scroll returns to base game)."); } else { _placementEnabled = true; _ui.Refresh(pulse: true); _ui.ShowPanel(); _lastSelectionTime = Time.unscaledTime; Log.LogInfo((object)"[MinecraftLite] Enabled."); } } Ray val = main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)); RaycastHit hit = default(RaycastHit); if (Physics.Raycast(val, ref hit, 8f)) { if (_placementEnabled && _selectedIndex >= 0) { Vector3Int placementPosition = GridUtil.GetPlacementPosition(hit); bool flag = !_blocks.HasBlock(placementPosition); _preview.UpdatePreview(placementPosition, flag); if (Input.GetMouseButtonDown(1) && flag) { BlockKind selectedKind = GetSelectedKind(); if (selectedKind != null) { _blocks.PlaceBlock(placementPosition, selectedKind, _placeClip); } } } else { _preview.Hide(); } if (Input.GetMouseButton(0)) { Block componentInParent = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<Block>(); if ((Object)(object)componentInParent != (Object)null) { componentInParent.TickMining(Time.deltaTime); if (componentInParent.IsBroken) { _blocks.RemoveBlock(componentInParent.GridPos, _breakClip); } } } else { ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<Block>()?.ResetMining(); } } else { _preview.Hide(); } if (_placementEnabled) { HandleScroll(Input.mouseScrollDelta.y); } if (_ui.IsVisible && _selectedIndex >= 0 && Time.unscaledTime - _lastSelectionTime > 5f) { _ui.HidePanel(); } } private void SetNoneAndHideUI() { _selectedIndex = -1; _ui.Refresh(); _ui.HidePanel(); _preview.Hide(); Log.LogInfo((object)"[MinecraftLite] Selection set to NONE; UI hidden."); } private void HandleScroll(float scrollY) { if (!(Mathf.Abs(scrollY) <= 0.1f) && !(Time.unscaledTime <= _scrollCooldown) && _blocks.Kinds.Count != 0) { _scrollCooldown = Time.unscaledTime + 0.15f; if (_selectedIndex < 0) { _selectedIndex = ((!(scrollY > 0f)) ? (_blocks.Kinds.Count - 1) : 0); } else { _selectedIndex = ((scrollY > 0f) ? ((_selectedIndex + 1) % _blocks.Kinds.Count) : ((_selectedIndex - 1 + _blocks.Kinds.Count) % _blocks.Kinds.Count)); } _lastSelectionTime = Time.unscaledTime; _ui.Refresh(pulse: true); _ui.ShowPanel(); } } } public static class OmnibinReader { public class Entry { public string Name; public byte[] Data; } private static readonly byte[] MAGIC = new byte[4] { 79, 77, 66, 78 }; public static List<Entry> ReadOmnibin(string path) { List<Entry> list = new List<Entry>(); using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { using BinaryReader binaryReader = new BinaryReader(fileStream); byte[] array = binaryReader.ReadBytes(4); if (array.Length != 4 || array[0] != MAGIC[0] || array[1] != MAGIC[1] || array[2] != MAGIC[2] || array[3] != MAGIC[3]) { throw new InvalidDataException("Not a valid .omnibin file (bad magic)."); } ushort num = binaryReader.ReadUInt16(); if (num != 1) { throw new InvalidDataException($"Unsupported omnibin version: {num}"); } ushort num2 = binaryReader.ReadUInt16(); uint num3 = binaryReader.ReadUInt32(); List<(string, ulong, uint, uint, uint)> list2 = new List<(string, ulong, uint, uint, uint)>(); for (uint num4 = 0u; num4 < num3; num4++) { ushort count = binaryReader.ReadUInt16(); byte[] bytes = binaryReader.ReadBytes(count); string @string = Encoding.UTF8.GetString(bytes); ulong item = binaryReader.ReadUInt64(); uint item2 = binaryReader.ReadUInt32(); uint item3 = binaryReader.ReadUInt32(); uint item4 = binaryReader.ReadUInt32(); list2.Add((@string, item, item2, item3, item4)); } foreach (var item5 in list2) { fileStream.Seek((long)item5.Item2, SeekOrigin.Begin); byte[] array2 = binaryReader.ReadBytes((int)item5.Item4); byte[] array3 = (((item5.Item5 & 1) == 0) ? array2 : DecompressDeflate(array2)); if (array3.Length != item5.Item3) { ManualLogSource log = EmpressMinecraftLitePlugin.Log; if (log != null) { log.LogWarning((object)$"[OMNIBIN] Size mismatch for {item5.Item1}: {array3.Length} != {item5.Item3}"); } } list.Add(new Entry { Name = item5.Item1, Data = array3 }); } } return list; } private static byte[] DecompressDeflate(byte[] compressed) { using MemoryStream stream = new MemoryStream(compressed); using DeflateStream deflateStream = new DeflateStream(stream, CompressionMode.Decompress); using MemoryStream memoryStream = new MemoryStream(); deflateStream.CopyTo(memoryStream); return memoryStream.ToArray(); } } public class BlockKind { public string Id; public Material Material; public Texture2D Texture; } public static class GridUtil { public static Vector3Int RoundToGrid(Vector3 pos) { //IL_0000: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) return new Vector3Int(Mathf.RoundToInt(pos.x), Mathf.RoundToInt(pos.y), Mathf.RoundToInt(pos.z)); } public static Vector3Int GetPlacementPosition(RaycastHit hit) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_001f: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) Vector3 pos = ((RaycastHit)(ref hit)).point + ((RaycastHit)(ref hit)).normal * 0.5f; return RoundToGrid(pos); } } public class BlockSystem : MonoBehaviour { public readonly Dictionary<Vector3Int, Block> Blocks = new Dictionary<Vector3Int, Block>(); public readonly List<BlockKind> Kinds = new List<BlockKind>(); public readonly Dictionary<string, BlockKind> KindById = new Dictionary<string, BlockKind>(StringComparer.OrdinalIgnoreCase); public Material CrackOverlayMaterial; public Material PreviewGoodMat; public Material PreviewBadMat; private Transform _root; private string _textureDir; public void Init(string textureDir) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) _textureDir = textureDir; _root = new GameObject("Empress_BlocksRoot").transform; _root.SetParent(((Component)this).transform); LoadAllMaterials(_textureDir); } public void ReloadTextures(string textureDir) { if (!string.IsNullOrEmpty(textureDir)) { _textureDir = textureDir; } LoadAllMaterials(_textureDir); foreach (KeyValuePair<Vector3Int, Block> block in Blocks) { Block value = block.Value; if (!((Object)(object)value == (Object)null) && !string.IsNullOrEmpty(value.KindId) && KindById.TryGetValue(value.KindId, out BlockKind value2) && (Object)(object)value2.Material != (Object)null) { Renderer component = ((Component)value).GetComponent<Renderer>(); if ((Object)(object)component != (Object)null) { component.sharedMaterial = value2.Material; } } } } private void LoadAllMaterials(string textureDir) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) ManualLogSource log = EmpressMinecraftLitePlugin.Log; if (log != null) { log.LogInfo((object)("[MinecraftLite] Loading textures from: " + textureDir)); } Kinds.Clear(); KindById.Clear(); string text = Path.Combine(textureDir, "RMC.omnibin"); if (File.Exists(text)) { LoadFromOmnibin(text); } else { ManualLogSource log2 = EmpressMinecraftLitePlugin.Log; if (log2 != null) { log2.LogInfo((object)"[MinecraftLite] RMC.omnibin not found, loading loose PNGs..."); } LoadFromLooseFiles(textureDir); } if (Kinds.Count == 0) { ManualLogSource log3 = EmpressMinecraftLitePlugin.Log; if (log3 != null) { log3.LogWarning((object)"[MinecraftLite] No selectable block textures found. Add RMC.omnibin or drop some *.png files next to the DLL."); } } PreviewGoodMat = MakeTintMat(new Color(0f, 1f, 0f, 0.35f)); PreviewBadMat = MakeTintMat(new Color(1f, 0f, 0f, 0.35f)); } private void LoadFromOmnibin(string omnibinPath) { try { ManualLogSource log = EmpressMinecraftLitePlugin.Log; if (log != null) { log.LogInfo((object)("[MinecraftLite] Loading from OMNIBIN: " + omnibinPath)); } List<OmnibinReader.Entry> list = OmnibinReader.ReadOmnibin(omnibinPath); OmnibinReader.Entry entry = null; foreach (OmnibinReader.Entry item in list) { if (item.Name.Equals("crack.png", StringComparison.OrdinalIgnoreCase) || item.Name.Equals("cracked.png", StringComparison.OrdinalIgnoreCase)) { entry = item; break; } } if (entry != null) { CrackOverlayMaterial = MakeTransparentMatFromBytes(entry.Data); ManualLogSource log2 = EmpressMinecraftLitePlugin.Log; if (log2 != null) { log2.LogInfo((object)string.Format(" {0,8} {1}", "OK", entry.Name)); } } else { CrackOverlayMaterial = null; ManualLogSource log3 = EmpressMinecraftLitePlugin.Log; if (log3 != null) { log3.LogInfo((object)string.Format(" {0,8} crack.png", "MISSING")); } } foreach (OmnibinReader.Entry item2 in list) { if (!item2.Name.Equals("crack.png", StringComparison.OrdinalIgnoreCase) && !item2.Name.Equals("cracked.png", StringComparison.OrdinalIgnoreCase) && item2.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item2.Name); Texture2D outTex; Material material = MakeMatFromBytes(item2.Data, out outTex); BlockKind blockKind = new BlockKind { Id = fileNameWithoutExtension, Material = material, Texture = outTex }; Kinds.Add(blockKind); KindById[fileNameWithoutExtension] = blockKind; ManualLogSource log4 = EmpressMinecraftLitePlugin.Log; if (log4 != null) { log4.LogInfo((object)string.Format(" {0,8} {1}", "OK", item2.Name)); } } } } catch (Exception ex) { ManualLogSource log5 = EmpressMinecraftLitePlugin.Log; if (log5 != null) { log5.LogError((object)("[MinecraftLite] Failed to load OMNIBIN: " + ex.Message)); } } } private void LoadFromLooseFiles(string textureDir) { string text = FindTexture(textureDir, new string[2] { "crack.png", "cracked.png" }); CrackOverlayMaterial = ((!string.IsNullOrEmpty(text)) ? MakeTransparentMat(text) : null); ManualLogSource log = EmpressMinecraftLitePlugin.Log; if (log != null) { log.LogInfo((object)string.Format(" {0,8} crack.png", ((Object)(object)CrackOverlayMaterial != (Object)null) ? "OK" : "MISSING")); } string[] array = Array.Empty<string>(); try { if (Directory.Exists(textureDir)) { array = Directory.GetFiles(textureDir, "*.png", SearchOption.TopDirectoryOnly); } } catch { } Array.Sort(array, (IComparer<string>?)StringComparer.OrdinalIgnoreCase); string[] array2 = array; foreach (string text2 in array2) { string fileName = Path.GetFileName(text2); if (!fileName.Equals("crack.png", StringComparison.OrdinalIgnoreCase) && !fileName.Equals("cracked.png", StringComparison.OrdinalIgnoreCase)) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text2); Texture2D outTex; Material material = MakeMat(text2, out outTex); BlockKind blockKind = new BlockKind { Id = fileNameWithoutExtension, Material = material, Texture = outTex }; Kinds.Add(blockKind); KindById[fileNameWithoutExtension] = blockKind; ManualLogSource log2 = EmpressMinecraftLitePlugin.Log; if (log2 != null) { log2.LogInfo((object)string.Format(" {0,8} {1}", "OK", fileName)); } } } } private static string FindTexture(string dir, string[] candidates) { try { if (!Directory.Exists(dir)) { return null; } string[] files = Directory.GetFiles(dir, "*.png", SearchOption.TopDirectoryOnly); foreach (string b in candidates) { string[] array = files; foreach (string text in array) { if (string.Equals(Path.GetFileName(text), b, StringComparison.OrdinalIgnoreCase)) { return text; } } } } catch { } return null; } private static Texture2D LoadTexture(string path) { byte[] data = File.ReadAllBytes(path); return LoadTextureFromBytes(data); } private static Texture2D LoadTextureFromBytes(byte[] data) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true); ImageConversion.LoadImage(val, data, false); ((Texture)val).wrapMode = (TextureWrapMode)0; ((Texture)val).filterMode = (FilterMode)0; return val; } private static Material MakeMat(string pngPath, out Texture2D outTex) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) outTex = null; Shader val = Shader.Find("Standard"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Legacy Shaders/Diffuse"); } if ((Object)(object)val == (Object)null) { GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3); val = val2.GetComponent<Renderer>().sharedMaterial.shader; Object.Destroy((Object)(object)val2); } Material val3 = new Material(val); val3.color = Color.white; if (!string.IsNullOrEmpty(pngPath) && File.Exists(pngPath)) { Texture2D val4 = (outTex = LoadTexture(pngPath)); if (val3.HasProperty("_MainTex")) { val3.SetTexture("_MainTex", (Texture)(object)val4); } } return val3; } private static Material MakeMatFromBytes(byte[] pngData, out Texture2D outTex) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) outTex = null; Shader val = Shader.Find("Standard"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Legacy Shaders/Diffuse"); } if ((Object)(object)val == (Object)null) { GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3); val = val2.GetComponent<Renderer>().sharedMaterial.shader; Object.Destroy((Object)(object)val2); } Material val3 = new Material(val); val3.color = Color.white; if (pngData != null && pngData.Length != 0) { Texture2D val4 = (outTex = LoadTextureFromBytes(pngData)); if (val3.HasProperty("_MainTex")) { val3.SetTexture("_MainTex", (Texture)(object)val4); } } return val3; } private static Material MakeTransparentMat(string pngPath) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown Shader val = Shader.Find("Standard"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Legacy Shaders/Transparent/Diffuse"); } if ((Object)(object)val == (Object)null) { GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3); val = val2.GetComponent<Renderer>().sharedMaterial.shader; Object.Destroy((Object)(object)val2); } Material val3 = new Material(val); if (((Object)val3.shader).name.Contains("Standard")) { val3.SetFloat("_Mode", 3f); val3.SetInt("_SrcBlend", 5); val3.SetInt("_DstBlend", 10); val3.SetInt("_ZWrite", 0); val3.DisableKeyword("_ALPHATEST_ON"); val3.EnableKeyword("_ALPHABLEND_ON"); val3.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val3.renderQueue = 3000; } if (!string.IsNullOrEmpty(pngPath) && File.Exists(pngPath)) { Texture2D val4 = LoadTexture(pngPath); if (val3.HasProperty("_MainTex")) { val3.SetTexture("_MainTex", (Texture)(object)val4); } } return val3; } private static Material MakeTransparentMatFromBytes(byte[] pngData) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown Shader val = Shader.Find("Standard"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Legacy Shaders/Transparent/Diffuse"); } if ((Object)(object)val == (Object)null) { GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3); val = val2.GetComponent<Renderer>().sharedMaterial.shader; Object.Destroy((Object)(object)val2); } Material val3 = new Material(val); if (((Object)val3.shader).name.Contains("Standard")) { val3.SetFloat("_Mode", 3f); val3.SetInt("_SrcBlend", 5); val3.SetInt("_DstBlend", 10); val3.SetInt("_ZWrite", 0); val3.DisableKeyword("_ALPHATEST_ON"); val3.EnableKeyword("_ALPHABLEND_ON"); val3.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val3.renderQueue = 3000; } if (pngData != null && pngData.Length != 0) { Texture2D val4 = LoadTextureFromBytes(pngData); if (val3.HasProperty("_MainTex")) { val3.SetTexture("_MainTex", (Texture)(object)val4); } } return val3; } private static Material MakeTintMat(Color c) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Standard"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Legacy Shaders/Diffuse"); } if ((Object)(object)val == (Object)null) { GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3); val = val2.GetComponent<Renderer>().sharedMaterial.shader; Object.Destroy((Object)(object)val2); } Material val3 = new Material(val); if (((Object)val3.shader).name.Contains("Standard")) { val3.SetFloat("_Mode", 3f); val3.SetInt("_SrcBlend", 5); val3.SetInt("_DstBlend", 10); val3.SetInt("_ZWrite", 0); val3.DisableKeyword("_ALPHATEST_ON"); val3.EnableKeyword("_ALPHABLEND_ON"); val3.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val3.renderQueue = 3000; } val3.color = c; return val3; } public bool HasBlock(Vector3Int grid) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return Blocks.ContainsKey(grid); } public void PlaceBlock(Vector3Int grid, BlockKind kind, AudioClip placeClip) { //IL_0007: 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_005b: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) if (!Blocks.ContainsKey(grid) && kind != null) { GameObject val = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val).name = $"Block_{kind.Id}_{grid}"; val.transform.SetParent(_root); val.transform.position = Vector3Int.op_Implicit(grid); val.transform.localScale = Vector3.one; Renderer component = val.GetComponent<Renderer>(); if ((Object)(object)kind.Material != (Object)null && (Object)(object)component != (Object)null) { component.sharedMaterial = kind.Material; } Block block = val.AddComponent<Block>(); block.Init(this, grid, kind.Id); Blocks[grid] = block; if ((Object)(object)placeClip != (Object)null) { EmpressMinecraftLitePlugin.Instance.PlayClipAt(placeClip, Vector3Int.op_Implicit(grid) + new Vector3(0.5f, 0.5f, 0.5f)); } } } public void RemoveBlock(Vector3Int grid, AudioClip breakClip) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (Blocks.TryGetValue(grid, out Block value)) { if ((Object)(object)breakClip != (Object)null) { EmpressMinecraftLitePlugin.Instance.PlayClipAt(breakClip, Vector3Int.op_Implicit(grid) + new Vector3(0.5f, 0.5f, 0.5f)); } Blocks.Remove(grid); Object.Destroy((Object)(object)((Component)value).gameObject); } } } public class Block : MonoBehaviour { private BlockSystem _sys; private float _miningTime; private const float BreakTime = 1f; private GameObject _crackOverlay; private Renderer _renderer; private Color _baseColor = Color.white; public Vector3Int GridPos { get; private set; } public string KindId { get; private set; } public bool IsBroken => _miningTime >= 1f; public void Init(BlockSystem sys, Vector3Int grid, string kindId) { //IL_0009: 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_005b: Unknown result type (might be due to invalid IL or missing references) _sys = sys; GridPos = grid; KindId = kindId; _renderer = ((Component)this).GetComponent<Renderer>(); if ((Object)(object)_renderer != (Object)null && (Object)(object)_renderer.sharedMaterial != (Object)null) { _baseColor = _renderer.sharedMaterial.color; } } public void TickMining(float dt) { _miningTime = Mathf.Clamp(_miningTime + dt, 0f, 1f); UpdateCrackVisual(); } public void ResetMining() { if (_miningTime > 0f) { _miningTime = Mathf.Max(0f, _miningTime - Time.deltaTime * 2f); UpdateCrackVisual(); } } private void UpdateCrackVisual() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0194: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown if ((Object)(object)_renderer == (Object)null) { return; } float num = Mathf.InverseLerp(0f, 1f, _miningTime); Material material = _renderer.material; material.color = Color.Lerp(_baseColor, Color.black, num * 0.35f); if ((Object)(object)_sys.CrackOverlayMaterial != (Object)null) { if ((Object)(object)_crackOverlay == (Object)null) { _crackOverlay = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)_crackOverlay).name = "CrackOverlay"; _crackOverlay.transform.SetParent(((Component)this).transform, false); _crackOverlay.transform.localPosition = Vector3.zero; _crackOverlay.transform.localRotation = Quaternion.identity; _crackOverlay.transform.localScale = new Vector3(1.005f, 1.005f, 1.005f); Renderer component = _crackOverlay.GetComponent<Renderer>(); component.sharedMaterial = new Material(_sys.CrackOverlayMaterial); component.sharedMaterial.renderQueue = 3100; Object.Destroy((Object)(object)_crackOverlay.GetComponent<Collider>()); _crackOverlay.layer = 2; } Material material2 = _crackOverlay.GetComponent<Renderer>().material; material2.color = new Color(1f, 1f, 1f, Mathf.Lerp(0f, 0.9f, num)); } } } public class PlacementPreview : MonoBehaviour { private GameObject _cube; private Renderer _renderer; private GameObject _outlineRoot; private LineRenderer[] _edges; private BlockSystem _sys; private Material _outlineGoodMat; private Material _outlineBadMat; public void Init(BlockSystem sys) { _sys = sys; EnsureBuilt(); Hide(); } private void EnsureBuilt() { //IL_006a: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Expected O, but got Unknown if ((Object)(object)_sys == (Object)null) { return; } if ((Object)(object)_cube == (Object)null) { _cube = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)_cube).name = "Empress_PreviewCube"; _cube.transform.SetParent(((Component)this).transform, false); _cube.transform.localScale = Vector3.one; _renderer = _cube.GetComponent<Renderer>(); Collider component = _cube.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } _cube.layer = 2; } if ((Object)(object)_renderer == (Object)null && (Object)(object)_cube != (Object)null) { _renderer = _cube.GetComponent<Renderer>(); } if ((Object)(object)_sys.PreviewGoodMat == (Object)null) { _sys.PreviewGoodMat = BlockSystemTint(new Color(0f, 1f, 0f, 0.35f)); } if ((Object)(object)_sys.PreviewBadMat == (Object)null) { _sys.PreviewBadMat = BlockSystemTint(new Color(1f, 0f, 0f, 0.35f)); } if ((Object)(object)_outlineRoot == (Object)null) { _outlineRoot = new GameObject("Empress_PreviewOutline"); _outlineRoot.transform.SetParent(((Component)this).transform, false); _outlineRoot.layer = 2; _edges = (LineRenderer[])(object)new LineRenderer[12]; for (int i = 0; i < _edges.Length; i++) { GameObject val = new GameObject($"Edge_{i}") { layer = 2 }; val.transform.SetParent(_outlineRoot.transform, false); LineRenderer val2 = val.AddComponent<LineRenderer>(); val2.positionCount = 2; val2.useWorldSpace = false; val2.widthMultiplier = 0.06f; val2.numCapVertices = 2; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; ((Renderer)val2).motionVectorGenerationMode = (MotionVectorGenerationMode)2; val2.textureMode = (LineTextureMode)0; val2.alignment = (LineAlignment)0; ((Renderer)val2).sortingOrder = 32767; Shader val3 = Shader.Find("Unlit/Color"); if ((Object)(object)val3 == (Object)null) { val3 = Shader.Find("Sprites/Default"); } if ((Object)(object)val3 == (Object)null) { val3 = Shader.Find("Legacy Shaders/Particles/Alpha Blended"); } ((Renderer)val2).material = new Material(val3); _edges[i] = val2; } SetOutlineBox(_edges); } if ((Object)(object)_outlineGoodMat == (Object)null) { _outlineGoodMat = MakeFlatColor(new Color(0f, 1f, 0f, 0.95f)); } if ((Object)(object)_outlineBadMat == (Object)null) { _outlineBadMat = MakeFlatColor(new Color(1f, 0f, 0f, 0.95f)); } } private static void SetOutlineBox(LineRenderer[] edges) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0089: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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) Vector3[] array = (Vector3[])(object)new Vector3[8] { new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, 0.5f), new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(-0.5f, 0.5f, 0.5f) }; int[,] array2 = new int[12, 2] { { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 0 }, { 4, 5 }, { 5, 6 }, { 6, 7 }, { 7, 4 }, { 0, 4 }, { 1, 5 }, { 2, 6 }, { 3, 7 } }; for (int i = 0; i < 12; i++) { edges[i].SetPosition(0, array[array2[i, 0]]); edges[i].SetPosition(1, array[array2[i, 1]]); } } private static Material BlockSystemTint(Color c) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Standard"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Legacy Shaders/Diffuse"); } if ((Object)(object)val == (Object)null) { GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3); val = val2.GetComponent<Renderer>().sharedMaterial.shader; Object.Destroy((Object)(object)val2); } Material val3 = new Material(val); if (((Object)val3.shader).name.Contains("Standard")) { val3.SetFloat("_Mode", 3f); val3.SetInt("_SrcBlend", 5); val3.SetInt("_DstBlend", 10); val3.SetInt("_ZWrite", 0); val3.DisableKeyword("_ALPHATEST_ON"); val3.EnableKeyword("_ALPHABLEND_ON"); val3.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val3.renderQueue = 3000; } val3.color = c; return val3; } private static Material MakeFlatColor(Color c) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Unlit/Color"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Sprites/Default"); } if ((Object)(object)val == (Object)null) { GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3); val = val2.GetComponent<Renderer>().sharedMaterial.shader; Object.Destroy((Object)(object)val2); } Material val3 = new Material(val); if (val3.HasProperty("_Color")) { val3.color = c; } val3.renderQueue = 3100; return val3; } public void UpdatePreview(Vector3Int grid, bool canPlace) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) EnsureBuilt(); if (!((Object)(object)_cube == (Object)null) && !((Object)(object)_renderer == (Object)null) && !((Object)(object)_outlineRoot == (Object)null) && _edges != null) { _cube.SetActive(true); _outlineRoot.SetActive(true); ((Component)this).transform.position = Vector3Int.op_Implicit(grid); _renderer.sharedMaterial = (canPlace ? _sys.PreviewGoodMat : _sys.PreviewBadMat); Material sharedMaterial = (canPlace ? _outlineGoodMat : _outlineBadMat); for (int i = 0; i < _edges.Length; i++) { ((Renderer)_edges[i]).sharedMaterial = sharedMaterial; } } } public void Hide() { if ((Object)(object)_cube != (Object)null) { _cube.SetActive(false); } if ((Object)(object)_outlineRoot != (Object)null) { _outlineRoot.SetActive(false); } } } public class BlockUI : MonoBehaviour { [CompilerGenerated] private sealed class <_InitLate>d__15 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public BlockUI <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <_InitLate>d__15(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this.EnsureUI(); <>4__this.Refresh(pulse: true); <>4__this.ShowPanel(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private Func<BlockKind> _getSelected; private BlockSystem _sys; private RawImage _icon; private Text _label; private CanvasGroup _panelGroup; private Canvas _canvas; private GameObject _panel; private float _pulseUntil; private bool _initialized; private bool _building; private bool _isPulsing; private float _fadeT; public bool IsVisible => (Object)(object)_panel != (Object)null && _panel.activeSelf; public void Init(Func<BlockKind> selected, BlockSystem sys) { _getSelected = selected; _sys = sys; ((MonoBehaviour)this).StartCoroutine(_InitLate()); } [IteratorStateMachine(typeof(<_InitLate>d__15))] private IEnumerator _InitLate() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <_InitLate>d__15(0) { <>4__this = this }; } private void EnsureUI() { if (_initialized || _building) { return; } _building = true; try { BuildUI(); _initialized = true; ManualLogSource log = EmpressMinecraftLitePlugin.Log; if (log != null) { log.LogInfo((object)"[MinecraftLite] Block UI initialized"); } } finally { _building = false; } } private void BuildUI() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00cf: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Expected O, but got Unknown //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Empress_BlockCanvas"); Object.DontDestroyOnLoad((Object)(object)val); _canvas = val.AddComponent<Canvas>(); _canvas.renderMode = (RenderMode)0; _canvas.overrideSorting = true; _canvas.sortingOrder = 32767; CanvasScaler val2 = val.AddComponent<CanvasScaler>(); val2.uiScaleMode = (ScaleMode)1; val2.referenceResolution = new Vector2(1920f, 1080f); val2.screenMatchMode = (ScreenMatchMode)0; val2.matchWidthOrHeight = 0.5f; val.AddComponent<GraphicRaycaster>().blockingObjects = (BlockingObjects)0; _panel = new GameObject("Panel"); _panel.transform.SetParent(val.transform, false); RectTransform val3 = _panel.AddComponent<RectTransform>(); val3.anchorMin = new Vector2(0.5f, 0f); val3.anchorMax = new Vector2(0.5f, 0f); val3.pivot = new Vector2(0.5f, 0f); val3.anchoredPosition = new Vector2(0f, 16f); val3.sizeDelta = new Vector2(280f, 64f); Image val4 = _panel.AddComponent<Image>(); ((Graphic)val4).color = new Color(0f, 0f, 0f, 0.75f); _panelGroup = _panel.AddComponent<CanvasGroup>(); _panelGroup.alpha = 0.9f; GameObject val5 = new GameObject("Icon"); val5.transform.SetParent(_panel.transform, false); RectTransform val6 = val5.AddComponent<RectTransform>(); val6.anchorMin = new Vector2(0f, 0f); val6.anchorMax = new Vector2(0f, 1f); val6.pivot = new Vector2(0f, 0.5f); val6.anchoredPosition = new Vector2(8f, 0f); val6.sizeDelta = new Vector2(48f, 48f); _icon = val5.AddComponent<RawImage>(); ((Graphic)_icon).raycastTarget = false; _icon.texture = null; ((Graphic)_icon).color = Color.white; ((Behaviour)_icon).enabled = false; GameObject val7 = new GameObject("Label"); val7.transform.SetParent(_panel.transform, false); RectTransform val8 = val7.AddComponent<RectTransform>(); val8.anchorMin = new Vector2(0f, 0f); val8.anchorMax = new Vector2(1f, 1f); val8.pivot = new Vector2(0.5f, 0.5f); val8.anchoredPosition = new Vector2(32f, 0f); val8.sizeDelta = new Vector2(-72f, 0f); _label = val7.AddComponent<Text>(); _label.text = ""; _label.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); _label.fontSize = 18; _label.alignment = (TextAnchor)3; ((Graphic)_label).color = Color.white; ((Graphic)_label).raycastTarget = false; _panel.SetActive(true); } public void Refresh(bool pulse = false) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) if (!_initialized) { EnsureUI(); } if (_initialized && !((Object)(object)_label == (Object)null)) { BlockKind blockKind = _getSelected?.Invoke(); string text = blockKind?.Id ?? "(none)"; _label.text = "Selected: " + text; if (blockKind != null && (Object)(object)blockKind.Texture != (Object)null && (Object)(object)_icon != (Object)null) { _icon.texture = (Texture)(object)blockKind.Texture; ((Behaviour)_icon).enabled = true; _icon.uvRect = new Rect(0f, 0f, 1f, 1f); } else if ((Object)(object)_icon != (Object)null) { _icon.texture = null; ((Behaviour)_icon).enabled = false; } if (pulse && (Object)(object)_panelGroup != (Object)null) { Pulse(); } } } public void ShowPanel() { if (_initialized) { if ((Object)(object)_panel != (Object)null && !_panel.activeSelf) { _panel.SetActive(true); } if ((Object)(object)_panelGroup != (Object)null) { _panelGroup.alpha = 0.9f; } } } public void HidePanel() { if (_initialized && (Object)(object)_panel != (Object)null && _panel.activeSelf) { _panel.SetActive(false); } } private void Pulse() { if (!((Object)(object)_panelGroup == (Object)null)) { _isPulsing = true; _fadeT = 0f; _panelGroup.alpha = 1f; _pulseUntil = Time.unscaledTime + 0.8f; } } private void Update() { if (!_isPulsing || (Object)(object)_panelGroup == (Object)null || !IsVisible) { return; } if (Time.unscaledTime < _pulseUntil) { _panelGroup.alpha = 1f; return; } _fadeT += Time.unscaledDeltaTime; if (_fadeT < 0.2f) { _panelGroup.alpha = Mathf.Lerp(1f, 0.9f, _fadeT / 0.2f); return; } _panelGroup.alpha = 0.9f; _isPulsing = false; } } }