mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-17 17:34:36 +08:00
Merge branch 'dev' of github.com:DCFApixels/DragonECS into dev
This commit is contained in:
commit
a0f9f696fd
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user