示例#1
0
        public void TestMapObjectSerialisation()
        {
            // compare the *'s:
            // brush -> GS -> string* -> GS -> brush -> GS -> string*

            var brush = new BlockBrush();
            var b = brush.Create(new IDGenerator(), new Box(Coordinate.Zero, Coordinate.One * 100), null, 0);
            var serialised = GenericStructure.Serialise(b);
            var toString = serialised.ToString();
            var parsed = GenericStructure.Parse(new StringReader(toString));
            var deserialised = GenericStructure.Deserialise<List<MapObject>>(parsed.First());
            var reserialised = GenericStructure.Serialise(deserialised);

            Assert.AreEqual(serialised.ToString(), reserialised.ToString());
        }
示例#2
0
 private MapObject GetBrush(Box bounds, IDGenerator idg)
 {
     var brush = new BlockBrush();
     var ti = Document.TextureCollection.SelectedTexture;
     var texture = ti != null ? ti.GetTexture() : null;
     var created = brush.Create(idg, bounds, texture, 0).ToList();
     if (created.Count > 1)
     {
         var g = new Group(idg.GetNextObjectID());
         created.ForEach(x => x.SetParent(g));
         g.UpdateBoundingBox();
         return g;
     }
     return created.FirstOrDefault();
 }
示例#3
0
 private Map GenerateInvalidSolidMap(decimal variance, decimal startLocation, decimal cubeSize)
 {
     var map = new Map();
     var block = new BlockBrush();
     var st = Coordinate.One * startLocation;
     var brush = block.Create(map.IDGenerator, new Box(st, st + Coordinate.One * cubeSize), null, 0).OfType<Solid>().First();
     var verts = brush.Faces.SelectMany(x => x.Vertices).Where(x => x.Location == st).ToList();
     verts.ForEach(x => x.Location.X -= variance);
     brush.SetParent(map.WorldSpawn);
     return map;
 }