示例#1
0
 public static void CleanData()
 {
     FrameNameTable   = null;
     FrameResource    = null;
     VertexBufferPool = null;
     IndexBufferPool  = null;
     SoundSector      = null;
     Actors           = null;
     ItemDescs        = null;
     Collisions       = null;
     CityAreas        = null;
 }
示例#2
0
 public static void CleanData()
 {
     FrameNameTable   = null;
     FrameResource    = null;
     VertexBufferPool = null;
     IndexBufferPool  = null;
     SoundSector      = null;
     Actors           = null;
     ItemDescs        = null;
     Collisions       = null;
     CityAreas        = null;
     CityShops        = null;
     roadMap          = null;
     ATLoader         = null;
     AIWorlds         = null;
     OBJData          = null;
 }
示例#3
0
        public static void BuildData()
        {
            List <FileInfo>       vbps = new List <FileInfo>();
            List <FileInfo>       ibps = new List <FileInfo>();
            List <ItemDescLoader> ids  = new List <ItemDescLoader>();
            List <Actor>          act  = new List <Actor>();
            List <NAVData>        aiw  = new List <NAVData>();
            List <NAVData>        obj  = new List <NAVData>();

            DirectoryInfo dirInfo = new DirectoryInfo(ScenePath);

            FileInfo[] files = dirInfo.GetFiles("*", SearchOption.AllDirectories);

            XmlDocument document = new XmlDocument();

            document.Load(ScenePath + "/SDSContent.xml");
            XPathNavigator nav   = document.CreateNavigator();
            var            nodes = nav.Select("/SDSResource/ResourceEntry");

            while (nodes.MoveNext() == true)
            {
                string type;
                string name;

                nodes.Current.MoveToFirstChild();
                type = nodes.Current.Value;
                nodes.Current.MoveToNext();
                name = ScenePath + "/" + nodes.Current.Value;

                if (type == "IndexBufferPool")
                {
                    ibps.Add(new FileInfo(name));
                }
                else if (type == "VertexBufferPool")
                {
                    vbps.Add(new FileInfo(name));
                }
                else if (type == "Actors")
                {
                    try
                    {
                        act.Add(new Actor(name));
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Failed to read actor {0}", name);
                    }
                }
                else if (type == "FrameResource")
                {
                    FrameResource = new FrameResource(name);
                }
                else if (type == "ItemDesc")
                {
                    ids.Add(new ItemDescLoader(name));
                }
                else if (type == "FrameNameTable")
                {
                    FrameNameTable = new FrameNameTable(name);
                }
                else if (type == "Collisions")
                {
                    Collisions = new Collision(name);
                }
                else if (type == "AnimalTrafficPaths")
                {
                    try
                    {
                        ATLoader = new AnimalTrafficLoader(new FileInfo(name));
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Failed to read AnimalTrafficPaths {0}", ATLoader);
                    }
                }
                else if (nodes.Current.Value == "roadmap.gsd")
                {
                    roadMap = new Roadmap(new FileInfo(name));
                }
                else if (type == "NAV_OBJ_DATA")
                {
                    obj.Add(new NAVData(new FileInfo(name)));
                }
                else if (type == "Translokator")
                {
                    Translokator = new TranslokatorLoader(new FileInfo(name));
                }
            }

            IndexBufferPool  = new IndexBufferManager(ibps);
            VertexBufferPool = new VertexBufferManager(vbps);
            ItemDescs        = ids.ToArray();
            Actors           = act.ToArray();
            OBJData          = obj.ToArray();
        }
