mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:44:33 +08:00
rework EcsWorldProvider.BuildWorld
This commit is contained in:
parent
18b8d112db
commit
bddb71faf1
@ -3,5 +3,8 @@
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
[CreateAssetMenu(fileName = nameof(EcsDefaultWorldProvider), menuName = EcsConsts.FRAMEWORK_NAME + "/WorldProviders/" + nameof(EcsDefaultWorldProvider), order = 1)]
|
||||
public class EcsDefaultWorldProvider : EcsWorldProvider<EcsDefaultWorld> { }
|
||||
public class EcsDefaultWorldProvider : EcsWorldProvider<EcsDefaultWorld>
|
||||
{
|
||||
protected override EcsDefaultWorld BuildWorld(ConfigContainer configs) { return new EcsDefaultWorld(configs, WorldID); }
|
||||
}
|
||||
}
|
||||
|
@ -14,5 +14,6 @@
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
protected override EcsDefaultWorld BuildWorld(ConfigContainer configs) { return new EcsDefaultWorld(configs, WorldID); }
|
||||
}
|
||||
}
|
||||
|
@ -3,5 +3,8 @@
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
[CreateAssetMenu(fileName = nameof(EcsWorldProvider), menuName = EcsConsts.FRAMEWORK_NAME + "/WorldProviders/" + nameof(EcsWorldProvider), order = 1)]
|
||||
public class EcsWorldProvider : EcsWorldProvider<EcsWorld> { }
|
||||
public class EcsWorldProvider : EcsWorldProvider<EcsWorld>
|
||||
{
|
||||
protected override EcsWorld BuildWorld(ConfigContainer configs) { return new EcsWorld(configs, WorldID); }
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,10 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
get { return _world == null; }
|
||||
}
|
||||
public short WorldID
|
||||
{
|
||||
get { return _worldID; }
|
||||
}
|
||||
public int EntitiesCapacity
|
||||
{
|
||||
get { return _entitiesCapacity; }
|
||||
@ -89,7 +93,9 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
if (_world == null || _world.IsDestroyed)
|
||||
{
|
||||
Set(BuildWorld());
|
||||
EcsWorldConfig config = new EcsWorldConfig(_entitiesCapacity, _groupCapacity, _poolsCapacity, _poolComponentsCapacity, _poolRecycledComponentsCapacity);
|
||||
ConfigContainer configs = new ConfigContainer().Set(config);
|
||||
Set(BuildWorld(configs));
|
||||
OnWorldCreated(_world);
|
||||
}
|
||||
return _world;
|
||||
@ -119,12 +125,7 @@ namespace DCFApixels.DragonECS
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
protected virtual TWorld BuildWorld()
|
||||
{
|
||||
EcsWorldConfig config = new EcsWorldConfig(_entitiesCapacity, _groupCapacity, _poolsCapacity, _poolComponentsCapacity, _poolRecycledComponentsCapacity);
|
||||
ConfigContainer configs = new ConfigContainer().Set(config);
|
||||
return (TWorld)Activator.CreateInstance(typeof(TWorld), new object[] { configs, _worldID });
|
||||
}
|
||||
protected abstract TWorld BuildWorld(ConfigContainer configs);
|
||||
protected virtual void OnWorldCreated(TWorld world) { }
|
||||
#endregion
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user