Exemplo n.º 1
0
 public DeferredEntity(AEntity entity, Vector3 drawPosition, int z)
     : base(entity.Serial, entity.Map)
 {
     m_BaseView = GetBaseView(entity);
     m_DrawPosition = drawPosition;
     Position.Set(int.MinValue, int.MinValue, z);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the passed entity to this Tile's entity collection, and forces a resort of the entities on this tile.
        /// </summary>
        /// <param name="entity"></param>
        public void OnEnter(AEntity entity)
        {
            // only allow one ground object.
            if (entity is Ground)
            {
                if (Ground != null)
                    Ground.Dispose();
                Ground = (Ground)entity;
            }

            // if we are receiving a Item with the same position and itemID as a static item, then replace the static item.
            if (entity is Item)
            {
                Item item = entity as Item;
                for (int i = 0; i < m_Entities.Count; i++)
                {
                    if (m_Entities[i] is Item)
                    {
                        Item comparison = m_Entities[i] as Item;
                        if (comparison.ItemID == item.ItemID &&
                            comparison.Z == item.Z)
                        {
                            m_Entities.RemoveAt(i);
                            i--;
                        }
                    }
                }
            }

            m_Entities.Add(entity);
            m_NeedsSorting = true;
        }
Exemplo n.º 3
0
 public DeferredEntity(AEntity entity, Vector3 drawPosition, int z)
     : base(entity.Serial, entity.Map)
 {
     m_BaseView     = GetBaseView(entity);
     m_DrawPosition = drawPosition;
     Position.Set(int.MinValue, int.MinValue, z);
 }
Exemplo n.º 4
0
 public DeferredEntity(AEntity entity, Vector3 drawPosition, int z)
     : base(entity.Serial, entity.Map)
 {
     m_BaseView     = GetBaseView(entity);
     m_DrawPosition = drawPosition;
     m_Z            = z;
 }
Exemplo n.º 5
0
 private AEntityView GetBaseView(AEntity entity)
 {
     if (entity is Mobile)
     {
         return((MobileView)entity.GetView());
     }
     else if (entity is Corpse)
     {
         return((MobileView)entity.GetView());
     }
     else if (entity is LightningEffect)
     {
         return((LightningEffectView)entity.GetView());
     }
     else if (entity is AnimatedItemEffect)
     {
         return((AnimatedItemEffectView)entity.GetView());
     }
     else if (entity is MovingEffect)
     {
         return((MovingEffectView)entity.GetView());
     }
     else
     {
         Tracer.Critical("Cannot defer this type of object.");
     }
     return(null);
 }
Exemplo n.º 6
0
        public static int Compare(AEntity x, AEntity y)
        {
            int xZ, xType, xThreshold, xTiebreaker;
            int yZ, yType, yThreshold, yTiebreaker;

            GetSortValues(x, out xZ, out xType, out xThreshold, out xTiebreaker);
            GetSortValues(y, out yZ, out yType, out yThreshold, out yTiebreaker);

            xZ += xThreshold;
            yZ += yThreshold;

            int comparison = xZ - yZ;
            if (comparison == 0)
            {
                comparison = xType - yType;
            }
            if (comparison == 0)
            {
                comparison = xThreshold - yThreshold;
            }
            if (comparison == 0)
            {
                comparison = xTiebreaker - yTiebreaker;
            }
            return comparison;
        }
Exemplo n.º 7
0
 public DeferredEntity(AEntity entity, Vector3 drawPosition, int z)
     : base(entity.Serial, entity.Map)
 {
     m_BaseView = GetBaseView(entity);
     m_DrawPosition = drawPosition;
     m_Z = z;
 }
Exemplo n.º 8
0
        public VendorBuyGump(AEntity vendorBackpack, VendorBuyListPacket packet)
            : base(0, 0)
        {
            // sanity checking: don't show buy gumps for empty containers.
            if (!(vendorBackpack is Container) || ((vendorBackpack as Container).Contents.Count <= 0) || (packet.Items.Count <= 0))
            {
                Dispose();
                return;
            }

            IsMoveable = true;
            // note: original gumplings start at index 0x0870.
            AddControl(m_Background = new ExpandableScroll(this, 0, 0, 360, false));
            AddControl(new HtmlGumpling(this, 0, 6, 300, 20, 0, 0, " <center><span color='#004' style='font-family:uni0;'>Shop Inventory"));

            m_ScrollBar = (IScrollBar)AddControl(new ScrollFlag(this));
            AddControl(m_ShopContents = new RenderedTextList(this, 22, 32, 250, 260, m_ScrollBar));
            BuildShopContents(vendorBackpack, packet);

            AddControl(m_TotalCost = new HtmlGumpling(this, 44, 334, 200, 30, 0, 0, string.Empty));
            UpdateCost();

            Button okButton = (Button)AddControl(new Button(this, 220, 333, 0x907, 0x908, ButtonTypes.Activate, 0, 0));
            okButton.GumpOverID = 0x909;
            okButton.MouseClickEvent += okButton_MouseClickEvent;
        }
Exemplo n.º 9
0
        public static int Compare(AEntity x, AEntity y)
        {
            int x_z;
            int x_threshold;
            int x_type;
            int x_tiebreaker;
            int y_z;
            int y_threshold;
            int y_type;
            int y_tiebreaker;

            GetSortValues(x, out x_z, out x_threshold, out x_type, out x_tiebreaker);
            GetSortValues(y, out y_z, out y_threshold, out y_type, out y_tiebreaker);

            x_z += x_threshold;
            y_z += y_threshold;

            int comparison = x_z - y_z;
            if (comparison == 0)
            {
                comparison = x_type - y_type;
            }
            if (comparison == 0)
            {
                comparison = x_threshold - y_threshold;
            }
            if (comparison == 0)
            {
                comparison = x_tiebreaker - y_tiebreaker;
            }
            return comparison;
        }
Exemplo n.º 10
0
        // ======================================================================
        // Public methods and properties: ctr, update, draw
        // ======================================================================

        public MobileView(AEntity entity)
            : base(entity)
        {
            m_MobileLayers = new MobileViewLayer[(int)EquipLayer.LastUserValid];
            PickType = PickType.PickObjects;

            IsShadowCastingView = true;
        }
Exemplo n.º 11
0
 public static void GetSortValues(AEntity e, out int z, out int type, out int threshold, out int tiebreaker)
 {
     if (e is AEffect)
     {
         AEffect effect = e as AEffect;
         z = effect.Z;
         type = 4;
         threshold = 2;
         tiebreaker = 0;
     }
     else if (e is DeferredEntity)
     {
         DeferredEntity mobile = (DeferredEntity)e;
         z = mobile.Z;
         type = 2;
         threshold = 1;
         tiebreaker = 0;
     }
     else if (e is Mobile)
     {
         Mobile mobile = (Mobile)e;
         z = mobile.Z;
         type = mobile.IsSitting ? 0 : 3;
         threshold = 2;
         tiebreaker = mobile.IsClientEntity ? 0x40000000 : (int)mobile.Serial;
     }
     else if (e is Ground)
     {
         Ground tile = (Ground)e;
         z = tile.GetView().SortZ;
         type = 0;
         threshold = 0;
         tiebreaker = 0;
     }
     else if (e is StaticItem)
     {
         StaticItem item = (StaticItem)e;
         z = item.Z;
         type = 1;
         threshold = (item.ItemData.Height > 0 ? 1 : 0) + (item.ItemData.IsBackground ? 0 : 1);
         tiebreaker = item.SortInfluence;
     }
     else if (e is Item)
     {
         Item item = (Item)e;
         z = item.Z;
         type = ((item.ItemID & 0x3fff) == 0x2006) ? 4 : 2; // corpses show on top of mobiles and items.
         threshold = (item.ItemData.Height > 0 ? 1 : 0) + (item.ItemData.IsBackground ? 0 : 1);
         tiebreaker = item.Serial;
     }
     else
     {
         z = 0;
         threshold = 0;
         type = 0;
         tiebreaker = 0;
     }
 }
Exemplo n.º 12
0
        public Overhead(AEntity parent, MessageTypes msgType, string text)
            : base(parent.Serial, parent.Map)
        {
            Parent = parent;
            MessageType = msgType;
            Text = text;

            m_TimePersist = 5000;
        }
Exemplo n.º 13
0
        public Overhead(AEntity parent, MessageTypes msgType, string text)
            : base(parent.Serial, parent.Map)
        {
            Parent      = parent;
            MessageType = msgType;
            Text        = text;

            m_TimePersist = 5000;
        }
Exemplo n.º 14
0
 internal void UpdateEntity(AEntity entity)
 {
     if (m_Entity == null || m_Entity != entity || m_PropertyListHash != m_Entity.PropertyList.Hash)
     {
         m_Entity = entity;
         m_PropertyListHash = m_Entity.PropertyList.Hash;
         Caption = m_Entity.PropertyList.Properties;
     }
 }
Exemplo n.º 15
0
        public ContainerGump(AEntity containerItem, int gumpID)
            : base(containerItem.Serial, 0)
        {
            m_data = ContainerData.GetData(gumpID);
            m_item = (Container)containerItem;
            m_item.OnContentsUpdated += OnItemContentsUpdate;

            IsMoveable = true;

            AddControl(new GumpPicContainer(this, 0, 0, m_data.GumpID, 0, m_item));
        }
Exemplo n.º 16
0
 public TargetObjectPacket(AEntity entity, int cursorID)
     : base(0x6C, "Target Object", 19)
 {
     Stream.Write((byte)0x00); // BYTE[1] type: 0x00 = Select Object; 0x01 = Select X, Y, Z
     Stream.Write((int)cursorID); // BYTE[4] cursorID
     Stream.Write((byte)0x00); // BYTE[1] Cursor Type; 3 to cancel.
     Stream.Write((int)entity.Serial); // BYTE[4] Clicked On ID. Not used in this packet.
     Stream.Write((short)entity.X); // BYTE[2] click xLoc
     Stream.Write((short)entity.Y); // BYTE[2] click yLoc
     Stream.Write((byte)0x00); // BYTE unknown (0x00)
     Stream.Write((byte)entity.Z); // BYTE click zLoc
     Stream.Write((short)0); // BYTE[2] model # (if a static tile, 0 if a map/landscape tile)
 }
Exemplo n.º 17
0
        public Overhead(AEntity parent, MessageTypes msgType, string text)
            : base(parent.Serial, parent.Map)
        {
            Parent = parent;
            MessageType = msgType;
            Text = text;

            string plainText = text.Substring(text.IndexOf('>') + 1);

            // Every speech message lasts at least 2.5s, and increases by 100ms for every char, to a max of 10s
            m_TimePersist = 2500 + (plainText.Length * 100);
            if (m_TimePersist > 10000)
                m_TimePersist = 10000;
        }
Exemplo n.º 18
0
 private AEntityView GetBaseView(AEntity entity)
 {
     if (entity is Mobile)
         return (MobileView)entity.GetView();
     else if (entity is LightningEffect)
         return (LightningEffectView)entity.GetView();
     else if (entity is AnimatedItemEffect)
         return (AnimatedItemEffectView)entity.GetView();
     else if (entity is MovingEffect)
         return (MovingEffectView)entity.GetView();
     else
         Tracer.Critical("Cannot defer this type of object.");
     return null;
 }
Exemplo n.º 19
0
        public Overhead(AEntity parent, MessageTypes msgType, string text)
            : base(parent.Serial, parent.Map)
        {
            Parent      = parent;
            MessageType = msgType;
            Text        = text;

            string plainText = text.Substring(text.IndexOf('>') + 1);

            // Every speech message lasts at least 2.5s, and increases by 100ms for every char, to a max of 10s
            m_TimePersist = 2500 + (plainText.Length * 100);
            if (m_TimePersist > 10000)
            {
                m_TimePersist = 10000;
            }
        }
Exemplo n.º 20
0
        void mouseTargetingEventObject(AEntity selectedEntity)
        {
            // If we are passed a null object, keep targeting.
            if (selectedEntity == null)
                return;
            Serial serial = selectedEntity.Serial;
            // Send the targetting event back to the server
            if (serial.IsValid)
            {
                m_Network.Send(new TargetObjectPacket(selectedEntity, m_TargetID));
            }
            else
            {
                int modelNumber = 0;
                if (selectedEntity is StaticItem)
                {
                    modelNumber = ((StaticItem)selectedEntity).ItemID;
                }
                else
                {
                    modelNumber = 0;
                }
                m_Network.Send(new TargetXYZPacket((short)selectedEntity.Position.X, (short)selectedEntity.Position.Y, (short)selectedEntity.Z, (ushort)modelNumber, m_TargetID));
            }

            // Clear our target cursor.
            ClearTargetingWithoutTargetCancelPacket();
        }
Exemplo n.º 21
0
 private void MergeHeldItem(AEntity target)
 {
     m_Network.Send(new DropItemPacket(HeldItem.Serial, 0xFFFF, 0xFFFF, 0, 0, target.Serial));
     ClearHolding();
 }
Exemplo n.º 22
0
        private void onInteractButton(InputEventMouse e, AEntity overEntity, Vector2 overEntityPoint)
        {
            if(e.EventType == MouseEvent.Down)
            {
                // prepare to pick this item up.
                m_DraggingEntity = overEntity;
                m_dragOffset = overEntityPoint;
            }
            else if(e.EventType == MouseEvent.Click)
            {
                if(overEntity is Ground)
                {
                    // no action.
                }
                else if(overEntity is StaticItem)
                {
                    // pop up name of item.
                    overEntity.AddOverhead(MessageTypes.Label, "<outline>" + overEntity.Name, 0, 0);
                    WorldModel.Statics.AddStaticThatNeedsUpdating(overEntity as StaticItem);
                }
                else if(overEntity is Item)
                {
                    // request context menu
                    World.Interaction.SingleClick(overEntity);
                }
                else if(overEntity is Mobile)
                {
                    // request context menu
                    World.Interaction.SingleClick(overEntity);
                }
            }
            else if(e.EventType == MouseEvent.DoubleClick)
            {
                if(overEntity is Ground)
                {
                    // no action.
                }
                else if(overEntity is StaticItem)
                {
                    // no action.
                }
                else if(overEntity is Item)
                {
                    // request context menu
                    World.Interaction.DoubleClick(overEntity);
                }
                else if(overEntity is Mobile)
                {
                    // Send double click packet.
                    // Set LastTarget == targeted Mobile.
                    // If in WarMode, set Attacking == true.
                    World.Interaction.DoubleClick(overEntity);
                    World.Interaction.LastTarget = overEntity.Serial;

                    if (WorldModel.Entities.GetPlayerEntity().Flags.IsWarMode)
                    {
                        m_Network.Send(new AttackRequestPacket(overEntity.Serial));
                    }
                }
            }
            else if(e.EventType == MouseEvent.DragBegin)
            {
                if(overEntity is Ground)
                {
                    // no action.
                }
                else if(overEntity is StaticItem)
                {
                    // no action.
                }
                else if(overEntity is Item)
                {
                    // attempt to pick up item.
                    World.Interaction.PickupItem((Item)overEntity, new Point((int)m_dragOffset.X, (int)m_dragOffset.Y));
                }
                else if(overEntity is Mobile)
                {
                    // drag off a status gump for this mobile.
                    MobileHealthTrackerGump gump = new MobileHealthTrackerGump(overEntity as Mobile);
                    m_UserInterface.AddControl(gump, e.X - 77, e.Y - 30);
                    m_UserInterface.AttemptDragControl(gump, new Point(e.X, e.Y), true);
                }
            }

            e.Handled = true;
        }
Exemplo n.º 23
0
 private void InternalQueueSingleClick(InputEventMouse e, AEntity overEntity, Vector2 overEntityPoint)
 {
     m_QueuedEvent_InQueue = true;
     m_QueuedEntity = overEntity;
     m_QueuedEntityPosition = overEntityPoint;
     m_QueuedEvent_DequeueAt = Settings.World.Mouse.DoubleClickMS;
     m_QueuedEvent = e;
 }
Exemplo n.º 24
0
 private void ClearQueuedClick()
 {
     m_QueuedEvent_InQueue = false;
     m_QueuedEvent = null;
     m_QueuedEntity = null;
 }
Exemplo n.º 25
0
        // used by ultimaclient.
        public Gump OpenContainerGump(AEntity entity)
        {
            Gump gump;
            if ((gump = (Gump)m_UserInterface.GetControl(entity.Serial)) != null)
            {
                gump.Dispose();
            }
            else
            {

                if (entity is Corpse)
                {
                    gump = new ContainerGump(entity, 0x2006);
                    m_UserInterface.AddControl(gump, 96, 96);
                }
                else if (entity is SpellBook)
                {
                    gump = new SpellbookGump((SpellBook)entity, ((Container)entity).ItemID);
                    m_UserInterface.AddControl(gump, 96, 96);
                }
                else
                {
                    gump = new ContainerGump(entity, ((Container)entity).ItemID);
                    m_UserInterface.AddControl(gump, 64, 64);
                }
            }
            return gump;
        }
Exemplo n.º 26
0
 public AEntityView(AEntity entity)
 {
     m_Entity = entity;
     SortZ = Entity.Z;
 }
Exemplo n.º 27
0
 internal MouseOverItem(Point inTexturePoint, AEntity entity)
 {
     InTexturePoint = inTexturePoint;
     Entity = entity;
 }
Exemplo n.º 28
0
 void mouseTargetingEventXYZ(AEntity selectedEntity)
 {
     // Send the targetting event back to the server!
     int modelNumber = 0;
     if (selectedEntity is StaticItem)
     {
         modelNumber = ((StaticItem)selectedEntity).ItemID;
     }
     else
     {
         modelNumber = 0;
     }
     // Send the target ...
     m_Network.Send(new TargetXYZPacket((short)selectedEntity.Position.X, (short)selectedEntity.Position.Y, (short)selectedEntity.Z, (ushort)modelNumber, m_TargetID));
     // ... and clear our targeting cursor.
     ClearTargetingWithoutTargetCancelPacket();
 }
Exemplo n.º 29
0
        private void BuildShopContents(AEntity vendorBackpack, VendorBuyListPacket packet)
        {
            if (!(vendorBackpack is Container))
            {
                m_ShopContents.AddEntry("<span color='#800'>Err: vendorBackpack is not Container.");
                return;
            }

            Container contents = (vendorBackpack as Container);
            AEntity vendor = contents.Parent;
            if (vendor == null || !(vendor is Mobile))
            {
                m_ShopContents.AddEntry("<span color='#800'>Err: vendorBackpack item does not belong to a vendor Mobile.");
                return;
            }
            m_VendorSerial = vendor.Serial;

            m_Items = new VendorItemInfo[packet.Items.Count];

            for (int i = 0; i < packet.Items.Count; i++)
            {
                Item item = contents.Contents[packet.Items.Count - 1 - i];
                if (item.Amount > 0)
                {
                    string cliLocAsString = packet.Items[i].Description;
                    int price = packet.Items[i].Price;

                    int clilocDescription;
                    string description;
                    if (!(int.TryParse(cliLocAsString, out clilocDescription)))
                    {
                        description = cliLocAsString;
                    }
                    else
                    {
                        // get the resource provider
                        IResourceProvider provider = ServiceRegistry.GetService<IResourceProvider>();
                        description = Utility.CapitalizeAllWords(provider.GetString(clilocDescription));
                    }

                    string html = string.Format(c_Format, description, price.ToString(), item.DisplayItemID, item.Amount, i);
                    m_ShopContents.AddEntry(html);

                    m_Items[i] = new VendorItemInfo(item, description, price, item.Amount);
                }
            }

            // list starts displaying first item.
            m_ScrollBar.Value = 0;
        }
Exemplo n.º 30
0
 public LightningEffect(Map map, AEntity Source, int hue)
     : this(map, hue)
 {
     SetSource(Source);
 }
Exemplo n.º 31
0
 internal void UpdateCaption(string caption)
 {
     m_Entity = null;
     Caption = caption;
 }
Exemplo n.º 32
0
 // used by itemgumpling, paperdollinteractable, topmenu, worldinput.
 public void DoubleClick(AEntity item)
 {
     if (item!=null)
         m_Network.Send(new DoubleClickPacket(item.Serial));
 }
Exemplo n.º 33
0
 // used by itemgumpling, paperdollinteractable, topmenu, worldinput.
 public void DoubleClick(AEntity e)
 {
     if (e != null)
         m_Network.Send(new DoubleClickPacket(e.Serial));
 }
Exemplo n.º 34
0
 /// <summary>
 /// Informs the server we have single-clicked on an entity. Also requests a context menu.
 /// </summary>
 /// <param name="item">The entity clicked on.</param>
 public void SingleClick(AEntity item)
 {
     m_Network.Send(new SingleClickPacket(item.Serial));
     m_Network.Send(new RequestContextMenuPacket(item.Serial));
 }
Exemplo n.º 35
0
 /// <summary>
 /// For items, if server.expansion is less than AOS, sends single click packet.
 /// For mobiles, always sends a single click.
 /// Requests a context menu regardless of version.
 /// </summary>
 public void SingleClick(AEntity e)
 {
     if (!PlayerState.ClientFeatures.TooltipsEnabled)
     {
         m_Network.Send(new SingleClickPacket(e.Serial));
     }
     m_Network.Send(new RequestContextMenuPacket(e.Serial));
 }