2024-01-31 04:25:48 +08:00
|
|
|
|
using DCFApixels.DragonECS.Relations.Internal;
|
|
|
|
|
using DCFApixels.DragonECS.Relations.Utils;
|
2023-12-25 08:59:00 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
|
|
|
|
|
namespace DCFApixels.DragonECS
|
|
|
|
|
{
|
2024-01-29 17:40:38 +08:00
|
|
|
|
//Arc
|
|
|
|
|
//Arc world
|
|
|
|
|
//Rel entity
|
|
|
|
|
//Component
|
2024-01-28 02:19:49 +08:00
|
|
|
|
public class EcsArc
|
2023-12-25 08:59:00 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly EcsWorld _startWorld;
|
|
|
|
|
private readonly EcsWorld _endWorld;
|
|
|
|
|
private readonly EcsArcWorld _arcWorld;
|
|
|
|
|
|
2024-01-28 02:19:49 +08:00
|
|
|
|
private readonly StartWorldHandler _startWorldHandler;
|
|
|
|
|
private readonly ArcWorldHandler _arcWorldHandler;
|
|
|
|
|
private readonly EndWorldHandler _endWorldHandler;
|
2024-02-01 01:17:06 +08:00
|
|
|
|
private readonly LoopWorldHandler _loopWorldHandler;
|
2023-12-25 08:59:00 +08:00
|
|
|
|
|
|
|
|
|
private readonly SparseArray64<int> _relationsMatrix = new SparseArray64<int>();
|
|
|
|
|
|
2024-02-03 21:37:11 +08:00
|
|
|
|
private EcsGraph _entitiesGraph;
|
|
|
|
|
private EcsGraph.FriendEcsArc _entitiesGraphFriend;
|
2024-01-31 04:25:48 +08:00
|
|
|
|
|
2024-01-29 17:40:38 +08:00
|
|
|
|
private EcsGroup _relEntities;
|
|
|
|
|
private RelEntityInfo[] _relEntityInfos; //N * (N - 1) / 2
|
|
|
|
|
|
|
|
|
|
private bool _isLoop;
|
2024-01-31 04:25:48 +08:00
|
|
|
|
private bool _isInit = false;
|
2023-12-25 08:59:00 +08:00
|
|
|
|
|
|
|
|
|
#region Properties
|
2024-01-31 04:25:48 +08:00
|
|
|
|
internal bool IsInit_Internal
|
|
|
|
|
{
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
get { return _isInit; }
|
|
|
|
|
}
|
2024-01-29 17:40:38 +08:00
|
|
|
|
public EcsWorld StartWorld
|
|
|
|
|
{
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
get { return _startWorld; }
|
|
|
|
|
}
|
|
|
|
|
public EcsWorld EndWorld
|
|
|
|
|
{
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
get { return _endWorld; }
|
|
|
|
|
}
|
|
|
|
|
public EcsArcWorld ArcWorld
|
|
|
|
|
{
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
get { return _arcWorld; }
|
|
|
|
|
}
|
|
|
|
|
public int ArcWorldID
|
|
|
|
|
{
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
get { return _arcWorld.id; }
|
|
|
|
|
}
|
|
|
|
|
public EcsReadonlyGroup RelEntities
|
|
|
|
|
{
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
get { return _relEntities.Readonly; }
|
|
|
|
|
}
|
2024-02-03 21:37:11 +08:00
|
|
|
|
public EcsReadonlyGraph EntitiesGraph
|
2024-01-29 17:40:38 +08:00
|
|
|
|
{
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-02-03 21:37:11 +08:00
|
|
|
|
get { return _entitiesGraph.Readonly; }
|
2024-01-29 17:40:38 +08:00
|
|
|
|
}
|
|
|
|
|
public bool IsLoop
|
|
|
|
|
{
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
get { return _isLoop; }
|
|
|
|
|
}
|
2023-12-25 08:59:00 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
2024-01-31 04:25:48 +08:00
|
|
|
|
#region Constructors/Destroy
|
2024-01-07 23:19:03 +08:00
|
|
|
|
internal EcsArc(EcsWorld startWorld, EcsWorld endWorld, EcsArcWorld arcWorld)
|
2023-12-25 08:59:00 +08:00
|
|
|
|
{
|
2024-01-07 23:19:03 +08:00
|
|
|
|
_startWorld = startWorld;
|
|
|
|
|
_endWorld = endWorld;
|
2023-12-25 08:59:00 +08:00
|
|
|
|
_arcWorld = arcWorld;
|
|
|
|
|
|
2024-01-29 17:40:38 +08:00
|
|
|
|
_isLoop = startWorld == endWorld;
|
|
|
|
|
|
|
|
|
|
_relEntityInfos = new RelEntityInfo[arcWorld.Capacity];
|
2023-12-25 08:59:00 +08:00
|
|
|
|
|
2024-02-01 01:17:06 +08:00
|
|
|
|
|
2024-02-03 21:37:11 +08:00
|
|
|
|
_relEntities = EcsGroup.New(_arcWorld);
|
|
|
|
|
_entitiesGraph = new EcsGraph(this);
|
|
|
|
|
|
|
|
|
|
_entitiesGraphFriend = new EcsGraph.FriendEcsArc(this, _entitiesGraph);
|
|
|
|
|
|
|
|
|
|
_arcWorldHandler = new ArcWorldHandler(this);
|
2024-02-01 01:17:06 +08:00
|
|
|
|
if (_isLoop)
|
|
|
|
|
{
|
|
|
|
|
_loopWorldHandler = new LoopWorldHandler(this);
|
|
|
|
|
}
|
|
|
|
|
else
|
2024-01-29 17:40:38 +08:00
|
|
|
|
{
|
2024-02-01 01:17:06 +08:00
|
|
|
|
_startWorldHandler = new StartWorldHandler(this);
|
2024-01-29 17:40:38 +08:00
|
|
|
|
_endWorldHandler = new EndWorldHandler(this);
|
|
|
|
|
}
|
2024-01-07 23:19:03 +08:00
|
|
|
|
|
2024-01-31 04:25:48 +08:00
|
|
|
|
_isInit = true;
|
|
|
|
|
}
|
|
|
|
|
public void Destroy()
|
|
|
|
|
{
|
2024-02-01 01:17:06 +08:00
|
|
|
|
_arcWorldHandler.Destroy();
|
|
|
|
|
if (_isLoop)
|
|
|
|
|
{
|
|
|
|
|
_loopWorldHandler.Destroy();
|
|
|
|
|
}
|
|
|
|
|
else
|
2024-01-31 04:40:27 +08:00
|
|
|
|
{
|
2024-02-01 01:17:06 +08:00
|
|
|
|
_startWorldHandler.Destroy();
|
|
|
|
|
_endWorldHandler.Destroy();
|
2024-01-31 04:40:27 +08:00
|
|
|
|
}
|
2024-02-03 21:37:11 +08:00
|
|
|
|
|
2023-12-25 08:59:00 +08:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region New/Del
|
2024-01-29 17:40:38 +08:00
|
|
|
|
public int NewRelation(int startEntityID, int endEntityID)
|
2023-12-25 08:59:00 +08:00
|
|
|
|
{
|
2024-01-31 04:25:48 +08:00
|
|
|
|
if (HasRelation(startEntityID, endEntityID))
|
2024-01-29 17:40:38 +08:00
|
|
|
|
{
|
2024-02-03 21:37:11 +08:00
|
|
|
|
Throw.RelationAlreadyExists();
|
2024-01-29 17:40:38 +08:00
|
|
|
|
}
|
2024-01-07 23:19:03 +08:00
|
|
|
|
|
2024-01-29 17:40:38 +08:00
|
|
|
|
int relEntity = _arcWorld.NewEntity();
|
|
|
|
|
_relationsMatrix.Add(startEntityID, endEntityID, relEntity);
|
2024-01-07 23:19:03 +08:00
|
|
|
|
|
2024-01-29 17:40:38 +08:00
|
|
|
|
_relEntityInfos[relEntity] = new RelEntityInfo(startEntityID, endEntityID);
|
|
|
|
|
_relEntities.Add(relEntity);
|
2024-02-03 21:37:11 +08:00
|
|
|
|
_entitiesGraph.Add(relEntity);
|
2024-01-29 17:40:38 +08:00
|
|
|
|
return relEntity;
|
2023-12-25 08:59:00 +08:00
|
|
|
|
}
|
2024-01-29 17:40:38 +08:00
|
|
|
|
public void DelRelation(int startEntityID, int endEntityID)
|
2023-12-25 08:59:00 +08:00
|
|
|
|
{
|
2024-01-31 04:25:48 +08:00
|
|
|
|
if (_relationsMatrix.TryGetValue(startEntityID, endEntityID, out int relEntity))
|
2024-01-29 17:40:38 +08:00
|
|
|
|
{
|
2024-01-31 04:25:48 +08:00
|
|
|
|
_arcWorld.DelEntity(relEntity);
|
2024-01-29 17:40:38 +08:00
|
|
|
|
}
|
2024-01-31 04:25:48 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Throw.UndefinedRelationException();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-01-07 23:19:03 +08:00
|
|
|
|
|
2024-01-31 04:25:48 +08:00
|
|
|
|
private void ClearRelation_Internal(int startEntityID, int endEntityID)
|
|
|
|
|
{
|
|
|
|
|
if (_relationsMatrix.TryGetValue(startEntityID, endEntityID, out int relEntity))
|
|
|
|
|
{
|
|
|
|
|
_relEntities.Remove(relEntity);
|
2024-02-03 21:37:11 +08:00
|
|
|
|
_entitiesGraph.Del(relEntity);
|
2024-01-31 04:25:48 +08:00
|
|
|
|
_relationsMatrix.Remove(startEntityID, endEntityID);
|
|
|
|
|
_relEntityInfos[relEntity] = RelEntityInfo.Empty;
|
|
|
|
|
}
|
2023-12-25 08:59:00 +08:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2024-01-31 04:25:48 +08:00
|
|
|
|
#region GetRelation/HasRelation
|
|
|
|
|
public bool HasRelation(int startEntityID, int endEntityID)
|
2023-12-25 08:59:00 +08:00
|
|
|
|
{
|
|
|
|
|
return _relationsMatrix.Contains(startEntityID, endEntityID);
|
|
|
|
|
}
|
2024-01-31 04:25:48 +08:00
|
|
|
|
public int GetRelation(int startEntityID, int endEntityID)
|
2023-12-25 08:59:00 +08:00
|
|
|
|
{
|
2024-01-31 04:25:48 +08:00
|
|
|
|
if (!_relationsMatrix.TryGetValue(startEntityID, endEntityID, out int relEntityID))
|
|
|
|
|
{
|
|
|
|
|
Throw.UndefinedRelationException();
|
|
|
|
|
}
|
|
|
|
|
return relEntityID;
|
2023-12-25 08:59:00 +08:00
|
|
|
|
}
|
2024-01-31 04:25:48 +08:00
|
|
|
|
public bool TryGetRelation(int startEntityID, int endEntityID, out int relEntityID)
|
2023-12-25 08:59:00 +08:00
|
|
|
|
{
|
2024-01-31 04:25:48 +08:00
|
|
|
|
return _relationsMatrix.TryGetValue(startEntityID, endEntityID, out relEntityID);
|
2023-12-25 08:59:00 +08:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ArcEntityInfo
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-01-31 04:25:48 +08:00
|
|
|
|
public bool IsRelation(int relEntityID)
|
2023-12-25 08:59:00 +08:00
|
|
|
|
{
|
2024-01-31 04:25:48 +08:00
|
|
|
|
if (relEntityID <= 0 || relEntityID >= _relEntityInfos.Length)
|
|
|
|
|
{
|
2023-12-25 08:59:00 +08:00
|
|
|
|
return false;
|
2024-01-31 04:25:48 +08:00
|
|
|
|
}
|
|
|
|
|
return !_relEntityInfos[relEntityID].IsEmpty;
|
2023-12-25 08:59:00 +08:00
|
|
|
|
}
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-01-31 04:25:48 +08:00
|
|
|
|
public RelEntityInfo GetRelationInfo(int relEntityID)
|
2023-12-25 08:59:00 +08:00
|
|
|
|
{
|
2024-01-31 04:25:48 +08:00
|
|
|
|
if (relEntityID <= 0 || relEntityID >= _relEntityInfos.Length)
|
|
|
|
|
{
|
|
|
|
|
Throw.UndefinedException();
|
|
|
|
|
}
|
|
|
|
|
return _relEntityInfos[relEntityID];
|
|
|
|
|
}
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
public int GetRelStart(int relEntityID)
|
|
|
|
|
{
|
|
|
|
|
return GetRelationInfo(relEntityID).start;
|
2023-12-25 08:59:00 +08:00
|
|
|
|
}
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-01-31 04:25:48 +08:00
|
|
|
|
public int GetRelEnd(int relEntityID)
|
|
|
|
|
{
|
|
|
|
|
return GetRelationInfo(relEntityID).end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
public int GetInversedRelation(int relEntityID)
|
2023-12-25 08:59:00 +08:00
|
|
|
|
{
|
2024-01-31 04:25:48 +08:00
|
|
|
|
var (startEntityID, endEntityID) = GetRelationInfo(relEntityID);
|
|
|
|
|
return GetRelation(endEntityID, startEntityID);
|
2023-12-25 08:59:00 +08:00
|
|
|
|
}
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-01-31 04:25:48 +08:00
|
|
|
|
public bool TryGetInversedRelation(int relEntityID, out int inversedRelEntityID)
|
2023-12-25 08:59:00 +08:00
|
|
|
|
{
|
2024-01-31 04:25:48 +08:00
|
|
|
|
var (startEntityID, endEntityID) = GetRelationInfo(relEntityID);
|
|
|
|
|
return TryGetRelation(endEntityID, startEntityID, out inversedRelEntityID);
|
2023-12-25 08:59:00 +08:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Other
|
|
|
|
|
public EcsArc GetInversetArc()
|
|
|
|
|
{
|
2024-01-26 21:56:03 +08:00
|
|
|
|
return _endWorld.GetArc(_startWorld);
|
2023-12-25 08:59:00 +08:00
|
|
|
|
}
|
|
|
|
|
public bool TryGetInversetArc(out EcsArc arc)
|
|
|
|
|
{
|
2024-01-26 21:56:03 +08:00
|
|
|
|
return _endWorld.TryGetArc(_startWorld, out arc);
|
2023-12-25 08:59:00 +08:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2024-01-28 02:19:49 +08:00
|
|
|
|
|
|
|
|
|
#region VertexWorldHandler
|
2024-01-31 04:25:48 +08:00
|
|
|
|
private class ArcWorldHandler : IEcsWorldEventListener
|
2023-12-25 08:59:00 +08:00
|
|
|
|
{
|
2024-01-28 02:19:49 +08:00
|
|
|
|
private readonly EcsArc _arc;
|
|
|
|
|
public ArcWorldHandler(EcsArc arc)
|
|
|
|
|
{
|
|
|
|
|
_arc = arc;
|
2024-01-31 04:25:48 +08:00
|
|
|
|
_arc.ArcWorld.AddListener(this);
|
|
|
|
|
}
|
|
|
|
|
public void Destroy()
|
|
|
|
|
{
|
|
|
|
|
_arc.ArcWorld.RemoveListener(this);
|
2024-01-28 02:19:49 +08:00
|
|
|
|
}
|
|
|
|
|
#region Callbacks
|
2024-01-31 04:25:48 +08:00
|
|
|
|
public void OnReleaseDelEntityBuffer(ReadOnlySpan<int> relEntityBuffer)
|
2024-01-28 02:19:49 +08:00
|
|
|
|
{
|
2024-01-31 04:25:48 +08:00
|
|
|
|
foreach (var relEntityID in relEntityBuffer)
|
2024-01-28 02:19:49 +08:00
|
|
|
|
{
|
2024-01-31 04:25:48 +08:00
|
|
|
|
var (startEntityID, endEntityID) = _arc._relEntityInfos[relEntityID];
|
|
|
|
|
_arc.ClearRelation_Internal(startEntityID, endEntityID);
|
2024-01-28 02:19:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-01-29 17:40:38 +08:00
|
|
|
|
public void OnWorldDestroy() { }
|
2024-01-31 04:25:48 +08:00
|
|
|
|
public void OnWorldResize(int arcWorldNewSize)
|
2024-01-28 02:19:49 +08:00
|
|
|
|
{
|
2024-01-31 04:25:48 +08:00
|
|
|
|
Array.Resize(ref _arc._relEntityInfos, arcWorldNewSize);
|
2024-02-03 21:37:11 +08:00
|
|
|
|
_arc._entitiesGraph.UpArcSize(arcWorldNewSize);
|
2024-01-28 02:19:49 +08:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
2023-12-25 08:59:00 +08:00
|
|
|
|
}
|
2024-01-31 04:25:48 +08:00
|
|
|
|
private class StartWorldHandler : IEcsWorldEventListener
|
2024-01-07 23:19:03 +08:00
|
|
|
|
{
|
2024-01-28 02:19:49 +08:00
|
|
|
|
private readonly EcsArc _arc;
|
2024-01-29 17:40:38 +08:00
|
|
|
|
public StartWorldHandler(EcsArc arc)
|
2024-01-28 02:19:49 +08:00
|
|
|
|
{
|
|
|
|
|
_arc = arc;
|
2024-01-31 04:25:48 +08:00
|
|
|
|
_arc.StartWorld.AddListener(this);
|
2024-02-03 21:37:11 +08:00
|
|
|
|
OnWorldResize(_arc.StartWorld.Capacity);
|
2024-01-31 04:25:48 +08:00
|
|
|
|
}
|
|
|
|
|
public void Destroy()
|
|
|
|
|
{
|
|
|
|
|
_arc.StartWorld.RemoveListener(this);
|
2024-01-28 02:19:49 +08:00
|
|
|
|
}
|
|
|
|
|
#region Callbacks
|
2024-01-31 04:25:48 +08:00
|
|
|
|
public void OnReleaseDelEntityBuffer(ReadOnlySpan<int> startEntityBuffer)
|
2024-01-28 02:19:49 +08:00
|
|
|
|
{
|
2024-01-31 04:25:48 +08:00
|
|
|
|
foreach (var startEntityID in startEntityBuffer)
|
2024-01-29 17:40:38 +08:00
|
|
|
|
{
|
2024-02-03 21:37:11 +08:00
|
|
|
|
_arc._entitiesGraphFriend.DelStartAndDelRelEntities(startEntityID, _arc);
|
2024-01-29 17:40:38 +08:00
|
|
|
|
}
|
2024-02-03 21:37:11 +08:00
|
|
|
|
_arc._arcWorld.ReleaseDelEntityBufferAll();
|
2024-01-28 02:19:49 +08:00
|
|
|
|
}
|
2024-01-29 17:40:38 +08:00
|
|
|
|
public void OnWorldDestroy() { }
|
2024-02-03 21:37:11 +08:00
|
|
|
|
public void OnWorldResize(int startWorldNewSize)
|
|
|
|
|
{
|
|
|
|
|
_arc._entitiesGraph.UpStartSize(startWorldNewSize);
|
|
|
|
|
}
|
2024-01-28 02:19:49 +08:00
|
|
|
|
#endregion
|
|
|
|
|
}
|
2024-01-31 04:25:48 +08:00
|
|
|
|
private class EndWorldHandler : IEcsWorldEventListener
|
2023-12-25 08:59:00 +08:00
|
|
|
|
{
|
2024-01-28 02:19:49 +08:00
|
|
|
|
private readonly EcsArc _arc;
|
2024-01-29 17:40:38 +08:00
|
|
|
|
public EndWorldHandler(EcsArc arc)
|
2023-12-25 08:59:00 +08:00
|
|
|
|
{
|
2024-01-28 02:19:49 +08:00
|
|
|
|
_arc = arc;
|
2024-01-31 04:25:48 +08:00
|
|
|
|
_arc.EndWorld.AddListener(this);
|
2024-02-03 21:37:11 +08:00
|
|
|
|
OnWorldResize(_arc.EndWorld.Capacity);
|
2024-01-31 04:25:48 +08:00
|
|
|
|
}
|
|
|
|
|
public void Destroy()
|
|
|
|
|
{
|
|
|
|
|
_arc.EndWorld.RemoveListener(this);
|
2023-12-25 08:59:00 +08:00
|
|
|
|
}
|
2024-01-07 23:19:03 +08:00
|
|
|
|
#region Callbacks
|
2024-01-31 04:25:48 +08:00
|
|
|
|
public void OnReleaseDelEntityBuffer(ReadOnlySpan<int> endEntityBuffer)
|
2024-01-07 23:19:03 +08:00
|
|
|
|
{
|
2024-01-31 04:25:48 +08:00
|
|
|
|
foreach (var endEntityID in endEntityBuffer)
|
2024-01-29 17:40:38 +08:00
|
|
|
|
{
|
2024-02-03 21:37:11 +08:00
|
|
|
|
_arc._entitiesGraphFriend.DelEndAndDelRelEntities(endEntityID, _arc);
|
2024-01-29 17:40:38 +08:00
|
|
|
|
}
|
2024-02-03 21:37:11 +08:00
|
|
|
|
_arc._arcWorld.ReleaseDelEntityBufferAll();
|
2024-01-07 23:19:03 +08:00
|
|
|
|
}
|
2024-01-29 17:40:38 +08:00
|
|
|
|
public void OnWorldDestroy() { }
|
2024-02-03 21:37:11 +08:00
|
|
|
|
public void OnWorldResize(int endWorldNewSize)
|
|
|
|
|
{
|
|
|
|
|
_arc._entitiesGraph.UpEndSize(endWorldNewSize);
|
|
|
|
|
}
|
2024-01-07 23:19:03 +08:00
|
|
|
|
#endregion
|
2023-12-25 08:59:00 +08:00
|
|
|
|
}
|
2024-02-01 01:17:06 +08:00
|
|
|
|
private class LoopWorldHandler : IEcsWorldEventListener
|
|
|
|
|
{
|
|
|
|
|
private readonly EcsArc _arc;
|
|
|
|
|
public LoopWorldHandler(EcsArc arc)
|
|
|
|
|
{
|
|
|
|
|
_arc = arc;
|
|
|
|
|
_arc.StartWorld.AddListener(this);
|
2024-02-03 21:37:11 +08:00
|
|
|
|
OnWorldResize(_arc.StartWorld.Capacity);
|
2024-02-01 01:17:06 +08:00
|
|
|
|
}
|
|
|
|
|
public void Destroy()
|
|
|
|
|
{
|
|
|
|
|
_arc.StartWorld.RemoveListener(this);
|
|
|
|
|
}
|
|
|
|
|
#region Callbacks
|
|
|
|
|
public void OnReleaseDelEntityBuffer(ReadOnlySpan<int> startEntityBuffer)
|
|
|
|
|
{
|
|
|
|
|
foreach (var startEntityID in startEntityBuffer)
|
|
|
|
|
{
|
2024-02-03 21:37:11 +08:00
|
|
|
|
_arc._entitiesGraphFriend.DelStartAndDelRelEntities(startEntityID, _arc);
|
|
|
|
|
_arc._entitiesGraphFriend.DelEndAndDelRelEntities(startEntityID, _arc);
|
2024-02-01 01:17:06 +08:00
|
|
|
|
}
|
2024-02-03 21:37:11 +08:00
|
|
|
|
_arc._arcWorld.ReleaseDelEntityBufferAll();
|
2024-02-01 01:17:06 +08:00
|
|
|
|
}
|
|
|
|
|
public void OnWorldDestroy() { }
|
2024-02-03 21:37:11 +08:00
|
|
|
|
public void OnWorldResize(int startWorldNewSize)
|
|
|
|
|
{
|
|
|
|
|
_arc._entitiesGraph.UpStartSize(startWorldNewSize);
|
|
|
|
|
_arc._entitiesGraph.UpEndSize(startWorldNewSize);
|
|
|
|
|
}
|
2024-02-01 01:17:06 +08:00
|
|
|
|
#endregion
|
|
|
|
|
}
|
2023-12-25 08:59:00 +08:00
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|