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