using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
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 Microsoft.CodeAnalysis;
using Mirror;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.UI;
using YAPYAP;
[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("com.Omniscye.YapCraft")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+174558dd641ee37bf40ded0d24866ac172d24388")]
[assembly: AssemblyProduct("com.Omniscye.YapCraft")]
[assembly: AssemblyTitle("EmpressYapCraft")]
[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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace Empress.REPO.MinecraftLite
{
public class Block : MonoBehaviour
{
private BlockSystem _sys;
private float _miningTime;
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_0008: 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_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: 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)
{
if (_renderer.sharedMaterial.HasProperty("_BaseColor"))
{
_baseColor = _renderer.sharedMaterial.GetColor("_BaseColor");
}
else
{
_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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: 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_0107: 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)
//IL_0132: Expected O, but got Unknown
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_renderer == (Object)null)
{
return;
}
float num = Mathf.InverseLerp(0f, 1f, _miningTime);
Material material = _renderer.material;
Color val2 = (material.color = Color.Lerp(_baseColor, Color.black, num * 0.35f));
if (material.HasProperty("_BaseColor"))
{
material.SetColor("_BaseColor", val2);
}
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;
Color val3 = default(Color);
((Color)(ref val3))..ctor(1f, 1f, 1f, Mathf.Lerp(0f, 0.9f, num));
material2.color = val3;
if (material2.HasProperty("_BaseColor"))
{
material2.SetColor("_BaseColor", val3);
}
}
}
}
public class BlockKind
{
public string Id;
public Material Material;
public Texture2D Texture;
}
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_000d: 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_008c: 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)
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
{
LoadFromLooseFiles(textureDir);
}
if (Kinds.Count == 0)
{
ManualLogSource log2 = EmpressMinecraftLitePlugin.Log;
if (log2 != null)
{
log2.LogWarning((object)"[MinecraftLite] No selectable block textures found.");
}
}
PreviewGoodMat = MakeTintMat(new Color(0f, 1f, 0f, 0.35f));
PreviewBadMat = MakeTintMat(new Color(1f, 0f, 0f, 0.35f));
}
private void LoadFromOmnibin(string omnibinPath)
{
try
{
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;
}
}
CrackOverlayMaterial = ((entry != null) ? MakeTransparentMatFromBytes(entry.Data) : null);
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;
}
}
}
catch (Exception ex)
{
ManualLogSource log = EmpressMinecraftLitePlugin.Log;
if (log != null)
{
log.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);
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;
}
}
}
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)
{
return LoadTextureFromBytes(File.ReadAllBytes(path));
}
private static Texture2D LoadTextureFromBytes(byte[] data)
{
//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_0011: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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 Shader FindProperShader()
{
Shader val = Shader.Find("CustomLit_Amplify");
if ((Object)(object)val == (Object)null)
{
val = Shader.Find("Universal Render Pipeline/Lit");
}
if ((Object)(object)val == (Object)null)
{
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);
if ((Object)(object)val2.GetComponent<Renderer>() != (Object)null && (Object)(object)val2.GetComponent<Renderer>().sharedMaterial != (Object)null)
{
val = val2.GetComponent<Renderer>().sharedMaterial.shader;
}
Object.Destroy((Object)(object)val2);
}
return val;
}
private static void ApplyTextureToMat(Material mat, Texture2D tex)
{
if (!((Object)(object)tex == (Object)null))
{
if (mat.HasProperty("_MainTex"))
{
mat.SetTexture("_MainTex", (Texture)(object)tex);
}
if (mat.HasProperty("_BaseMap"))
{
mat.SetTexture("_BaseMap", (Texture)(object)tex);
}
if (mat.HasProperty("_AlbedoTexture"))
{
mat.SetTexture("_AlbedoTexture", (Texture)(object)tex);
}
}
}
private static Material MakeMat(string pngPath, out Texture2D outTex)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//IL_000f: 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)
outTex = null;
Material val = new Material(FindProperShader());
val.color = Color.white;
if (val.HasProperty("_BaseColor"))
{
val.SetColor("_BaseColor", Color.white);
}
if (!string.IsNullOrEmpty(pngPath) && File.Exists(pngPath))
{
outTex = LoadTexture(pngPath);
ApplyTextureToMat(val, outTex);
}
return val;
}
private static Material MakeMatFromBytes(byte[] pngData, out Texture2D outTex)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//IL_000f: 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)
outTex = null;
Material val = new Material(FindProperShader());
val.color = Color.white;
if (val.HasProperty("_BaseColor"))
{
val.SetColor("_BaseColor", Color.white);
}
if (pngData != null && pngData.Length != 0)
{
outTex = LoadTextureFromBytes(pngData);
ApplyTextureToMat(val, outTex);
}
return val;
}
private static void SetupTransparent(Material mat)
{
mat.SetInt("_SrcBlend", 5);
mat.SetInt("_DstBlend", 10);
mat.SetInt("_ZWrite", 0);
mat.EnableKeyword("_ALPHABLEND_ON");
mat.DisableKeyword("_ALPHATEST_ON");
mat.renderQueue = 3000;
if (mat.HasProperty("_Surface"))
{
mat.SetFloat("_Surface", 1f);
}
if (mat.HasProperty("_Blend"))
{
mat.SetFloat("_Blend", 0f);
}
if (mat.HasProperty("_Mode"))
{
mat.SetFloat("_Mode", 3f);
}
}
private static Material MakeTransparentMat(string pngPath)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
Material val = new Material(FindProperShader());
SetupTransparent(val);
if (!string.IsNullOrEmpty(pngPath) && File.Exists(pngPath))
{
Texture2D tex = LoadTexture(pngPath);
ApplyTextureToMat(val, tex);
}
return val;
}
private static Material MakeTransparentMatFromBytes(byte[] pngData)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
Material val = new Material(FindProperShader());
SetupTransparent(val);
if (pngData != null && pngData.Length != 0)
{
Texture2D tex = LoadTextureFromBytes(pngData);
ApplyTextureToMat(val, tex);
}
return val;
}
private static Material MakeTintMat(Color c)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_0012: 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)
Material val = new Material(FindProperShader());
SetupTransparent(val);
val.color = c;
if (val.HasProperty("_BaseColor"))
{
val.SetColor("_BaseColor", c);
}
return val;
}
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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: 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)
if (NetworkClient.active)
{
BlockUpdateMessage blockUpdateMessage = default(BlockUpdateMessage);
blockUpdateMessage.GridPos = grid;
blockUpdateMessage.BlockId = kind.Id;
blockUpdateMessage.IsPlacement = true;
NetworkClient.Send<BlockUpdateMessage>(blockUpdateMessage, 0);
}
else
{
PlaceBlockLocal(grid, kind?.Id, placeClip);
}
}
public void RemoveBlock(Vector3Int grid, AudioClip breakClip)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: 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)
if (NetworkClient.active)
{
BlockUpdateMessage blockUpdateMessage = default(BlockUpdateMessage);
blockUpdateMessage.GridPos = grid;
blockUpdateMessage.BlockId = "";
blockUpdateMessage.IsPlacement = false;
NetworkClient.Send<BlockUpdateMessage>(blockUpdateMessage, 0);
}
else
{
RemoveBlockLocal(grid, breakClip);
}
}
public void PlaceBlockLocal(Vector3Int grid, string kindId, AudioClip placeClip)
{
//IL_001f: 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_0061: 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)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: 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_00d6: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
if (!string.IsNullOrEmpty(kindId) && KindById.TryGetValue(kindId, out BlockKind value) && !Blocks.ContainsKey(grid))
{
GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
((Object)obj).name = $"Block_{value.Id}_{grid}";
obj.transform.SetParent(_root);
obj.transform.position = Vector3Int.op_Implicit(grid);
obj.transform.localScale = Vector3.one;
Renderer component = obj.GetComponent<Renderer>();
if ((Object)(object)value.Material != (Object)null && (Object)(object)component != (Object)null)
{
component.sharedMaterial = value.Material;
}
Block block = obj.AddComponent<Block>();
block.Init(this, grid, value.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 RemoveBlockLocal(Vector3Int grid, AudioClip breakClip)
{
//IL_0006: 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_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_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)
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 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_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
int num = <>1__state;
BlockUI blockUI = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForEndOfFrame();
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
blockUI.EnsureUI();
blockUI.Refresh(pulse: true);
blockUI.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
{
get
{
if ((Object)(object)_panel != (Object)null)
{
return _panel.activeSelf;
}
return false;
}
}
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;
}
finally
{
_building = false;
}
}
private void BuildUI()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_005d: 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_0094: Expected O, but got Unknown
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: 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_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Expected O, but got Unknown
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Expected O, but got Unknown
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
//IL_0318: 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 obj = val.AddComponent<CanvasScaler>();
obj.uiScaleMode = (ScaleMode)1;
obj.referenceResolution = new Vector2(1920f, 1080f);
obj.screenMatchMode = (ScreenMatchMode)0;
obj.matchWidthOrHeight = 0.5f;
val.AddComponent<GraphicRaycaster>().blockingObjects = (BlockingObjects)0;
_panel = new GameObject("Panel");
_panel.transform.SetParent(val.transform, false);
RectTransform obj2 = _panel.AddComponent<RectTransform>();
obj2.anchorMin = new Vector2(0.5f, 0f);
obj2.anchorMax = new Vector2(0.5f, 0f);
obj2.pivot = new Vector2(0.5f, 0f);
obj2.anchoredPosition = new Vector2(0f, 16f);
obj2.sizeDelta = new Vector2(280f, 64f);
((Graphic)_panel.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.75f);
_panelGroup = _panel.AddComponent<CanvasGroup>();
_panelGroup.alpha = 0.9f;
GameObject val2 = new GameObject("Icon");
val2.transform.SetParent(_panel.transform, false);
RectTransform obj3 = val2.AddComponent<RectTransform>();
obj3.anchorMin = new Vector2(0f, 0f);
obj3.anchorMax = new Vector2(0f, 1f);
obj3.pivot = new Vector2(0f, 0.5f);
obj3.anchoredPosition = new Vector2(8f, 0f);
obj3.sizeDelta = new Vector2(48f, 48f);
_icon = val2.AddComponent<RawImage>();
((Graphic)_icon).raycastTarget = false;
_icon.texture = null;
((Graphic)_icon).color = Color.white;
((Behaviour)_icon).enabled = false;
GameObject val3 = new GameObject("Label");
val3.transform.SetParent(_panel.transform, false);
RectTransform obj4 = val3.AddComponent<RectTransform>();
obj4.anchorMin = new Vector2(0f, 0f);
obj4.anchorMax = new Vector2(1f, 1f);
obj4.pivot = new Vector2(0.5f, 0.5f);
obj4.anchoredPosition = new Vector2(32f, 0f);
obj4.sizeDelta = new Vector2(-72f, 0f);
_label = val3.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_00bf: 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;
}
}
[BepInPlugin("empress.repo.minecraftlite", "Empress Minecraft-Lite", "1.3.1")]
public class EmpressMinecraftLitePlugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <LoadAudioClips>d__24 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public EmpressMinecraftLitePlugin <>4__this;
public string dir;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadAudioClips>d__24(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
EmpressMinecraftLitePlugin CS$<>8__locals0 = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = ((MonoBehaviour)CS$<>8__locals0).StartCoroutine(CS$<>8__locals0.LoadOne(dir, "place.ogg", delegate(AudioClip c)
{
CS$<>8__locals0.PlaceClip = c;
}));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>2__current = ((MonoBehaviour)CS$<>8__locals0).StartCoroutine(CS$<>8__locals0.LoadOne(dir, "break.ogg", delegate(AudioClip c)
{
CS$<>8__locals0.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__25 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public string dir;
public string fileName;
public Action<AudioClip> setter;
private UnityWebRequest <req>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadOne>d__25(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();
}
}
<req>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Invalid comparison between Unknown and I4
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Invalid comparison between Unknown and I4
try
{
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
string text = Path.Combine(dir, fileName);
if (!File.Exists(text))
{
Log.LogWarning((object)("[MinecraftLite] Audio missing: " + fileName + " (optional)"));
return false;
}
<req>5__2 = UnityWebRequestMultimedia.GetAudioClip(new Uri(text).AbsoluteUri, (AudioType)14);
<>1__state = -3;
<>2__current = <req>5__2.SendWebRequest();
<>1__state = 1;
return true;
}
case 1:
<>1__state = -3;
if ((int)<req>5__2.result == 2 || (int)<req>5__2.result == 3)
{
Log.LogWarning((object)("[MinecraftLite] Failed loading " + fileName + ": " + <req>5__2.error));
}
else
{
AudioClip content = DownloadHandlerAudioClip.GetContent(<req>5__2);
if ((Object)(object)content != (Object)null)
{
((Object)content).name = Path.GetFileNameWithoutExtension(fileName);
setter?.Invoke(content);
Log.LogInfo((object)("[MinecraftLite] Audio OK: " + fileName));
}
}
<>m__Finally1();
<req>5__2 = null;
return false;
}
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
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__2 != null)
{
((IDisposable)<req>5__2).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;
public AudioClip PlaceClip;
public AudioClip BreakClip;
private void Awake()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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)
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
NetworkMessageSerialization.Register();
_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));
YapNetworkManager.OnServerStartedAction += OnServerStarted;
YapNetworkManager.OnClientStartedAction += OnClientStarted;
YapNetworkManager.OnClientConnectedOnServerAction += OnClientConnectedToServer;
((BaseUnityPlugin)this).Logger.LogInfo((object)("Empress Minecraft-Lite 1.3.1 loaded. Content: " + text));
}
private void OnServerStarted()
{
NetworkServer.RegisterHandler<BlockUpdateMessage>((Action<NetworkConnectionToClient, BlockUpdateMessage>)OnServerBlockUpdate, true);
}
private void OnClientStarted()
{
NetworkClient.RegisterHandler<BlockUpdateMessage>((Action<BlockUpdateMessage>)OnClientBlockUpdate, true);
NetworkClient.RegisterHandler<BulkBlockSyncMessage>((Action<BulkBlockSyncMessage>)OnClientBulkSync, true);
}
private void OnClientConnectedToServer(NetworkConnectionToClient conn)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
List<Vector3Int> list = new List<Vector3Int>();
List<string> list2 = new List<string>();
foreach (KeyValuePair<Vector3Int, Block> block in _blocks.Blocks)
{
list.Add(block.Key);
list2.Add(block.Value.KindId);
}
if (list.Count > 0)
{
((NetworkConnection)conn).Send<BulkBlockSyncMessage>(new BulkBlockSyncMessage
{
Count = list.Count,
Positions = list.ToArray(),
BlockIds = list2.ToArray()
}, 0);
}
}
private void OnServerBlockUpdate(NetworkConnectionToClient conn, BlockUpdateMessage msg)
{
//IL_0029: 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)
if (msg.IsPlacement)
{
_blocks.PlaceBlockLocal(msg.GridPos, msg.BlockId, null);
}
else
{
_blocks.RemoveBlockLocal(msg.GridPos, null);
}
NetworkServer.SendToAll<BlockUpdateMessage>(msg, 0, false);
}
private void OnClientBlockUpdate(BlockUpdateMessage msg)
{
//IL_002d: 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)
if (msg.IsPlacement)
{
_blocks.PlaceBlockLocal(msg.GridPos, msg.BlockId, PlaceClip);
}
else
{
_blocks.RemoveBlockLocal(msg.GridPos, BreakClip);
}
}
private void OnClientBulkSync(BulkBlockSyncMessage msg)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < msg.Count; i++)
{
_blocks.PlaceBlockLocal(msg.Positions[i], msg.BlockIds[i], null);
}
}
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__24))]
private IEnumerator LoadAudioClips(string dir)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadAudioClips>d__24(0)
{
<>4__this = this,
dir = dir
};
}
[IteratorStateMachine(typeof(<LoadOne>d__25))]
private IEnumerator LoadOne(string dir, string fileName, Action<AudioClip> setter)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadOne>d__25(0)
{
dir = dir,
fileName = fileName,
setter = setter
};
}
internal void PlayClipAt(AudioClip clip, Vector3 worldPos, float volume = 0.9f)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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_00ac: Expected O, but got Unknown
if ((Object)(object)clip != (Object)null)
{
GameObject val = new GameObject("Empress_AudioOneShot_" + ((Object)clip).name);
val.transform.position = worldPos;
AudioSource obj = val.AddComponent<AudioSource>();
obj.spatialBlend = 1f;
obj.rolloffMode = (AudioRolloffMode)1;
obj.minDistance = 2f;
obj.maxDistance = 20f;
obj.playOnAwake = false;
obj.clip = clip;
obj.volume = Mathf.Clamp01(volume);
obj.dopplerLevel = 0f;
obj.spread = 0f;
obj.priority = 128;
obj.Play();
Object.Destroy((Object)val, clip.length + 0.1f);
}
}
private void Update()
{
//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)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: 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)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: 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)
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();
}
else
{
_placementEnabled = true;
_ui.Refresh(pulse: true);
_ui.ShowPanel();
_lastSelectionTime = Time.unscaledTime;
}
}
RaycastHit hit = default(RaycastHit);
if (Physics.Raycast(main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)), 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();
}
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 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_0002: 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_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
return RoundToGrid(((RaycastHit)(ref hit)).point + ((RaycastHit)(ref hit)).normal * 0.5f);
}
}
public struct BlockUpdateMessage : NetworkMessage
{
public Vector3Int GridPos;
public string BlockId;
public bool IsPlacement;
}
public struct BulkBlockSyncMessage : NetworkMessage
{
public int Count;
public Vector3Int[] Positions;
public string[] BlockIds;
}
public static class NetworkMessageSerialization
{
public static void Register()
{
Writer<BlockUpdateMessage>.write = WriteBlockUpdate;
Reader<BlockUpdateMessage>.read = ReadBlockUpdate;
Writer<BulkBlockSyncMessage>.write = WriteBulkBlockSync;
Reader<BulkBlockSyncMessage>.read = ReadBulkBlockSync;
}
private static void WriteBlockUpdate(NetworkWriter writer, BlockUpdateMessage msg)
{
NetworkWriterExtensions.WriteInt(writer, ((Vector3Int)(ref msg.GridPos)).x);
NetworkWriterExtensions.WriteInt(writer, ((Vector3Int)(ref msg.GridPos)).y);
NetworkWriterExtensions.WriteInt(writer, ((Vector3Int)(ref msg.GridPos)).z);
NetworkWriterExtensions.WriteString(writer, msg.BlockId);
NetworkWriterExtensions.WriteBool(writer, msg.IsPlacement);
}
private static BlockUpdateMessage ReadBlockUpdate(NetworkReader reader)
{
//IL_001c: 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)
BlockUpdateMessage result = default(BlockUpdateMessage);
result.GridPos = new Vector3Int(NetworkReaderExtensions.ReadInt(reader), NetworkReaderExtensions.ReadInt(reader), NetworkReaderExtensions.ReadInt(reader));
result.BlockId = NetworkReaderExtensions.ReadString(reader);
result.IsPlacement = NetworkReaderExtensions.ReadBool(reader);
return result;
}
private static void WriteBulkBlockSync(NetworkWriter writer, BulkBlockSyncMessage msg)
{
NetworkWriterExtensions.WriteInt(writer, msg.Count);
int num = ((msg.Positions != null) ? msg.Positions.Length : 0);
NetworkWriterExtensions.WriteInt(writer, num);
if (msg.Positions != null)
{
for (int i = 0; i < num; i++)
{
NetworkWriterExtensions.WriteInt(writer, ((Vector3Int)(ref msg.Positions[i])).x);
NetworkWriterExtensions.WriteInt(writer, ((Vector3Int)(ref msg.Positions[i])).y);
NetworkWriterExtensions.WriteInt(writer, ((Vector3Int)(ref msg.Positions[i])).z);
}
}
int num2 = ((msg.BlockIds != null) ? msg.BlockIds.Length : 0);
NetworkWriterExtensions.WriteInt(writer, num2);
if (msg.BlockIds != null)
{
for (int j = 0; j < num2; j++)
{
NetworkWriterExtensions.WriteString(writer, msg.BlockIds[j]);
}
}
}
private static BulkBlockSyncMessage ReadBulkBlockSync(NetworkReader reader)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
int count = NetworkReaderExtensions.ReadInt(reader);
int num = NetworkReaderExtensions.ReadInt(reader);
Vector3Int[] array = (Vector3Int[])(object)new Vector3Int[num];
for (int i = 0; i < num; i++)
{
array[i] = new Vector3Int(NetworkReaderExtensions.ReadInt(reader), NetworkReaderExtensions.ReadInt(reader), NetworkReaderExtensions.ReadInt(reader));
}
int num2 = NetworkReaderExtensions.ReadInt(reader);
string[] array2 = new string[num2];
for (int j = 0; j < num2; j++)
{
array2[j] = NetworkReaderExtensions.ReadString(reader);
}
BulkBlockSyncMessage result = default(BulkBlockSyncMessage);
result.Count = count;
result.Positions = array;
result.BlockIds = array2;
return result;
}
}
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();
}
binaryReader.ReadUInt16();
binaryReader.ReadUInt16();
uint num = binaryReader.ReadUInt32();
List<(string, ulong, uint, uint, uint)> list2 = new List<(string, ulong, uint, uint, uint)>();
for (uint num2 = 0u; num2 < num; num2++)
{
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[] data = (((item5.Item5 & 1) == 0) ? array2 : DecompressDeflate(array2));
list.Add(new Entry
{
Name = item5.Item1,
Data = data
});
}
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 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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: 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_0158: Expected O, but got Unknown
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: 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>();
Object.Destroy((Object)(object)_cube.GetComponent<Collider>());
_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 = MakeTintMat(new Color(0f, 1f, 0f, 0.35f));
}
if ((Object)(object)_sys.PreviewBadMat == (Object)null)
{
_sys.PreviewBadMat = MakeTintMat(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;
Shader val3 = Shader.Find("Unlit/Color");
if ((Object)(object)val3 == (Object)null)
{
val3 = Shader.Find("Sprites/Default");
}
((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_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: 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_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: 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_0068: 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_0083: 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_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_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
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 MakeTintMat(Color c)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_0027: 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)
Shader val = Shader.Find("CustomLit_Amplify");
if ((Object)(object)val == (Object)null)
{
val = Shader.Find("Standard");
}
Material val2 = new Material(val);
val2.color = c;
if (val2.HasProperty("_BaseColor"))
{
val2.SetColor("_BaseColor", c);
}
val2.SetInt("_SrcBlend", 5);
val2.SetInt("_DstBlend", 10);
val2.SetInt("_ZWrite", 0);
val2.EnableKeyword("_ALPHABLEND_ON");
val2.DisableKeyword("_ALPHATEST_ON");
val2.renderQueue = 3000;
return val2;
}
private static Material MakeFlatColor(Color c)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: 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");
}
Material val2 = new Material(val);
if (val2.HasProperty("_Color"))
{
val2.color = c;
}
if (val2.HasProperty("_BaseColor"))
{
val2.SetColor("_BaseColor", c);
}
val2.renderQueue = 3100;
return val2;
}
public void UpdatePreview(Vector3Int grid, bool canPlace)
{
//IL_0062: 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)
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);
}
}
}
}
namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ConstantExpectedAttribute : Attribute
{
public object? Min { get; set; }
public object? Max { get; set; }
}
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ExperimentalAttribute : Attribute
{
public string DiagnosticId { get; }
public string? UrlFormat { get; set; }
public ExperimentalAttribute(string diagnosticId)
{
DiagnosticId = diagnosticId;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullAttribute : Attribute
{
public string[] Members { get; }
public MemberNotNullAttribute(string member)
{
Members = new string[1] { member };
}
public MemberNotNullAttribute(params string[] members)
{
Members = members;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullWhenAttribute : Attribute
{
public bool ReturnValue { get; }
public string[] Members { get; }
public MemberNotNullWhenAttribute(bool returnValue, string member)
{
ReturnValue = returnValue;
Members = new string[1] { member };
}
public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
{
ReturnValue = returnValue;
Members = members;
}
}
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SetsRequiredMembersAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class StringSyntaxAttribute : Attribute
{
public const string CompositeFormat = "CompositeFormat";
public const string DateOnlyFormat = "DateOnlyFormat";
public const string DateTimeFormat = "DateTimeFormat";
public const string EnumFormat = "EnumFormat";
public const string GuidFormat = "GuidFormat";
public const string Json = "Json";
public const string NumericFormat = "NumericFormat";
public const string Regex = "Regex";
public const string TimeOnlyFormat = "TimeOnlyFormat";
public const string TimeSpanFormat = "TimeSpanFormat";
public const string Uri = "Uri";
public const string Xml = "Xml";
public string Syntax { get; }
public object?[] Arguments { get; }
public StringSyntaxAttribute(string syntax)
{
Syntax = syntax;
Arguments = new object[0];
}
public StringSyntaxAttribute(string syntax, params object?[] arguments)
{
Syntax = syntax;
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class UnscopedRefAttribute : Attribute
{
}
}
namespace System.Runtime.Versioning
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresPreviewFeaturesAttribute : Attribute
{
public string? Message { get; }
public string? Url { get; set; }
public RequiresPreviewFeaturesAttribute()
{
}
public RequiresPreviewFeaturesAttribute(string? message)
{
Message = message;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CallerArgumentExpressionAttribute : Attribute
{
public string ParameterName { get; }
public CallerArgumentExpressionAttribute(string parameterName)
{
ParameterName = parameterName;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CollectionBuilderAttribute : Attribute
{
public Type BuilderType { get; }
public string MethodName { get; }
public CollectionBuilderAttribute(Type builderType, string methodName)
{
BuilderType = builderType;
MethodName = methodName;
}
}
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CompilerFeatureRequiredAttribute : Attribute
{
public const string RefStructs = "RefStructs";
public const string RequiredMembers = "RequiredMembers";
public string FeatureName { get; }
public bool IsOptional { get; set; }
public CompilerFeatureRequiredAttribute(string featureName)
{
FeatureName = featureName;
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
{
public string[] Arguments { get; }
public InterpolatedStringHandlerArgumentAttribute(string argument)
{
Arguments = new string[1] { argument };
}
public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
{
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerAttribute : Attribute
{
}
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal static class IsExternalInit
{
}
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ModuleInitializerAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class OverloadResolutionPriorityAttribute : Attribute
{
public int Priority { get; }
public OverloadResolutionPriorityAttribute(int priority)
{
Priority = priority;
}
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
[ExcludeFromCodeCoverage]
internal sealed class ParamCollectionAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiredMemberAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresLocationAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SkipLocalsInitAttribute : Attribute
{
}
}