示例#4
0
        public static void BuildData(bool forceBigEndian)
        {
            List <FileInfo>       vbps = new List <FileInfo>();
            List <FileInfo>       ibps = new List <FileInfo>();
            List <ItemDescLoader> ids  = new List <ItemDescLoader>();
            List <Actor>          act  = new List <Actor>();
            List <NAVData>        aiw  = new List <NAVData>();
            List <NAVData>        obj  = new List <NAVData>();

            isBigEndian = forceBigEndian;
            VertexTranslator.IsBigEndian = forceBigEndian;

            if (isBigEndian)
            {
                MessageBox.Show("Detected 'Big Endian' formats. This will severely effect functionality!", "Toolkit", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            DirectoryInfo dirInfo = new DirectoryInfo(ScenePath);

            sdsContent = new SDSContentFile();
            sdsContent.ReadFromFile(new FileInfo(Path.Combine(ScenePath + "/SDSContent.xml")));

            //IndexBuffers
            var paths = sdsContent.GetResourceFiles("IndexBufferPool", true);

            foreach (var item in paths)
            {
                ibps.Add(BuildFileInfo(item));
            }

            //Vertex Buffers
            paths = sdsContent.GetResourceFiles("VertexBufferPool", true);
            foreach (var item in paths)
            {
                vbps.Add(BuildFileInfo(item));
            }

            //Actors
            if (!isBigEndian)
            {
                paths = sdsContent.GetResourceFiles("Actors", true);
                foreach (var item in paths)
                {
                    try
                    {
                        act.Add(new Actor(item));
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Failed to read actor {0}", item);
                    }
                }
            }

            //FrameResource
            if (sdsContent.HasResource("FrameResource"))
            {
                var name = sdsContent.GetResourceFiles("FrameResource", true)[0];
                FrameResource = new FrameResource(name, isBigEndian);
            }

            //Item Desc
            if (!isBigEndian)
            {
                paths = sdsContent.GetResourceFiles("ItemDesc", true);
                foreach (var item in paths)
                {
                    ids.Add(new ItemDescLoader(item));
                }
            }

            //FrameNameTable
            if (sdsContent.HasResource("FrameNameTable"))
            {
                var name = sdsContent.GetResourceFiles("FrameNameTable", true)[0];
                FrameNameTable = new FrameNameTable(name, isBigEndian);
            }

            //Collisions
            if (!isBigEndian && sdsContent.HasResource("Collisions"))
            {
                var name = sdsContent.GetResourceFiles("Collisions", true)[0];
                Collisions = new Collision(name);
            }

            //~ENABLE THIS SECTION AT YOUR OWN RISK
            //AnimalTrafficPaths
            //if (!isBigEndian && sdsContent.HasResource("AnimalTrafficPaths"))
            //{
            //    var name = sdsContent.GetResourceFiles("AnimalTrafficPaths", true)[0];
            //    try
            //    {
            //        ATLoader = new AnimalTrafficLoader(new FileInfo(name));
            //    }
            //    catch (Exception ex)
            //    {
            //        Console.WriteLine("Failed to read AnimalTrafficPaths {0}", ex.Message);
            //    }
            //}
            //~ENABLE THIS SECTION AT YOUR OWN RISK

            if (!isBigEndian && sdsContent.HasResource("PREFAB"))
            {
                var          name   = sdsContent.GetResourceFiles("PREFAB", true)[0];
                PrefabLoader loader = new PrefabLoader(new FileInfo(name));
                Prefabs = loader;
            }

            //RoadMap
            if (!isBigEndian)
            {
                paths = sdsContent.GetResourceFiles("MemFile", true);
                foreach (var item in paths)
                {
                    if (item.Contains("RoadMap") || item.Contains("roadmap"))
                    {
                        roadMap = new Roadmap(new FileInfo(item));
                    }
                }
            }

            //~ENABLE THIS SECTION AT YOUR OWN RISK
            //Translokator
            //if (!isBigEndian && sdsContent.HasResource("Translokator"))
            //{
            //    var name = sdsContent.GetResourceFiles("Translokator", true)[0];
            //    Translokator = new TranslokatorLoader(new FileInfo(name));
            //}
            //~ENABLE THIS SECTION AT YOUR OWN RISK

            //~ENABLE THIS SECTION AT YOUR OWN RISK

            /* Kynapse OBJ_DATA
             * if (!isBigEndian)
             * {
             *  tis' broken for now
             *  paths = sdsContent.GetResourceFiles("NAV_OBJ_DATA", true);
             *  foreach (var item in paths)
             *  {
             *      obj.Add(new NAVData(new FileInfo(item)));
             *  }
             *
             *  for (int i = 0; i < obj.Count; i++)
             *  {
             *      obj[i].WriteToFile();
             *  }
             * }
             *
             * AI WORLD
             * if (!isBigEndian)
             * {
             *  paths = sdsContent.GetResourceFiles("NAV_AIWORLD_DATA", true);
             *  foreach (var Item in paths)
             *  {
             *      aiw.Add(new NAVData(new FileInfo(Item)));
             *  }
             * }
             *
             * if (!isBigEndian && sdsContent.HasResource("NAV_HPD_DATA"))
             * {
             *  var name = sdsContent.GetResourceFiles("NAV_HPD_DATA", true)[0];
             *  var data = new NAVData(new FileInfo(name));
             *  HPDData = (data.data as HPDData);
             *  data.WriteToFile();
             * }
             */
            //~ENABLE THIS SECTION AT YOUR OWN RISK

            IndexBufferPool  = new IndexBufferManager(ibps, dirInfo, isBigEndian);
            VertexBufferPool = new VertexBufferManager(vbps, dirInfo, isBigEndian);
            ItemDescs        = ids.ToArray();
            Actors           = act.ToArray();
            OBJData          = obj.ToArray();
            AIWorlds         = aiw.ToArray();
        }
示例#5
0
        public static void BuildData(bool forceBigEndian)
        {
            List <FileInfo>       vbps = new List <FileInfo>();
            List <FileInfo>       ibps = new List <FileInfo>();
            List <ItemDescLoader> ids  = new List <ItemDescLoader>();
            List <Actor>          act  = new List <Actor>();
            List <NAVData>        aiw  = new List <NAVData>();
            List <NAVData>        obj  = new List <NAVData>();

            DirectoryInfo dirInfo = new DirectoryInfo(ScenePath);

            FileInfo[] files = dirInfo.GetFiles("*", SearchOption.AllDirectories);

            XmlDocument document = new XmlDocument();

            document.Load(ScenePath + "/SDSContent.xml");
            XPathNavigator nav   = document.CreateNavigator();
            var            nodes = nav.Select("/SDSResource/ResourceEntry");

            isBigEndian = forceBigEndian;
            Utils.Models.VertexTranslator.IsBigEndian = forceBigEndian;
            if (isBigEndian)
            {
                MessageBox.Show("Detected 'Big Endian' formats. This will severely effect functionality!", "Toolkit", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            while (nodes.MoveNext() == true)
            {
                string type;
                string name;

                nodes.Current.MoveToFirstChild();
                type = nodes.Current.Value;
                nodes.Current.MoveToNext();
                name = ScenePath + "/" + nodes.Current.Value;

                if (type == "IndexBufferPool")
                {
                    ibps.Add(new FileInfo(name));
                }
                else if (type == "VertexBufferPool")
                {
                    vbps.Add(new FileInfo(name));
                }
                else if (type == "Actors" && !isBigEndian)
                {
                    try
                    {
                        act.Add(new Actor(name));
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Failed to read actor {0}", name);
                    }
                }
                else if (type == "FrameResource")
                {
                    FrameResource = new FrameResource(name, isBigEndian);
                }
                else if (type == "ItemDesc" && !isBigEndian)
                {
                    ids.Add(new ItemDescLoader(name));
                }
                else if (type == "FrameNameTable")
                {
                    FrameNameTable = new FrameNameTable(name, isBigEndian);
                }
                else if (type == "Collisions" && !isBigEndian)
                {
                    Collisions = new Collision(name);
                }
                else if (type == "AnimalTrafficPaths" && !isBigEndian)
                {
                    try
                    {
                        ATLoader = new AnimalTrafficLoader(new FileInfo(name));
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Failed to read AnimalTrafficPaths {0}", ex.Message);
                    }
                }
                else if (nodes.Current.Value == "roadmap.gsd" && !isBigEndian)
                {
                    roadMap = new Roadmap(new FileInfo(name));
                }
                //else if (type == "NAV_OBJ_DATA" && !isBigEndian)
                //    obj.Add(new NAVData(new FileInfo(name)));
                else if (type == "Translokator" && !isBigEndian)
                {
                    Translokator = new TranslokatorLoader(new FileInfo(name));
                }
            }

            IndexBufferPool  = new IndexBufferManager(ibps, isBigEndian);
            VertexBufferPool = new VertexBufferManager(vbps, isBigEndian);
            ItemDescs        = ids.ToArray();
            Actors           = act.ToArray();
            OBJData          = obj.ToArray();
        }
示例#6
0
        public static void BuildData()
        {
            List <FileInfo> vbps = new List <FileInfo>();
            List <FileInfo> ibps = new List <FileInfo>();
            List <ItemDesc> ids  = new List <ItemDesc>();
            List <Actor>    act  = new List <Actor>();

            DirectoryInfo dirInfo = new DirectoryInfo(ScenePath);

            FileInfo[] files = dirInfo.GetFiles("*", SearchOption.AllDirectories);

            XmlDocument document = new XmlDocument();

            document.Load(ScenePath + "/SDSContent.xml");
            XPathNavigator nav   = document.CreateNavigator();
            var            nodes = nav.Select("/SDSResource/ResourceEntry");

            while (nodes.MoveNext() == true)
            {
                string type;
                string name;

                nodes.Current.MoveToFirstChild();
                type = nodes.Current.Value;
                nodes.Current.MoveToNext();
                name = ScenePath + "/" + nodes.Current.Value;

                if (type == "IndexBufferPool")
                {
                    ibps.Add(new FileInfo(name));
                }
                else if (type == "VertexBufferPool")
                {
                    vbps.Add(new FileInfo(name));
                }
                else if (type == "FrameResource")
                {
                    FrameResource = new FrameResource(name);
                }
                else if (type == "ItemDesc")
                {
                    ids.Add(new ItemDesc(name));
                }
                else if (type == "FrameNameTable")
                {
                    FrameNameTable = new FrameNameTable(name);
                }
                //else if ((type == "MemFile") && (name.Contains("cityshops")))
                //    CityShops = new CityShops(name);
                //else if (type == "Actors")
                //    act.Add(new Actor(name));
                //else if (type == "AudioSectors")
                //    SoundSector = new SoundSector(name);
                //else if ((type == "MemFile") && (name.Contains("cityareas")))
                //    CityAreas = new CityAreas(name);
            }

            IndexBufferPool  = new IndexBufferManager(ibps);
            VertexBufferPool = new VertexBufferManager(vbps);
            ItemDescs        = ids.ToArray();
            Actors           = act.ToArray();

            for (int i = 0; i != ItemDescs.Length; i++)
            {
                ItemDescs[i].WriteToEDC();
            }

            if (Actors == null)
            {
                return;
            }

            AttachActors();
        }