add EcsWorld.InitEntitySlot

This commit is contained in:
DCFApixels 2024-12-17 12:20:39 +08:00
parent d970212c23
commit 32ed705fc4
2 changed files with 15 additions and 1 deletions

View File

@ -389,7 +389,16 @@ namespace DCFApixels.DragonECS
return *(entlong*)&x; return *(entlong*)&x;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe EntitySlotInfo GetEntitySlotInfoDebug(int entityID) public void InitEntitySlot(int entityID, short gen)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
if (Count > 0) { Throw.World_MethodCalledAfterEntityCreation(nameof(InitEntitySlot)); }
#endif
_entityDispenser.Upsize(entityID);
_entities[entityID].gen = gen;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public EntitySlotInfo GetEntitySlotInfoDebug(int entityID)
{ {
return new EntitySlotInfo(entityID, _entities[entityID].gen, ID); return new EntitySlotInfo(entityID, _entities[entityID].gen, ID);
} }

View File

@ -113,6 +113,11 @@ namespace DCFApixels.DragonECS.Internal
{ {
throw new EcsFrameworkException("This world can't be destroyed"); throw new EcsFrameworkException("This world can't be destroyed");
} }
[MethodImpl(MethodImplOptions.NoInlining)]
public static void World_MethodCalledAfterEntityCreation(string methodName)
{
throw new EcsFrameworkException($"The method {methodName} can only be executed before creating entities in the world.");
}
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
internal static void Ent_ThrowIsNotAlive(entlong entity) internal static void Ent_ThrowIsNotAlive(entlong entity)