Esempio n. 1
0
        /// <summary>
        /// See <see cref="IBodyAccessoryManager"/> documentation.
        /// </summary>
        public bool Remove(Accessory accessory)
        {
            if (!accessory)
            {
                return(false);
            }

            for (int i = 0; i < m_Items.Count; i++)
            {
                var mountInfo = m_Items[i];

                if (mountInfo.Accessory == accessory)
                {
                    var wasMounted = mountInfo.Accessory.Status.IsMounted();

                    UnlinkAccessory(i, true);
                    accessory.Release();  // Keep it simple.  Let the event do the cleanup.

                    if (wasMounted && m_AutoRetryStored)
                    {
                        TryToMountStored(null);
                    }

                    return(true);
                }
            }

            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// Removes the accessory from management, unmounting as needed.
        /// </summary>
        /// <remarks>
        /// <para>
        /// There are vaious reasons why an accessory that was added isn't recognized by the
        /// remove operation.  Some examples:  The accessory may have unmounted itself or been
        /// unmounted directly through the outfit. Outfit specific accessories are auto-removed
        /// when the outfit changes.
        /// </para>
        /// </remarks>
        /// <param name="accessory">The accessory to remove.</param>
        /// <param name="priorityMounter">
        /// The priority mounter to use if unmounting is required.  If non-null, this will
        /// override any value provided during the add operation.
        /// </param>
        /// <returns>
        /// True if accessory was removed, false if the accessory is unrecognized.
        /// </returns>
        public bool Remove(Accessory accessory)
        {
            if (!accessory)
            {
                return(false);
            }

            for (int i = 0; i < m_Items.Count; i++)
            {
                var mountInfo = m_Items[i];

                if (mountInfo.Accessory == accessory)
                {
                    var outfit = mountInfo.Outfit;

                    UnlinkAccessory(i);

                    if (outfit)
                    {
                        outfit.Release(accessory);  // Ignore failure.
                    }
                    else
                    {
                        accessory.Release();  // From storage.
                    }
                    return(true);
                }
            }

            return(false);
        }
        public sealed override bool Release(Accessory accessory)
        {
            if (UnlinkAccessory(accessory))
            {
                accessory.Release();
                SendUnmount(accessory);

                return(true);
            }

            return(false);
        }