MCPcopy
hub / github.com/4ian/GDevelop / removeAllLinksOf

Method removeAllLinksOf

Extensions/LinkedObjects/linkedobjects.ts:99–138  ·  view source on GitHub ↗
(removedObject: gdjs.RuntimeObject)

Source from the content-addressed store, hash-verified

97 }
98
99 removeAllLinksOf(removedObject: gdjs.RuntimeObject) {
100 // Remove the other side of the links
101 // Note: don't use `this._getMapOfObjectsLinkedWith` as this would
102 // create an empty map of linked objects if not existing already.
103 const links = this._links.get(removedObject.id);
104 if (!links) {
105 // No existing links to other objects.
106 // This also means no links to the object from other objects.
107 return;
108 }
109
110 for (const linkedObjects of links.linkedObjectMap.values()) {
111 for (let i = 0; i < linkedObjects.length; i++) {
112 // This is the object on the other side of the link.
113 // We find the removed object in its list of linked objects and remove it.
114 const linkedObject = linkedObjects[i];
115
116 if (this._links.has(linkedObject.id)) {
117 const otherObjList = this._links
118 .get(linkedObject.id)!
119 .linkedObjectMap.get(removedObject.getName());
120
121 if (!otherObjList) {
122 logger.error(
123 `Can't find link from ${linkedObject.id} (${linkedObject.name}) to ${removedObject.id} (${removedObject.name})`
124 );
125 return;
126 }
127
128 const index = otherObjList.indexOf(removedObject);
129 if (index !== -1) {
130 otherObjList.splice(index, 1);
131 }
132 }
133 }
134 }
135
136 // Remove the links on the removedObject side.
137 this._links.delete(removedObject.id);
138 }
139
140 removeLinkBetween(objA: gdjs.RuntimeObject, objB: gdjs.RuntimeObject) {
141 if (this._links.has(objA.id)) {

Callers 3

linkedobjects.tsFile · 0.80
removeAllLinksOfFunction · 0.80
doTestFunction · 0.80

Calls 6

getMethod · 0.65
getNameMethod · 0.65
errorMethod · 0.65
deleteMethod · 0.65
valuesMethod · 0.45
hasMethod · 0.45

Tested by 1

doTestFunction · 0.64