mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-17 17:34:34 +08:00
update / fix
This commit is contained in:
parent
13be11b5fd
commit
d704fa2418
@ -14,7 +14,14 @@ namespace DCFApixels.DragonECS
|
||||
private bool _created;
|
||||
|
||||
#region Properties
|
||||
public EcsEntityConnect Connect => _connect;
|
||||
public EcsEntityConnect Connect
|
||||
{
|
||||
get { return _connect; }
|
||||
}
|
||||
public EcsWorldProviderBase World
|
||||
{
|
||||
get { return _world; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UnityEvents
|
||||
@ -27,7 +34,6 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
|
||||
CreateEntity();
|
||||
}
|
||||
#endregion
|
||||
@ -35,7 +41,11 @@ namespace DCFApixels.DragonECS
|
||||
#region Methods
|
||||
private void AutoResolveWorldProviderDependensy()
|
||||
{
|
||||
_world = EcsDefaultWorldSingletonProvider.Instance;
|
||||
_world = AutoGetWorldProvider();
|
||||
}
|
||||
protected virtual EcsWorldProviderBase AutoGetWorldProvider()
|
||||
{
|
||||
return EcsDefaultWorldSingletonProvider.Instance;
|
||||
}
|
||||
public void ManualStart()
|
||||
{
|
||||
@ -57,9 +67,14 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
_created = true;
|
||||
}
|
||||
|
||||
private void InitConnect(EcsEntityConnect connect, EcsWorld world)
|
||||
{
|
||||
connect.ConnectWith(world.NewEntityLong(), true);
|
||||
connect.ConnectWith(CreateEntity(world), true);
|
||||
}
|
||||
protected virtual entlong CreateEntity(EcsWorld world)
|
||||
{
|
||||
return world.NewEntityLong();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -57,12 +57,14 @@ namespace DCFApixels.DragonECS
|
||||
private entlong _entity;
|
||||
private EcsWorld _world;
|
||||
|
||||
[SerializeField]
|
||||
private bool _deleteEntiityWithDestroy = false;
|
||||
[SerializeField]
|
||||
private ScriptableEntityTemplate[] _scriptableTemplates;
|
||||
[SerializeField]
|
||||
private MonoEntityTemplate[] _monoTemplates;
|
||||
|
||||
private bool _isConnected = false;
|
||||
private bool _isConnectInvoked = false;
|
||||
|
||||
#region Properties
|
||||
public entlong Entity
|
||||
@ -101,7 +103,7 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
if (entity.TryUnpack(out int newEntityID, out EcsWorld world))
|
||||
{
|
||||
_isConnected = true;
|
||||
_isConnectInvoked = true;
|
||||
_entity = entity;
|
||||
_world = world;
|
||||
var goConnects = world.GetPool<GameObjectConnect>();
|
||||
@ -123,11 +125,11 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
public void Disconnect()
|
||||
{
|
||||
if (_isConnected == false)
|
||||
if (_isConnectInvoked == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_isConnected = false;
|
||||
_isConnectInvoked = false;
|
||||
if (_entity.TryGetID(out int oldEntityID) && _world != null)
|
||||
{
|
||||
var unityGameObjects = _world.GetPool<GameObjectConnect>();
|
||||
@ -155,7 +157,12 @@ namespace DCFApixels.DragonECS
|
||||
#region UnityEvents
|
||||
private void OnDestroy()
|
||||
{
|
||||
entlong ent = _entity;
|
||||
Disconnect();
|
||||
if (_deleteEntiityWithDestroy && ent.TryUnpack(out int id, out EcsWorld world))
|
||||
{
|
||||
world.DelEntity(id);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -191,7 +198,15 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
private static void Autoset(EcsEntityConnect target)
|
||||
{
|
||||
var result = target.MonoTemplates.Where(o => o != null).Union(GetTemplatesFor(target.transform));
|
||||
IEnumerable<MonoEntityTemplate> result;
|
||||
if (target.MonoTemplates != null && target.MonoTemplates.Count() > 0)
|
||||
{
|
||||
result = target.MonoTemplates.Where(o => o != null).Union(GetTemplatesFor(target.transform));
|
||||
}
|
||||
else
|
||||
{
|
||||
result = GetTemplatesFor(target.transform);
|
||||
}
|
||||
|
||||
target._monoTemplates = result.ToArray();
|
||||
EditorUtility.SetDirty(target);
|
||||
|
@ -256,12 +256,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
GenericMenu genericMenu = new GenericMenu();
|
||||
|
||||
var pools = world.AllPools;
|
||||
for (int i = 0; i < world.PoolsCount; i++)
|
||||
for (int i = 0; i < pools.Length; i++)
|
||||
{
|
||||
var pool = pools[i];
|
||||
if (pool.IsNullOrDummy())
|
||||
{
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
var meta = pool.ComponentType.ToMeta();
|
||||
|
Loading…
Reference in New Issue
Block a user