update singleaspect

This commit is contained in:
DCFApixels 2025-03-10 12:59:43 +08:00
parent 689932f40b
commit bea20d57f0
2 changed files with 13 additions and 3 deletions

View File

@ -1,3 +1,4 @@
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Internal; using DCFApixels.DragonECS.Internal;
using DCFApixels.DragonECS.PoolsCore; using DCFApixels.DragonECS.PoolsCore;
using System; using System;
@ -27,7 +28,7 @@ namespace DCFApixels.DragonECS
[MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.POOLS_GROUP)] [MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.POOLS_GROUP)]
[MetaDescription(EcsConsts.AUTHOR, "Pool for IEcsComponent components.")] [MetaDescription(EcsConsts.AUTHOR, "Pool for IEcsComponent components.")]
[MetaID("C501547C9201A4B03FC25632E4FAAFD7")] [MetaID("C501547C9201A4B03FC25632E4FAAFD7")]
[DebuggerDisplay("Count: {Count}")] [DebuggerDisplay("{ComponentType}: {Count}")]
public sealed class EcsPool<T> : IEcsPoolImplementation<T>, IEcsStructPool<T>, IEnumerable<T> //IEnumerable<T> - IntelliSense hack public sealed class EcsPool<T> : IEcsPoolImplementation<T>, IEcsStructPool<T>, IEnumerable<T> //IEnumerable<T> - IntelliSense hack
where T : struct, IEcsComponent where T : struct, IEcsComponent
{ {
@ -218,7 +219,7 @@ namespace DCFApixels.DragonECS
_recycledItemsCount = 0; // ñïåðåäè ïîòîìó ÷òîáû îáíóëÿëîñü, òàê êàê Del íå îáíóëÿåò _recycledItemsCount = 0; // ñïåðåäè ïîòîìó ÷òîáû îáíóëÿëîñü, òàê êàê Del íå îáíóëÿåò
if (_itemsCount <= 0) { return; } if (_itemsCount <= 0) { return; }
_itemsCount = 0; _itemsCount = 0;
var span = _source.Where(out SingleAspect<EcsPool<T>> _); var span = _source.Where(out SingleAspect<T> _);
foreach (var entityID in span) foreach (var entityID in span)
{ {
ref int itemIndex = ref _mapping[entityID]; ref int itemIndex = ref _mapping[entityID];
@ -235,6 +236,10 @@ namespace DCFApixels.DragonECS
#region Callbacks #region Callbacks
void IEcsPoolImplementation.OnInit(EcsWorld world, EcsWorld.PoolsMediator mediator, int componentTypeID) void IEcsPoolImplementation.OnInit(EcsWorld world, EcsWorld.PoolsMediator mediator, int componentTypeID)
{ {
#if DEBUG
AllowedInWorldsAttribute.CheckAllows<T>(world);
#endif
_source = world; _source = world;
_mediator = mediator; _mediator = mediator;
_componentTypeID = componentTypeID; _componentTypeID = componentTypeID;

View File

@ -1,3 +1,4 @@
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.PoolsCore; using DCFApixels.DragonECS.PoolsCore;
using System; using System;
using System.Collections; using System.Collections;
@ -185,7 +186,7 @@ namespace DCFApixels.DragonECS
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); } if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
#endif #endif
if (_count <= 0) { return; } if (_count <= 0) { return; }
var span = _source.Where(out SingleAspect<EcsTagPool<T>> _); var span = _source.Where(out SingleTagAspect<T> _);
_count = 0; _count = 0;
foreach (var entityID in span) foreach (var entityID in span)
{ {
@ -201,6 +202,10 @@ namespace DCFApixels.DragonECS
#region Callbacks #region Callbacks
void IEcsPoolImplementation.OnInit(EcsWorld world, EcsWorld.PoolsMediator mediator, int componentTypeID) void IEcsPoolImplementation.OnInit(EcsWorld world, EcsWorld.PoolsMediator mediator, int componentTypeID)
{ {
#if DEBUG
AllowedInWorldsAttribute.CheckAllows<T>(world);
#endif
_source = world; _source = world;
_mediator = mediator; _mediator = mediator;
_componentTypeID = componentTypeID; _componentTypeID = componentTypeID;