您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
29 行
693 B
29 行
693 B
|
|
namespace AxelF {
|
|
|
|
[System.Serializable]
|
|
public struct TernaryBool {
|
|
int value;
|
|
|
|
public override bool Equals(object o) {
|
|
return o is TernaryBool ? ((TernaryBool) o).value == value : false;
|
|
}
|
|
|
|
public override int GetHashCode() {
|
|
return (value + 2) * 0x1357;
|
|
}
|
|
|
|
public bool ToBool(bool polarity) {
|
|
return polarity ? value > 0 : value < 0;
|
|
}
|
|
|
|
public static implicit operator TernaryBool(bool b) {
|
|
return new TernaryBool {value = (b ? 1 : -1)};
|
|
}
|
|
|
|
public static bool operator ==(TernaryBool a, bool b) { return a.ToBool(b); }
|
|
public static bool operator !=(TernaryBool a, bool b) { return !a.ToBool(b); }
|
|
}
|
|
|
|
} // AxelF
|
|
|