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 override bool OnDragDropInto(Mobile from, Item dropped, Point3D point)
        {
            if (dropped is BasePiece piece && piece.Board == this && base.OnDragDropInto(from, dropped, point))
            {
                if (RootParent == from)
                {
                    from.SendSound(0x127, GetWorldLocation());
                }
                else
                {
                    Span <byte> buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength];
                    buffer.InitializePacket();

                    foreach (var state in GetClientsInRange(2))
                    {
                        if (buffer[0] == 0)
                        {
                            OutgoingEffectPackets.CreateSoundEffect(buffer, 0x127, GetWorldLocation());
                        }

                        state.Send(buffer);
                    }
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        public static void PlaySound(Point3D p, Map map, int soundID)
        {
            if (soundID <= -1)
            {
                return;
            }

            if (map != null)
            {
                Span <byte> buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength];
                buffer.InitializePacket();

                var eable = map.GetClientsInRange(new Point3D(p));

                foreach (var state in eable)
                {
                    state.Mobile.ProcessDelta();

                    if (buffer[0] == 0)
                    {
                        OutgoingEffectPackets.CreateSoundEffect(buffer, soundID, p);
                    }

                    state.Send(buffer);
                }

                eable.Free();
            }
        }
Exemplo n.º 4
0
        public static void SendTargetParticles(
            IEntity target, int itemID, int speed, int duration, int hue, int renderMode,
            int effect, EffectLayer layer, int unknown = 0
            )
        {
            (target as Mobile)?.ProcessDelta();

            var map = target.Map;

            if (map == null)
            {
                return;
            }

            Span <byte> particles = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength];

            particles.InitializePacket();

            Span <byte> regular = itemID != 0 ? stackalloc byte[OutgoingEffectPackets.HuedEffectLength] : null;

            if (itemID != 0)
            {
                regular.InitializePacket();
            }

            var eable = map.GetClientsInRange(target.Location);

            foreach (var state in eable)
            {
                state.Mobile.ProcessDelta();

                if (SendParticlesTo(state))
                {
                    if (particles[0] == 0)
                    {
                        OutgoingEffectPackets.CreateTargetParticleEffect(
                            particles,
                            target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown
                            );
                    }

                    state.Send(particles);
                }
                else if (itemID != 0)
                {
                    if (regular[0] == 0)
                    {
                        OutgoingEffectPackets.CreateTargetHuedEffect(regular, target, itemID, speed, duration, hue, renderMode);
                    }

                    state.Send(regular);
                }
            }

            eable.Free();
        }
Exemplo n.º 5
0
        public void TestBoltEffect()
        {
            IEntity entity   = new Entity((Serial)0x1000, new Point3D(1000, 100, -10), Map.Felucca);
            var     hue      = 0x1024;
            var     expected = new BoltEffect(entity, hue).Compile();

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

            OutgoingEffectPackets.CreateBoltEffect(actual, entity, hue);

            AssertThat.Equal(actual, expected);
        }
Exemplo n.º 6
0
        public static void SendMovingParticles(
            IEntity from, IEntity to, int itemID, int speed, int duration,
            bool fixedDirection, bool explodes, int hue, int renderMode, int effect, int explodeEffect, int explodeSound,
            EffectLayer layer, int unknown
            )
        {
            (from as Mobile)?.ProcessDelta();
            (to as Mobile)?.ProcessDelta();

            var map = from.Map;

            if (map == null)
            {
                return;
            }

            Span <byte> particles = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength];

            OutgoingEffectPackets.CreateMovingParticleEffect(
                ref particles,
                from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect,
                explodeEffect, explodeSound, layer, unknown
                );

            Span <byte> regular = itemID != 0 ? stackalloc byte[OutgoingEffectPackets.HuedEffectLength] : null;

            if (itemID != 0)
            {
                OutgoingEffectPackets.CreateMovingHuedEffect(
                    ref regular,
                    from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode
                    );
            }

            var eable = map.GetClientsInRange(from.Location);

            foreach (var state in eable)
            {
                state.Mobile.ProcessDelta();

                if (SendParticlesTo(state))
                {
                    state.Send(particles);
                }
                else if (itemID > 1)
                {
                    state.Send(regular);
                }
            }

            eable.Free();
        }
Exemplo n.º 7
0
        public static void SendTargetEffect(IEntity target, int itemID, int speed, int duration, int hue = 0, int renderMode = 0)
        {
            (target as Mobile)?.ProcessDelta();

            Span <byte> effect = stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket();

            OutgoingEffectPackets.CreateTargetHuedEffect(
                effect,
                target, itemID, speed, duration, hue, renderMode
                );

            SendPacket(target.Location, target.Map, effect);
        }
