public static bool CheckDoubleClick( this Item item, Mobile from, bool handle = true, bool allowDead = false, int range = 20, bool packOnly = false, bool inTrade = false, bool inDisplay = true, AccessLevel access = AccessLevel.Player) { if (item == null || item.Deleted || from == null || from.Deleted) { return(false); } if (from.AccessLevel < access) { if (handle) { from.SendMessage("You do not have sufficient access to use this item."); } return(false); } if (!from.CanSee(item)) { if (handle) { from.SendMessage("This item can't be seen."); item.OnDoubleClickCantSee(from); } return(false); } if (!item.IsAccessibleTo(from)) { if (handle) { item.OnDoubleClickNotAccessible(from); } return(false); } if (item.InSecureTrade && !inTrade) { if (handle) { item.OnDoubleClickSecureTrade(from); } return(false); } if (((item.Parent == null && !item.Movable && !item.IsLockedDown && !item.IsSecure && !item.InSecureTrade) || IsShopItem(item)) && !inDisplay) { if (handle) { from.SendMessage("This item can not be accessed because it is part of a display."); } return(false); } if (!from.Alive && !allowDead) { if (handle) { item.OnDoubleClickDead(from); } return(false); } if (range >= 0 && !from.InRange(item.GetWorldLocation(), range) && !packOnly) { if (handle) { if (range > 0) { from.SendMessage("You must be within {0:#,0} paces to use this item.", range); } else { from.SendMessage("You must be standing on this item to use it."); } item.OnDoubleClickOutOfRange(from); } return(false); } if (packOnly && item.RootParent != from) { if (handle) { // This item must be in your backpack. from.SendLocalizedMessage(1054107); } return(false); } return(true); }
public virtual void Use( Item item ) { if ( item == null || item.Deleted ) return; DisruptiveAction(); if ( m_Spell != null && !m_Spell.OnCasterUsingObject( item ) ) return; object root = item.RootParent; bool okay = false; if ( !Utility.InUpdateRange( this, item.GetWorldLocation() ) ) item.OnDoubleClickOutOfRange( this ); else if ( !CanSee( item ) ) item.OnDoubleClickCantSee( this ); else if ( !item.IsAccessibleTo( this ) ) { Region reg = Region.Find( item.GetWorldLocation(), item.Map ); if ( reg == null || !reg.SendInaccessibleMessage( item, this ) ) item.OnDoubleClickNotAccessible( this ); } else if ( !CheckAlive( false ) ) item.OnDoubleClickDead( this ); else if ( item.InSecureTrade ) item.OnDoubleClickSecureTrade( this ); else if ( !AllowItemUse( item ) ) okay = false; else if ( !item.CheckItemUse( this, item ) ) okay = false; else if ( root != null && root is Mobile && ((Mobile)root).IsSnoop( this ) ) item.OnSnoop( this ); else if ( m_Region.OnDoubleClick( this, item ) ) okay = true; if ( okay ) { if ( !item.Deleted ) item.OnItemUsed( this, item ); if ( !item.Deleted ) item.OnDoubleClick( this ); } }