Skip to content

Commit

Permalink
Revert
Browse files Browse the repository at this point in the history
  • Loading branch information
rexrainbow committed Oct 21, 2024
1 parent bc91af9 commit dd279a5
Show file tree
Hide file tree
Showing 22 changed files with 41 additions and 42 deletions.
15 changes: 0 additions & 15 deletions plugins/graph/graph/Graph.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import EE from '../../utils/eventemitter/EventEmitter.js';
import Methods from './Methods.js';
import GetObjUID from './graphitem/GetObjUID.js';
import UIDToObj from './graphitem/UIDToObj.js';
import UIDListToObjList from './graphitem/UIDListToObjList.js';
import GraphData from 'graphology';

class Graph extends EE {
Expand Down Expand Up @@ -76,18 +73,6 @@ class Graph extends EE {
this.removeAllNodes(destroy);
return this;
}

getObjUID(gameObject) {
return GetObjUID(gameObject);
}

getObj(uid, out) {
if (Array.isArray(uid)) {
return UIDListToObjList(uid, out);
} else {
return UIDToObj(uid);
}
}
}

Object.assign(
Expand Down
9 changes: 5 additions & 4 deletions plugins/graph/graph/edge/AddEdge.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import GetGraphItem from '../graphitem/GetGraphItem.js';
import GetGraphItem from '../../graphitem/GetGraphItem.js';
import GetObjUID from '../../graphitem/GetObjUID.js';

const DIRAtoB = 1;
const DIRBtoA = 2;
Expand Down Expand Up @@ -27,9 +28,9 @@ var AddEdge = function (edgeGameObject, nodeAGameObject, nodeBGameObject, dir) {
// Add edge
GetGraphItem(edgeGameObject).setGraph(this);

var edgeUID = this.getObjUID(edgeGameObject);
var nodeAUID = this.getObjUID(nodeAGameObject);
var nodeBUID = this.getObjUID(nodeBGameObject);
var edgeUID = GetObjUID(edgeGameObject);
var nodeAUID = GetObjUID(nodeAGameObject);
var nodeBUID = GetObjUID(nodeBGameObject);

if (!edgeUID || !nodeAUID || !nodeBUID) {
return this;
Expand Down
2 changes: 1 addition & 1 deletion plugins/graph/graph/edge/GetAllEdges.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import UIDToObj from '../graphitem/UIDToObj.js';
import UIDToObj from '../../graphitem/UIDToObj.js';

var GetAllEdges = function (out) {
if (out === undefined) {
Expand Down
5 changes: 3 additions & 2 deletions plugins/graph/graph/edge/GetEdgesOfNode.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import UIDToObj from '../graphitem/UIDToObj.js';
import UIDToObj from '../../graphitem/UIDToObj.js';
import GetObjUID from '../../graphitem/GetObjUID.js';

var GetEdgesOfNode = function (nodeGameObject, out) {
if (out === undefined) {
out = [];
}

var nodeUID = this.getObjUID(nodeGameObject);
var nodeUID = GetObjUID(nodeGameObject);
this.graph.forEachEdge(nodeUID, function (edgeUID) {
var edgeGameObject = UIDToObj(edgeUID);
if (!edgeGameObject) {
Expand Down
4 changes: 3 additions & 1 deletion plugins/graph/graph/edge/IsEdge.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import GetObjUID from '../../graphitem/GetObjUID.js';

var IsEdge = function (gameObejct) {
// uid or game object
var uid = this.getObjUID(gameObejct);
var uid = GetObjUID(gameObejct);
return this.graph.hasEdge(uid);
}

Expand Down
5 changes: 3 additions & 2 deletions plugins/graph/graph/edge/RemoveEdge.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import GetGraphItem from '../graphitem/GetGraphItem.js';
import GetGraphItem from '../../graphitem/GetGraphItem.js';
import GetObjUID from '../../graphitem/GetObjUID.js';

var RemoveEdge = function (edgeGameObject, destroy) {
if (!this.isEdge(edgeGameObject)) {
Expand All @@ -10,7 +11,7 @@ var RemoveEdge = function (edgeGameObject, destroy) {
}

// Remove node
var edgeUID = this.getObjUID(edgeGameObject);
var edgeUID = GetObjUID(edgeGameObject);
this.graph.dropEdge(edgeUID);

// Clear reference of graph
Expand Down
6 changes: 4 additions & 2 deletions plugins/graph/graph/neighbors/AreNeighborNodes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import GetObjUID from '../../graphitem/GetObjUID.js';

var AreNeighborNodes = function (nodeGameObjectA, nodeGameObjectB) {
var nodeUIDA = this.getObjUID(nodeGameObjectA),
nodeUIDB = this.getObjUID(nodeGameObjectB);
var nodeUIDA = GetObjUID(nodeGameObjectA),
nodeUIDB = GetObjUID(nodeGameObjectB);
if (!nodeUIDA || !nodeUIDB) {
return false;
}
Expand Down
5 changes: 3 additions & 2 deletions plugins/graph/graph/neighbors/GetNeighborNodes.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import UIDToObj from '../graphitem/UIDToObj.js';
import UIDToObj from '../../graphitem/UIDToObj.js';
import GetObjUID from '../../graphitem/GetObjUID.js';

var GetNeighborNodes = function (nodeGameObject, out) {
if (out === undefined) {
out = [];
}
var nodeUID = this.getObjUID(nodeGameObject);
var nodeUID = GetObjUID(nodeGameObject);
if (!nodeUID) {
return out;
}
Expand Down
5 changes: 3 additions & 2 deletions plugins/graph/graph/node/AddNode.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import GetGraphItem from '../graphitem/GetGraphItem.js';
import GetGraphItem from '../../graphitem/GetGraphItem.js';
import GetObjUID from '../../graphitem/GetObjUID.js';

var AddNode = function (gameObejct) {
if (this.isNode(gameObejct)) {
Expand All @@ -7,7 +8,7 @@ var AddNode = function (gameObejct) {

GetGraphItem(gameObejct).setGraph(this);

var nodeUID = this.getObjUID(gameObejct);
var nodeUID = GetObjUID(gameObejct);
this.graph.addNode(nodeUID);

return this;
Expand Down
2 changes: 1 addition & 1 deletion plugins/graph/graph/node/GetAllNodes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import UIDToObj from '../graphitem/UIDToObj.js';
import UIDToObj from '../../graphitem/UIDToObj.js';

var GetAllNodes = function (out) {
if (out === undefined) {
Expand Down
5 changes: 3 additions & 2 deletions plugins/graph/graph/node/GetNodesOfEdge.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import UIDListToObjList from '../graphitem/UIDListToObjList.js';
import UIDListToObjList from '../../graphitem/UIDListToObjList.js';
import GetObjUID from '../../graphitem/GetObjUID.js';

var GetNodesOfEdge = function (edgeGameObject, out) {
if (out === undefined) {
out = [];
}

var edgeUID = this.getObjUID(edgeGameObject);
var edgeUID = GetObjUID(edgeGameObject);
if (!this.graph.hasEdge(edgeUID)) {
return out;
}
Expand Down
4 changes: 3 additions & 1 deletion plugins/graph/graph/node/IsNode.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import GetObjUID from '../../graphitem/GetObjUID.js';

var IsNode = function (gameObejct) {
// uid or game object
var uid = this.getObjUID(gameObejct);
var uid = GetObjUID(gameObejct);
return this.graph.hasNode(uid);
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/graph/graph/node/RemoveAllNodes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import UIDToObj from '../graphitem/UIDToObj.js';
import GetGraphItem from '../graphitem/GetGraphItem.js';
import UIDToObj from '../../graphitem/UIDToObj.js';
import GetGraphItem from '../../graphitem/GetGraphItem.js';

var RemoveAllNodes = function (destroy) {
for (var nodeUid in this.nodes) {
Expand Down
5 changes: 3 additions & 2 deletions plugins/graph/graph/node/RemoveNode.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import GetGraphItem from '../graphitem/GetGraphItem.js';
import GetGraphItem from '../../graphitem/GetGraphItem.js';
import GetObjUID from '../../graphitem/GetObjUID.js';

var RemoveNode = function (nodeGameObject, destroy) {
if (!this.isNode(nodeGameObject)) {
Expand All @@ -10,7 +11,7 @@ var RemoveNode = function (nodeGameObject, destroy) {
}

// Remove node
var nodeUID = this.getObjUID(nodeGameObject);
var nodeUID = GetGraphItem(nodeGameObject);
this.graph.dropNode(nodeUID);

// Clear reference of graph
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ComponentBase from '../../../utils/componentbase/ComponentBase.js';
import ComponentBase from '../../utils/componentbase/ComponentBase.js';
import ObjBank from './ObjBank.js';

const uidKey = ObjBank.uidKey;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Bank from '../../../bank.js';
import Bank from '../../bank.js';

var ObjBank = new Bank({
uidKey: '$uid',
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion plugins/graph/layout/elkjs/BuildGraphData.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import UIDToObj from '../../graphitem/UIDToObj.js';
import { GetTopLeft } from '../../../utils/bounds/GetBounds.js';

var BuildGraphData = function (graph, config) {
var nodes = [];
graph.graph.forEachNode(function (uid) {
var nodeGameObject = graph.getObj(uid);
var nodeGameObject = UIDToObj(uid);
if (!nodeGameObject) {
return;
}
Expand Down

0 comments on commit dd279a5

Please sign in to comment.