Exemplo n.º 8
0
        public static void SendLocationEffect(
            Point3D p, Map map, int itemID, int duration, int speed = 10, int hue = 0, int renderMode = 0
            )
        {
            Span <byte> effect = stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket();

            OutgoingEffectPackets.CreateLocationHuedEffect(
                effect,
                p, itemID, speed, duration, hue, renderMode
                );

            SendPacket(p, map, effect);
        }
Exemplo n.º 9
0
        public static void SendBoltEffect(IEntity e, bool sound = true, int hue = 0)
        {
            var map = e.Map;

            if (map == null)
            {
                return;
            }

            e.ProcessDelta();

            Span <byte> preEffect = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength];

            OutgoingEffectPackets.CreateTargetParticleEffect(
                ref preEffect,
                e, 0, 10, 5, 0, 0, 5031, 3, 0
                );

            Span <byte> boltEffect = stackalloc byte[OutgoingEffectPackets.BoltEffectLength];

            OutgoingEffectPackets.CreateBoltEffect(ref boltEffect, e, hue);

            Span <byte> soundEffect = sound ? stackalloc byte[OutgoingEffectPackets.SoundPacketLength] : null;

            if (sound)
            {
                OutgoingEffectPackets.CreateSoundEffect(ref soundEffect, 0x29, e);
            }

            var eable = map.GetClientsInRange(e.Location);

            foreach (var state in eable)
            {
                if (state.Mobile.CanSee(e))
                {
                    if (SendParticlesTo(state))
                    {
                        state.Send(preEffect);
                    }

                    state.Send(boltEffect);

                    if (sound)
                    {
                        state.Send(soundEffect);
                    }
                }
            }

            eable.Free();
        }
Exemplo n.º 10
0
        public static void SendMovingEffect(
            Serial from, Serial to, Point3D origin, Map map, int itemID, Point3D fromLocation, Point3D toLocation,
            int speed, int duration, bool fixedDirection = false, bool explodes = false, int hue = 0, int renderMode = 0
            )
        {
            Span <byte> effect = stackalloc byte[OutgoingEffectPackets.HuedEffectLength];

            OutgoingEffectPackets.CreateMovingHuedEffect(
                effect,
                from, to, itemID, fromLocation, toLocation, speed, duration, fixedDirection,
                explodes, hue, renderMode
                );

            SendPacket(origin, map, effect);
        }
Exemplo n.º 11
0
        public static void SendLocationParticles(
            IEntity e, int itemID, int speed, int duration, int hue, int renderMode, int effect, int unknown
            )
        {
            var map = e.Map;

            if (map == null)
            {
                return;
            }

            Span <byte> particles = stackalloc byte[OutgoingEffectPackets.ParticleEffectLength];

            OutgoingEffectPackets.CreateLocationParticleEffect(
                ref particles,
                e, itemID, speed, duration, hue, renderMode, effect, unknown
                );

            Span <byte> regular = itemID != 0 ? stackalloc byte[OutgoingEffectPackets.HuedEffectLength] : null;

            if (itemID != 0)
            {
                OutgoingEffectPackets.CreateLocationHuedEffect(
                    ref regular,
                    e.Location, itemID, speed, duration, hue, renderMode
                    );
            }

            var eable = map.GetClientsInRange(e.Location);

            foreach (var state in eable)
            {
                state.Mobile.ProcessDelta();

                if (SendParticlesTo(state))
                {
                    state.Send(particles);
                }
                else if (itemID != 0)
                {
                    state.Send(regular);
                }
            }

            eable.Free();
        }
Exemplo n.º 12
0
        public void TestParticleEffect()
        {
            var    effectType    = EffectType.Moving;
            Serial serial        = (Serial)0x4000;
            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;
            ushort effect        = 3;
            ushort explodeEffect = 0;
            ushort explodeSound  = 0;
            byte   layer         = 9;
            ushort unknown       = 0;

            var expected = new ParticleEffect(
                effectType, from, to, itemId, fromPoint, toPoint, speed, duration, direction,
                explode, hue, renderMode, effect, explodeEffect, explodeSound, serial, layer,
                unknown
                ).Compile();

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

            OutgoingEffectPackets.CreateParticleEffect(
                actual,
                effectType, from, to, itemId, fromPoint, toPoint, speed, duration, direction,
                explode, hue, renderMode, effect, explodeEffect, explodeSound, serial, layer,
                unknown
                );

            AssertThat.Equal(actual, expected);
        }