usafe optimise GetEntityLong

This commit is contained in:
Mikhail 2023-07-02 21:39:44 +08:00
parent 649037577d
commit 43c5adc6cc

View File

@ -201,7 +201,11 @@ namespace DCFApixels.DragonECS
ReleaseDelEntityBuffer(); ReleaseDelEntityBuffer();
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public entlong GetEntityLong(int entityID) => new entlong(entityID, _gens[entityID], id); //TODO придумать получше имя метода public unsafe entlong GetEntityLong(int entityID)
{
long x = ((long)id << 48 | (long)_gens[entityID] << 32 | entityID);
return *(entlong*)&x;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool IsAlive(int entityID, short gen) => _gens[entityID] == gen; public bool IsAlive(int entityID, short gen) => _gens[entityID] == gen;
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]