mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
Merge branch 'dev'
This commit is contained in:
commit
ebe9a07189
@ -1,10 +1,14 @@
|
|||||||
namespace DCFApixels.DragonECS
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
|
[DebuggerTypeProxy(typeof(DebuggerProxy))]
|
||||||
public sealed class EcsDefaultWorld : EcsWorld
|
public sealed class EcsDefaultWorld : EcsWorld
|
||||||
{
|
{
|
||||||
public EcsDefaultWorld(EcsWorldConfig config, short worldID = -1) : base(config, worldID) { }
|
public EcsDefaultWorld(EcsWorldConfig config, short worldID = -1) : base(config, worldID) { }
|
||||||
public EcsDefaultWorld(IConfigContainer configs = null, short worldID = -1) : base(configs, worldID) { }
|
public EcsDefaultWorld(IConfigContainer configs = null, short worldID = -1) : base(configs, worldID) { }
|
||||||
}
|
}
|
||||||
|
[DebuggerTypeProxy(typeof(DebuggerProxy))]
|
||||||
public sealed class EcsEventWorld : EcsWorld
|
public sealed class EcsEventWorld : EcsWorld
|
||||||
{
|
{
|
||||||
public EcsEventWorld(EcsWorldConfig config, short worldID = -1) : base(config, worldID) { }
|
public EcsEventWorld(EcsWorldConfig config, short worldID = -1) : base(config, worldID) { }
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
@ -7,10 +8,17 @@ namespace DCFApixels.DragonECS
|
|||||||
public sealed class MetaGroupAttribute : EcsMetaAttribute
|
public sealed class MetaGroupAttribute : EcsMetaAttribute
|
||||||
{
|
{
|
||||||
public readonly MetaGroupRef Data;
|
public readonly MetaGroupRef Data;
|
||||||
|
|
||||||
|
[Obsolete("With empty parameters, this attribute makes no sense.")]
|
||||||
|
public MetaGroupAttribute() { }
|
||||||
public MetaGroupAttribute(string name)
|
public MetaGroupAttribute(string name)
|
||||||
{
|
{
|
||||||
Data = new MetaGroupRef(name);
|
Data = new MetaGroupRef(name);
|
||||||
}
|
}
|
||||||
|
public MetaGroupAttribute(params string[] path)
|
||||||
|
{
|
||||||
|
Data = new MetaGroupRef(string.Join('/', path));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public class MetaGroupRef
|
public class MetaGroupRef
|
||||||
{
|
{
|
||||||
@ -18,6 +26,7 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public readonly string Name;
|
public readonly string Name;
|
||||||
private string[] path = null;
|
private string[] path = null;
|
||||||
|
private static string pattern = @"Module(?=/)";
|
||||||
public IReadOnlyCollection<string> Splited
|
public IReadOnlyCollection<string> Splited
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -41,7 +50,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
name += '/';
|
name += '/';
|
||||||
}
|
}
|
||||||
Name = name;
|
Name = Regex.Replace(name, pattern, ""); ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private static Stack<Builder> _constructorBuildersStack = null;
|
private static Stack<Builder> _constructorBuildersStack = null;
|
||||||
private static Stack<Builder> GetBuildersStack()
|
private static Stack<Builder> GetBuildersStack()
|
||||||
{
|
{
|
||||||
if(_constructorBuildersStack == null)
|
if (_constructorBuildersStack == null)
|
||||||
{
|
{
|
||||||
_constructorBuildersStack = new Stack<Builder>();
|
_constructorBuildersStack = new Stack<Builder>();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using DCFApixels.DragonECS.Internal;
|
using DCFApixels.DragonECS.Internal;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@ -23,6 +24,7 @@ namespace DCFApixels.DragonECS
|
|||||||
PoolRecycledComponentsCapacity = poolRecycledComponentsCapacity;
|
PoolRecycledComponentsCapacity = poolRecycledComponentsCapacity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[DebuggerTypeProxy(typeof(DebuggerProxy))]
|
||||||
public partial class EcsWorld : IEntityStorage
|
public partial class EcsWorld : IEntityStorage
|
||||||
{
|
{
|
||||||
public readonly short id;
|
public readonly short id;
|
||||||
@ -544,6 +546,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
_entityDispenser.Upsize(minSize);
|
_entityDispenser.Upsize(minSize);
|
||||||
}
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
private int CalcEntityComponentMaskLastIndex()
|
private int CalcEntityComponentMaskLastIndex()
|
||||||
{
|
{
|
||||||
int result = _pools.Length / COMPONENT_MASK_CHUNK_SIZE;
|
int result = _pools.Length / COMPONENT_MASK_CHUNK_SIZE;
|
||||||
@ -554,7 +557,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
Array.Resize(ref _entities, newSize);
|
Array.Resize(ref _entities, newSize);
|
||||||
Array.Resize(ref _delEntBuffer, newSize);
|
Array.Resize(ref _delEntBuffer, newSize);
|
||||||
_entityComponentMaskLength = CalcEntityComponentMaskLastIndex();//_pools.Length / COMPONENT_MASK_CHUNK_SIZE + 1;
|
_entityComponentMaskLength = CalcEntityComponentMaskLastIndex(); //_pools.Length / COMPONENT_MASK_CHUNK_SIZE + 1;
|
||||||
Array.Resize(ref _entityComponentMasks, newSize * _entityComponentMaskLength);
|
Array.Resize(ref _entityComponentMasks, newSize * _entityComponentMaskLength);
|
||||||
|
|
||||||
ArrayUtility.Fill(_entities, EntitySlot.Empty, _entitiesCapacity);
|
ArrayUtility.Fill(_entities, EntitySlot.Empty, _entitiesCapacity);
|
||||||
@ -734,6 +737,34 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region DebuggerProxy
|
||||||
|
private EcsSpan GetSpan_Debug()
|
||||||
|
{
|
||||||
|
return _entityDispenser.UsedToEcsSpan(id);
|
||||||
|
}
|
||||||
|
protected class DebuggerProxy
|
||||||
|
{
|
||||||
|
private EcsWorld _world;
|
||||||
|
public EntitySlotInfo[] Entities
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
EntitySlotInfo[] result = new EntitySlotInfo[_world.Count];
|
||||||
|
int i = 0;
|
||||||
|
foreach (var e in _world.ToSpan())
|
||||||
|
{
|
||||||
|
result[i++] = _world.GetEntitySlotInfoDebug(e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public DebuggerProxy(EcsWorld world)
|
||||||
|
{
|
||||||
|
_world = world;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class EcsWorldExtenssions
|
public static class EcsWorldExtenssions
|
||||||
|
@ -77,8 +77,8 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
_listeners.InvokeOnAddAndGet(entityID);
|
|
||||||
EnableComponent(ref _items[itemIndex]);
|
EnableComponent(ref _items[itemIndex]);
|
||||||
|
_listeners.InvokeOnAddAndGet(entityID);
|
||||||
return ref _items[itemIndex];
|
return ref _items[itemIndex];
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@ -117,10 +117,10 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
|
EnableComponent(ref _items[itemIndex]);
|
||||||
_listeners.InvokeOnAdd(entityID);
|
_listeners.InvokeOnAdd(entityID);
|
||||||
}
|
}
|
||||||
_listeners.InvokeOnGet(entityID);
|
_listeners.InvokeOnGet(entityID);
|
||||||
EnableComponent(ref _items[itemIndex]);
|
|
||||||
return ref _items[itemIndex];
|
return ref _items[itemIndex];
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
Loading…
Reference in New Issue
Block a user