You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
741 B
31 lines
741 B
using Unity.Collections.LowLevel.Unsafe; |
|
|
|
namespace GameCore.LowLevel |
|
{ |
|
public static class LowLevelUtility |
|
{ |
|
public static int HashCombine(int h1, int h2) |
|
{ |
|
var hash = h1; |
|
hash = (hash * 397) ^ h2; |
|
return hash; |
|
} |
|
|
|
public static int HashCombine(int h1, int h2, int h3) |
|
{ |
|
return HashCombine(HashCombine(h1, h2), h3); |
|
} |
|
|
|
public static int OffsetOf<T, F>() |
|
{ |
|
var fields = typeof(T).GetFields(); |
|
foreach (var f in fields) |
|
{ |
|
if (f.DeclaringType == typeof(F)) |
|
return UnsafeUtility.GetFieldOffset(f); |
|
} |
|
|
|
return -1; |
|
} |
|
} |
|
} |