protected virtual FaceAttributes GetBackFaceAttributes(NBTChunk chunk, NBTMesh mesh, CubeAttributes ca) { UnityEngine.Profiling.Profiler.BeginSample("GetBackFaceAttributes"); backFA.pos = backVertices; backFA.faceIndex = GetBackIndexByData(chunk, ca.blockData); backFA.color = GetBackTintColorByData(chunk, ca.pos, ca.blockData); backFA.normal = Vector3.back; //farBottomRight, farTopRight, farTopLeft, farBottomLeft backFA.skyLight[0] = (ca.back.skyLight + ca.backBottom.skyLight + ca.backRight.skyLight + ca.backBottomRight.skyLight) / 60.0f; backFA.skyLight[1] = (ca.back.skyLight + ca.backTop.skyLight + ca.backRight.skyLight + ca.backTopRight.skyLight) / 60.0f; backFA.skyLight[2] = (ca.back.skyLight + ca.backTop.skyLight + ca.backLeft.skyLight + ca.backTopLeft.skyLight) / 60.0f; backFA.skyLight[3] = (ca.back.skyLight + ca.backBottom.skyLight + ca.backLeft.skyLight + ca.backBottomLeft.skyLight) / 60.0f; backFA.blockLight[0] = (ca.back.blockLight + ca.backBottom.blockLight + ca.backRight.blockLight + ca.backBottomRight.blockLight) / 60.0f; backFA.blockLight[1] = (ca.back.blockLight + ca.backTop.blockLight + ca.backRight.blockLight + ca.backTopRight.blockLight) / 60.0f; backFA.blockLight[2] = (ca.back.blockLight + ca.backTop.blockLight + ca.backLeft.blockLight + ca.backTopLeft.blockLight) / 60.0f; backFA.blockLight[3] = (ca.back.blockLight + ca.backBottom.blockLight + ca.backLeft.blockLight + ca.backBottomLeft.blockLight) / 60.0f; Rotation rotation = GetFrontRotationByData(ca.blockData); if (rotation == Rotation.Right) { backFA.uv = uv_right; } else { backFA.uv = uv_zero; } UnityEngine.Profiling.Profiler.EndSample(); return(backFA); }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.blockData = blockData; FillMesh(chunk, ca, nbtGO.nbtMesh); }
protected virtual FaceAttributes GetRightFaceAttributes(NBTChunk chunk, NBTMesh mesh, CubeAttributes ca) { UnityEngine.Profiling.Profiler.BeginSample("GetRightFaceAttributes"); rightFA.pos = rightVertices; rightFA.faceIndex = GetRightIndexByData(chunk, ca.blockData); rightFA.color = GetRightTintColorByData(chunk, ca.pos, ca.blockData); rightFA.normal = Vector3.right; //nearBottomRight, nearTopRight, farTopRight, farBottomRight rightFA.skyLight[0] = (ca.right.skyLight + ca.frontRight.skyLight + ca.bottomRight.skyLight + ca.frontBottomRight.skyLight) / 60.0f; rightFA.skyLight[1] = (ca.right.skyLight + ca.frontRight.skyLight + ca.topRight.skyLight + ca.frontTopRight.skyLight) / 60.0f; rightFA.skyLight[2] = (ca.right.skyLight + ca.backRight.skyLight + ca.topRight.skyLight + ca.backTopRight.skyLight) / 60.0f; rightFA.skyLight[3] = (ca.right.skyLight + ca.backRight.skyLight + ca.bottomRight.skyLight + ca.backBottomRight.skyLight) / 60.0f; rightFA.blockLight[0] = (ca.right.blockLight + ca.frontRight.blockLight + ca.bottomRight.blockLight + ca.frontBottomRight.blockLight) / 60.0f; rightFA.blockLight[1] = (ca.right.blockLight + ca.frontRight.blockLight + ca.topRight.blockLight + ca.frontTopRight.blockLight) / 60.0f; rightFA.blockLight[2] = (ca.right.blockLight + ca.backRight.blockLight + ca.topRight.blockLight + ca.backTopRight.blockLight) / 60.0f; rightFA.blockLight[3] = (ca.right.blockLight + ca.backRight.blockLight + ca.bottomRight.blockLight + ca.backBottomRight.blockLight) / 60.0f; Rotation rotation = GetFrontRotationByData(ca.blockData); if (rotation == Rotation.Right) { rightFA.uv = uv_right; } else { rightFA.uv = uv_zero; } UnityEngine.Profiling.Profiler.EndSample(); return(rightFA); }
void FillMesh(NBTChunk chunk, CubeAttributes ca, NBTMesh nbtMesh) { chunk.GetLights(ca.pos.x, ca.pos.y, ca.pos.z, out float skyLight, out float blockLight); FaceAttributes fa = new FaceAttributes(); fa.faceIndex = TextureArrayManager.GetIndexByName("ladder"); fa.color = Color.white; fa.skyLight = new float[] { skyLight, skyLight, skyLight, skyLight }; fa.blockLight = new float[] { blockLight, blockLight, blockLight, blockLight }; fa.normal = Vector3.zero; fa.uv = uv_zero; if (ca.blockData == 2) { fa.pos = frontFace; AddFace(nbtMesh, fa, ca); } else if (ca.blockData == 3) { fa.pos = backFace; AddFace(nbtMesh, fa, ca); } else if (ca.blockData == 4) { fa.pos = leftFace; AddFace(nbtMesh, fa, ca); } else if (ca.blockData == 5) { fa.pos = rightFace; AddFace(nbtMesh, fa, ca); } }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.blockData = blockData; chunk.GetLights(pos.x, pos.y, pos.z, out float skyLight, out float blockLight); FaceAttributes fa = new FaceAttributes(); fa.faceIndex = GetPlantIndexByData(chunk, blockData); fa.color = Color.white; fa.skyLight = new float[] { skyLight, skyLight, skyLight, skyLight }; fa.blockLight = new float[] { blockLight, blockLight, blockLight, blockLight }; fa.normal = Vector3.zero; fa.uv = uv_zero; try { fa.pos = face1; AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = face2; AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = face3; AddFace(nbtGO.nbtMesh, fa, ca); fa.pos = face4; AddFace(nbtGO.nbtMesh, fa, ca); } catch (System.Exception e) { Debug.Log(e.ToString() + "\n" + "pos=" + pos + ",data=" + blockData); } }
public override void OnRightClick() { bool isUpper = (WireFrameHelper.data & 0b1000) > 0; int direction = 0; bool isOpen = false; if (isUpper) { NBTHelper.GetBlockData(WireFrameHelper.pos.x, WireFrameHelper.pos.y - 1, WireFrameHelper.pos.z, out byte belowType, out byte belowData); if (belowType == 64) { isOpen = (belowData & 0b0100) > 0; direction = belowData & 0b0011; } byte newData = (byte)(belowData ^ 0b0100); NBTHelper.SetBlockData(WireFrameHelper.pos + Vector3Int.down, WireFrameHelper.type, newData); } else { isOpen = (WireFrameHelper.data & 0b0100) > 0; byte newData = (byte)(WireFrameHelper.data ^ 0b0100); NBTHelper.SetBlockData(WireFrameHelper.pos, WireFrameHelper.type, newData); } SoundManager.Play2DSound(isOpen ? "Player_Door_Close" : "Player_Door_Open"); NBTChunk chunk = NBTHelper.GetChunk(WireFrameHelper.pos); chunk.RebuildMesh(UpdateFlags.Collidable); }
public override Mesh GetItemMesh(NBTChunk chunk, Vector3Int pos, byte blockData) { CubeAttributes ca = new CubeAttributes(); ca.blockData = blockData; NBTMesh nbtMesh = new NBTMesh(256); chunk.GetLights(pos.x - chunk.x * 16, pos.y, pos.z - chunk.z * 16, out float skyLight, out float blockLight); FaceAttributes fa = new FaceAttributes(); fa.faceIndex = TextureArrayManager.GetIndexByName(GetNameByData(blockData)); fa.skyLight = new float[] { skyLight, skyLight, skyLight, skyLight }; fa.blockLight = new float[] { blockLight, blockLight, blockLight, blockLight }; fa.color = Color.white; FillMesh(fa, ca, nbtMesh); nbtMesh.Refresh(); nbtMesh.Dispose(); return(nbtMesh.mesh); }
public override int GetRightIndexByData(NBTChunk chunk, int data) { switch (data) { case 0: case 8: return(TextureArrayManager.GetIndexByName("log_oak")); case 1: case 9: return(TextureArrayManager.GetIndexByName("log_spruce")); case 2: case 10: return(TextureArrayManager.GetIndexByName("log_birch")); case 3: case 11: return(TextureArrayManager.GetIndexByName("log_jungle")); case 4: return(TextureArrayManager.GetIndexByName("log_oak_top")); case 5: return(TextureArrayManager.GetIndexByName("log_spruce_top")); case 6: return(TextureArrayManager.GetIndexByName("log_birch_top")); case 7: return(TextureArrayManager.GetIndexByName("log_jungle_top")); } return(TextureArrayManager.GetIndexByName("log_oak")); }
public static void Recover(NBTChunk chunk) { chunk.transform.parent = instance.transform; chunk.transform.localPosition = Vector3.zero; chunk.gameObject.SetActive(false); chunks.Enqueue(chunk); }
public static NBTGameObject Create(string name, NBTChunk chunk, int layer, bool navigate = true) { GameObject go = new GameObject(name); go.transform.parent = chunk.transform; go.AddComponent <MeshFilter>(); go.layer = layer; if (navigate) { go.AddComponent <NavMeshSourceTag>(); } Material mat = new Material(Shader.Find("Custom/TextureArrayShader")); if (layer == 12) { mat.SetFloat("_Culling", 0); } go.AddComponent <MeshRenderer>().sharedMaterial = mat; go.AddComponent <MeshCollider>(); NBTGameObject nbtGO = go.AddComponent <NBTGameObject>(); nbtGO.mat = mat; nbtGO.nbtMesh.mesh.name = name; return(nbtGO); }
// get the dot product between the player front vector and chunk to player vector. public static float GetChunkToFrontDot(NBTChunk chunk) { Vector2 chunk2player = new Vector2(chunk.globalX - instance.position.x, chunk.globalZ - instance.position.z); Vector2 playerForward = new Vector2(instance.forward.x, instance.forward.z); return(Vector2.Dot(playerForward.normalized, chunk2player.normalized)); }
MeshData GetMesh(NBTChunk chunk, Vector3Int pos) { byte eastType = chunk.GetBlockByte(pos + Vector3Int.right); bool eastConnect = !NBTGeneratorManager.IsTransparent(eastType) || NBTGeneratorManager.IsFence(eastType); byte southType = chunk.GetBlockByte(pos + Vector3Int.back); bool southConnect = !NBTGeneratorManager.IsTransparent(southType) || NBTGeneratorManager.IsFence(southType); byte westType = chunk.GetBlockByte(pos + Vector3Int.left); bool westConnect = !NBTGeneratorManager.IsTransparent(westType) || NBTGeneratorManager.IsFence(westType); byte northType = chunk.GetBlockByte(pos + Vector3Int.forward); bool northConnect = !NBTGeneratorManager.IsTransparent(northType) || NBTGeneratorManager.IsFence(northType); int index = 0; if (westConnect) { index += 8; } if (northConnect) { index += 4; } if (eastConnect) { index += 2; } if (southConnect) { index += 1; } return(meshes[index]); }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.blockData = blockData; if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z - 1)) { FaceAttributes fa = GetFrontFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x + 1, pos.y, pos.z)) { FaceAttributes fa = GetRightFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x - 1, pos.y, pos.z)) { FaceAttributes fa = GetLeftFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z + 1)) { FaceAttributes fa = GetBackFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } AddFace(nbtGO.nbtMesh, GetTopFaceAttributes(chunk, nbtGO.nbtMesh, ca), ca); if (!chunk.HasOpaqueBlock(pos.x, pos.y - 1, pos.z)) { FaceAttributes fa = GetBottomFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } }
public static NBTChunk LoadChunk(int chunkX, int chunkZ) { UnityEngine.Profiling.Profiler.BeginSample("ChunkChecker.Update"); key.Set(chunkX, chunkZ); if (!chunkDict.ContainsKey(key)) { TagNodeCompound Chunk = GetChunkNode(chunkX, chunkZ); if (Chunk != null) { TagNodeCompound Level = Chunk["Level"] as TagNodeCompound; TagNodeList Sections = Level["Sections"] as TagNodeList; NBTChunk chunk = ChunkPool.GetChunk(); chunk.SetData(chunkX, chunkZ, Sections); chunkDict.Add(key, chunk); } } UnityEngine.Profiling.Profiler.EndSample(); if (chunkDict.ContainsKey(key)) { return(chunkDict[key]); } return(null); }
public virtual Mesh GetItemMesh(NBTChunk chunk, byte data) { if (!itemMeshDict.ContainsKey(data)) { Mesh oldMesh = GetPrefabMesh(chunk, data); Mesh mesh = new Mesh(); List <Vector3> vertices = new List <Vector3>(); List <Vector2> uv = new List <Vector2>(); List <int> triangles = new List <int>(); foreach (Vector3 vertex in oldMesh.vertices) { vertices.Add(vertex); } uv.AddRange(oldMesh.uv); foreach (int index in oldMesh.triangles) { triangles.Add(index); } mesh.vertices = vertices.ToArray(); mesh.uv = uv.ToArray(); mesh.triangles = triangles.ToArray(); itemMeshDict.Add(data, mesh); } return(itemMeshDict[data]); }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.blockData = blockData; InitBlockAttributes(chunk, ref ca); bool topIsSnow = chunk.GetBlockByte(pos.x, pos.y + 1, pos.z) == 78; if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z - 1)) { FaceAttributes fa = GetFrontFaceAttributes(chunk, nbtGO.nbtMesh, ca); if (topIsSnow) { fa.faceIndex = TextureArrayManager.GetIndexByName("grass_side_snowed"); } AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x + 1, pos.y, pos.z)) { FaceAttributes fa = GetRightFaceAttributes(chunk, nbtGO.nbtMesh, ca); if (topIsSnow) { fa.faceIndex = TextureArrayManager.GetIndexByName("grass_side_snowed"); } AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x - 1, pos.y, pos.z)) { FaceAttributes fa = GetLeftFaceAttributes(chunk, nbtGO.nbtMesh, ca); if (topIsSnow) { fa.faceIndex = TextureArrayManager.GetIndexByName("grass_side_snowed"); } AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y, pos.z + 1)) { FaceAttributes fa = GetBackFaceAttributes(chunk, nbtGO.nbtMesh, ca); if (topIsSnow) { fa.faceIndex = TextureArrayManager.GetIndexByName("grass_side_snowed"); } AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y + 1, pos.z)) { FaceAttributes fa = GetTopFaceAttributes(chunk, nbtGO.nbtMesh, ca); if (topIsSnow) { fa.faceIndex = TextureArrayManager.GetIndexByName("snow"); } AddFace(nbtGO.nbtMesh, fa, ca); } if (!chunk.HasOpaqueBlock(pos.x, pos.y - 1, pos.z)) { FaceAttributes fa = GetBottomFaceAttributes(chunk, nbtGO.nbtMesh, ca); AddFace(nbtGO.nbtMesh, fa, ca); } }
// get the dot product between the player front vector and chunk to player vector. public static float GetChunkToFrontDot(NBTChunk chunk) { _chunkPos.Set(chunk.globalX, instance.position.y, chunk.globalZ); Vector3 chunk2player = _chunkPos - instance.position; return(Vector3.Dot(instance.forward, chunk2player.normalized)); }
// 1 east // 2 west // 3 south // 4 north // 5 up public override GameObject GetTileEntityGameObject(NBTChunk chunk, byte blockData, Vector3Int pos) { GameObject torch_prefab; switch (blockData) { case 1: torch_prefab = Resources.Load <GameObject>("Prefabs/Blocks/torch_+x"); break; case 2: torch_prefab = Resources.Load <GameObject>("Prefabs/Blocks/torch_-x"); break; case 3: torch_prefab = Resources.Load <GameObject>("Prefabs/Blocks/torch_+z"); break; case 4: torch_prefab = Resources.Load <GameObject>("Prefabs/Blocks/torch_-z"); break; default: torch_prefab = Resources.Load <GameObject>("Prefabs/Blocks/torch"); break; } GameObject torch = Object.Instantiate(torch_prefab); torch.transform.parent = chunk.special.transform; torch.transform.localPosition = pos; return(torch); }
public static void SetBlockByte(int x, int y, int z, byte type) { int chunkX = Mathf.FloorToInt(x / 16f); int chunkZ = Mathf.FloorToInt(z / 16f); int xInChunk = x - chunkX * 16; int zInChunk = z - chunkZ * 16; NBTChunk chunk = GetChunk(chunkX, chunkZ); NBTBlock oldGenerator = NBTGeneratorManager.GetMeshGenerator(chunk.GetBlockByte(xInChunk, y, zInChunk)); UpdateFlags updateFlag = GetUpdateFlags(oldGenerator); if (type == 0) { chunk.GetBlockData(xInChunk, y + 1, zInChunk, out byte topType, out byte topData); NBTBlock topGenerator = NBTGeneratorManager.GetMeshGenerator(topType); if (topGenerator != null && topGenerator is NBTPlant) { BreakBlockEffect.Create(topType, topData, new Vector3(x, y + 1, z)); chunk.SetBlockByte(xInChunk, y + 1, zInChunk, 0); updateFlag |= UpdateFlags.NotCollidable; } } chunk.SetBlockByte(xInChunk, y, zInChunk, type); if (updateFlag.HasFlag(UpdateFlags.Lighting)) { UpdateLighting(x, y, z); } chunk.RebuildMesh(updateFlag); NBTChunk leftChunk = GetChunk(chunkX - 1, chunkZ); if (xInChunk == 0) { leftChunk.RebuildMesh(); } NBTChunk rightChunk = GetChunk(chunkX + 1, chunkZ); if (xInChunk == 15) { rightChunk.RebuildMesh(); } NBTChunk backChunk = GetChunk(chunkX, chunkZ - 1); if (zInChunk == 0) { backChunk.RebuildMesh(); } NBTChunk frontChunk = GetChunk(chunkX, chunkZ + 1); if (zInChunk == 15) { frontChunk.RebuildMesh(); } }
public virtual Mesh GetPrefabMesh(NBTChunk chunk, byte data) { if (!string.IsNullOrEmpty(itemMeshPath)) { return(Resources.Load <Mesh>("Meshes/items/" + itemMeshPath + "/" + itemMeshPath)); } return(null); }
public override void AddCube(NBTChunk chunk, byte blockData, Vector3Int pos, NBTGameObject nbtGO) { ca.pos = pos; ca.blockData = blockData; AddDiagonalFace(chunk, nbtGO.nbtMesh, ca); AddAntiDiagonalFace(chunk, nbtGO.nbtMesh, ca); }
public static NBTChunk GetChunk() { NBTChunk chunk = chunks.Dequeue(); chunk.transform.parent = chunkParent; chunk.transform.localPosition = Vector3.zero; chunk.gameObject.SetActive(true); return(chunk); }
public static void PreloadChunks(List <Vector2Int> enterViewChunks) { foreach (Vector2Int chunkPos in enterViewChunks) { NBTChunk chunk = NBTHelper.LoadChunk(chunkPos.x, chunkPos.y); ChunkRefresher.Add(chunk); } ChunkRefresher.ForceRefreshAll(); }
public override Mesh GetItemMesh(NBTChunk chunk, byte data) { if (!itemMeshDict.ContainsKey(data)) { Mesh mesh = new Mesh(); pos = Vector3Int.zero; blockData = data; List <Vertex> vertexList = new List <Vertex>(); List <int> triangles = new List <int>(); this.vertices = vertexList; this.triangles = triangles; topIndex = GetTopIndexByData(chunk, blockData); bottomIndex = GetBottomIndexByData(chunk, blockData); frontIndex = GetFrontIndexByData(chunk, blockData); backIndex = GetBackIndexByData(chunk, blockData); leftIndex = GetLeftIndexByData(chunk, blockData); rightIndex = GetRightIndexByData(chunk, blockData); topColor = GetTopTintColorByData(chunk, blockData); bottomColor = GetBottomTintColorByData(chunk, blockData); frontColor = GetFrontTintColorByData(chunk, blockData); backColor = GetBackTintColorByData(chunk, blockData); leftColor = GetLeftTintColorByData(chunk, blockData); rightColor = GetRightTintColorByData(chunk, blockData); AddFrontFace(blockData); AddRightFace(blockData); AddLeftFace(blockData); AddBackFace(blockData); AddTopFace(blockData); AddBottomFace(blockData); var vertexCount = vertexList.Count; mesh.SetVertexBufferParams(vertexCount, new[] { new VertexAttributeDescriptor(VertexAttribute.Position, VertexAttributeFormat.Float32, 4), new VertexAttributeDescriptor(VertexAttribute.Color, VertexAttributeFormat.Float32, 4), new VertexAttributeDescriptor(VertexAttribute.TexCoord0, VertexAttributeFormat.Float32, 2), }); var verts = new NativeArray <Vertex>(vertexCount, Allocator.Temp); verts.CopyFrom(vertexList.ToArray()); mesh.SetVertexBufferData(verts, 0, 0, vertexCount); mesh.SetTriangles(triangles.ToArray(), 0); mesh.RecalculateBounds(); itemMeshDict.Add(data, mesh); } return(itemMeshDict[data]); }
public void GetLightsByte(int xInChunk, int yInChunk, int zInChunk, out byte skyLight, out byte blockLight, bool extends = false) { skyLight = 15; blockLight = 0; if (xInChunk < 0 || xInChunk > 15 || zInChunk < 0 || zInChunk > 15) { if (extends) { int xOffset = 0; int zOffset = 0; if (xInChunk < 0) { xOffset = -1; } else if (xInChunk > 15) { xOffset = 1; } if (zInChunk < 0) { zOffset = -1; } else if (zInChunk > 15) { zOffset = 1; } NBTChunk chunk = NBTHelper.GetChunk(x + xOffset, z + zOffset); if (chunk != null) { chunk.GetLightsByte(xInChunk - xOffset * 16, yInChunk, zInChunk - zOffset * 16, out skyLight, out blockLight); } } return; } int sectionIndex = yInChunk / 16; if (sectionIndex >= Sections.Count || yInChunk < 0 || yInChunk > 255) { return; } int yInSection = yInChunk % 16; int blockPos = yInSection * 16 * 16 + zInChunk * 16 + xInChunk; TagNodeCompound Section = Sections[sectionIndex] as TagNodeCompound; TagNodeByteArray SkyLight = Section["SkyLight"] as TagNodeByteArray; skyLight = NBTHelper.GetNibble(SkyLight.Data, blockPos); TagNodeByteArray BlockLight = Section["BlockLight"] as TagNodeByteArray; blockLight = NBTHelper.GetNibble(BlockLight.Data, blockPos); }
public override Mesh GetItemMesh(NBTChunk chunk, byte data) { if (!itemMeshDict.ContainsKey(data)) { Texture2D tex = Resources.Load <Texture2D>(pathPrefix + GetIconPathByData(data)); Mesh mesh = ItemMeshGenerator.instance.Generate(tex); itemMeshDict.Add(data, mesh); } return(itemMeshDict[data]); }
public override Mesh GetItemMesh(NBTChunk chunk, Vector3Int pos, byte blockData) { if (!itemMeshDict.ContainsKey(0)) { Texture2D tex = Resources.Load <Texture2D>(pathPrefix + GetIconPathByData(0)); Mesh mesh = ItemMeshGenerator.instance.Generate(tex); itemMeshDict.Add(0, mesh); } return(itemMeshDict[0]); }
public override int GetTopIndexByData(NBTChunk chunk, int data) { if (data == 10) { return(TextureArrayManager.GetIndexByName("mushroom_block_inside")); } else { return(TextureArrayManager.GetIndexByName("mushroom_block_skin_brown")); } }
public override int GetTopIndexByData(NBTChunk chunk, int data) { if (data == 7) { return(TextureArrayManager.GetIndexByName("farmland_wet")); } else { return(TextureArrayManager.GetIndexByName("farmland_dry")); } }
public override int GetRightIndexByData(NBTChunk chunk, int data) { if (data == 3) { return(TextureArrayManager.GetIndexByName("pumpkin_face_off")); } else { return(TextureArrayManager.GetIndexByName("pumpkin_side")); } }