diff --git a/Engine.Systems/Network/TypeHasher.cs b/Engine.Systems/Network/TypeHasher.cs new file mode 100644 index 0000000..82451d4 --- /dev/null +++ b/Engine.Systems/Network/TypeHasher.cs @@ -0,0 +1,27 @@ +namespace Engine.Systems.Network; + +public static class TypeHasher +{ + 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; + } + } +}