/// <summary> /// Replaces the current items with the specified items. /// </summary> /// <remarks> /// <para> /// To use this method safely either set <paramref name="asReference"/> to false or discard all external /// refrences to <paramref name="items"/>. /// </para> /// </remarks> /// <param name="mountPoints">The object to update. (Required)</param> /// <param name="items">The items.</param> /// <param name="asReference"> /// If true the internal buffer will be replaced with a reference to <paramref name="items"/>, otherwise /// <paramref name="items"/> will be copied. /// </param> public static void UnsafeReplaceItems(MountPointGroup mountPoints, bool asReference, params MountPoint[] items) { if (items == null) { mountPoints.Clear(); } else { mountPoints.m_Items = asReference ? items : (MountPoint[])items.Clone(); } }
/// <summary> /// Replaces the current mount points with the provided mounts points. /// </summary> /// <remarks> /// <para> /// Behavior is undefined if this method if used after outfit initialization or after /// accessories are attached. /// </para> /// <para> /// If <paramref name="asReference"/> is true, then all external references to the /// <paramref name="mountPoints"/> array must be discared or behavior will be undefined. /// </para> /// </remarks> /// <param name="outfit">The outfit. (Required)</param> /// <param name="asReference"> /// If true, the <paramref name="mountPoints"/> refrence will be used internally, otherwise the array will /// be copied. /// </param> /// <param name="mountPoints">The mount points, or null to clear all mount points.</param> public static void UnsafeSet(OutfitCore outfit, bool asReference, params MountPoint[] mountPoints) { // Design note: While an odd use case, it is not required that a mount point be a child of the outfit, so // don't put any restrictions in place for that. if (mountPoints == null) { outfit.m_MountPoints.Clear(); } else { MountPointGroup.UnsafeReplaceItems(outfit.m_MountPoints, asReference, mountPoints); } }