void SetOptions(string shape, string special, string material, string variant, string direction, TiletypeMatch match) { if (shape == "*") { match.difference |= 16; foreach (var item in TiletypeTokenList.tileDefs.Values) { SetOptions(special, material, variant, direction, item, match); } } else { try { TiletypeShape tileShape = (TiletypeShape)Enum.Parse(typeof(TiletypeShape), shape); if (TiletypeTokenList.tileDefs.ContainsKey(tileShape)) { SetOptions(special, material, variant, direction, TiletypeTokenList.tileDefs[tileShape], match); } } catch (Exception) { Debug.LogError(shape + " is not a valid tile shape."); return; } } }
public void SetAllTiles(TiletypeShape tile) { for (int i = 0; i < terrain.GetLength(0); i++) { terrain[i] = tile; } SetOpenness(); }
static void AddTile(TiletypeShape tileShape, TiletypeSpecial tileSpecial, TiletypeMaterial tileMaterial, TiletypeVariant tileVariant, string tileDirection, Tiletype token) { if (tileDefs == null) tileDefs = new Dictionary<TiletypeShape, Dictionary<TiletypeSpecial, Dictionary<TiletypeMaterial, Dictionary<TiletypeVariant, Dictionary<string, Tiletype>>>>>(); if (!tileDefs.ContainsKey(tileShape)) tileDefs[tileShape] = new Dictionary<TiletypeSpecial, Dictionary<TiletypeMaterial, Dictionary<TiletypeVariant, Dictionary<string, Tiletype>>>>(); if (!tileDefs[tileShape].ContainsKey(tileSpecial)) tileDefs[tileShape][tileSpecial] = new Dictionary<TiletypeMaterial, Dictionary<TiletypeVariant, Dictionary<string, Tiletype>>>(); if (!tileDefs[tileShape][tileSpecial].ContainsKey(tileMaterial)) tileDefs[tileShape][tileSpecial][tileMaterial] = new Dictionary<TiletypeVariant, Dictionary<string, Tiletype>>(); if (!tileDefs[tileShape][tileSpecial][tileMaterial].ContainsKey(tileVariant)) tileDefs[tileShape][tileSpecial][tileMaterial][tileVariant] = new Dictionary<string, Tiletype>(); tileDefs[tileShape][tileSpecial][tileMaterial][tileVariant][tileDirection] = token; }
static void AddTile(TiletypeShape tileShape, TiletypeSpecial tileSpecial, TiletypeMaterial tileMaterial, TiletypeVariant tileVariant, string tileDirection, Tiletype token) { if (tileDefs == null) { tileDefs = new Dictionary <TiletypeShape, Dictionary <TiletypeSpecial, Dictionary <TiletypeMaterial, Dictionary <TiletypeVariant, Dictionary <string, Tiletype> > > > >(); } if (!tileDefs.ContainsKey(tileShape)) { tileDefs[tileShape] = new Dictionary <TiletypeSpecial, Dictionary <TiletypeMaterial, Dictionary <TiletypeVariant, Dictionary <string, Tiletype> > > >(); } if (!tileDefs[tileShape].ContainsKey(tileSpecial)) { tileDefs[tileShape][tileSpecial] = new Dictionary <TiletypeMaterial, Dictionary <TiletypeVariant, Dictionary <string, Tiletype> > >(); } if (!tileDefs[tileShape][tileSpecial].ContainsKey(tileMaterial)) { tileDefs[tileShape][tileSpecial][tileMaterial] = new Dictionary <TiletypeVariant, Dictionary <string, Tiletype> >(); } if (!tileDefs[tileShape][tileSpecial][tileMaterial].ContainsKey(tileVariant)) { tileDefs[tileShape][tileSpecial][tileMaterial][tileVariant] = new Dictionary <string, Tiletype>(); } tileDefs[tileShape][tileSpecial][tileMaterial][tileVariant][tileDirection] = token; }
public override void OnInspectorGUI() { MapBlock[] targetBlocks = Array.ConvertAll(targets, element => (MapBlock)element); if(targets.Length == 1) EditorGUILayout.LabelField(targets.Length + " Map Block selected."); else EditorGUILayout.LabelField(targets.Length + " Map Blocks selected."); parent = targetBlocks[0].parent; parent = (GameMap)EditorGUILayout.ObjectField("Parent", parent, typeof(GameMap), true); for (int index = 0; index < targetBlocks.Length; index++) { targetBlocks[index].parent = parent; } selectedColor = EditorGUILayout.ColorField("Material Color", selectedColor); selectedShape = (TiletypeShape)EditorGUILayout.EnumPopup("Terrain Shape ", selectedShape); showEditorGrid = EditorGUILayout.Foldout(showEditorGrid, "Block Tiles"); if (showEditorGrid) { EditorGUILayout.BeginVertical(); DFHack.DFCoord2d tempCoord = new DFHack.DFCoord2d(); for (int i = 0; i < MapBlock.blockWidthTiles; i++) { EditorGUILayout.BeginHorizontal(); for (int j = 0; j < MapBlock.blockWidthTiles; j++) { tempCoord.x = j; tempCoord.y = i; Color currentColor = targetBlocks[0].GetColor(tempCoord); for (int index = 1; index < targetBlocks.Length; index++) { if (currentColor != targetBlocks[index].GetColor(tempCoord)) { currentColor = Color.white; break; } } currentColor.a = 1.0f; GUI.color = currentColor; string buttonIcon = "\u00A0"; TiletypeShape tile = targetBlocks[0].GetSingleTile(tempCoord); for (int index = 1; index < targetBlocks.Length; index++) { if (tile != targetBlocks[index].GetSingleTile(tempCoord)) { tile = TiletypeShape.EMPTY; break; } } switch (tile) { case TiletypeShape.NO_SHAPE: buttonIcon = "?"; break; case TiletypeShape.WALL: buttonIcon = "▓"; break; case TiletypeShape.FLOOR: buttonIcon = "+"; break; case TiletypeShape.EMPTY: buttonIcon = "\u00A0"; break; case TiletypeShape.RAMP: buttonIcon = "▲"; break; case TiletypeShape.RAMP_TOP: buttonIcon = "▼"; break; default: buttonIcon = "?"; break; } if (GUILayout.Button(buttonIcon)) { for (int index = 0; index < targetBlocks.Length; index++) { targetBlocks[index].SetSingleTile(tempCoord, selectedShape); targetBlocks[index].SetColor(tempCoord, selectedColor); targetBlocks[index].Regenerate(); EditorUtility.SetDirty(targetBlocks[index]); } } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } GUI.color = Color.white; if (GUILayout.Button("Fill")) { for (int index = 0; index < targetBlocks.Length; index++) { for (int i = 0; i < MapBlock.blockWidthTiles; i++) for (int j = 0; j < MapBlock.blockWidthTiles; j++) { DFHack.DFCoord2d here = new DFHack.DFCoord2d(j, i); targetBlocks[index].SetSingleTile(here, selectedShape); targetBlocks[index].SetColor(here, selectedColor); } targetBlocks[index].Regenerate(); EditorUtility.SetDirty(targetBlocks[index]); } } }
public void SetAllTiles(TiletypeShape tile) { for(int i = 0; i < terrain.GetLength(0);i++) { terrain[i] = tile; } SetOpenness(); }
public void SetSingleTile(DFCoord2d position, TiletypeShape tile) { terrain[position.x + position.y * blockWidthTiles] = tile; SetOpenness(); }
public override void OnInspectorGUI() { MapBlock[] targetBlocks = Array.ConvertAll(targets, element => (MapBlock)element); if (targets.Length == 1) { EditorGUILayout.LabelField(targets.Length + " Map Block selected."); } else { EditorGUILayout.LabelField(targets.Length + " Map Blocks selected."); } parent = targetBlocks[0].parent; parent = (GameMap)EditorGUILayout.ObjectField("Parent", parent, typeof(GameMap), true); for (int index = 0; index < targetBlocks.Length; index++) { targetBlocks[index].parent = parent; } selectedColor = EditorGUILayout.ColorField("Material Color", selectedColor); selectedShape = (TiletypeShape)EditorGUILayout.EnumPopup("Terrain Shape ", selectedShape); showEditorGrid = EditorGUILayout.Foldout(showEditorGrid, "Block Tiles"); if (showEditorGrid) { EditorGUILayout.BeginVertical(); DFHack.DFCoord2d tempCoord = new DFHack.DFCoord2d(); for (int i = 0; i < MapBlock.blockWidthTiles; i++) { EditorGUILayout.BeginHorizontal(); for (int j = 0; j < MapBlock.blockWidthTiles; j++) { tempCoord.x = j; tempCoord.y = i; Color currentColor = targetBlocks[0].GetColor(tempCoord); for (int index = 1; index < targetBlocks.Length; index++) { if (currentColor != targetBlocks[index].GetColor(tempCoord)) { currentColor = Color.white; break; } } currentColor.a = 1.0f; GUI.color = currentColor; string buttonIcon = "\u00A0"; TiletypeShape tile = targetBlocks[0].GetSingleTile(tempCoord); for (int index = 1; index < targetBlocks.Length; index++) { if (tile != targetBlocks[index].GetSingleTile(tempCoord)) { tile = TiletypeShape.EMPTY; break; } } switch (tile) { case TiletypeShape.NO_SHAPE: buttonIcon = "?"; break; case TiletypeShape.WALL: buttonIcon = "▓"; break; case TiletypeShape.FLOOR: buttonIcon = "+"; break; case TiletypeShape.EMPTY: buttonIcon = "\u00A0"; break; case TiletypeShape.RAMP: buttonIcon = "▲"; break; case TiletypeShape.RAMP_TOP: buttonIcon = "▼"; break; default: buttonIcon = "?"; break; } if (GUILayout.Button(buttonIcon)) { for (int index = 0; index < targetBlocks.Length; index++) { targetBlocks[index].SetSingleTile(tempCoord, selectedShape); targetBlocks[index].SetColor(tempCoord, selectedColor); targetBlocks[index].Regenerate(); EditorUtility.SetDirty(targetBlocks[index]); } } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } GUI.color = Color.white; if (GUILayout.Button("Fill")) { for (int index = 0; index < targetBlocks.Length; index++) { for (int i = 0; i < MapBlock.blockWidthTiles; i++) { for (int j = 0; j < MapBlock.blockWidthTiles; j++) { DFHack.DFCoord2d here = new DFHack.DFCoord2d(j, i); targetBlocks[index].SetSingleTile(here, selectedShape); targetBlocks[index].SetColor(here, selectedColor); } } targetBlocks[index].Regenerate(); EditorUtility.SetDirty(targetBlocks[index]); } } }
public void SetSingleTile(DFCoord2d position, TiletypeShape tile) { terrain[position.x + position.y * blockWidthTiles] = tile; SetOpenness(); }