示例#1
0
 public override void DeserializeData(UnityBinaryReader reader, uint dataSize)
 {
     part     = reader.ReadByte();
     vampire  = reader.ReadByte();
     flags    = reader.ReadByte();
     partType = reader.ReadByte();
 }
示例#2
0
 public override void DeserializeData(UnityBinaryReader reader, uint dataSize)
 {
     distance  = reader.ReadLEInt16();
     duration  = reader.ReadByte();
     timeOfDay = reader.ReadByte();
     idle      = reader.ReadBytes(10);
 }
示例#3
0
 public RDATField(UnityBinaryReader r, int dataSize)
 {
     Type     = r.ReadLEUInt32();
     Flags    = (REGNType)r.ReadByte();
     Priority = r.ReadByte();
     r.SkipBytes(2); // Unused
 }
示例#4
0
            public int    Parameter2; // Parameter #2

            public CTDAField(UnityBinaryReader r, int dataSize, GameFormatId format)
            {
                if (format == GameFormatId.TES3)
                {
                    Index           = r.ReadByte();
                    Type            = r.ReadByte();
                    FunctionId      = r.ReadASCIIString(2);
                    CompareOp       = (byte)(r.ReadByte() << 1);
                    Name            = r.ReadASCIIString(dataSize - 5);
                    ComparisonValue = Parameter1 = Parameter2 = 0;
                    return;
                }
                CompareOp = r.ReadByte();
                r.SkipBytes(3); // Unused
                ComparisonValue = r.ReadLESingle();
                FunctionId      = r.ReadASCIIString(4);
                Parameter1      = r.ReadLEInt32();
                Parameter2      = r.ReadLEInt32();
                if (dataSize != 24)
                {
                    r.SkipBytes(4); // Unused
                }
                Index = Type = 0;
                Name  = null;
            }
示例#5
0
 public BYDTField(UnityBinaryReader r, int dataSize)
 {
     Part     = r.ReadByte();
     Vampire  = r.ReadByte();
     Flags    = r.ReadByte();
     PartType = r.ReadByte();
 }
 public PSDTField(UnityBinaryReader r, int dataSize)
 {
     Month = r.ReadByte();
     DayOfWeek = r.ReadByte();
     Date = r.ReadByte();
     Time = (sbyte)r.ReadByte();
     Duration = r.ReadLEInt32();
 }
示例#7
0
 public AI_WField(UnityBinaryReader r, int dataSize)
 {
     Distance  = r.ReadLEInt16();
     Duration  = r.ReadLEInt16();
     TimeOfDay = r.ReadByte();
     Idle      = r.ReadBytes(8);
     Unknown   = r.ReadByte();
 }
示例#8
0
 public DATA3Field(UnityBinaryReader r, int dataSize)
 {
     Unknown1    = r.ReadLEInt32();
     Disposition = r.ReadLEInt32();
     Rank        = r.ReadByte();
     Gender      = r.ReadByte();
     PCRank      = r.ReadByte();
     Unknown2    = r.ReadByte();
 }
        public void Test_BinaryRange()
        {
            UnityBinaryReader r = new UnityBinaryReader(TestData, 4, 4);

            for (int i = 4; i < 8; i++)
            {
                Assert.AreEqual <byte>(TestData[i], r.ReadByte());
            }
            Assert.ThrowsException <IndexOutOfRangeException>(delegate() { r.ReadByte(); });
        }
示例#10
0
 public ENAMField(UnityBinaryReader r, int dataSize)
 {
     EffectId    = r.ReadLEInt16();
     SkillId     = r.ReadByte();
     AttributeId = r.ReadByte();
     Unknown1    = r.ReadLEInt32();
     Unknown2    = r.ReadLEInt32();
     Duration    = r.ReadLEInt32();
     Magnitude   = r.ReadLEInt32();
     Unknown4    = r.ReadLEInt32();
 }
 public XLOCField(UnityBinaryReader r, int dataSize)
 {
     LockLevel = r.ReadByte();
     r.SkipBytes(3); // Unused
     Key = new FormId <KEYMRecord>(r.ReadLEUInt32());
     if (dataSize == 16)
     {
         r.SkipBytes(4); // Unused
     }
     Flags = r.ReadByte();
     r.SkipBytes(3); // Unused
 }
