public Item(int id, string name, int maxStackSize, ItemTexture texture) { this.id = id; this.name = name; this.maxStackSize = maxStackSize; this.texture = texture; }
public static void AddFace(Vector3 corner, int id, Vector3 normal, List <Vector3> vertices, List <int> triangles, List <Vector2> uv) { Vector3 right = Vector3.zero; Vector3 up = Vector3.zero; bool reversed = false; if (normal == Vector3.down || normal == Vector3.right || normal == Vector3.forward) { reversed = true; } int index = vertices.Count; if (normal == Vector3.up || normal == Vector3.down) { up = Vector3.forward; right = Vector3.right; } else if (normal == Vector3.left || normal == Vector3.right) { up = Vector3.up; right = Vector3.back; } else if (normal == Vector3.forward || normal == Vector3.back) { up = Vector3.up; right = Vector3.right; } vertices.Add(corner); vertices.Add(corner + up); vertices.Add(corner + up + right); vertices.Add(corner + right); if (reversed) { triangles.Add(index + 0); triangles.Add(index + 2); triangles.Add(index + 1); triangles.Add(index + 0); triangles.Add(index + 3); triangles.Add(index + 2); } else { triangles.Add(index + 0); triangles.Add(index + 1); triangles.Add(index + 2); triangles.Add(index + 0); triangles.Add(index + 2); triangles.Add(index + 3); } Vector2 offset = Vector3.zero; float resolution = 0.0625f; Vector2 _00 = new Vector2(0, 0) * resolution; Vector2 _01 = new Vector2(0, 1) * resolution; Vector2 _11 = new Vector2(1, 1) * resolution; Vector2 _10 = new Vector2(1, 0) * resolution; ItemTexture texture = ItemDatabase.GetItemById(id).texture; if (normal == Vector3.up) { offset = texture.top; } else if (normal == Vector3.down) { offset = texture.bottom; } else if (normal == Vector3.left) { offset = texture.left; } else if (normal == Vector3.right) { offset = texture.right; } else if (normal == Vector3.forward) { offset = texture.front; } else if (normal == Vector3.back) { offset = texture.back; } uv.Add(_00 + offset); uv.Add(_01 + offset); uv.Add(_11 + offset); uv.Add(_10 + offset); }