/// <summary> /// Applies the information values to the settings. /// </summary> /// <param name="settings">The infomration values to apply.</param> public void Apply(AccessoryMountInfo info) { LocationType = info.LocationType; IgnoreRestrictions = info.IgnoreRestrictions; Mounter = info.Mounter; // Use property. AdditionalCoverage = info.AdditionalCoverage; }
/// <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; }
/// <summary> /// Performs cleanups of settings unique to the current state. /// (Call before all state transitions.) /// </summary> private void CleanupCurrentState() { // Remember, transition is out of the current state. switch (Status) { case AccessoryStatus.Stored: if (m_UseDefaultStorage) { gameObject.SetActive(true); } break; case AccessoryStatus.Mounted: case AccessoryStatus.Mounting: m_CurrentCoverage = 0; if (!LizittUtil.IsUnityDestroyed(m_CurrentMounter)) // Is mounting. { m_CurrentMounter.CancelMount(this, CurrentLocation); m_CurrentMounter = null; } break; } }
/// <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); }
/// <summary> /// Performs a <see cref="IAccessoryMounter.CanMount"/> check on the mounters and returns the index of the /// first one that returns true, or -1 if none was found. /// </summary> /// <param name="accessory">The accessory. (Required)</param> /// <param name="location">The location.</param> /// <param name="restrictions">The body converage restrictions.</param> /// <returns>The index of the mounter than can mount the accessory, or -1 if none was found.</returns> public int CanMount(Accessory accessory, MountPoint location, BodyCoverage restrictions) { for (int i = 0; i < Count; i++) { if (Accessory.CanMount(accessory, this[i], location, restrictions)) { return(i); } } return(-1); }
public sealed override bool CanMount(MountPointType locationType, BodyCoverage restrictions) { if (m_UseDefaultMounter) { return(true); } if (Accessory.CanMount(this, PriorityMounter, locationType, restrictions)) { return(true); } return(m_Mounters.CanMount(this, locationType, restrictions) != -1); }
public sealed override bool CanMount(MountPoint location, BodyCoverage restrictions) { if (!location) { return(false); } if (Accessory.CanMount(this, PriorityMounter, location, restrictions)) { return(true); } return(m_Mounters.CanMount(this, location, restrictions) != -1); }
/// <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); } }
/// <summary> /// Mount the accessory to the specified mount point. /// </summary> /// <remarks> /// <para> /// This method is guarenteed to return true if <see cref="CanMount"/> returns true. /// But it is valid to use a call to this method without pre-checking mountability. E.g. As an optimitation, /// it is valid to simply call this method on a list of all available accessories to let the accessory /// decide whether or not it can attach /// </para> /// <para> /// <paramref name="additionalCoverage"/> is useful in when an accessory uses a generic mounter that doesn't /// provide coverage information. /// </para> /// <para> /// Mount priority is as follows: The priority mounter supplied by the mount method, /// the mounter provided by <see cref="GetInitializedMounter"/>, <see cref="MountInternal"/> if /// <see cref="CanMountInteral"/> is true. <see cref="MountInternal"/> only supports immediate completion /// mounting. /// </para> /// </remarks> /// <param name="location">The mount location. (Required)</param> /// <param name="owner"> /// The object that will own the accessory after a successful mount. (Required) /// </param> /// <param name="priorityMounter"> /// The mounter to attempt before any others are tried. (I.e. A custom mounter.) /// </param> /// <param name="additionalCoverage"> /// Additional coverage to apply on a successful mount, above and beyond the coverage /// supplied by the mounter or built into the accessory. /// </param> /// <returns>True if the mount succeeded, otherwise false.</returns> public sealed override bool Mount(MountPoint location, GameObject owner, IAccessoryMounter priorityMounter, BodyCoverage additionalCoverage) { // While not expected to be common, it is technically ok to re-attach to the same // mount location. So there is no optimization check for that. if (!(location && owner)) { Debug.LogError("Null mount location and/or owner.", this); return(false); } ; if (!LizittUtil.IsUnityDestroyed(priorityMounter) && priorityMounter.InitializeMount(this, location)) { RunMounter(priorityMounter, owner, location, additionalCoverage); return(true); } var mounter = GetInitializedMounter(location, owner); if (!LizittUtil.IsUnityDestroyed(mounter)) { RunMounter(mounter, owner, location, additionalCoverage); return(true); } if (CanMountInternal(location, owner)) { CleanupCurrentState(); m_CurrentCoverage = MountInternal(location, owner) | additionalCoverage; SetState(AccessoryStatus.Mounted, owner, location); return(true); } return(false); }
//////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Mount the accessory to the specified location. /// </summary> /// <remarks> /// <para> /// This method will always succeed if <see cref="CanMount(MountPoint, BodyCoverage)"/> returns true. /// </para> /// <para> /// Supports lazy calling. E.g. As an optimitation it is valid to simply call this method on a list of /// available accessories and let each accessory decide whether or not it can mount. /// </para> /// <para> /// <paramref name="additionalCoverage"/> is useful in situations where an accessory uses a generic mounter /// that doesn't provide coverage information. On a successful mount the additional coverage will be /// added to the coverage supplied by the mounter and/or built into the accessory. /// </para> /// </remarks> /// <param name="location">The mount location. (Required)</param> /// <param name="owner">The object that will own the accessory after a successful mount. (Required)</param> /// <param name="priorityMounter">The mounter to attempt before any others are tried. (Optional) </param> /// <param name="additionalCoverage"> /// Additional coverage to apply on a successful mount, above and beyond the coverage supplied by the /// mounter and/or built into the accessory. (Optional) /// </param> /// <returns>True if the mount succeeded, otherwise false.</returns> public abstract bool Mount(MountPoint location, GameObject owner, IAccessoryMounter priorityMounter, BodyCoverage additionalCoverage);
/// <summary> /// True if the accessory can be mounted to the location without violating the specified coverage restrictions. /// </summary> /// <remarks> /// <para> /// When an accessory can mount to multiple locations it will often have different coverage for each /// location. In such cases, <paramref name="restrictions"/> allows the accessory to evaluate whether it /// should be mounted to a specific location. This method will return false if the accessory's coverage /// for the location overlaps with <paramref name="restrictions"/>. /// </para> /// </remarks> /// <param name="location">The desired location.</param> /// <param name="restrictions">Disallowed body coverage.</param> /// <returns> /// True if the accessory can mount to the specified location without violating the specified coverage /// restrictions. /// </returns> public abstract bool CanMount(MountPoint location, BodyCoverage restrictions);
private void ResetAccessorySettings() { m_Blocks = 0; }
/// <summary> /// Mount the accessory to the specified location. /// </summary> /// <remarks> /// <para> /// Remounting to a different or same location is allowed. If a remount fails the accessory will be /// released. This behavior is due to the multiple actors involved. E.g. The outfit, accessory, and /// possibly a mounter. The outfit can't guarentee behavior of all actors, so it implements a behavior that /// is consistant. /// </para> /// </remarks> /// <param name="accessory">The accessory to mount. (Required)</param> /// <param name="locationType">The location to mount the accessory to.</param> /// <param name="ignoreRestrictions"> /// If true, ignore coverage restrictions and the value of <see cref="AccessoriesLimited"/>. /// </param> /// <param name="priorityMounter"> /// The mounter that should be tried before any other mounters. (Optional) /// </param> /// <param name="additionalCoverage"> /// Coverage to add to the accessory if it is successfully mounted, above and beyond any coverage inherent /// iin the accessory and/or mounter. /// </param> /// <returns>The result of the mount attempt.</returns> public abstract MountResult Mount(Accessory accessory, MountPointType locationType, bool ignoreRestrictions, IAccessoryMounter priorityMounter, BodyCoverage additionalCoverage);
public sealed override MountResult Mount(Accessory accessory, MountPointType locationType, bool ignoreRestrictions, IAccessoryMounter priorityMounter, BodyCoverage additionalCoverage) { // Error checks are optimized with the assumption that the mount will succeed. if (m_Accessories.Contains(accessory)) { Debug.LogWarning("Attempted to attach same accessory more than once. Attempt ignored: " + accessory.name); // It is a success since the accessory is mounted. But no event. return(MountResult.Success); } if (!ignoreRestrictions) { if (AccessoriesLimited && !accessory.IgnoreLimited) { return(MountResult.OutfitIsLimited); } if (((accessory.GetCoverageFor(locationType) | additionalCoverage) & CurrentCoverage) != 0) { return(MountResult.CoverageBlocked); } } var location = GetMountPoint(locationType); if (!location) { return(MountResult.NoMountPoint); } else if (location.IsBlocked) { return(MountResult.LocationBlocked); } if (priorityMounter != null && LizittUtil.IsUnityDestroyed(priorityMounter)) { Debug.LogError("The priority mounter is a reference to a destroyed object.", this); return(MountResult.FailedOnError); } if (!accessory.Mount(location, gameObject, priorityMounter, additionalCoverage)) { return(MountResult.RejectedByAccessory); } LinkAccessory(accessory); Observers.SendMount(this, accessory); return(MountResult.Success); }
// Don't seal this. Extensions may need to put in place additional checks. public override bool CanMount(MountPoint location, BodyCoverage restrictions) { return(location && location.LocationType == m_Location && (m_Coverage & restrictions) == 0); }
public sealed override bool CanMount(MountPointType locationType, BodyCoverage restrictions) { return(locationType == m_Location && (m_Coverage & restrictions) == 0); }
public sealed override MountResult Mount(Accessory accessory, MountPointType locationType, bool ignoreRestrictions, IAccessoryMounter priorityMounter, BodyCoverage additionalCoverage) { // Error checks are optimized with the assumption that the mount will succeed. Remounts to the same // location are allowed. (Mounter may have changed or may have special remount behavior.) var location = GetMountPoint(locationType); if (!location) { Release(accessory); return(MountResult.NoMountPoint); } else if (location.IsBlocked) { Release(accessory); return(MountResult.LocationBlocked); } if (!ignoreRestrictions) { if (AccessoriesLimited && !accessory.IgnoreLimited) { Release(accessory); return(MountResult.OutfitIsLimited); } var currentCoverage = CurrentCoverage; if (m_Accessories.Contains(accessory)) { currentCoverage &= ~accessory.CurrentCoverage; } if (((accessory.GetCoverageFor(location) | additionalCoverage) & currentCoverage) != 0) { Release(accessory); return(MountResult.CoverageBlocked); } } if (priorityMounter != null && LizUtil.IsUnityDestroyed(priorityMounter)) { Debug.LogError("The priority mounter is a reference to a destroyed object.", this); Release(accessory); return(MountResult.FailedOnError); } if (!accessory.Mount(location, gameObject, priorityMounter, additionalCoverage)) { Release(accessory); return(MountResult.RejectedByAccessory); } LinkAccessory(accessory); Observers.SendAccessoryMount(this, accessory); return(MountResult.Success); }