mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 18:14:37 +08:00
refactoring
This commit is contained in:
parent
3d6155ea80
commit
50ea02f967
@ -289,7 +289,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region EcsMask
|
#region EcsMask
|
||||||
public class EcsMaskBase
|
public class EcsComponentMask
|
||||||
{
|
{
|
||||||
internal Type WorldArchetypeType;
|
internal Type WorldArchetypeType;
|
||||||
internal int[] Inc;
|
internal int[] Inc;
|
||||||
@ -308,7 +308,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public sealed class EcsMask : EcsMaskBase
|
public sealed class EcsMask : EcsComponentMask
|
||||||
{
|
{
|
||||||
// internal readonly Type WorldArchetypeType;
|
// internal readonly Type WorldArchetypeType;
|
||||||
internal readonly int UniqueID;
|
internal readonly int UniqueID;
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
using DCFApixels.DragonECS;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
@ -45,13 +40,10 @@ namespace DCFApixels.DragonECS
|
|||||||
get => group.Readonly;
|
get => group.Readonly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public EcsGroup.Enumerator GetEnumerator() => group.GetEnumerator();
|
public EcsGroup.Enumerator GetEnumerator() => group.GetEnumerator();
|
||||||
|
|
||||||
|
|
||||||
protected virtual void Init(Builder b) { }
|
protected virtual void Init(Builder b) { }
|
||||||
|
|
||||||
|
|
||||||
#region Builder
|
#region Builder
|
||||||
public sealed class Builder : EcsQueryBuilder
|
public sealed class Builder : EcsQueryBuilder
|
||||||
{
|
{
|
||||||
@ -88,6 +80,7 @@ namespace DCFApixels.DragonECS
|
|||||||
_exc = new List<int>(4);
|
_exc = new List<int>(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Init query member methods
|
||||||
public override inc<TComponent> Include<TComponent>() where TComponent : struct
|
public override inc<TComponent> Include<TComponent>() where TComponent : struct
|
||||||
{
|
{
|
||||||
_inc.Add(_world.GetComponentID<TComponent>());
|
_inc.Add(_world.GetComponentID<TComponent>());
|
||||||
@ -102,6 +95,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
return new opt<TComponent>(_world.GetPool<TComponent>());
|
return new opt<TComponent>(_world.GetPool<TComponent>());
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
private void End(out EcsQueryMask mask)
|
private void End(out EcsQueryMask mask)
|
||||||
{
|
{
|
||||||
@ -119,7 +113,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EcsQueryMask : EcsMaskBase
|
public class EcsQueryMask : EcsComponentMask
|
||||||
{
|
{
|
||||||
public EcsQueryMask(Type worldArchetypeType, int[] inc, int[] exc)
|
public EcsQueryMask(Type worldArchetypeType, int[] inc, int[] exc)
|
||||||
{
|
{
|
||||||
|
@ -203,27 +203,13 @@ namespace DCFApixels.DragonECS
|
|||||||
for (int i = 0; i < _entitiesCount && _entitiesCount <= _denseEntities.Length; i++)
|
for (int i = 0; i < _entitiesCount && _entitiesCount <= _denseEntities.Length; i++)
|
||||||
{
|
{
|
||||||
int entity = _denseEntities[i];
|
int entity = _denseEntities[i];
|
||||||
if (IsMaskCompatible(mask.Inc, mask.Exc, entity))
|
if (IsMaskCompatible(mask, entity))
|
||||||
filter.AddEntity(entity);
|
filter.AddEntity(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entities = (TQuery)_queries[uniqueID];
|
entities = (TQuery)_queries[uniqueID];
|
||||||
return entities;
|
return entities;
|
||||||
}
|
}
|
||||||
private bool IsMaskCompatible(int[] inc, int[] exc, int entity)
|
|
||||||
{
|
|
||||||
for (int i = 0, iMax = inc.Length; i < iMax; i++)
|
|
||||||
{
|
|
||||||
if (!_pools[inc[i]].Has(entity))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (int i = 0, iMax = exc.Length; i < iMax; i++)
|
|
||||||
{
|
|
||||||
if (_pools[exc[i]].Has(entity))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IsMaskCompatible/IsMaskCompatibleWithout
|
#region IsMaskCompatible/IsMaskCompatibleWithout
|
||||||
@ -238,7 +224,7 @@ namespace DCFApixels.DragonECS
|
|||||||
return IsMaskCompatible(EcsMaskMap<TWorldArchetype>.GetMask<TInc, TExc>(), entityID);
|
return IsMaskCompatible(EcsMaskMap<TWorldArchetype>.GetMask<TInc, TExc>(), entityID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsMaskCompatible(EcsMaskBase mask, int entity)
|
public bool IsMaskCompatible(EcsComponentMask mask, int entity)
|
||||||
{
|
{
|
||||||
#if (DEBUG && !DISABLE_DRAGONECS_DEBUG) || !DRAGONECS_NO_SANITIZE_CHECKS
|
#if (DEBUG && !DISABLE_DRAGONECS_DEBUG) || !DRAGONECS_NO_SANITIZE_CHECKS
|
||||||
if (mask.WorldArchetypeType != typeof(TWorldArchetype))
|
if (mask.WorldArchetypeType != typeof(TWorldArchetype))
|
||||||
@ -257,7 +243,7 @@ namespace DCFApixels.DragonECS
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsMaskCompatibleWithout(EcsMaskBase mask, int entity, int otherComponentID)
|
public bool IsMaskCompatibleWithout(EcsComponentMask mask, int entity, int otherComponentID)
|
||||||
{
|
{
|
||||||
#if (DEBUG && !DISABLE_DRAGONECS_DEBUG) || !DRAGONECS_NO_SANITIZE_CHECKS
|
#if (DEBUG && !DISABLE_DRAGONECS_DEBUG) || !DRAGONECS_NO_SANITIZE_CHECKS
|
||||||
if (mask.WorldArchetypeType != typeof(TWorldArchetype))
|
if (mask.WorldArchetypeType != typeof(TWorldArchetype))
|
||||||
|
@ -22,8 +22,8 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public bool IsMaskCompatible<TInc>(int entity) where TInc : struct, IInc;
|
public bool IsMaskCompatible<TInc>(int entity) where TInc : struct, IInc;
|
||||||
public bool IsMaskCompatible<TInc, TExc>(int entity) where TInc : struct, IInc where TExc : struct, IExc;
|
public bool IsMaskCompatible<TInc, TExc>(int entity) where TInc : struct, IInc where TExc : struct, IExc;
|
||||||
public bool IsMaskCompatible(EcsMaskBase mask, int entity);
|
public bool IsMaskCompatible(EcsComponentMask mask, int entity);
|
||||||
public bool IsMaskCompatibleWithout(EcsMaskBase mask, int entity, int otherPoolID);
|
public bool IsMaskCompatibleWithout(EcsComponentMask mask, int entity, int otherPoolID);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
Loading…
Reference in New Issue
Block a user