Beispiel #1
0
        private void LoadAtom(TextReader rdr)
        {
            // "aai" = (/obj/structure/sign/securearea{desc = "A warning sign which reads 'HIGH VOLTAGE'"; icon_state = "shock"; name = "HIGH VOLTAGE"; pixel_y = -32},/turf/space,/area)
            // Move to ID.

            ReaderUtils.ReadUntil(rdr, '"');

            Tile t = new Tile();

            // Get ID contents
            t.origID = ReaderUtils.ReadUntil(rdr, '"');
            idlen    = t.origID.Length;
            //log.InfoFormat("Reading tile {0}", t.origID);

            ReaderUtils.ReadUntil(rdr, '(');

            uint atomID = 0; // Which atom we're currently on IN THIS TILEDEF.

            // Read atomdefs.
            bool finishedReadingAtoms = false;

            while (!finishedReadingAtoms)
            {
                char nextChar = ReaderUtils.GetNextChar(rdr);
                if (nextChar == ')')
                {
                    break;
                }

                ReaderUtils.ReadUntil(rdr, '/');

                string atomType = ReaderUtils.ReadCharRange(rdr, ATOM_NAME_CHARS);
                if (string.IsNullOrWhiteSpace(atomType))
                {
                    throw new InvalidDataException(string.Format("atomType is \"{0}\"", atomType));
                }

                Atom a = new Atom(atomType, false);

                nextChar = ReaderUtils.GetNextChar(rdr);
                switch (nextChar)
                {
                case '{':
                    // We're in a propertygroup.  Read the properties.
                    rdr.Read();
                    LoadPropertyGroup(rdr, a);
                    //rdr.Read();
                    break;

                case ',':
                    rdr.Read();
                    break;

                case ')':
                    finishedReadingAtoms = true;
                    rdr.Read();
                    break;

                default:
                    //log.FatalFormat(
                    Console.WriteLine("UNKNOWN CHARACTER {0} IN TILEDEF {1}, ATOMDEF #{2}. EXPECTING: '{{),'", nextChar, t.origID, atomID);
                    break;
                }
                t.Atoms.Add(a);
                atomID++;
            }

            Tiles[t.origID] = t;

            string read           = ReaderUtils.ReadCharRange(rdr, WHITESPACE);
            int    numLineReturns = read.Count((char c) => {
                return(c == '\n');
            });

            //Console.WriteLine("{1}",read,numLineReturns);
            if (numLineReturns > 1)
            {
                section = DMMSection.Map;
                Console.WriteLine("Finished reading Tile List section:  {0} tiles loaded.", Tiles.Count);
            }
        }