예제 #1
0
 private IList<WEDWallGroup> ReadWallgroups(BinaryReader reader, WEDSecondDescriptor descriptor)
 {
     reader.BaseStream.Seek(descriptor.WallGroupOffset, SeekOrigin.Begin);
     return reader.ReadStructs<WEDWallGroup>(descriptor.PolygonCount);
 }
예제 #2
0
        public void should_create_secondary_descriptor()
        {
            var expectedOutput = new WEDSecondDescriptor();
            expectedOutput.PolygonCount = 2;
            expectedOutput.PolygonOffset = 0x0D;
            expectedOutput.VerticeOffset = 0x1D;
            expectedOutput.WallGroupOffset = 0x2D;
            expectedOutput.IndiciesOffset = 0x3D;

            var plugin = new WEDPlugin();

            var entriesBytes = new byte[]
                                  {
                                    // Secondary Descriptor
                                    0x02, 0x00, 0x00, 0x00,     // Polygon Count int32
                                    0x0D, 0x00, 0x00, 0x00,     // Polygon Offset int32
                                    0x1D, 0x00, 0x00, 0x00,     // Vertice Offset int32
                                    0x2D, 0x00, 0x00, 0x00,     // Wall Offset int32
                                    0x3D, 0x00, 0x00, 0x00      // Indicies Offset int32
                                  };

            var descriptor = new WEDDescriptor();
            descriptor.SecondaryDescriptorOffset = 0x0;

            var memoryStream = new MemoryStream(entriesBytes);
            var binaryReader = new BinaryReader(memoryStream);

            var createDescriptorMethod = plugin.GetType().GetMethod("ReadSecondaryDescriptor", BindingFlags.NonPublic | BindingFlags.Instance);
            var result = createDescriptorMethod.Invoke(plugin, new object[] { binaryReader, descriptor });

            Assert.That(result, Is.EqualTo(expectedOutput));
        }