Netcode Bootstrap

This commit is contained in:
Luis Gonzalez
2026-05-31 14:27:52 -07:00
parent 99d8d2d2a9
commit 7fa77ce821
1813 changed files with 2921554 additions and 84 deletions
@@ -0,0 +1,55 @@
using Unity.Collections;
using Hash128 = Unity.Entities.Hash128;
using FixedStringName = Unity.Collections.FixedString512Bytes;
using Unity.Core;
////////////////////////////////////////////////////////////////////////////////////
namespace Rukhanka.Toolbox
{
public static class FixedStringExtensions
{
public static unsafe Hash128 CalculateHash128(in this FixedStringName s)
{
if (s.IsEmpty)
return default;
var hasher = new xxHash3.StreamingState();
hasher.Update(s.GetUnsafePtr(), s.Length);
var rv = new Hash128(hasher.DigestHash128());
return rv;
}
////////////////////////////////////////////////////////////////////////////////////
public static Hash128 CalculateHash128(this string s)
{
if (s == null)
return default;
var fs = new FixedStringName(s);
return fs.CalculateHash128();
}
////////////////////////////////////////////////////////////////////////////////////
public static unsafe uint CalculateHash32(in this FixedStringName s)
{
if (s.IsEmpty)
return default;
var rv = XXHash.Hash32(s.GetUnsafePtr(), s.Length);
return rv;
}
////////////////////////////////////////////////////////////////////////////////////
public static uint CalculateHash32(this string s)
{
if (s == null)
return 0;
var fs = new FixedStringName(s);
return fs.CalculateHash32();
}
}
}