public VariantInfo(Piece top, Piece bottom, Mesh mesh) { Top = top; Bottom = bottom; Meshes = new List <Mesh>(); Meshes.Add(mesh); }
public void FillBaseVariantsFromMeshList(List <Mesh> meshes, string filter, string configPrefix) { List <VariantInfo> results = new List <VariantInfo>(); for (int i = 0; i < meshes.Count; ++i) { var mesh = meshes[i]; if (filter != null && filter.Length > 0 && !mesh.name.Contains(filter)) { continue; } byte top = 0; byte bottom = 0; if (FindConfigFromMeshName(mesh.name, out top, out bottom, configPrefix)) { bool added = false; top = (byte)(top >> 4); Piece topPiece = Tile.ToPiece(top); Piece bottomPiece = Tile.ToPiece(bottom); foreach (var info in results) { if (info.IsVariant(topPiece, bottomPiece)) { info.Add(mesh); added = true; break; } } if (!added) { results.Add(new VariantInfo(topPiece, bottomPiece, mesh)); } } else { Debug.LogWarning(themeName + ": Couldn't find configuration in mesh name:" + mesh.name); } } if (results.Count > 0) { baseVariants = new BaseMeshVariants[results.Count]; for (int i = 0; i < baseVariants.Length; ++i) { baseVariants[i] = results[i].ToBaseMeshVariants(); } VerifyBaseVariants(); } else { Debug.LogWarning(themeName + ": Couldn't find any mesh variants!"); } }
public BaseMeshVariants(Piece top, Piece bottom, Mesh[] variantMeshes) { topConfig = top; bottomConfig = bottom; variants = new Mesh[variantMeshes.Length]; System.Array.Copy(variantMeshes, variants, variants.Length); }
public bool IsVariant(Piece top, Piece bottom) { return(Top == top && Bottom == bottom); }