mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-11-13 00:55:55 +08:00
update
This commit is contained in:
parent
a83dacedcf
commit
e56c7f94d7
@ -157,6 +157,8 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
int entitiesCapacity = ArrayUtility.NormalizeSizeToPowerOfTwo(config.EntitiesCapacity);
|
||||
_entityDispenser = new IdDispenser(entitiesCapacity, 0, OnEntityDispenserResized);
|
||||
|
||||
GetComponentTypeID<NullComponent>();
|
||||
}
|
||||
public void Destroy()
|
||||
{
|
||||
|
||||
@ -166,6 +166,21 @@ namespace DCFApixels.DragonECS
|
||||
#endif
|
||||
CopyComponent(ref Get(fromEntityID), ref toWorld.GetPool<T>().TryAddOrGet(toEntityID));
|
||||
}
|
||||
|
||||
public void ClearAll()
|
||||
{
|
||||
var span = _source.Where(out SingleAspect<EcsPool<T>> _);
|
||||
_itemsCount = 0;
|
||||
_recycledItemsCount = 0;
|
||||
foreach (var entityID in span)
|
||||
{
|
||||
ref int itemIndex = ref _mapping[entityID];
|
||||
DisableComponent(ref _items[itemIndex]);
|
||||
itemIndex = 0;
|
||||
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
||||
_listeners.InvokeOnDel(entityID);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Callbacks
|
||||
@ -199,9 +214,15 @@ namespace DCFApixels.DragonECS
|
||||
#endregion
|
||||
|
||||
#region Other
|
||||
void IEcsPool.AddRaw(int entityID, object dataRaw) { Add(entityID) = (T)dataRaw; }
|
||||
void IEcsPool.AddRaw(int entityID, object dataRaw)
|
||||
{
|
||||
Add(entityID) = dataRaw == null ? default : (T)dataRaw;
|
||||
}
|
||||
object IEcsReadonlyPool.GetRaw(int entityID) { return Get(entityID); }
|
||||
void IEcsPool.SetRaw(int entityID, object dataRaw) { Get(entityID) = (T)dataRaw; }
|
||||
void IEcsPool.SetRaw(int entityID, object dataRaw)
|
||||
{
|
||||
Get(entityID) = dataRaw == null ? default : (T)dataRaw;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Listeners
|
||||
|
||||
@ -33,6 +33,7 @@ namespace DCFApixels.DragonECS
|
||||
void AddRaw(int entityID, object dataRaw);
|
||||
void SetRaw(int entityID, object dataRaw);
|
||||
void Del(int entityID);
|
||||
void ClearAll();
|
||||
#endregion
|
||||
}
|
||||
/// <summary>A pool for struct components.</summary>
|
||||
@ -103,21 +104,68 @@ namespace DCFApixels.DragonECS
|
||||
public static readonly EcsNullPool instance = new EcsNullPool();
|
||||
|
||||
#region Properties
|
||||
int IEcsReadonlyPool.ComponentTypeID => -1;
|
||||
Type IEcsReadonlyPool.ComponentType => typeof(NullComponent);
|
||||
EcsWorld IEcsReadonlyPool.World => throw new NotImplementedException();
|
||||
public int Count => -1;
|
||||
int IEcsReadonlyPool.ComponentTypeID { get { return 0; } }//TODO Првоерить что NullComponent всегда имеет id 0
|
||||
Type IEcsReadonlyPool.ComponentType { get { return typeof(NullComponent); } }
|
||||
EcsWorld IEcsReadonlyPool.World
|
||||
{
|
||||
get
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG)
|
||||
throw new NullInstanceException();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
public int Count { get { return 0; } }
|
||||
public bool IsReadOnly { get { return true; } }
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
bool IEcsReadonlyPool.Has(int index) => false;
|
||||
void IEcsPool.Del(int entityID) => throw new NotImplementedException();
|
||||
void IEcsPool.AddRaw(int entityID, object dataRaw) => throw new NotImplementedException();
|
||||
object IEcsReadonlyPool.GetRaw(int entityID) => throw new NotImplementedException();
|
||||
void IEcsPool.SetRaw(int entity, object dataRaw) => throw new NotImplementedException();
|
||||
void IEcsReadonlyPool.Copy(int fromEntityID, int toEntityID) => throw new NotImplementedException();
|
||||
void IEcsReadonlyPool.Copy(int fromEntityID, EcsWorld toWorld, int toEntityID) => throw new NotImplementedException();
|
||||
bool IEcsReadonlyPool.Has(int index)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
void IEcsPool.Del(int entityID)
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG)
|
||||
throw new NullInstanceException();
|
||||
#endif
|
||||
}
|
||||
void IEcsPool.AddRaw(int entityID, object dataRaw)
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG)
|
||||
throw new NullInstanceException();
|
||||
#endif
|
||||
}
|
||||
object IEcsReadonlyPool.GetRaw(int entityID)
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG)
|
||||
throw new NullInstanceException();
|
||||
#endif
|
||||
}
|
||||
void IEcsPool.SetRaw(int entity, object dataRaw)
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG)
|
||||
throw new NullInstanceException();
|
||||
#endif
|
||||
}
|
||||
void IEcsReadonlyPool.Copy(int fromEntityID, int toEntityID)
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG)
|
||||
throw new NullInstanceException();
|
||||
#endif
|
||||
}
|
||||
void IEcsReadonlyPool.Copy(int fromEntityID, EcsWorld toWorld, int toEntityID)
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG)
|
||||
throw new NullInstanceException();
|
||||
#endif
|
||||
}
|
||||
void IEcsPool.ClearAll()
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG)
|
||||
throw new NullInstanceException();
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Callbacks
|
||||
|
||||
@ -145,6 +145,18 @@ namespace DCFApixels.DragonECS
|
||||
Add(entityID);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearAll()
|
||||
{
|
||||
var span = _source.Where(out SingleAspect<EcsTagPool<T>> _);
|
||||
_count = 0;
|
||||
foreach (var entityID in span)
|
||||
{
|
||||
_mapping[entityID] = false;
|
||||
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
||||
_listeners.InvokeOnDel(entityID);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Callbacks
|
||||
|
||||
@ -11,6 +11,13 @@ namespace DCFApixels.DragonECS
|
||||
public EcsFrameworkException(string message, Exception inner) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message, inner) { }
|
||||
}
|
||||
[Serializable]
|
||||
public class NullInstanceException : EcsFrameworkException
|
||||
{
|
||||
public NullInstanceException() { }
|
||||
public NullInstanceException(string message) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message) { }
|
||||
public NullInstanceException(string message, Exception inner) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message, inner) { }
|
||||
}
|
||||
[Serializable]
|
||||
public class EcsRunnerImplementationException : EcsFrameworkException
|
||||
{
|
||||
public EcsRunnerImplementationException() { }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user