/// <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; }
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); }
//For PS4. Does nothing on PC and Xbox public static bool OpenMountPoint(MountPointType type, int index, MountPointMode mode, bool async = false) { #if UNITY_PS4 return(PS4Manager.OpenMountPoint(type, index, mode, async)); #else return(true); #endif }
/// <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)); }
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); }
/// <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="locationType">The mount location type.</param> /// <param name="restrictions">The body coverage restrictions.</param> /// <returns> /// True if accessory and mounter are non-null and the mounter can mount the accessory to the specified /// location based on the accessory's current state and coverage restrictions.</returns> public static bool CanMount( Accessory accessory, IAccessoryMounter mounter, MountPointType locationType, BodyCoverage restrictions) { if (accessory && !LizittUtil.IsUnityDestroyed(mounter) && (mounter.GetCoverageFor(locationType) & restrictions) == 0) { return(mounter.CanMount(accessory, locationType)); } return(false); }
/////////////////////////////////////////////////////////////////////////////////////////// /// <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="locationType">The mount target of the accessory.</param> /// <param name="ignoreRestrictions"> /// If true, ignore outfit 'limited accessory' and coverage restrictions. (Other restictions may still apply.) /// </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 MountResult AddAccessory(Accessory accessory, MountPointType locationType, bool ignoreRestrictions = false, bool mustMount = false) { var settings = new AccessoryAddSettings(); settings.IgnoreRestrictions = ignoreRestrictions; settings.LocationType = locationType; settings.Mounter = null; settings.AdditionalCoverage = 0; return(AddAccessory(accessory, settings, mustMount)); }
/// <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="locationType">The location type.</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, MountPointType locationType, BodyCoverage restrictions) { for (int i = 0; i < Count; i++) { if (Accessory.CanMount(accessory, this[i], locationType, restrictions)) { return(i); } } return(-1); }
/// <summary> /// Gets the specified mount point, or null if there is none. /// </summary> /// <param name="locationType">The location type.</param> /// <returns>The specified mount point, or null if there is none.</returns> public virtual MountPoint GetMountPoint(MountPointType locationType) { for (int i = 0; i < MountPointCount; i++) { var item = GetMountPoint(i); if (item && item.LocationType == locationType) { return(item); } } return(null); }
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); }
/// <summary> /// The item associated with the specified type, or null if there is none. /// </summary> /// <param name="typ">The item type.</param> /// <returns> /// The item associated with the specified type, or null if there is none. /// </returns> public MountPoint this[MountPointType locationType] { get { for (int i = 0; i < m_Items.Length; i++) { if (m_Items[i] && m_Items[i].LocationType == locationType) { return(m_Items[i]); } } return(null); } }
public sealed override BodyCoverage GetCoverageFor(MountPointType locationType) { if (Accessory.CanMount(this, PriorityMounter, locationType, 0)) { return(PriorityMounter.GetCoverageFor(locationType)); } for (int i = 0; i < m_Mounters.Count; i++) { if (Accessory.CanMount(this, m_Mounters[i], locationType, 0)) { return(m_Mounters[i].GetCoverageFor(locationType)); } } return(0); }
public static void DeleteMountPoint(MountPointType type, int index) { #if UNITY_PS4 switch (type) { case MountPointType.Pilot: PS4Manager.DeleteMountPoint("Pilot"); break; case MountPointType.SavedGame: PS4Manager.DeleteMountPoint("SavedGame" + index); break; case MountPointType.Temp: PS4Manager.DeleteMountPoint("Temp"); break; default: throw new Exception("Unknown Mount Point type"); } #else throw new Exception("Cannot delete mount point on this system"); #endif }
public override bool CanMount(Accessory accessory, MountPointType locationType) { return(locationType == m_To && accessory && accessory.CurrentLocation && accessory.CurrentLocation.LocationType == m_From); }
public sealed override MountPoint GetMountPoint(MountPointType locationType) { CheckInitializeMountPoints(); return(m_MountPoints[locationType]); }
/// <summary> /// Set the 'to' and 'from' locations. /// </summary> /// <param name="from">The location the mounter can transfer the accessory from.</param> /// <param name="to">The location the mounter can mount the accessory to.</param> public void SetLocations(MountPointType from, MountPointType to) { m_From = from; m_To = to; }
/// <summary> /// Returns <see cref="Coverage"/> if <paramref name="locationType"/> is equal to <see cref="LocationType"/>, /// otherwise zero. /// </summary> /// <param name="locationType">The location type to check.</param> /// <returns> /// <see cref="Coverage"/> if <paramref name="locationType"/> is equal to <see cref="LocationType"/>, /// otherwise zero. /// </returns> public sealed override BodyCoverage GetCoverageFor(MountPointType locationType) { return((locationType == m_Location) ? Coverage : 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);
/// <summary> /// Sets the value of <see cref="DefaultLocationType"/>. /// </summary> /// <param name="locationType">The new default location type.</param> public void SetDefaultLocationType(MountPointType locationType) { m_DefaultLocation = locationType; }
/// <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> /// <returns>The result of the mount attempt.</returns> public MountResult Mount(Accessory accessory, MountPointType locationType, bool ignoreRestrictions) { return(Mount(accessory, locationType, ignoreRestrictions, null, 0)); }
//For PS4. Does nothing on PC and Xbox public static bool OpenMountPoint(MountPointType type, MountPointMode mode, bool async = false) { return(OpenMountPoint(type, 0, mode, async)); }
private void DrawMountPointActions() { EditorGUILayout.LabelField("Mount Points"); var outfit = Target; LizEditorGUIUtil.BeginLabelWidth(70); m_ContextChoice = EditorGUILayout.ObjectField(ContextLabel, m_ContextChoice, typeof(GameObject), true) as GameObject; EditorGUILayout.BeginHorizontal(); m_MountTypeChoice = (MountPointType)EditorGUILayout.EnumPopup(m_MountTypeChoice); if (m_TransformPopup == null) { m_TransformPopup = new LocalComponentPopup(typeof(Transform), false); } m_TransformChoice = m_TransformPopup.OnGUI( EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight * 1.1f), m_TransformChoice, GUIContent.none, outfit.gameObject) as Transform; EditorGUILayout.EndHorizontal(); GUI.enabled = m_TransformChoice; if (GUILayout.Button("Create Mount Point")) { if (m_TransformChoice.gameObject.GetComponent <MountPoint>()) { Debug.LogError(m_TransformChoice.name + " Already has a mount point attached.", outfit); } else if (outfit.GetMountPoint(m_MountTypeChoice)) { Debug.LogError("Outfit already has a mount point of type: " + m_MountTypeChoice, outfit); } else { // Note for prefabs: If there is a missing body part in the array before the action and the // user undoes the action, the mount point array may end up containing an invalid reference // to the prefab's asset. This appears to be some kind of prefab related bug. const string undoLabel = "Create Mount Point"; Undo.IncrementCurrentGroup(); Undo.RecordObjects(Outfit.UnsafeGetUndoObjects(outfit).ToArray(), undoLabel); // For the refresh. var bp = Undo.AddComponent <MountPoint>(m_TransformChoice.gameObject); Undo.RecordObject(bp, undoLabel); bp.LocationType = m_MountTypeChoice; bp.Context = m_ContextChoice; StandardOutfit.UnsafeRefreshMountPoints(outfit); Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); m_TransformChoice = null; } } GUI.enabled = true; EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(ApplyMountPointContextLabel)) { string undoLabel = "Apply Mount Point Context"; Undo.IncrementCurrentGroup(); Undo.RecordObjects(Outfit.UnsafeGetUndoObjects(outfit).ToArray(), undoLabel); outfit.ApplyMountPointContext(m_ContextChoice); Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); } if (GUILayout.Button(RefreshMountPointsLabel)) { Undo.RecordObject(Target, "Refresh Mount Points"); StandardOutfit.UnsafeRefreshMountPoints(Target, false); } if (GUILayout.Button(ResetMountPointsLabel)) { Undo.RecordObject(Target, "Reset Mount Points"); StandardOutfit.UnsafeClearMountPoints(Target); } EditorGUILayout.EndHorizontal(); LizEditorGUIUtil.EndLabelWidth(); }
public sealed override MountPoint GetMountPoint(MountPointType locationType) { return(m_MountPoints[locationType]); }
/// <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 the specified location. /// This method will return false if the accessory's coverage for the location overlaps /// with <paramref name="restrictions"/>. /// </para> /// </remarks> /// <param name="locationType">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(MountPointType locationType, BodyCoverage restrictions);
/// <summary> /// Set the location the accessory can mount to. /// </summary> public void SetDefaultLocationType(MountPointType value) { m_Location = value; }
//////////////////////////////////////////////////////////////////////////////////////////// // HACK: Unity 5.3.1: Workaround for Mono's optional parameter key duplication bug. /// <summary> /// True if the accessory can be mounted to the specified location, without regard for /// coverage restrictions. /// </summary> /// <param name="locationType">The desired location.</param> /// <returns> /// True if the accessory can mount to the specified location, without regard for /// coverage restrictions. /// </returns> public bool CanMount(MountPointType locationType) { return(CanMount(locationType, 0)); }
public sealed override bool CanMount(MountPointType locationType, BodyCoverage restrictions) { return(locationType == m_Location && (m_Coverage & restrictions) == 0); }
//////////////////////////////////////////////////////////////////////////////////////////// // HACK: Unity 5.3.1: Workaround for Mono's optional parameter key duplication bug. /// <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> /// <returns>The result of the mount attempt.</returns> public MountResult Mount(Accessory accessory, MountPointType locationType, bool ignoreRestrictions, IAccessoryMounter priorityMounter) { return(Mount(accessory, locationType, ignoreRestrictions, priorityMounter, 0)); }
/// <summary> /// The body coverage of the accessory when attached to the specified location. /// </summary> /// <remarks> /// <para> /// Will return zero if either the accessory has no coverage when mounted to the location, /// or it can't mount to the specified location at all. (See: <see cref="CanMount"/>) /// </para> /// </remarks> /// <param name="locationType">The mount location.</param> /// <returns> /// The body coverage of the accessory when attached to the specified mount point. /// </returns> /// <seealso cref="CanMount"/> public abstract BodyCoverage GetCoverageFor(MountPointType locationType);
/// <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> /// <returns>The result of the mount attempt.</returns> public MountResult Mount(Accessory accessory, MountPointType locationType) { return(Mount(accessory, locationType, false, null, 0)); }