feat: networking type hasher added
This commit is contained in:
parent
f5a7077570
commit
8e314f3269
27
Engine.Systems/Network/TypeHasher.cs
Normal file
27
Engine.Systems/Network/TypeHasher.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
namespace Engine.Systems.Network;
|
||||||
|
|
||||||
|
public static class TypeHasher<T>
|
||||||
|
{
|
||||||
|
private static long _fnv1a = 0;
|
||||||
|
public static long FNV1a
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_fnv1a == 0)
|
||||||
|
unchecked
|
||||||
|
{
|
||||||
|
const long fnvPrime = 1099511628211;
|
||||||
|
_fnv1a = 1469598103934665603;
|
||||||
|
|
||||||
|
string typeName = typeof(T).FullName ?? typeof(T).Name;
|
||||||
|
foreach (char c in typeName)
|
||||||
|
{
|
||||||
|
_fnv1a ^= c;
|
||||||
|
_fnv1a *= fnvPrime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _fnv1a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user