Ejemplo n.º 1
0
        //TODO: This can be instanced
        internal static void OpenVCDForWriting(out FileStream VCDFile, uint CRC)
        {
            //throw new NotImplementedException();
            string VCDName   = "";
            bool   PathFound = false;
            UInt32 sceneIterator;

            for (sceneIterator = 0; sceneIterator < Common.Scenes.Count; sceneIterator++)
            {
                Common.Scene scene = Common.Scenes[(int)Convert.ToInt64(sceneIterator)];
                if (CRC == scene.CRC)
                {
                    string sceneName = scene.Name;
                    VCDName   = Common.GameDirectory + Path.DirectorySeparatorChar + sceneName;
                    PathFound = true;
                    break;
                }
            }
            if (!PathFound)
            {
                VCDName = $"{Common.GameDirectory}{Path.DirectorySeparatorChar}scenes{Path.DirectorySeparatorChar}{CRC.ToString()}.vcd";
            }
            Directory.CreateDirectory(Path.GetDirectoryName(VCDName));
            VCDFile = File.OpenWrite(VCDName);
        }
Ejemplo n.º 2
0
        private static void ParseEntities(byte[] lump, uint lumpSize)
        {
            char[] lump_char   = Encoding.ASCII.GetChars(lump);
            String lump_string = new string(lump_char);

            String[] lump_ready = lump_string.Split('\n');
            Dictionary <string, string> entity = new Dictionary <string, string>();
            //List<KeyValuePair<string, string>> entity = new List<KeyValuePair<string, string>>();
            Regex r = new Regex("\"(.*?)\"");

            //parsing start
            foreach (string Line in lump_ready)
            {
                if (Line == "{")
                {
                    //start of entity. Prepare the dictionary
                    entity.Clear();
                }
                else if (Line == "}")
                {
                    if (entity["classname"] == "logic_choreographed_scene")
                    {
                        Common.Scene scene = new Common.Scene
                        {
                            Name = entity["SceneFile"]
                        };
                        Common.Scenes.Add(scene);
                    }
                    // if (entity["classname"] == "env_speaker")
                    // {
                    //    Common.ResponseFiles.Add(entity["rulescript"]);
                    // }
                }
                else
                { //entity key and value
                    Match  m = r.Match(Line);
                    string key, value;
                    key   = m.Groups[1].Value;
                    m     = m.NextMatch();
                    value = m.Groups[1].Value;
                    if (entity.TryGetValue(key, out string existing_key))
                    {
                        value = existing_key + "\n" + value;
                        entity.Remove(key);
                    }
                    entity.Add(key, value);
                }
            }
        }
Ejemplo n.º 3
0
 internal static void Parse()
 {
     foreach (string file in Common.ResponseFiles)
     {
         string[] TXT = File.ReadAllLines(file);
         for (int i = 0; i < TXT.Length; i++)
         {
             string line = TXT[i];
             if (line.Contains("//", StringComparison.Ordinal))
             {
                 //first we remove the comments
                 Regex rgx = new Regex("(.*?)\\/\\/");
                 line   = rgx.Match(line).Groups[1].Value;
                 TXT[i] = line;
             }
         }
         ResponseData.AddRange(TXT);
     }
     ResponseData.RemoveAll(String.IsNullOrEmpty);
     string[] finished = ResponseData.ToArray();
     for (int i = 0; i < finished.Length; i++)
     {
         string line = finished[i];
         if (line.Contains("scene", StringComparison.Ordinal))
         {
             //first we remove the comments
             Regex rgx = new Regex("\\Wscene \"(.*)\"");
             line = rgx.Match(line).Groups[1].Value;
             Common.Scene scene = new Common.Scene
             {
                 Name = line
             };
             Common.Scenes.Add(scene);
         }
     }
 }