Merge branch 'main' into dev

This commit is contained in:
DCFApixels 2024-12-06 20:06:57 +08:00
commit f388254857
5 changed files with 18 additions and 10 deletions

View File

@ -8,7 +8,7 @@
"displayName": "DragonECS-Unity", "displayName": "DragonECS-Unity",
"description": "Integration with Unity for DragonECS", "description": "Integration with Unity for DragonECS",
"unity": "2021.2", "unity": "2021.2",
"version": "0.5.6", "version": "0.5.7",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/DCFApixels/DragonECS-Unity.git" "url": "https://github.com/DCFApixels/DragonECS-Unity.git"

View File

@ -3,5 +3,8 @@
namespace DCFApixels.DragonECS namespace DCFApixels.DragonECS
{ {
[CreateAssetMenu(fileName = nameof(EcsDefaultWorldProvider), menuName = EcsConsts.FRAMEWORK_NAME + "/WorldProviders/" + nameof(EcsDefaultWorldProvider), order = 1)] [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); }
}
} }

View File

@ -14,5 +14,6 @@
return _instance; return _instance;
} }
} }
protected override EcsDefaultWorld BuildWorld(ConfigContainer configs) { return new EcsDefaultWorld(configs, WorldID); }
} }
} }

View File

@ -3,5 +3,8 @@
namespace DCFApixels.DragonECS namespace DCFApixels.DragonECS
{ {
[CreateAssetMenu(fileName = nameof(EcsWorldProvider), menuName = EcsConsts.FRAMEWORK_NAME + "/WorldProviders/" + nameof(EcsWorldProvider), order = 1)] [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); }
}
} }

View File

@ -46,6 +46,10 @@ namespace DCFApixels.DragonECS
{ {
get { return _world == null; } get { return _world == null; }
} }
public short WorldID
{
get { return _worldID; }
}
public int EntitiesCapacity public int EntitiesCapacity
{ {
get { return _entitiesCapacity; } get { return _entitiesCapacity; }
@ -89,7 +93,9 @@ namespace DCFApixels.DragonECS
{ {
if (_world == null || _world.IsDestroyed) 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); OnWorldCreated(_world);
} }
return _world; return _world;
@ -119,12 +125,7 @@ namespace DCFApixels.DragonECS
#endregion #endregion
#region Events #region Events
protected virtual TWorld BuildWorld() protected abstract TWorld BuildWorld(ConfigContainer configs);
{
EcsWorldConfig config = new EcsWorldConfig(_entitiesCapacity, _groupCapacity, _poolsCapacity, _poolComponentsCapacity, _poolRecycledComponentsCapacity);
ConfigContainer configs = new ConfigContainer().Set(config);
return (TWorld)Activator.CreateInstance(typeof(TWorld), new object[] { configs, null, _worldID });
}
protected virtual void OnWorldCreated(TWorld world) { } protected virtual void OnWorldCreated(TWorld world) { }
#endregion #endregion
} }