示例#1
0
        public static void SendPacket(IPoint3D origin, Map map, Packet p)
        {
            if (map != null)
            {
                IPooledEnumerable eable = map.GetClientsInRange(new Point3D(origin));

                p.Acquire();

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

                    state.Send(p);
                }

                p.Release();

                eable.Free();
            }
        }
示例#2
0
        public static void NonlocalOverheadMessage(this Item item, MessageType type, int hue, int number, string args)
        {
            if (item == null || item.Map == null)
            {
                return;
            }

            var p = Packet.Acquire(new MessageLocalized(item.Serial, item.ItemID, type, hue, 3, number, item.Name, args));

            var eable = item.Map.GetClientsInRange(item.Location, item.GetMaxUpdateRange());

            foreach (var state in eable.Where(state => state.Mobile.CanSee(item)))
            {
                state.Send(p);
            }

            eable.Free();

            Packet.Release(p);
        }
示例#3
0
        public static void SendLocationParticles(IEntity e, int itemID, int speed, int duration, int hue, int renderMode, int effect, int unknown)
        {
            Map map = e.Map;

            if (map != null)
            {
                Packet particles = null, regular = null;

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

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

                    if (SendParticlesTo(state))
                    {
                        if (particles == null)
                        {
                            particles = Packet.Acquire(new LocationParticleEffect(e, itemID, speed, duration, hue, renderMode, effect, unknown));
                        }

                        state.Send(particles);
                    }
                    else if (itemID != 0)
                    {
                        if (regular == null)
                        {
                            regular = Packet.Acquire(new LocationEffect(e, itemID, speed, duration, hue, renderMode));
                        }

                        state.Send(regular);
                    }
                }

                Packet.Release(particles);
                Packet.Release(regular);

                eable.Free();
            }
            //SendPacket( e.Location, e.Map, new LocationParticleEffect( e, itemID, speed, duration, hue, renderMode, effect, unknown ) );
        }
示例#4
0
文件: Effects.cs 项目: dpisanu/xrunuo
        public static void SendTargetParticles(IEntity target, int itemID, int speed, int duration, int hue, int renderMode, int effect, EffectLayer layer, int unknown)
        {
            if (target is Mobile)
            {
                ((Mobile)target).ProcessDelta();
            }

            IMap map = target.Map;

            if (map != null)
            {
                Packet particles = null, regular = null;

                foreach (NetState state in map.GetClientsInRange(target.Location))
                {
                    state.Mobile.ProcessDelta();

                    if (SendParticlesTo(state))
                    {
                        if (particles == null)
                        {
                            particles = Packet.Acquire(new TargetParticleEffect(target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown));
                        }

                        state.Send(particles);
                    }
                    else if (itemID != 0)
                    {
                        if (regular == null)
                        {
                            regular = Packet.Acquire(new TargetEffect(target, itemID, speed, duration, hue, renderMode));
                        }

                        state.Send(regular);
                    }
                }

                Packet.Release(particles);
                Packet.Release(regular);
            }
        }
示例#5
0
        public static void SendPacket(IPoint3D origin, Map map, Packet p)
        {
            if (map == null)
            {
                return;
            }

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

            p.Acquire();

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

            p.Release();

            eable.Free();
        }
示例#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
            )
        {
            if (from is Mobile fromMob)
            {
                fromMob.ProcessDelta();
            }

            if (to is Mobile toMob)
            {
                toMob.ProcessDelta();
            }

            var map = from.Map;

            if (map != null)
            {
                Packet particles = null, regular = null;

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

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

                    if (SendParticlesTo(state))
                    {
                        particles ??= Packet.Acquire(
                            new MovingParticleEffect(
                                from,
                                to,
                                itemID,
                                speed,
                                duration,
                                fixedDirection,
                                explodes,
                                hue,
                                renderMode,
                                effect,
                                explodeEffect,
                                explodeSound,
                                layer,
                                unknown
                                )
                            );

                        state.Send(particles);
                    }
                    else if (itemID > 1)
                    {
                        regular ??= Packet.Acquire(
                            new MovingEffect(
                                from,
                                to,
                                itemID,
                                speed,
                                duration,
                                fixedDirection,
                                explodes,
                                hue,
                                renderMode
                                )
                            );

                        state.Send(regular);
                    }
                }

                Packet.Release(particles);
                Packet.Release(regular);

                eable.Free();
            }

            // SendPacket( from.Location, from.Map, new MovingParticleEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, unknown ) );
        }
示例#7
0
        public static void SendBoltEffect(IEntity e, bool sound, int hue)
        {
            Map map = e.Map;

            if (map == null)
            {
                return;
            }

            e.ProcessDelta();

            Packet preEffect = null, postEffect = null, boltEffect = null, playSound = null;

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

            foreach (NetState state in eable)
            {
                if (state.Mobile.CanSee(e))
                {
                    bool sendParticles = SendParticlesTo(state);

                    if (sendParticles)
                    {
                        if (preEffect == null)
                        {
                            preEffect = Packet.Acquire(new TargetParticleEffect(e, 0, 10, 5, 0, 0, 5031, 3, 0));
                        }

                        state.Send(preEffect);
                    }

                    if (boltEffect == null)
                    {
                        if (hue == 0)
                        {
                            boltEffect = Packet.Acquire(new BoltEffectNew(e));
                        }
                        else
                        {
                            boltEffect = Packet.Acquire(new BoltEffect(e, hue));
                        }
                    }

                    state.Send(boltEffect);

                    if (sendParticles)
                    {
                        if (postEffect == null)
                        {
                            postEffect = Packet.Acquire(new GraphicalEffect(EffectType.FixedFrom, e.Serial, Serial.Zero, 0, e.Location, e.Location, 0, 0, false, 0));
                        }

                        state.Send(postEffect);
                    }

                    if (sound)
                    {
                        if (playSound == null)
                        {
                            playSound = Packet.Acquire(new PlaySound(0x29, e));
                        }

                        state.Send(playSound);
                    }
                }
            }

            Packet.Release(preEffect);
            Packet.Release(postEffect);
            Packet.Release(boltEffect);
            Packet.Release(playSound);

            eable.Free();
        }
示例#8
0
        public static void SendBoltEffect(IEntity e, bool sound, int hue)
        {
            Map map = e.Map;

            if (map == null)
            {
                return;
            }

            if (e is Item)
            {
                ((Item)e).ProcessDelta();
            }
            else if (e is Mobile)
            {
                ((Mobile)e).ProcessDelta();
            }

            Packet preEffect = null, boltEffect = null, playSound = null;

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

            foreach (NetState state in eable)
            {
                if (state.Mobile.CanSee(e))
                {
                    if (SendParticlesTo(state))
                    {
                        if (preEffect == null)
                        {
                            preEffect = Packet.Acquire(new TargetParticleEffect(e, 0, 10, 5, 0, 0, 5031, 3, 0));
                        }

                        state.Send(preEffect);
                    }

                    if (boltEffect == null)
                    {
                        boltEffect = Packet.Acquire(new BoltEffect(e, hue));
                    }

                    state.Send(boltEffect);

                    if (sound)
                    {
                        if (playSound == null)
                        {
                            playSound = Packet.Acquire(new PlaySound(0x29, e));
                        }

                        state.Send(playSound);
                    }
                }
            }

            Packet.Release(preEffect);
            Packet.Release(boltEffect);
            Packet.Release(playSound);

            eable.Free();
        }