GetMovingEntities() public méthode

public GetMovingEntities ( ) : List
Résultat List
Exemple #1
0
        public void DockBoat(BaseBoat boat, BaseHouse house)
        {
            List<ISpawnable> list = boat.GetMovingEntities();

            foreach (ISpawnable o in list)
            {
                if (!(o is Item) || o == this || boat.IsComponentItem(o) || o is EffectItem || o == boat.TillerMan)
                    continue;

                Item item = o as Item;

                if (!item.Deleted && boat.Contains(item))
                {
                    if (item is AddonComponent || item is BaseAddon)
                    {
                        BaseAddon addon = item is AddonComponent ? ((AddonComponent)item).Addon : (BaseAddon)item;
                        Item deed = addon.Deed;

                        bool retainDeedHue = false;
                        int hue = 0;

                        if (addon != null && addon.RetainDeedHue)
                        {
                            retainDeedHue = true;

                            for (int j = 0; hue == 0 && j < addon.Components.Count; ++j)
                            {
                                AddonComponent c = addon.Components[j];

                                if (c.Hue != 0)
                                    hue = c.Hue;
                            }
                        }

                        if (deed != null)
                        {
                            if (retainDeedHue)
                                deed.Hue = hue;

                            house.DropToMovingCrate(deed);
                        }
                    }
                    else
                    {
                        item.Delete();
                    }
                }

                Container cont;

                if (boat is BaseGalleon)
                    cont = ((BaseGalleon)boat).GalleonHold;
                else
                    cont = boat.Hold;

                if (cont != null)
                {
                    cont.Items.ForEach(i =>
                        {
                            if (i is BaseWeapon)
                                house.DropToMovingCrate(i);
                            else
                                i.Delete();
                        });
                }
            }

            BaseDockedBoat model = boat.BoatItem;

            if (model == null || model.Deleted)
                model = boat.DockedBoat;

            if (model == null)
                return;

            model.BoatItem = boat;

            if (boat.IsClassicBoat && boat.Owner != null)
                boat.RemoveKeys(boat.Owner);

            house.DropToMovingCrate(model);

            boat.OnDryDock();

            boat.Refresh();
            boat.Internalize();

            list.Clear();
            list.TrimExcess();
        }
Exemple #2
0
            public DisplayBoatHS(Mobile beholder, BaseBoat boat)
                : base(0xF7)
            {
                List<IEntity> ents = boat.GetMovingEntities();

                SafeAdd(boat.TillerMan, ents);
                SafeAdd(boat.Hold, ents);
                SafeAdd(boat.PPlank, ents);
                SafeAdd(boat.SPlank, ents);
                foreach (BoatComponent component in boat.BoatComponents)
                {
                    SafeAdd(component, ents);
                }

                ents.Add(boat);

                EnsureCapacity(3 + 2 + ents.Count * 26);

                m_Stream.Write((short)0); // count placeholder

                int count = 0;

                foreach (IEntity ent in ents)
                {
                    if (!beholder.CanSee(ent))
                        continue;

                    // Embedded WorldItemHS packets
                    m_Stream.Write((byte)0xF3);
                    m_Stream.Write((short)0x1);

                    if (ent is BaseMulti)
                    {
                        BaseMulti bm = (BaseMulti)ent;

                        m_Stream.Write((byte)0x02);
                        m_Stream.Write((int)bm.Serial);
                        // TODO: Mask no longer needed, merge with Item case?
                        m_Stream.Write((ushort)(bm.ItemID & 0x3FFF));
                        m_Stream.Write((byte)0);

                        m_Stream.Write((short)bm.Amount);
                        m_Stream.Write((short)bm.Amount);

                        m_Stream.Write((short)(bm.X & 0x7FFF));
                        m_Stream.Write((short)(bm.Y & 0x3FFF));
                        m_Stream.Write((sbyte)bm.Z);

                        m_Stream.Write((byte)bm.Light);
                        m_Stream.Write((short)bm.Hue);
                        m_Stream.Write((byte)bm.GetPacketFlags());
                    }
                    else if (ent is Mobile)
                    {
                        Mobile m = (Mobile)ent;

                        m_Stream.Write((byte)0x01);
                        m_Stream.Write((int)m.Serial);
                        m_Stream.Write((short)m.Body);
                        m_Stream.Write((byte)0);

                        m_Stream.Write((short)1);
                        m_Stream.Write((short)1);

                        m_Stream.Write((short)(m.X & 0x7FFF));
                        m_Stream.Write((short)(m.Y & 0x3FFF));
                        m_Stream.Write((sbyte)m.Z);

                        m_Stream.Write((byte)m.Direction);
                        m_Stream.Write((short)m.Hue);
                        m_Stream.Write((byte)m.GetPacketFlags());
                    }
                    else if (ent is Item)
                    {
                        Item item = (Item)ent;

                        m_Stream.Write((byte)0x00);
                        m_Stream.Write((int)item.Serial);
                        m_Stream.Write((ushort)(item.ItemID & 0xFFFF));
                        m_Stream.Write((byte)0);

                        m_Stream.Write((short)item.Amount);
                        m_Stream.Write((short)item.Amount);

                        m_Stream.Write((short)(item.X & 0x7FFF));
                        m_Stream.Write((short)(item.Y & 0x3FFF));
                        m_Stream.Write((sbyte)item.Z);

                        m_Stream.Write((byte)item.Light);
                        m_Stream.Write((short)item.Hue);
                        m_Stream.Write((byte)item.GetPacketFlags());
                    }

                    m_Stream.Write((short)0x00);
                    ++count;
                }

                m_Stream.Seek(3, System.IO.SeekOrigin.Begin);
                m_Stream.Write((short)count);
            }
			public static ArrayList BOATMOBILES(TriggerObject trigObject, BaseBoat boat, bool deadOnly)
			{
				return boat != null
						   ? new ArrayList(boat.GetMovingEntities().OfType<Mobile>().Where(m => !deadOnly || !m.Alive).ToArray())
						   : new ArrayList();
			}
			public static bool INBOAT(TriggerObject trigObject, BaseBoat boat, IEntity testEntity)
			{
				return boat != null && boat.GetMovingEntities().Any(entity => entity == testEntity);
			}
Exemple #5
0
            public DisplayBoatHS(BaseBoat boat) : base(0xF7)
            {
                List<ISpawnable> ents = boat.GetMovingEntities();

                EnsureCapacity(5 + ents.Count * 26);
                m_Stream.Write((short)ents.Count);

                new WorldItemHS(boat, m_Stream);

                for (int i = 0; i < ents.Count; i++)
                {
                    if (ents[i] is Item)
                        new WorldItemHS((Item)ents[i], m_Stream);
                    else if (ents[i] is Mobile)
                        new WorldItemHS((Mobile)ents[i], m_Stream);
                }
            }