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