Example #1
0
        public string GetString(long count, long offset = 0, bool next = true)
        {
            TesBytes b      = GetBytes(count, offset, next);
            string   result = b.ToString();

            return(result);
        }
Example #2
0
 public TesRotation(int x, int y, int z)
 {
     X = IntToByte(x);
     Y = IntToByte(y);
     Z = IntToByte(z);
     Initialize();
 }
Example #3
0
        public void Overwrite(ITesBase bytes, int pos = 0)
        {
            TesBytes b = bytes.ToBytes();

            this.RemoveRange(pos, b.Count);
            this.InsertRange(pos, b);
        }
Example #4
0
 public TesRotation(TesBytes x, TesBytes y, TesBytes z)
 {
     X = x;
     Y = y;
     Z = z;
     Initialize();
 }
Example #5
0
 public TesBytes this[int index]
 {
     get
     {
         TesBytes result = (TesBytes)Values[index];
         return(result);
     }
 }
Example #6
0
        public ushort GetUInt16(long offset = 0, bool next = true)
        {
            long     count  = 2;
            TesBytes b      = GetBytes(count, offset, next);
            ushort   result = b.ToUInt16();

            return(result);
        }
Example #7
0
        public uint GetUInt32(long offset = 0, bool next = true)
        {
            long     count  = 4;
            TesBytes b      = GetBytes(count, offset, next);
            uint     result = b.ToUInt32();

            return(result);
        }
Example #8
0
        public float GetFloat(long offset = 0, bool next = true)
        {
            long     count  = 4;
            TesBytes b      = GetBytes(count, offset, next);
            float    result = b.ToFloat();

            return(result);
        }
Example #9
0
        public TesString(TesBytes value)
        {
            if (value[value.Count() - 1] == 0x00)
            {
                isNullTerminated = true;
            }

            this.Value = value.ToString();
        }
Example #10
0
        public TesBytes ToBytes()
        {
            TesBytes result = new TesBytes();

            foreach (var x in this)
            {
                result.AddRange(x.ToBytes());
            }
            return(result);
        }
Example #11
0
        public TesGroup(TesFileReader fr, bool readRecord = true)
        {
            GRUP     = new TesString(fr);
            DataSize = new TesUInt32(fr);
            OutputItems.Add(GRUP);
            OutputItems.Add(DataSize);

            //グループタイプ別
            uint type = fr.GetUInt32(4, false);

            switch (type)
            {
            case 0:
                Signature = new TesString(fr);
                OutputItems.Add(Signature);
                break;

            case 1:
            case 6:
            case 8:
            case 9:
                FormID = new TesUInt32(fr);
                OutputItems.Add(FormID);
                break;

            case 2:
            case 3:
                Index = new TesUInt32(fr);
                OutputItems.Add(Index);
                break;

            case 4:
            case 5:
                Grid = new TesCellGrid(fr);
                OutputItems.Add(Grid);
                break;

            default:
                throw new Exception();
            }
            GroupType = new TesUInt32(fr);
            Other     = new TesBytes(fr.GetBytes(8));
            OutputItems.Add(GroupType);
            OutputItems.Add(Other);

            if (readRecord)
            {
                while (!fr.EOF)
                {
                    Records.Add(new TesRecord(fr.GetRecord()));
                }
            }
            OutputItems.Add(Records);
        }
Example #12
0
        public TesBytes GetOffset(long offset, long count)
        {
            if (Int32.MaxValue < offset + count)
            {
                throw new Exception();
            }

            TesBytes result = new TesBytes(this.GetRange((int)offset, (int)count).ToArray());

            return(result);
        }
Example #13
0
        public TesRecordCell(TesFileReader fr) : base(fr, false)
        {
            CellInfo = new TesBytes(fr.GetBytes(Header.DataSize));
            OutputItems.Add(CellInfo);

            if (!fr.EOF)
            {
                CellMain = new TesCellMain(fr.GetGroup());
                OutputItems.Add(CellMain);
            }
        }
