mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
Update EcsEntityConnect.cs
This commit is contained in:
parent
1d8b693cca
commit
d0d3d5bd78
@ -53,15 +53,6 @@ namespace DCFApixels.DragonECS
|
|||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
public class EcsEntityConnect : MonoBehaviour
|
public class EcsEntityConnect : MonoBehaviour
|
||||||
{
|
{
|
||||||
private sealed class Aspect : EcsAspect
|
|
||||||
{
|
|
||||||
public EcsPool<UnityGameObjectConnect> unityGameObjects;
|
|
||||||
protected override void Init(Builder b)
|
|
||||||
{
|
|
||||||
unityGameObjects = b.Include<UnityGameObjectConnect>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private entlong _entity;
|
private entlong _entity;
|
||||||
private EcsWorld _world;
|
private EcsWorld _world;
|
||||||
|
|
||||||
@ -109,17 +100,17 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
_entity = entity;
|
_entity = entity;
|
||||||
_world = world;
|
_world = world;
|
||||||
var a = _world.GetAspect<Aspect>();
|
var unityGameObjects = _world.GetPool<UnityGameObjectConnect>();
|
||||||
if (a.unityGameObjects.Has(newEntityID))
|
if (unityGameObjects.Has(newEntityID))
|
||||||
{
|
{
|
||||||
ref readonly var uconnect = ref a.unityGameObjects.Read(newEntityID);
|
ref readonly var uconnect = ref unityGameObjects.Read(newEntityID);
|
||||||
if (uconnect.IsConnected)
|
if (uconnect.IsConnected)
|
||||||
{
|
{
|
||||||
uconnect.connect.Disconnect();
|
uconnect.connect.Disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a.unityGameObjects.TryAddOrGet(newEntityID) = new UnityGameObjectConnect(this);
|
unityGameObjects.TryAddOrGet(newEntityID) = new UnityGameObjectConnect(this);
|
||||||
if (applyTemplates)
|
if (applyTemplates)
|
||||||
{
|
{
|
||||||
ApplyTemplatesFor(world.id, newEntityID);
|
ApplyTemplatesFor(world.id, newEntityID);
|
||||||
@ -134,8 +125,8 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
if (_entity.TryGetID(out int oldEntityID) && _world != null)
|
if (_entity.TryGetID(out int oldEntityID) && _world != null)
|
||||||
{
|
{
|
||||||
var a = _world.GetAspect<Aspect>();
|
var unityGameObjects = _world.GetPool<UnityGameObjectConnect>();
|
||||||
a.unityGameObjects.TryDel(oldEntityID);
|
unityGameObjects.TryDel(oldEntityID);
|
||||||
}
|
}
|
||||||
_world = null;
|
_world = null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user