mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-17 17:34:36 +08:00
update world constructor
This commit is contained in:
parent
e0a3d54979
commit
04691e1716
@ -305,7 +305,6 @@ namespace DCFApixels.DragonECS
|
||||
return obj is IEcsTypeMetaProvider intr ? intr.MetaSource : obj;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
public interface ITypeMeta
|
||||
|
@ -33,7 +33,7 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
Name = string.Empty;
|
||||
Name = string.Empty;
|
||||
return;
|
||||
}
|
||||
name = name.Replace('\\', '/');
|
||||
|
@ -8,25 +8,6 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
public partial class EcsWorld : IEntityStorage
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Pack = 4, Size = 4 * 3)]
|
||||
private struct EntitySlot
|
||||
{
|
||||
public static readonly EntitySlot Empty = new EntitySlot(SLEEPING_GEN_FLAG, 0, false);
|
||||
[FieldOffset(0)]
|
||||
public short gen;
|
||||
[FieldOffset(2)]
|
||||
public short componentsCount;
|
||||
[FieldOffset(4)]
|
||||
public bool isUsed;
|
||||
//[FieldOffset(5)]
|
||||
//public bool isLocked;
|
||||
public EntitySlot(short gen, short componentsCount, bool isUsed)
|
||||
{
|
||||
this.gen = gen;
|
||||
this.componentsCount = componentsCount;
|
||||
this.isUsed = isUsed;
|
||||
}
|
||||
}
|
||||
public readonly short id;
|
||||
private IEcsWorldConfig _config;
|
||||
|
||||
@ -120,9 +101,14 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
config = EcsWorldConfig.Empty;
|
||||
}
|
||||
bool nullWorld = this is NullWorld;
|
||||
if(nullWorld == false && worldID == NULL_WORLD_ID)
|
||||
{
|
||||
EcsDebug.PrintWarning($"The world identifier cannot be {NULL_WORLD_ID}");
|
||||
}
|
||||
_config = config;
|
||||
|
||||
if (worldID < 0)
|
||||
if (worldID < 0 || (worldID == NULL_WORLD_ID && nullWorld == false))
|
||||
{
|
||||
worldID = (short)_worldIdDispenser.UseFree();
|
||||
}
|
||||
@ -686,6 +672,28 @@ namespace DCFApixels.DragonECS
|
||||
return count;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region EntitySlot
|
||||
[StructLayout(LayoutKind.Explicit, Pack = 4, Size = 4 * 3)]
|
||||
private struct EntitySlot
|
||||
{
|
||||
public static readonly EntitySlot Empty = new EntitySlot(SLEEPING_GEN_FLAG, 0, false);
|
||||
[FieldOffset(0)]
|
||||
public short gen;
|
||||
[FieldOffset(2)]
|
||||
public short componentsCount;
|
||||
[FieldOffset(4)]
|
||||
public bool isUsed;
|
||||
//[FieldOffset(5)]
|
||||
//public bool isLocked;
|
||||
public EntitySlot(short gen, short componentsCount, bool isUsed)
|
||||
{
|
||||
this.gen = gen;
|
||||
this.componentsCount = componentsCount;
|
||||
this.isUsed = isUsed;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Callbacks Interface
|
||||
|
@ -16,6 +16,8 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
public partial class EcsWorld
|
||||
{
|
||||
private const short NULL_WORLD_ID = 0;
|
||||
|
||||
private const short GEN_MASK = 0x7fff;
|
||||
private const short SLEEPING_GEN_FLAG = short.MinValue;
|
||||
private const int DEL_ENT_BUFFER_SIZE_OFFSET = 5;
|
||||
@ -29,7 +31,7 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
static EcsWorld()
|
||||
{
|
||||
_worlds[0] = new NullWorld();
|
||||
_worlds[NULL_WORLD_ID] = new NullWorld();
|
||||
}
|
||||
private static void ReleaseData(int worldID)
|
||||
{
|
||||
@ -78,8 +80,7 @@ namespace DCFApixels.DragonECS
|
||||
public static ref T GetForWorldUnchecked(int worldID)
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG)
|
||||
if (_mapping[worldID] <= 0)
|
||||
throw new Exception();
|
||||
if (_mapping[worldID] <= 0) { Throw.UndefinedException(); }
|
||||
#endif
|
||||
return ref _items[_mapping[worldID]];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user