Exemplo n.º 1
0
        public void TestHuedEffect()
        {
            var    effectType = EffectType.Moving;
            Serial from       = (Serial)0x1000;
            Serial to         = (Serial)0x2000;
            var    itemId     = 0x100;
            var    fromPoint  = new Point3D(1000, 100, -10);
            var    toPoint    = new Point3D(1500, 500, 0);
            byte   speed      = 3;
            byte   duration   = 2;
            var    direction  = false;
            var    explode    = false;
            var    hue        = 0x1024;
            var    renderMode = 1;

            var expected = new HuedEffect(
                effectType, from, to, itemId, fromPoint, toPoint, speed,
                duration, direction, explode, hue, renderMode
                ).Compile();

            Span <byte> actual = stackalloc byte[OutgoingEffectPackets.HuedEffectLength];

            OutgoingEffectPackets.CreateHuedEffect(
                actual,
                effectType, from, to, itemId, fromPoint, toPoint, speed,
                duration, direction, explode, hue, renderMode
                );

            AssertThat.Equal(actual, expected);
        }
Exemplo n.º 2
0
        public void TestHuedEffect()
        {
            var    effectType = EffectType.Moving;
            Serial serial     = 0x4000;
            Serial from       = 0x1000;
            Serial to         = 0x2000;
            var    itemId     = 0x100;
            var    fromPoint  = new Point3D(1000, 100, -10);
            var    toPoint    = new Point3D(1500, 500, 0);
            byte   speed      = 3;
            byte   duration   = 2;
            var    direction  = false;
            var    explode    = false;
            var    hue        = 0x1024;
            var    renderMode = 1;

            var data = new HuedEffect(
                effectType,
                from,
                to,
                itemId,
                fromPoint,
                toPoint,
                speed,
                duration,
                direction,
                explode,
                hue,
                renderMode
                ).Compile();

            Span <byte> expectedData = stackalloc byte[36];

            var pos = 0;

            expectedData.Write(ref pos, (byte)0xC0); // Packet ID
            expectedData.Write(ref pos, (byte)effectType);
            expectedData.Write(ref pos, from);
            expectedData.Write(ref pos, to);
            expectedData.Write(ref pos, (ushort)itemId);
            expectedData.Write(ref pos, fromPoint);
            expectedData.Write(ref pos, toPoint);
            expectedData.Write(ref pos, speed);
            expectedData.Write(ref pos, duration);
#if NO_LOCAL_INIT
            expectedData.Write(ref pos, (ushort)0);
#else
            pos += 2;
#endif
            expectedData.Write(ref pos, direction);
            expectedData.Write(ref pos, explode);
            expectedData.Write(ref pos, hue);
            expectedData.Write(ref pos, renderMode);

            AssertThat.Equal(data, expectedData);
        }