mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 09:54:35 +08:00
update world constructors
This commit is contained in:
parent
d7b40e33b1
commit
8299c373b9
@ -2,12 +2,10 @@
|
|||||||
{
|
{
|
||||||
public sealed class EcsDefaultWorld : EcsWorld, IEntityStorage
|
public sealed class EcsDefaultWorld : EcsWorld, IEntityStorage
|
||||||
{
|
{
|
||||||
public EcsDefaultWorld() : base(null) { }
|
public EcsDefaultWorld(IEcsWorldConfig config = null, short worldID = -1) : base(config, worldID) { }
|
||||||
public EcsDefaultWorld(IEcsWorldConfig config) : base(config) { }
|
|
||||||
}
|
}
|
||||||
public sealed class EcsEventWorld : EcsWorld, IEntityStorage
|
public sealed class EcsEventWorld : EcsWorld, IEntityStorage
|
||||||
{
|
{
|
||||||
public EcsEventWorld() : base(null) { }
|
public EcsEventWorld(IEcsWorldConfig config = null, short worldID = -1) : base(config, worldID) { }
|
||||||
public EcsEventWorld(IEcsWorldConfig config) : base(config) { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,8 +92,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors/Destroy
|
#region Constructors/Destroy
|
||||||
public EcsWorld(IEcsWorldConfig config) : this(config, true) { }
|
public EcsWorld(IEcsWorldConfig config = null, short worldID = -1)
|
||||||
private EcsWorld(IEcsWorldConfig config, bool isIndexable)
|
|
||||||
{
|
{
|
||||||
if (config == null)
|
if (config == null)
|
||||||
{
|
{
|
||||||
@ -101,15 +100,22 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
_config = config;
|
_config = config;
|
||||||
|
|
||||||
if (isIndexable)
|
if (worldID < 0)
|
||||||
{
|
{
|
||||||
id = (short)_worldIdDispenser.UseFree();
|
worldID = (short)_worldIdDispenser.UseFree();
|
||||||
if (id >= Worlds.Length)
|
if (worldID >= Worlds.Length)
|
||||||
{
|
{
|
||||||
Array.Resize(ref Worlds, Worlds.Length << 1);
|
Array.Resize(ref Worlds, Worlds.Length << 1);
|
||||||
}
|
}
|
||||||
Worlds[id] = this;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Worlds[worldID] != null)
|
||||||
|
{
|
||||||
|
Throw.UndefinedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Worlds[worldID] = this;
|
||||||
|
|
||||||
_poolsMediator = new PoolsMediator(this);
|
_poolsMediator = new PoolsMediator(this);
|
||||||
|
|
||||||
|
@ -108,6 +108,12 @@ namespace DCFApixels.DragonECS
|
|||||||
TPool newPool = new TPool();
|
TPool newPool = new TPool();
|
||||||
|
|
||||||
Type componentType = newPool.ComponentType;
|
Type componentType = newPool.ComponentType;
|
||||||
|
//#if DEBUG //проверка соответсвия типов
|
||||||
|
// if(componentType != typeof(TPool).GetInterfaces().First(o => o.IsGenericType && o.GetGenericTypeDefinition() == typeof(IEcsPoolImplementation<>)).GetGenericArguments()[0])
|
||||||
|
// {
|
||||||
|
// Throw.UndefinedException();
|
||||||
|
// }
|
||||||
|
//#endif
|
||||||
int componentTypeCode = EcsTypeCode.Get(componentType);
|
int componentTypeCode = EcsTypeCode.Get(componentType);
|
||||||
|
|
||||||
if (_componentTypeCode_2_CmpTypeIDs.TryGetValue(componentTypeCode, out int componentTypeID))
|
if (_componentTypeCode_2_CmpTypeIDs.TryGetValue(componentTypeCode, out int componentTypeID))
|
||||||
|
@ -22,7 +22,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private const int DEL_ENT_BUFFER_MIN_SIZE = 64;
|
private const int DEL_ENT_BUFFER_MIN_SIZE = 64;
|
||||||
|
|
||||||
private static EcsWorld[] Worlds = new EcsWorld[4];
|
private static EcsWorld[] Worlds = new EcsWorld[4];
|
||||||
private static IdDispenser _worldIdDispenser = new IdDispenser(4);
|
private static IdDispenser _worldIdDispenser = new IdDispenser(4, 0);
|
||||||
|
|
||||||
private static List<DataReleaser> _dataReleaseres = new List<DataReleaser>();
|
private static List<DataReleaser> _dataReleaseres = new List<DataReleaser>();
|
||||||
//public static int Copacity => Worlds.Length;
|
//public static int Copacity => Worlds.Length;
|
||||||
@ -34,7 +34,9 @@ namespace DCFApixels.DragonECS
|
|||||||
private static void ReleaseData(int worldID)
|
private static void ReleaseData(int worldID)
|
||||||
{
|
{
|
||||||
for (int i = 0, iMax = _dataReleaseres.Count; i < iMax; i++)
|
for (int i = 0, iMax = _dataReleaseres.Count; i < iMax; i++)
|
||||||
|
{
|
||||||
_dataReleaseres[i].Release(worldID);
|
_dataReleaseres[i].Release(worldID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static EcsWorld GetWorld(int worldID) => Worlds[worldID];
|
public static EcsWorld GetWorld(int worldID) => Worlds[worldID];
|
||||||
@ -123,7 +125,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
private sealed class NullWorld : EcsWorld
|
private sealed class NullWorld : EcsWorld
|
||||||
{
|
{
|
||||||
internal NullWorld() : base(EcsWorldConfig.Empty, false) { }
|
internal NullWorld() : base(EcsWorldConfig.Empty, 0) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user