示例#12
0
 public DATAField(UnityBinaryReader r, int dataSize)
 {
     Density  = r.ReadByte();
     MinSlope = r.ReadByte();
     MaxSlope = r.ReadByte();
     r.ReadByte();
     UnitFromWaterAmount = r.ReadLEUInt16();
     r.SkipBytes(2);
     UnitFromWaterType = r.ReadLEUInt32();
     PositionRange     = r.ReadLESingle();
     HeightRange       = r.ReadLESingle();
     ColorRange        = r.ReadLESingle();
     WavePeriod        = r.ReadLESingle();
     Flags             = r.ReadByte();
     r.SkipBytes(3);
 }
        public void ReadDouble()
        {
            UnityBinaryReader r = new UnityBinaryReader(TestDoubleBytes);

            Assert.AreEqual <double>(TestDouble, r.ReadDouble());
            // Forward Test
            Assert.ThrowsException <IndexOutOfRangeException>(delegate() { r.ReadByte(); });
        }
        public void ReadSingle()
        {
            UnityBinaryReader r = new UnityBinaryReader(TestFloatBytes);

            Assert.AreEqual <float>(TestFloat, r.ReadFloat());
            // Forward Test
            Assert.ThrowsException <IndexOutOfRangeException>(delegate() { r.ReadByte(); });
        }
        public void ReadULongBE()
        {
            UnityBinaryReader r = new UnityBinaryReader(TestData);

            Assert.AreEqual <ulong>(0x0123456789ABCDEF, r.ReadULongBE());
            // Forward Test
            Assert.ThrowsException <IndexOutOfRangeException>(delegate() { r.ReadByte(); });
        }
        public void ReadULong()
        {
            UnityBinaryReader r = new UnityBinaryReader(TestData);

            Assert.AreEqual <ulong>(0xEFCDAB8967452301, r.ReadULong());
            // Forward Test
            Assert.ThrowsException <IndexOutOfRangeException>(delegate() { r.ReadByte(); });
        }
示例#17
0
 public DATAField(UnityBinaryReader r, int dataSize, GameFormatId format)
 {
     if (format == GameFormatId.TES3)
     {
         Weight     = r.ReadLESingle();
         Value      = r.ReadLEInt32();
         Flags      = (byte)r.ReadLEInt32();
         Teaches    = (byte)r.ReadLEInt32();
         EnchantPts = r.ReadLEInt32();
         return;
     }
     Flags      = r.ReadByte();
     Teaches    = r.ReadByte();
     Value      = r.ReadLEInt32();
     Weight     = r.ReadLESingle();
     EnchantPts = 0;
 }
 public XSEDField(UnityBinaryReader r, int dataSize)
 {
     Seed = r.ReadByte();
     if (dataSize == 4)
     {
         r.SkipBytes(3); // Unused
     }
 }
        public void ReadString()
        {
            UnityBinaryReader r = new UnityBinaryReader(TestStringBytes);

            Assert.AreEqual <string>(TestString, r.ReadString(TestStringBytes.Length));
            // Forward Test
            Assert.ThrowsException <IndexOutOfRangeException>(delegate() { r.ReadByte(); });
        }
示例#20
0
 public TRDTField(UnityBinaryReader r, int dataSize)
 {
     EmotionType  = r.ReadLEUInt32();
     EmotionValue = r.ReadLEInt32();
     r.SkipBytes(4); // Unused
     ResponseNumber = r.ReadByte();
     r.SkipBytes(3); // Unused
 }
        public void ReadLong()
        {
            UnityBinaryReader r = new UnityBinaryReader(TestData);

            // r_bin
            Assert.AreEqual <long>(unchecked ((long)0xEFCDAB8967452301), r.ReadLong());
            // Forward Test
            Assert.ThrowsException <IndexOutOfRangeException>(delegate() { r.ReadByte(); });
        }
        public void ReadByte()
        {
            UnityBinaryReader r = new UnityBinaryReader(TestData);

            foreach (var b in TestData)
            {
                Assert.AreEqual <byte>(b, r.ReadByte());
            }
        }
示例#23
0
 public AIDTField(UnityBinaryReader r, int dataSize)
 {
     Hello    = r.ReadByte();
     Unknown1 = r.ReadByte();
     Fight    = r.ReadByte();
     Flee     = r.ReadByte();
     Alarm    = r.ReadByte();
     Unknown2 = r.ReadByte();
     Unknown3 = r.ReadByte();
     Unknown4 = r.ReadByte();
     Flags    = r.ReadLEUInt32();
 }
示例#24
0
 public DATAField(UnityBinaryReader r, int dataSize, GameFormatId format)
 {
     if (format == GameFormatId.TES3)
     {
         Weight = r.ReadLESingle();
         return;
     }
     Flags  = r.ReadByte();
     Weight = r.ReadLESingle();
 }
