mirror of
https://github.com/DCFApixels/DragonECS-Graphs.git
synced 2025-09-17 11:04:34 +08:00
fix/update
This commit is contained in:
parent
21b891b44c
commit
c8c8337393
@ -10,10 +10,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MetaID("DragonECS_ECC4CF479301897718600925B00A7DB4")]
|
[MetaID("DragonECS_ECC4CF479301897718600925B00A7DB4")]
|
||||||
public sealed class EcsGraphWorld : EcsWorld, IInjectionUnit, IInjectionBlock
|
public sealed class EcsGraphWorld : EcsWorld, IInjectionUnit, IInjectionBlock
|
||||||
{
|
{
|
||||||
public EcsGraphWorld() : base() { }
|
private const string DEFAULT_NAME = "Graph";
|
||||||
public EcsGraphWorld(EcsWorldConfig config = null, string name = null, short worldID = -1) : base(config, name == null ? "Default" : name, worldID) { }
|
public EcsGraphWorld() : base(default(EcsWorldConfig), DEFAULT_NAME) { }
|
||||||
public EcsGraphWorld(IConfigContainer configs, string name = null, short worldID = -1) : base(configs, name == null ? "Default" : name, worldID) { }
|
public EcsGraphWorld(EcsWorldConfig config = null, string name = null, short worldID = -1) : base(config, name == null ? DEFAULT_NAME : name, worldID) { }
|
||||||
|
public EcsGraphWorld(IConfigContainer configs, string name = null, short worldID = -1) : base(configs, name == null ? DEFAULT_NAME : name, worldID) { }
|
||||||
void IInjectionUnit.InitInjectionNode(InjectionGraph nodes)
|
void IInjectionUnit.InitInjectionNode(InjectionGraph nodes)
|
||||||
{
|
{
|
||||||
nodes.AddNode(this);
|
nodes.AddNode(this);
|
||||||
|
@ -88,11 +88,29 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
if (_matrix.TryGetValue(startEntityID, endEntityID, out int relEntityID))
|
if (_matrix.TryGetValue(startEntityID, endEntityID, out int relEntityID))
|
||||||
{
|
{
|
||||||
|
#if DEBUG && DRAGONECS_DEEP_DEBUG
|
||||||
|
if(_graphWorld.IsUsed(relEntityID) == false)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
}
|
||||||
|
var (s, e) = GetRelationStartEnd(relEntityID);
|
||||||
|
if (s != startEntityID || e != endEntityID)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return relEntityID;
|
return relEntityID;
|
||||||
}
|
}
|
||||||
return NewRelationInternal(startEntityID, endEntityID);
|
return NewRelationInternal(startEntityID, endEntityID);
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public int GetOrNewRelationNoDirection(int entityID, int otherEntityID)
|
||||||
|
{
|
||||||
|
return GetOrNewRelation(
|
||||||
|
entityID < otherEntityID ? entityID : otherEntityID,
|
||||||
|
entityID > otherEntityID ? entityID : otherEntityID);
|
||||||
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public int GetOrNewInverseRelation(int relEntityID)
|
public int GetOrNewInverseRelation(int relEntityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || !DISABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || !DISABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
@ -106,6 +124,15 @@ namespace DCFApixels.DragonECS
|
|||||||
private int NewRelationInternal(int startEntityID, int endEntityID)
|
private int NewRelationInternal(int startEntityID, int endEntityID)
|
||||||
{
|
{
|
||||||
int relEntityID = _graphWorld.NewEntity();
|
int relEntityID = _graphWorld.NewEntity();
|
||||||
|
|
||||||
|
#if DEBUG && DRAGONECS_DEEP_DEBUG
|
||||||
|
var (s, e) = GetRelationStartEnd(relEntityID);
|
||||||
|
if (s != 0 || e != 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
_matrix.Add(startEntityID, endEntityID, relEntityID);
|
_matrix.Add(startEntityID, endEntityID, relEntityID);
|
||||||
_relEntityInfos[relEntityID] = new RelationInfo(startEntityID, endEntityID);
|
_relEntityInfos[relEntityID] = new RelationInfo(startEntityID, endEntityID);
|
||||||
_count++;
|
_count++;
|
||||||
|
Loading…
Reference in New Issue
Block a user