Example #14
0
                public Property()
                {
                    PropertyNameDataSize = new TesUInt16(0);
                    PropertyName         = new TesString("");
                    Type          = new TesBytes(new byte[] { 0x01, 0x01, 0x00, 0x00, 0xff, 0xff });
                    PropertyValue = new TesBytes();

                    OutputItems.Add(PropertyNameDataSize);
                    OutputItems.Add(PropertyName);
                    OutputItems.Add(Type);
                    OutputItems.Add(PropertyValue);
                }
Example #15
0
            public Script()
            {
                ScriptNameDataSize = new TesUInt16(0);
                ScriptName         = new TesString("");
                Flags         = new TesBytes(new byte[] { 0x01 });
                PropertyCount = new TesUInt16(0);

                OutputItems.Add(ScriptNameDataSize);
                OutputItems.Add(ScriptName);
                OutputItems.Add(Flags);
                OutputItems.Add(PropertyCount);
                OutputItems.Add(Propertys);
            }
Example #16
0
        public static int ByteToInt(TesBytes bytes)
        {
            int result = 0;

            if (bytes.SequenceEqual(new byte[] { 0xdb, 0x0f, 0xc9, 0x3f }))
            {
                result = 90;
            }
            else if (bytes.SequenceEqual(new byte[] { 0xdb, 0x0f, 0x49, 0x40 }))
            {
                result = 180;
            }
            else if (bytes.SequenceEqual(new byte[] { 0xdb, 0x0f, 0xc9, 0xbf }))
            {
                result = 270;
            }
            return(result);
        }
Example #17
0
        public TesBytes GetBytes(long count, long offset = 0, bool next = true)
        {
            if (len < pos + count + offset)
            {
                throw new Exception();
            }

            TesBytes result = Read(offset + count, next);

            if (0 < offset)
            {
                result = result.GetOffset(offset, count);
            }

            if (next)
            {
                pos += count;
            }

            return(result);
        }
Example #18
0
        private TesBytes Read(long count, bool next)
        {
            if (pos != br.BaseStream.Position)
            {
                br.BaseStream.Seek(pos, SeekOrigin.Begin);
            }

            if (Int32.MaxValue < count)
            {
                throw new Exception();
            }

            TesBytes result = new TesBytes(br.ReadBytes((int)count));

            if (!next)
            {
                br.BaseStream.Seek(-count, SeekOrigin.Current);
            }

            return(result);
        }
Example #19
0
        public string GetNullTerminatedString(long pos)
        {
            this.pos = pos;
            if (pos != br.BaseStream.Position)
            {
                br.BaseStream.Seek(pos, SeekOrigin.Begin);
            }

            TesBytes bytes = new TesBytes();
            byte     b;

            do
            {
                b = br.ReadByte();
                bytes.Add(b);
                ++pos;
            }while (b != 0x00 && pos < len);

            string result = bytes.ToString();

            return(result);
        }
Example #20
0
        public static TesBytes IntToByte(int value)
        {
            TesBytes result = null;

            switch (value)
            {
            case 90:
                result = new TesBytes(new byte[] { 0xdb, 0x0f, 0xc9, 0x3f });
                break;

            case 180:
                result = new TesBytes(new byte[] { 0xdb, 0x0f, 0x49, 0x40 });
                break;

            case 270:
                result = new TesBytes(new byte[] { 0xdb, 0x0f, 0xc9, 0xbf });
                break;

            default:
                result = new TesBytes(new byte[] { 0x00, 0x00, 0x00, 0x00 });
                break;
            }
            return(result);
        }
Example #21
0
 public TesRotation(TesFileReader fr)
 {
     X = fr.GetBytes(4);
     Y = fr.GetBytes(4);
     Z = fr.GetBytes(4);
 }
Example #22
0
 public TesBytes(TesBytes value)
 {
     this.AddRange(value);
 }
Example #23
0
        public TesBytes ToBytes()
        {
            TesBytes result = new TesBytes(Value, isNullTerminated);

            return(result);
        }
Example #24
0
        public TesBytes ToBytes()
        {
            TesBytes result = new TesBytes(Value);

            return(result);
        }