Exemple #1
0
        internal CELPrecinct clone()
        {
            CELPrecinct c = new CELPrecinct();

            c.ID           = ID;
            c.name         = name;
            c.iNumPoint    = iNumPoint;
            c.m_iPriority  = m_iPriority;
            c.m_idDstIns   = m_idDstIns;
            c.m_idSrcInst  = m_idSrcInst;
            c.m_idDomain   = m_idDomain;
            c.m_bPKProtect = m_bPKProtect;
            c.m_vCityPos   = m_vCityPos;
            c.m_aPoints    = m_aPoints;
            c.unk0         = unk0;
            c.unk1         = unk1;
            c.unk2         = unk2;
            c.unk3         = unk3;
            c.Npcs         = Npcs;
            c.music        = music;
            return(c);
        }
Exemple #2
0
        public bool ReadFile(string path)
        {
            try
            {
                zones = new List <CELPrecinct>();
                string line = "";
                using (FileStream fr = File.OpenRead(path))
                {
                    using (StreamReader sr = new StreamReader(fr))
                    {
                        while ((line = sr.ReadLine()) != null)
                        {
                            if (line.Contains("version") && !line.StartsWith("//"))
                            {
                                encoding    = sr.CurrentEncoding;
                                dwVersion   = uint.Parse(line.GetNumbers());
                                dwTimeStamp = int.Parse(sr.ReadLine().GetNumbers());
                            }
                            if (line.Contains("\"") && !line.StartsWith("//"))
                            {
                                CELPrecinct zone = new CELPrecinct();
                                zone.name = line.Replace("\"", "").Trim();
                                string[] heder = sr.ReadLine().Split(null).CleanArray();
                                //2210  7  0  3  178  0  60  1  178  0  0
                                //ID NUM ?
                                int x = 0;
                                zone.ID = int.Parse(heder[x].GetNumbers());
                                x++;
                                zone.iNumPoint = int.Parse(heder[x].GetNumbers());
                                x++;
                                zone.unk0 = int.Parse(heder[x].GetNumbers());
                                x++;
                                zone.m_iPriority = int.Parse(heder[x].GetNumbers());
                                x++;
                                zone.m_idDstIns = int.Parse(heder[x].GetNumbers());
                                x++;
                                zone.unk1 = int.Parse(heder[x].GetNumbers());
                                x++;
                                zone.unk2 = int.Parse(heder[x].GetNumbers());
                                x++;
                                zone.unk3 = int.Parse(heder[x].GetNumbers());
                                x++;
                                zone.m_idSrcInst = int.Parse(heder[x].GetNumbers());
                                x++;
                                if (dwVersion >= 6)
                                {
                                    zone.m_idDomain = int.Parse(heder[x].GetNumbers());
                                    x++;
                                }
                                if (dwVersion >= 7)
                                {
                                    zone.m_bPKProtect = byte.Parse(heder[x].GetNumbers());
                                    x++;
                                }

                                zone.m_vCityPos = new Vector3(sr.ReadLine(), ',');
                                zone.m_aPoints  = new List <Vector3>();
                                for (int i = 0; i < zone.iNumPoint; i++)
                                {
                                    zone.m_aPoints.Add(new Vector3(sr.ReadLine()));
                                }
                                sr.ReadLine();


                                zone.Npcs  = new List <CELNPC>();
                                zone.music = new List <string>();
                                while ((line = sr.ReadLine()) != null && line.Contains("\"") && !line.StartsWith("//"))
                                {
                                    string name = line.GetBetween("\"", "\"");
                                    CELNPC npc  = new CELNPC();
                                    npc.Name = name;
                                    string numberOnly = line.Split('"')[2].Trim();
                                    npc.position = new Vector3(numberOnly);
                                    zone.Npcs.Add(npc);
                                }

                                while ((line = sr.ReadLine()) != null && line.Contains("\"") && !line.StartsWith("//"))
                                {
                                    zone.music.Add(line.Replace("\"", ""));
                                }
                                zones.Add(zone);
                            }
                        }
                    }
                }
                return(true);
            }
            catch { }
            return(false);
        }