/// <summary>
        /// Determines if the mounter can mount the accessory to the specified location based on the accessory's
        /// current state and without violating the coverage restrictions.
        /// </summary>
        /// <remarks>
        /// <para>
        /// This method implements the standard method for this check, including all appropriate null checks.
        /// (E.g. If there is no accessory, it will return false.)
        /// </para>
        /// <para>
        /// The coverage restrictions are violated if a successful mount will result in a coverage that overlaps
        /// <paramref name="restrictions"/>.
        /// </para>
        /// </remarks>
        /// <param name="accessory">The accessory. (Optional)</param>
        /// <param name="mounter">The mounter. (Optional)</param>
        /// <param name="location">The mount location. (Optional)</param>
        /// <param name="restrictions">The body coverage restrictions.</param>
        /// <returns>
        /// True if accessory, mounter, and location are all non-null and the mounter can mount the accessory to the
        /// specified location with the coverage restrictions.
        /// </returns>
        public static bool CanMount(
            Accessory accessory, IAccessoryMounter mounter, MountPoint location, BodyCoverage restrictions)
        {
            if (accessory && location && !LizUtil.IsUnityDestroyed(mounter) &&
                (mounter.GetCoverageFor(location) & restrictions) == 0)
            {
                return(mounter.CanMount(accessory, location));
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Performs the first update on the mounter and takes the appropriate action if it completes or needs
        /// more updates.
        /// </summary>
        private void RunMounter(IAccessoryMounter mounter, GameObject owner, MountPoint location,
                                BodyCoverage additionalCoverage)
        {
            CleanupCurrentState();

            int id = m_MounterId + 1;

            m_MounterId = id;

            m_CurrentCoverage = mounter.GetCoverageFor(location.LocationType) | additionalCoverage;

            if (mounter.UpdateMount(this, location, !Application.isPlaying))
            {
                StartCoroutine(DoDurationMount(mounter, owner, location));
            }
            else
            {
                SetState(AccessoryStatus.Mounted, owner, location);
            }
        }