示例#25
0
 public override void DeserializeData(UnityBinaryReader reader, uint dataSize)
 {
     hello    = reader.ReadByte();
     unknown1 = reader.ReadByte();
     fight    = reader.ReadByte();
     flee     = reader.ReadByte();
     alarm    = reader.ReadByte();
     unknown2 = reader.ReadByte();
     unknown3 = reader.ReadByte();
     unknown4 = reader.ReadByte();
     flags    = reader.ReadLEInt32();
 }
        public void ReadDoubleBE()
        {
            byte[] rev = BitConverter.GetBytes(TestDouble);
            Array.Reverse(rev);
            UnityBinaryReader r = new UnityBinaryReader(rev);

            Assert.AreEqual <double>(TestDouble, r.ReadDoubleBE());
            // Forward Test
            Assert.ThrowsException <IndexOutOfRangeException>(delegate() { r.ReadByte(); });
        }
示例#27
0
 public DATAField(UnityBinaryReader r, int dataSize)
 {
     if (dataSize != 102 && dataSize != 86 && dataSize != 62 && dataSize != 42 && dataSize != 2)
     {
         WindVelocity = 1;
     }
     if (dataSize == 2)
     {
         Damage = r.ReadLEUInt16();
         return;
     }
     WindVelocity          = r.ReadLESingle();
     WindDirection         = r.ReadLESingle();
     WaveAmplitude         = r.ReadLESingle();
     WaveFrequency         = r.ReadLESingle();
     SunPower              = r.ReadLESingle();
     ReflectivityAmount    = r.ReadLESingle();
     FresnelAmount         = r.ReadLESingle();
     ScrollXSpeed          = r.ReadLESingle();
     ScrollYSpeed          = r.ReadLESingle();
     FogDistance_NearPlane = r.ReadLESingle();
     if (dataSize == 42)
     {
         Damage = r.ReadLEUInt16();
         return;
     }
     FogDistance_FarPlane = r.ReadLESingle();
     ShallowColor         = r.ReadT <ColorRef4>(dataSize);
     DeepColor            = r.ReadT <ColorRef4>(dataSize);
     ReflectionColor      = r.ReadT <ColorRef4>(dataSize);
     TextureBlend         = r.ReadByte();
     r.SkipBytes(3); // Unused
     if (dataSize == 62)
     {
         Damage = r.ReadLEUInt16();
         return;
     }
     RainSimulator_Force         = r.ReadLESingle();
     RainSimulator_Velocity      = r.ReadLESingle();
     RainSimulator_Falloff       = r.ReadLESingle();
     RainSimulator_Dampner       = r.ReadLESingle();
     RainSimulator_StartingSize  = r.ReadLESingle();
     DisplacementSimulator_Force = r.ReadLESingle();
     if (dataSize == 86)
     {
         //DisplacementSimulator_Velocity = DisplacementSimulator_Falloff = DisplacementSimulator_Dampner = DisplacementSimulator_StartingSize = 0F;
         Damage = r.ReadLEUInt16();
         return;
     }
     DisplacementSimulator_Velocity     = r.ReadLESingle();
     DisplacementSimulator_Falloff      = r.ReadLESingle();
     DisplacementSimulator_Dampner      = r.ReadLESingle();
     DisplacementSimulator_StartingSize = r.ReadLESingle();
     Damage = r.ReadLEUInt16();
 }
 public SkillBoost(UnityBinaryReader r, int dataSize, GameFormatId format)
 {
     if (format == GameFormatId.TES3)
     {
         SkillId = (byte)r.ReadLEInt32();
         Bonus   = (sbyte)r.ReadLEInt32();
         return;
     }
     SkillId = r.ReadByte();
     Bonus   = r.ReadSByte();
 }
        public void ReadValueArray()
        {
            UnityBinaryReader r = new UnityBinaryReader(TestArray);

            TestStruct[] read = r.ReadValueArray <TestStruct>();
            Assert.AreEqual <int>(unchecked (0x67452301), read[0].a);
            Assert.AreEqual <int>(unchecked ((int)0xEFCDAB89), read[0].b);
            Assert.AreEqual <long>(1L, read.LongLength);
            // Forward Test
            Assert.ThrowsException <IndexOutOfRangeException>(delegate() { r.ReadByte(); });
        }
        public void ReadStringToNull()
        {
            byte[] sz = new byte[TestStringBytes.Length + 1];
            Array.Copy(TestStringBytes, sz, TestStringBytes.Length);
            sz[TestStringBytes.Length] = 0x00;
            UnityBinaryReader r = new UnityBinaryReader(sz);

            Assert.AreEqual <string>(TestString, r.ReadStringToNull());
            // Forward Test
            Assert.ThrowsException <IndexOutOfRangeException>(delegate() { r.ReadByte(); });
        }
