#if UNITY_EDITOR
using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
namespace Phantom.XRMOD.UnityFusion.Editor
{
///
/// Specifies the different options that can be used when applying modifications.
///
[Flags]
internal enum ModifyOptions
{
///
/// Changes are applied after a delay.
///
/// Changes can be undone.
///
///
/// The object that holds the custom name and tooltip for the component is be removed,
/// if the component no longer has any name or tooltip override after the changes have been applied.
///
///
Defaults = 0,
///
/// Changes are applied immediately.
///
Immediate = 1,
///
/// Changes can not be undone.
///
NonUndoable = 2,
///
/// The object that holds the custom name and tooltip for the component should not be removed, even if
/// the component no longer has any name or tooltip override after the changes have been applied.
///
/// Use this option if you are using mode, and you are going to be making further
/// changes to the name or tooltip of the component after these changes.
///
///
DisallowRemoveNameContainer = 4,
///
/// The object that holds the custom name and tooltip for the component should not be affected by the operation.
///
DontUpdateNameContainer = 8
}
internal static class ModifyOptionsExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsSet(this ModifyOptions options, ModifyOptions flag) => (options & flag) != 0;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsDelayed(this ModifyOptions options) => !options.IsSet(ModifyOptions.Immediate);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsUndoable(this ModifyOptions options) => !options.IsSet(ModifyOptions.NonUndoable);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsRemovingNameContainerAllowed(this ModifyOptions options) => !options.IsSet(ModifyOptions.DisallowRemoveNameContainer) && options.IsUpdatingContainerAllowed();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsUpdatingContainerAllowed(this ModifyOptions options) => !options.IsSet(ModifyOptions.DontUpdateNameContainer);
[Pure, MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModifyOptions Immediately(this ModifyOptions options) => options | ModifyOptions.Immediate;
}
}
#endif