Compare commits

...

5 Commits
0.3.3 ... main

Author SHA1 Message Date
DCFApixels
e2a6fd1c6b up version to 0.3.5 2025-03-31 12:18:06 +08:00
DCFApixels
c8c8337393 fix/update 2025-03-31 12:06:33 +08:00
DCFApixels
21b891b44c up version to 0.3.4 2025-03-29 16:15:42 +08:00
DCFApixels
aff9c033d1 update MetaIDs 2025-03-19 16:30:51 +08:00
DCFApixels
516da428dd update 2025-03-17 13:05:32 +08:00
4 changed files with 34 additions and 6 deletions

View File

@ -8,7 +8,7 @@
"displayName": "DragonECS-Graphs",
"description": "Entity Graphs for DragonECS",
"unity": "2020.3",
"version": "0.3.3",
"version": "0.3.5",
"repository": {
"type": "git",
"url": "https://github.com/DCFApixels/DragonECS-Graphs.git"

View File

@ -7,13 +7,13 @@ namespace DCFApixels.DragonECS
[MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.WORLDS_GROUP)]
[MetaDescription(EcsConsts.AUTHOR, "Inherits EcsWorld without extending its functionality and is used for specific injections. Can be used as argument to EcsWorld.CreateGraph(new " + nameof(EcsGraphWorld) + "()) and to store relation entity.")]
[DebuggerTypeProxy(typeof(DebuggerProxy))]
[MetaID("ECC4CF479301897718600925B00A7DB4")]
[MetaID("DragonECS_ECC4CF479301897718600925B00A7DB4")]
public sealed class EcsGraphWorld : EcsWorld, IInjectionUnit, IInjectionBlock
{
public EcsGraphWorld() : base() { }
public EcsGraphWorld(EcsWorldConfig config = null, string name = null, short worldID = -1) : base(config, name == null ? "Default" : name, worldID) { }
public EcsGraphWorld(IConfigContainer configs, string name = null, short worldID = -1) : base(configs, name == null ? "Default" : name, worldID) { }
private const string DEFAULT_NAME = "Graph";
public EcsGraphWorld() : base(default(EcsWorldConfig), DEFAULT_NAME) { }
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)
{
nodes.AddNode(this);

View File

@ -88,11 +88,29 @@ namespace DCFApixels.DragonECS
{
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 NewRelationInternal(startEntityID, endEntityID);
}
[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)
{
#if DEBUG || !DISABLE_DRAGONECS_ASSERT_CHEKS
@ -106,6 +124,15 @@ namespace DCFApixels.DragonECS
private int NewRelationInternal(int startEntityID, int endEntityID)
{
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);
_relEntityInfos[relEntityID] = new RelationInfo(startEntityID, endEntityID);
_count++;

View File

@ -1,6 +1,7 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Graphs.Internal;
namespace DCFApixels.DragonECS