//! Load xml. public void LoadXml(XmlReader Reader, IEditor AssetDatabase) { m_PositionX = int.Parse(Reader.GetAttribute("position_x")); m_PositionY = int.Parse(Reader.GetAttribute("position_y")); m_Tiles = new TerrainTile[PARTITION_WIDTH * PARTITION_HEIGHT]; int i = 0; Reader.ReadToDescendant("tile"); do { byte[] v_types = new byte[] { byte.Parse(Reader.GetAttribute("type_0")), byte.Parse(Reader.GetAttribute("type_1")), byte.Parse(Reader.GetAttribute("type_2")), byte.Parse(Reader.GetAttribute("type_3")) }; var tile = new TerrainTile(int.Parse(Reader.GetAttribute("x")), int.Parse(Reader.GetAttribute("y")), (TerrainTile.Type)int.Parse(Reader.GetAttribute("type")), byte.Parse(Reader.GetAttribute("variant"))); tile.SetTerrainType(TerrainTile.Vertex.NORTH, v_types[0]); tile.SetTerrainType(TerrainTile.Vertex.WEST, v_types[1]); tile.SetTerrainType(TerrainTile.Vertex.SOUTH, v_types[2]); tile.SetTerrainType(TerrainTile.Vertex.EAST, v_types[3]); m_Tiles[i++] = tile; } while (Reader.ReadToNextSibling("tile")); var mesh_renderer = GetComponent<MeshRenderer>(); m_Properties = new Dictionary<ushort, he.TerrainTileProperty>(); Reader.ReadToFollowing("property_list"); if (Reader.ReadToDescendant("item")) { do { var tile_property = new TerrainTileProperty(); tile_property.nonMoveable = new NonMoveableObjectHandle(Reader.GetAttribute("nonmoveable")); m_Properties[ushort.Parse(Reader.GetAttribute("index"))] = tile_property; } while (Reader.ReadToNextSibling("item")); } Reader.ReadToFollowing("nonmoveable_list"); if (Reader.ReadToDescendant("item")) { do { ushort tile_index = ushort.Parse(Reader.GetAttribute("tile")); GameObject non_moveable_go = AssetDatabase.InstantiatePrefab(Resources.LoadAssetAtPath(Reader.GetAttribute("prefab"), typeof(GameObject))) as GameObject; var comp = non_moveable_go.GetComponent<NonMoveableObjectComponent>(); comp.LoadXml(Reader, AssetDatabase); TerrainTile tile = m_Tiles[tile_index]; AssociateNonMoveable(tile.x, tile.y, comp); } while (Reader.ReadToNextSibling("item")); } }