示例#1
0
        public void read(bool skip = false)
        {
            Name    = ESM.input.ReadChars(4);
            Size    = ESM.input.ReadInt32();
            Header1 = ESM.input.ReadInt32();
            Flags   = ESM.input.ReadInt32();

            if (skip)
            {
                ESM.input.BaseStream.Seek(Size, SeekOrigin.Current);
            }

            else
            {
                int read_size = 0;
                while (read_size < Size)
                {
                    SubRecord subrec = new SubRecord();
                    subrec.read();

                    string srec_name = Text.trim(new string(subrec.name));
                    if (!subrecord_index.ContainsKey(srec_name))
                    {
                        subrecord_index.Add(Text.trim(new string(subrec.name)), new List <SubRecord>());
                    }
                    subrecord_index[srec_name].Add(subrec);


                    subRecords.Add(subrec);
                    read_size = read_size + subrec.size + 8;
                }
            }
        }
示例#2
0
        public int read(int readable_size)
        {
            int read_size = 0;

            while (read_size < readable_size)
            {
                SubRecord subrec = new SubRecord();
                subrec.read();
                read_size = read_size + subrec.size + 8;

                BinaryReader srec_data = subrec.getData();

                if (subrec.isType("FRMR"))
                {
                    ESM.rewind(subrec.size + 8);
                    return(read_size - subrec.size - 8);
                }
                else if (subrec.isType("NAME"))
                {
                    editor_id = Text.trim(new string(srec_data.ReadChars(subrec.size)));
                }
                else if (subrec.isType("XSCL"))
                {
                    scale = srec_data.ReadSingle();
                }
                else if (subrec.isType("DATA"))
                {
                    x  = srec_data.ReadSingle();
                    y  = srec_data.ReadSingle();
                    z  = srec_data.ReadSingle();
                    xR = srec_data.ReadSingle();
                    yR = srec_data.ReadSingle();
                    zR = srec_data.ReadSingle();
                }
                else if (subrec.isType("DNAM"))
                {
                    isPortal = true;
                    portal.destination_cell = Text.trim(new string (srec_data.ReadChars(subrec.size)));
                }
                else if (subrec.isType("DODT"))
                {
                    editor_id = editor_id + "_zload";
                    isPortal  = true;
                    portal.x  = srec_data.ReadSingle();
                    portal.y  = srec_data.ReadSingle();
                    portal.z  = srec_data.ReadSingle();

                    portal.xR = srec_data.ReadSingle();
                    portal.yR = srec_data.ReadSingle();
                    portal.zR = srec_data.ReadSingle();
                }

                else if (subrec.isType("ANAM"))
                {
                    owner = Text.trim(new string(srec_data.ReadChars(subrec.size)));
                }
            }
            return(read_size);
        }
示例#3
0
        public void read()
        {
            base.read();

            for (int i = 0; i < subRecords.Count; i++)
            {
                SubRecord    srec      = subRecords[i];
                BinaryReader srec_data = srec.getData();
                switch (new string(srec.name))
                {
                case ("NAME"):
                    editor_id = new string(srec_data.ReadChars(srec.size));
                    break;

                case ("FNAM"):
                    region_name = new string(srec_data.ReadChars(srec.size));
                    break;
                }
            }
        }
示例#4
0
        public new void read(bool skip = false)
        {
            Name    = ESM.input.ReadChars(4);
            Size    = ESM.input.ReadInt32();
            Header1 = ESM.input.ReadInt32();
            Flags   = ESM.input.ReadInt32();

            if (!"CELL".Equals(new string(Name)))
            {
                Log.error("Error reading CELL, mismatch name");
            }

            int read_size = 0;

            while (read_size < Size)
            {
                SubRecord subrec = new SubRecord();
                subrec.read();
                read_size = read_size + subrec.size + 8;

                // Skipping over cell reference data for now
                if (subrec.isType("FRMR"))
                {
                    //Log.info("FRMR found");
                    REFR refr = new REFR();
                    read_size = read_size + refr.read(Size - read_size);
                    references.Add(refr);

                    continue;
                }

                subRecords.Add(subrec);
            }


            for (int i = 0; i < subRecords.Count; i++)
            {
                SubRecord    srec      = subRecords[i];
                BinaryReader srec_data = srec.getData();
                switch (new string(srec.name))
                {
                case ("NAME"):
                    if (srec.size > 1)
                    {
                        cell_name = new string(srec_data.ReadChars(srec.size));
                        cell_name = Text.trim(cell_name);
                    }
                    break;

                case ("RGNN"):
                    if (String.IsNullOrWhiteSpace(cell_name) || String.IsNullOrEmpty(cell_name.Trim()))
                    {
                        cell_name = new string(srec_data.ReadChars(srec.size));
                    }
                    break;

                case ("INTV"):
                    // water height is stored as a signed int, but the value
                    // corresponds to the float z-axis position of the water plane in the
                    // cell world
                    water_height = (float)srec_data.ReadInt32();

                    break;

                case ("AMBI"):
                    amb_col = srec_data.ReadBytes(4);
                    sun_col = srec_data.ReadBytes(4);
                    break;

                case ("DATA"):
                    data_flags = srec_data.ReadInt32();
                    grid_x     = srec_data.ReadInt32();
                    grid_y     = srec_data.ReadInt32();

                    interior = BinaryFlag.isSet(data_flags, (int)CELL_FLAGS.Interior);
                    HasWater = BinaryFlag.isSet(data_flags, (int)CELL_FLAGS.Water);
                    NoSleep  = BinaryFlag.isSet(data_flags, (int)CELL_FLAGS.NoSleep);

                    break;
                }
            }
        }