internal FlatBufferWrapper GetMonsterWrapper(TypeBuilder typeBuilder) { var builder = new FlatBufferBuilder(1); var builderWrapper = new FlatBufferBuilderWrapper(typeBuilder, builder); var monsterName = builderWrapper.CreateString("Fred"); builderWrapper.StartVector("Monster", "inventory", 2); builderWrapper.AddByte(3); //idx 1 builderWrapper.AddByte(2); //idx 0 var monsterInventory = builderWrapper.EndVector(); var minion1_name = builderWrapper.CreateString("Banana"); var minion2_name = builderWrapper.CreateString("Ananab"); var main_minion_name = builderWrapper.CreateString("MainMinion"); builderWrapper.StartTable("Minion"); builderWrapper.AddString("name", minion1_name); var minion1 = builderWrapper.EndTable(); builderWrapper.StartTable("Minion"); builderWrapper.AddString("name", minion2_name); var minion2 = builderWrapper.EndTable(); builderWrapper.StartTable("Minion"); builderWrapper.AddString("name", main_minion_name); var mainMinion = builderWrapper.EndTable(); builderWrapper.StartVector("Monster", "minions", 2); builderWrapper.AddTable(minion2); //idx 1 builderWrapper.AddTable(minion1); //idx 0 var minions = builderWrapper.EndVector(); builderWrapper.StartTable("Monster"); builderWrapper.AddStruct("pos", new object[] { 1.0f, 2.0f, 3.0f }); // x, y, z builderWrapper.AddShort("mana", 42); builderWrapper.AddShort("hp", 17); builderWrapper.AddString("name", monsterName); builderWrapper.AddBool("friendly", true); builderWrapper.AddVector("inventory", monsterInventory); builderWrapper.AddByte("color", 2); // Blue builderWrapper.AddVector("minions", minions); builderWrapper.AddTable("mainMinion", mainMinion); builderWrapper.Finish(builderWrapper.EndTable()); var beginData = builder.DataBuffer.Position; var countData = builder.DataBuffer.Length - beginData; var byteBuffer = new ByteBuffer(builder.DataBuffer.Data.Skip(beginData).Take(countData).ToArray()); return(new FlatBufferWrapper(_typeBuilder, "Monster", byteBuffer)); }