Merge branch 'dev' of github.com:DCFApixels/DragonECS into dev

This commit is contained in:
DCFApixels 2025-03-19 11:18:39 +08:00
commit a0f9f696fd
3 changed files with 39 additions and 3 deletions

View File

@ -3,6 +3,7 @@
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@ -67,6 +68,7 @@ namespace DCFApixels.DragonECS
private bool _isProcess;
private bool _isComponent;
private bool _isPool;
private InitFlag _initFlags = InitFlag.None;
@ -315,6 +317,18 @@ namespace DCFApixels.DragonECS
return _isProcess;
}
}
public bool IsPool
{
get
{
if (_initFlags.HasFlag(InitFlag.ReflectionInfo) == false)
{
MetaGenerator.GetReflectionInfo(this);
_initFlags |= InitFlag.ReflectionInfo;
}
return _isPool;
}
}
#endregion
#region InitializeAll
@ -574,9 +588,9 @@ namespace DCFApixels.DragonECS
#region GetReflectionInfo
public static void GetReflectionInfo(TypeMeta meta)
{
var interfaces = meta.Type.GetInterfaces();
meta._isComponent = Array.IndexOf(interfaces, typeof(IEcsComponentMember)) >= 0;
meta._isProcess = Array.IndexOf(interfaces, typeof(IEcsProcess)) >= 0;
meta._isComponent = typeof(IEcsComponentMember).IsAssignableFrom(meta.Type);
meta._isProcess = typeof(IEcsProcess).IsAssignableFrom(meta.Type);
meta._isPool = typeof(IEcsPoolImplementation).IsAssignableFrom(meta.Type);
}
#endregion
}

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