Archived
添加bool3,在inspecter中展示为横着的三个勾选框,但是保存为一个整数(๑•̀ㅂ•́)و✧
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -73,6 +71,21 @@ namespace XericLibrary.Runtime.MacroLibrary
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否包含给定,且只关注是否完全包含
|
||||
/// </summary>
|
||||
/// <param name="examineCC">要检查的特征</param>
|
||||
/// <param name="filterCC">过滤的特征</param>
|
||||
/// <returns></returns>
|
||||
public static bool CheckEnum(T examineCC, T filterCC)
|
||||
{
|
||||
var cc = Convert.ToInt32(filterCC);
|
||||
var isValid = Convert.ToInt32(examineCC) & cc;
|
||||
var isFull = isValid ^ cc;
|
||||
|
||||
return isValid > 0 && isFull <= 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置目标的枚举值
|
||||
/// </summary>
|
||||
@@ -146,25 +159,28 @@ namespace XericLibrary.Runtime.MacroLibrary
|
||||
target ^= Convert.ToInt32(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否包含给定,且只关注是否完全包含
|
||||
/// </summary>
|
||||
/// <param name="examineCC">要检查的特征</param>
|
||||
/// <param name="filterCC">过滤的特征</param>
|
||||
/// <returns></returns>
|
||||
public static bool CheckEnum(T examineCC, T filterCC)
|
||||
{
|
||||
var cc = Convert.ToInt32(filterCC);
|
||||
var isValid = Convert.ToInt32(examineCC) & cc;
|
||||
var isFull = isValid ^ cc;
|
||||
|
||||
return isValid > 0 && isFull <= 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static partial class MacroMath
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 获取给定索引下的位是否为真
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public static bool GetEnumIndex(this int target, int index)
|
||||
{
|
||||
return 0 != ((target >> index) & 1);
|
||||
}
|
||||
|
||||
public static void SetEnumIndex(this ref int target, int index)
|
||||
{
|
||||
target |= 1 << index;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static int EnumToInt32(this Enum target)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user