Пример #1
0
        public bool prepareGeoLookupArray(string base_path)
        {
            FileStream defnames;

            try
            {
                defnames = File.Open(base_path + "bin/defnames.bin", FileMode.Open);
            }
            catch (Exception)
            {
                Debug.LogError(String.Format("Failed to open {0}/bin/defnames.bin", base_path));
                return(false);
            }

            string contents;

            using (var sr = new StreamReader(defnames))
            {
                contents = sr.ReadToEnd();
            }

            string[]    defnames_arr = contents.Replace("CHUNKS.geo", "Chunks.geo").Split('\0');
            string      lookup_str;
            GeoStoreDef current_geosetinf = null;

            foreach (string str in defnames_arr)
            {
                int last_slash = str.LastIndexOf('/');
                if (-1 != last_slash)
                {
                    string geo_path = str.Substring(0, last_slash);
                    lookup_str = geo_path.ToLower();
                    if (!m_dir_to_geoset.ContainsKey(lookup_str))
                    {
                        m_dir_to_geoset[lookup_str] = new GeoStoreDef();
                    }

                    current_geosetinf         = m_dir_to_geoset[lookup_str];
                    current_geosetinf.geopath = geo_path;
                }

                current_geosetinf.entries.Add(str.Substring(last_slash + 1));
                m_modelname_to_geostore[str.Substring(last_slash + 1)] = current_geosetinf;
            }

            return(true);
        }
Пример #2
0
        public bool loadNamedPrefab(string name, LoadingContext ctx)
        {
            GeoStoreDef geo_store = groupGetFileEntryPtr(name);

            if (null == geo_store)
            {
                return(false);
            }
            if (geo_store.loaded)
            {
                return(true);
            }

            geo_store.loaded = true;
            // load given prefab's geoset
            GeoSet.Load(geo_store.geopath, m_base_path);
            ctx.loadSubgraph(geo_store.geopath, this);
            return(loadPrefabForNode(ctx.m_target.getNodeByName(name), ctx));
        }