add static pool.apply

This commit is contained in:
DCFApixels 2025-03-19 09:39:14 +08:00
parent 26f141fca9
commit 760e3d7e0f
2 changed files with 22 additions and 0 deletions

View File

@ -370,6 +370,17 @@ namespace DCFApixels.DragonECS
public static implicit operator EcsPool<T>(OptionalMarker a) { return a.GetInstance<EcsPool<T>>(); }
public static implicit operator EcsPool<T>(EcsWorld.GetPoolInstanceMarker a) { return a.GetInstance<EcsPool<T>>(); }
#endregion
#region Apply
public static void Apply(ref T component, int entityID, short worldID)
{
EcsWorld.GetPoolInstance<EcsPool<T>>(worldID).TryAddOrGet(entityID) = component;
}
public static void Apply(ref T component, int entityID, EcsPool<T> pool)
{
pool.TryAddOrGet(entityID) = component;
}
#endregion
}
public static class EcsPoolExtensions

View File

@ -317,6 +317,17 @@ namespace DCFApixels.DragonECS
public static implicit operator EcsTagPool<T>(OptionalMarker a) { return a.GetInstance<EcsTagPool<T>>(); }
public static implicit operator EcsTagPool<T>(EcsWorld.GetPoolInstanceMarker a) { return a.GetInstance<EcsTagPool<T>>(); }
#endregion
#region Apply
public static void Apply(ref T component, int entityID, short worldID)
{
EcsWorld.GetPoolInstance<EcsTagPool<T>>(worldID).TryAdd(entityID);
}
public static void Apply(ref T component, int entityID, EcsTagPool<T> pool)
{
pool.TryAdd(entityID);
}
#endregion
}
public static class EcsTagPoolExtensions