示例#31
0
		/// <summary>
		/// Decodes a DXT5-compressed 4x4 block of texels.
		/// </summary>
		/// <remarks>See https://msdn.microsoft.com/en-us/library/windows/desktop/bb694531(v=vs.85).aspx#BC3 </remarks>
		private static Color32[] DecodeDXT5TexelBlock(UnityBinaryReader reader)
		{
			// Create the alpha table.
			var alphaTable = new float[8];
			alphaTable[0] = reader.ReadByte();
			alphaTable[1] = reader.ReadByte();

			if(alphaTable[0] > alphaTable[1])
			{
				for(int i = 0; i < 6; i++)
				{
					alphaTable[2 + i] = Mathf.Lerp(alphaTable[0], alphaTable[1], (float)(1 + i) / 7);
				}
			}
			else
			{
				for(int i = 0; i < 4; i++)
				{
					alphaTable[2 + i] = Mathf.Lerp(alphaTable[0], alphaTable[1], (float)(1 + i) / 5);
				}

				alphaTable[6] = 0;
				alphaTable[7] = 255;
			}

			// Read pixel alpha indices.
			var alphaIndices = new uint[16];

			var alphaIndexBytesRow0 = new byte[3];
			reader.Read(alphaIndexBytesRow0, 0, alphaIndexBytesRow0.Length);
			Array.Reverse(alphaIndexBytesRow0); // Take care of little-endianness.

			var alphaIndexBytesRow1 = new byte[3];
			reader.Read(alphaIndexBytesRow1, 0, alphaIndexBytesRow1.Length);
			Array.Reverse(alphaIndexBytesRow1); // Take care of little-endianness.

			const uint bitsPerAlphaIndex = 3;

			alphaIndices[0] = (uint)Utils.GetBits(21, bitsPerAlphaIndex, alphaIndexBytesRow0);
			alphaIndices[1] = (uint)Utils.GetBits(18, bitsPerAlphaIndex, alphaIndexBytesRow0);
			alphaIndices[2] = (uint)Utils.GetBits(15, bitsPerAlphaIndex, alphaIndexBytesRow0);
			alphaIndices[3] = (uint)Utils.GetBits(12, bitsPerAlphaIndex, alphaIndexBytesRow0);
			alphaIndices[4] = (uint)Utils.GetBits(9, bitsPerAlphaIndex, alphaIndexBytesRow0);
			alphaIndices[5] = (uint)Utils.GetBits(6, bitsPerAlphaIndex, alphaIndexBytesRow0);
			alphaIndices[6] = (uint)Utils.GetBits(3, bitsPerAlphaIndex, alphaIndexBytesRow0);
			alphaIndices[7] = (uint)Utils.GetBits(0, bitsPerAlphaIndex, alphaIndexBytesRow0);
			alphaIndices[8] = (uint)Utils.GetBits(21, bitsPerAlphaIndex, alphaIndexBytesRow1);
			alphaIndices[9] = (uint)Utils.GetBits(18, bitsPerAlphaIndex, alphaIndexBytesRow1);
			alphaIndices[10] = (uint)Utils.GetBits(15, bitsPerAlphaIndex, alphaIndexBytesRow1);
			alphaIndices[11] = (uint)Utils.GetBits(12, bitsPerAlphaIndex, alphaIndexBytesRow1);
			alphaIndices[12] = (uint)Utils.GetBits(9, bitsPerAlphaIndex, alphaIndexBytesRow1);
			alphaIndices[13] = (uint)Utils.GetBits(6, bitsPerAlphaIndex, alphaIndexBytesRow1);
			alphaIndices[14] = (uint)Utils.GetBits(3, bitsPerAlphaIndex, alphaIndexBytesRow1);
			alphaIndices[15] = (uint)Utils.GetBits(0, bitsPerAlphaIndex, alphaIndexBytesRow1);

			// Create the color table.
			var colorTable = new Color[4];
			colorTable[0] = ColorUtils.R5G6B5ToColor(reader.ReadLEUInt16());
			colorTable[1] = ColorUtils.R5G6B5ToColor(reader.ReadLEUInt16());
			colorTable[2] = Color.Lerp(colorTable[0], colorTable[1], 1.0f / 3);
			colorTable[3] = Color.Lerp(colorTable[0], colorTable[1], 2.0f / 3);

			// Calculate pixel colors.
			var colors = DecodeDXT1TexelBlock(reader, colorTable);

			for(int i = 0; i < 16; i++)
			{
				colors[i].a = (byte)Mathf.Round(alphaTable[alphaIndices[i]]);
			}

			return colors;
		}