mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-17 17:34:36 +08:00
add auto template for aspect
This commit is contained in:
parent
307a84558d
commit
089a1ab60a
@ -6,7 +6,7 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
public abstract class EcsAspect
|
||||
public abstract class EcsAspect : ITemplateNode
|
||||
{
|
||||
internal EcsWorld _source;
|
||||
internal EcsMask _mask;
|
||||
@ -491,6 +491,29 @@ namespace DCFApixels.DragonECS
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Template
|
||||
public virtual void Apply(short worldID, int entityID)
|
||||
{
|
||||
EcsWorld world = EcsWorld.GetWorld(worldID);
|
||||
foreach (var incTypeID in _mask.inc)
|
||||
{
|
||||
var pool = world.GetPoolInstance(incTypeID);
|
||||
if (pool.Has(entityID) == false)
|
||||
{
|
||||
pool.AddRaw(entityID, null);
|
||||
}
|
||||
}
|
||||
foreach (var excTypeID in _mask.exc)
|
||||
{
|
||||
var pool = world.GetPoolInstance(excTypeID);
|
||||
if (pool.Has(entityID))
|
||||
{
|
||||
pool.Del(entityID);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public readonly ref struct IncludeMarker
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user