/// <summary> /// If you have checked the category outside the job, then you can `switch` on the `As` directly in-job. /// </summary> public ENUM As <ENUM>(ActionCategory <ENUM> ac) where ENUM : struct { if (ac.fastConvert.TryGetValue(categoryAndTypeIndex.y, out ENUM casted)) { return(casted); } else { throw new System.Exception($"Type index {categoryAndTypeIndex.y} does not belong in category {typeof(ENUM).FullName}"); } }
/// <summary> /// Works like `Category` of `DispatchAction` but requires baked `ActionCategory` from outside of the job. /// The baked `ActionCategory` includes `NativeHashMap` for fast casting to `out` variable from this method. /// </summary> public bool Category <ENUM>(ActionCategory <ENUM> ac, out ENUM outEnum) where ENUM : struct { if (categoryAndTypeIndex.x == ac.categoryIndex) { outEnum = As(ac); return(true); } else { outEnum = default(ENUM); return(false); } }