private void TestBuffer(ByteBuffer bb)
        {
            var monster = Monster.GetRootAsMonster(bb);

            Assert.AreEqual(80, monster.Hp());
            Assert.AreEqual(150, monster.Mana());
            Assert.AreEqual("MyMonster", monster.Name());

            var pos = monster.Pos();
            Assert.AreEqual(1.0f, pos.X());
            Assert.AreEqual(2.0f, pos.Y());
            Assert.AreEqual(3.0f, pos.Z());

            Assert.AreEqual(3.0f, pos.Test1());
            Assert.AreEqual(Color.Green, pos.Test2());
            var t = pos.Test3();
            Assert.AreEqual((short)5, t.A());
            Assert.AreEqual((sbyte)6, t.B());

            Assert.AreEqual((byte)Any.Monster, monster.TestType());

            var monster2 = new Monster();
            Assert.IsTrue(monster.Test(monster2) != null);
            Assert.AreEqual("Fred", monster2.Name());

            Assert.AreEqual(5, monster.InventoryLength());
            var invsum = 0;
            for (var i = 0; i < monster.InventoryLength(); i++)
            {
                invsum += monster.Inventory(i);
            }
            Assert.AreEqual(10, invsum);

            var test0 = monster.Test4(0);
            var test1 = monster.Test4(1);
            Assert.AreEqual(2, monster.Test4Length());

            Assert.AreEqual(100, test0.A() + test0.B() + test1.A() + test1.B());

            Assert.AreEqual(2, monster.TestarrayofstringLength());
            Assert.AreEqual("test1", monster.Testarrayofstring(0));
            Assert.AreEqual("test2", monster.Testarrayofstring(1));
        }
Пример #2
0
 public static Monster GetRootAsMonster(ByteBuffer _bb, Monster obj)
 {
     return(obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb));
 }
        private void TestBuffer(ByteBuffer bb)
        {
            var monster = Monster.GetRootAsMonster(bb);

            Assert.AreEqual(80, monster.Hp);
            Assert.AreEqual(150, monster.Mana);
            Assert.AreEqual("MyMonster", monster.Name);

            var pos = monster.Pos;
            Assert.AreEqual(1.0f, pos.X);
            Assert.AreEqual(2.0f, pos.Y);
            Assert.AreEqual(3.0f, pos.Z);

            Assert.AreEqual(3.0f, pos.Test1);
            Assert.AreEqual(Color.Green, pos.Test2);
            var t = pos.Test3;
            Assert.AreEqual((short)5, t.A);
            Assert.AreEqual((sbyte)6, t.B);

            Assert.AreEqual(Any.Monster, monster.TestType);

            var monster2 = new Monster();
            Assert.IsTrue(monster.GetTest(monster2) != null);
            Assert.AreEqual("Fred", monster2.Name);


            Assert.AreEqual(5, monster.InventoryLength);
            var invsum = 0;
            for (var i = 0; i < monster.InventoryLength; i++)
            {
                invsum += monster.GetInventory(i);
            }
            Assert.AreEqual(10, invsum);

            var test0 = monster.GetTest4(0);
            var test1 = monster.GetTest4(1);
            Assert.AreEqual(2, monster.Test4Length);

            Assert.AreEqual(100, test0.A + test0.B + test1.A + test1.B);

            Assert.AreEqual(2, monster.TestarrayofstringLength);
            Assert.AreEqual("test1", monster.GetTestarrayofstring(0));
            Assert.AreEqual("test2", monster.GetTestarrayofstring(1));

            Assert.AreEqual(false, monster.Testbool);

            var nameBytes = monster.GetNameBytes().Value;
            Assert.AreEqual("MyMonster", Encoding.UTF8.GetString(nameBytes.Array, nameBytes.Offset, nameBytes.Count));

            if (0 == monster.TestarrayofboolsLength)
            {
                Assert.IsFalse(monster.GetTestarrayofboolsBytes().HasValue);
            }
            else
            {
                Assert.IsTrue(monster.GetTestarrayofboolsBytes().HasValue);
            }
        }
Пример #4
0
 public Monster Testarrayoftables(Monster obj, int j)
 {
     int o = __offset(26); return o != 0 ? obj.__init(__indirect(__vector(o) + j * 4), bb) : null;
 }
Пример #5
0
 public Monster?TestarrayoftablesByKey(string key)
 {
     int o = __p.__offset(26); return(o != 0 ? Monster.__lookup_by_key(__p.__vector(o), key, __p.bb) : null);
 }
Пример #6
0
 public Monster Enemy(Monster obj)
 {
     int o = __offset(28); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null;
 }
Пример #7
0
 public static Monster GetRootAsMonster(ByteBuffer _bb, Monster obj)
 {
     return (obj.__init(_bb.GetInt(_bb.position()) + _bb.position(), _bb));
 }
Пример #8
0
 public Monster GetEnemy(Monster obj)
 {
     int o = __offset(28); return(o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null);
 }
Пример #9
0
 public Monster GetTestarrayoftables(Monster obj, int j)
 {
     int o = __offset(26); return(o != 0 ? obj.__init(__indirect(__vector(o) + j * 4), bb) : null);
 }
Пример #10
0
 public static Monster GetRootAsMonster(ByteBuffer _bb, Monster obj)
 {
     return(obj.__init(_bb.GetInt(_bb.position()) + _bb.position(), _bb));
 }