/// <summary>
 /// Applies the specified settings.
 /// </summary>
 /// <param name="settings">The settings to apply.</param>
 public void Apply(AccessoryAddSettings settings)
 {
     m_IgnoreRestrictions = settings.IgnoreRestrictions;
     m_LocationType       = settings.LocationType;
     Mounter = settings.Mounter;
     m_AdditionalCoverage = settings.AdditionalCoverage;
 }
Ejemplo n.º 2
0
 public override MountResult ModifyAccessory(
     Accessory accessory, AccessoryAddSettings settings)
 {
     CheckAccessoriesInitialized();
     CheckNeedsSoftReset();
     return(m_Accessories.Modify(accessory, settings));
 }
Ejemplo n.º 3
0
 public override MountResult AddAccessory(
     Accessory accessory, AccessoryAddSettings settings, bool mustMount)
 {
     CheckAccessoriesInitialized();
     CheckNeedsSoftReset();
     return(m_Accessories.Add(accessory, settings, mustMount));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Mount the accessory to all outfits, or store it when the it can't be mounted.
        /// </summary>
        /// <param name="accessory">The accessory to add.</param>
        /// <param name="addSettings">The accessory mount settings.</param>
        /// <param name="mustMount">
        /// If true a failure to immediately mount will result in a failure to add.  Otherwise
        /// a failure to immeidately mount will result in the accessory being stored.
        /// </param>
        /// <returns>
        /// The result of the add operation.  (Will only ever be 'success' or 'failure'.)
        /// </returns>
        public MountResult Add(
            Accessory accessory, AccessoryAddSettings addSettings, bool mustMount = false)
        {
            if (!accessory)
            {
                Debug.LogError("Accessory is null.");
                return(MountResult.FailedOnError);
            }

            // Remember: Don't need to check mounter validity.  Settings setter does that.

            for (int i = 0; i < m_Items.Count; i++)
            {
                if (m_Items[i].Accessory && m_Items[i].Accessory == accessory)
                {
                    // This is an error.  Must use modify method to change configuration.
                    Debug.LogError("Accessory is already added: " + accessory.name, Owner);
                    return(MountResult.FailedOnError);
                }
            }

            MountResult status = MountResult.FailedOnError;

            var mountInfo = new AccessoryMountInfo();

            mountInfo.Accessory = accessory;
            mountInfo.Apply(addSettings);

            if (m_Outfit)
            {
                status = MountToOutfit(ref mountInfo);
            }
            else if (mustMount)
            {
                Debug.LogError("Must succeed failure.  No outfit: " + accessory.name, Owner);
                return(MountResult.FailedOnError);
            }

            bool isMounted = (status == MountResult.Success);

            if (!isMounted)
            {
                if (mustMount)
                {
                    Debug.LogErrorFormat(Owner,
                                         "Must succeed failure.  Failed to mount to outfit: Accessory: {0}, Status: {1}",
                                         accessory.name, status);

                    return(MountResult.FailedOnError);
                }

                StoreAccessory(ref mountInfo);
            }

            LinkAccessory(mountInfo);

            return(isMounted ? MountResult.Success : MountResult.Stored);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// See <see cref="IBodyAccessoryManager"/> documentation.
        /// </summary>
        public MountResult Modify(Accessory accessory, MountPointType locationType, bool ignoreRestrictions = false)
        {
            var settings = new AccessoryAddSettings();

            settings.IgnoreRestrictions = ignoreRestrictions;
            settings.LocationType       = locationType;

            return(Modify(accessory, settings));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// See <see cref="IBodyAccessoryManager"/> documentation.
        /// </summary>
        public MountResult Add(Accessory accessory, bool ignoreRestrictions = false, bool mustMount = false)
        {
            var settings = new AccessoryAddSettings();

            settings.IgnoreRestrictions = ignoreRestrictions;
            settings.LocationType       = accessory.DefaultLocationType;
            settings.Mounter            = null;
            settings.AdditionalCoverage = 0;

            return(Add(accessory, settings, mustMount));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Modify the settings for an existing accessory.  (Performs remounting as needed.)
        /// </summary>
        /// <remarks>
        /// <para>
        /// Will only perform a mount if the mount location of the accessory has changed.
        /// </para>
        /// <para>
        /// A failure to mount, when needed, will result in a transition to storage.  All other errors will
        /// result in no change to the accessory's state, so an accessory will never be discarded by a failed
        /// modify.
        /// </para>
        /// </remarks>
        /// <param name="accessory">The accessory to change.</param>
        /// <param name="addSettings">The new settings for the accessory.</param>
        /// <returns>The result of the modification.</returns>
        public MountResult Modify(Accessory accessory, AccessoryAddSettings addSettings)
        {
            if (!accessory)
            {
                Debug.LogError("Can't modify a null accessory.", Owner);
                return(MountResult.FailedOnError);
            }

            // Remember: Don't need to check mounter validity.  Settings setter does that.

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

                if (mountInfo.Accessory && mountInfo.Accessory == accessory)
                {
                    /*
                     * Design note:
                     *
                     * There can be lots of reasons for modifying an accessory, some of which don't need/want a
                     * re-mount.  But it is better to keep it simple.  All modify calls for a mounted accessory
                     * result in a remount.)
                     */

                    mountInfo.Apply(addSettings);

                    if (m_Outfit)
                    {
                        if (MountToOutfit(ref mountInfo) != MountResult.Success)
                        {
                            StoreAccessory(ref mountInfo);
                        }
                    }
                    // else it is already in storage.

                    m_Items[i] = mountInfo;

                    return(mountInfo.Outfit ? MountResult.Success : MountResult.Stored);
                }
            }

            Debug.LogError("Attempt made to modify an unknown accessory: " + accessory.name, Owner);
            return(MountResult.FailedOnError);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Modify and remount the accessory.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The most common reason for modifying an accessory is to mount it to a new location.  Modifying any
 /// setting will result in a remount attempt.  <strong>Any</strong> failure to mount will result in the
 /// accessory being stored.
 /// </para>
 /// <para>
 /// This method will return only 'success', 'stored', or 'failed on error'.  If an error is returned then
 /// the settings were rejected and the accessory remains unchanged.
 /// </para>
 /// </remarks>
 /// <param name="accessory">The accessory to modify.</param>
 /// <param name="settings">The new settings.</param>
 /// <returns>The result of the modification.</returns>
 public abstract MountResult ModifyAccessory(Accessory accessory, AccessoryAddSettings settings);
Ejemplo n.º 9
0
        ////////////////////////////////////////////////////////////////////////////////////////////
        // HACK: Unity 5.3.1: Workaround for Mono's optional parameter key duplication bug.

        /// <summary>
        /// Add an accessory that will persist between outfits or be stored if there is no outfit the accessory
        /// can mount to.
        /// </summary>
        /// <remarks>
        /// <para>
        /// A persistant accessory will be mounted to all outfits that accept the accessory.  Otherwise it will
        /// be stored for later mounting.
        /// </para>
        /// <para>This method will return only three results: 'success', 'stored', and 'failed on error'.  This is
        /// because a non-error failure to mount results in storage.</para>
        /// </remarks>
        /// <param name="accessory">The accessory to add.</param>
        /// <param name="settings">The accessory settings.</param>
        /// <returns>The result of the add operation.</returns>
        public MountResult AddAccessory(Accessory accessory, AccessoryAddSettings settings)
        {
            return(AddAccessory(accessory, settings, false));
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Add an accessory that will persist between outfits or be stored if there is no outfit the accessory
 /// can mount to.
 /// </summary>
 /// <remarks>
 /// <para>
 /// A persistant accessory will be mounted to all outfits that accept the accessory.  Otherwise it will
 /// be stored for later mounting.
 /// </para>
 /// <para>This method will return only three results: 'success', 'stored', and 'failed on error'.  This is
 /// because a non-error failure to mount results in storage.</para>
 /// </remarks>
 /// <param name="accessory">The accessory to add.</param>
 /// <param name="settings">The accessory settings.</param>
 /// <param name="mustMount">
 /// True if a failure to immediately mount to an outfit is considered a failure.  Otherwise a non-error
 /// failure to mount will result in the accessory being stored for a later attempt.
 /// </param>
 /// <returns>The result of the add operation.</returns>
 public abstract MountResult AddAccessory(Accessory accessory, AccessoryAddSettings settings, bool mustMount);
Ejemplo n.º 11
0
        /// <summary>
        /// See <see cref="IBodyAccessoryManager"/> documentation.
        /// </summary>
        public MountResult Modify(Accessory accessory, AccessoryAddSettings settings)
        {
            if (!accessory)
            {
                Debug.LogError("Can't modify a null accessory.", this);
                return(MountResult.FailedOnError);
            }

            // Remember: Don't need to check mounter validity.  Settings did that.
            var  status         = MountResult.FailedOnError;
            bool tryMountStored = false;

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

                if (mountInfo.Accessory && mountInfo.Accessory == accessory)
                {
                    /*
                     * Design note:
                     *
                     * There can be lots of reasons for modifying an accessory, some of which don't need/want a
                     * re-mount.  But it is better to keep it simple.  All modify calls result in a mount call.)
                     */

                    bool wasMounted = mountInfo.Accessory.Status.IsMounted();

                    mountInfo.Apply(settings);

                    if (m_Outfit)
                    {
                        if (MountToOutfit(ref mountInfo) != MountResult.Success)
                        {
                            StoreAccessory(ref mountInfo);
                        }
                    }
                    // else it is already in storage.

                    m_Items[i] = mountInfo;

                    status = mountInfo.Accessory.Status.IsMounted() ? MountResult.Success : MountResult.Stored;

                    if (wasMounted && m_AutoRetryStored && status == MountResult.Stored)
                    {
                        tryMountStored = true;
                    }
                    else
                    {
                        return(status);
                    }
                }
            }

            if (tryMountStored)
            {
                // Will only get here if there was no failure.
                TryToMountStored(accessory);
            }
            else
            {
                Debug.LogError("Attempt made to modify an unknown accessory: " + accessory.name, this);
            }

            return(status);
        }