private static void LoadMapMeshes()
    {
        LoadMapTerrainInfo();

        _modelMeshes = new Dictionary <int, Mesh[]>();

        string objectsFolder = FFXIVHSPaths.GetTerritoryObjectsDirectory(territory);

        foreach (MapModel model in _map.models.Values)
        {
            if (DebugCustomLoad)
            {
                if (!debugCustomLoadList.Contains(model.id))
                {
                    continue;
                }
            }

            Mesh[] modelMeshes = new Mesh[model.numMeshes];

            for (int i = 0; i < model.numMeshes; i++)
            {
                string meshFileName = string.Format("{0}{1}_{2}.obj", objectsFolder, model.modelName, i);
                modelMeshes[i] = FastObjImporter.Instance.ImportFile(meshFileName);
            }
            _modelMeshes.Add(model.id, modelMeshes);
        }
        Debug.Log("_modelMeshes loaded.");
    }
        public static void WriteMapModels(ARealmReversed realm, TerritoryType teriType)
        {
            Territory territory = Plot.StringToWard(teriType.Name);

            string inpath = FFXIVHSPaths.GetTerritoryJson(territory);

            if (!File.Exists(inpath))
            {
                throw new FileNotFoundException();
            }

            string outpath = FFXIVHSPaths.GetTerritoryObjectsDirectory(territory);

            string json = File.ReadAllText(inpath);

            Map map = JsonConvert.DeserializeObject <Map>(json);

            foreach (MapModel model in map.models.Values)
            {
                if (realm.Packs.TryGetFile(model.modelPath, out SaintCoinach.IO.File f))
                {
                    ObjectFileWriter.WriteObjectFile(outpath, (ModelFile)f);
                }
            }
        }