add connections in NAT playground

This commit is contained in:
2022-09-08 01:17:00 +00:00
parent d328bc8227
commit 8e5fde91fb
5 changed files with 32 additions and 6 deletions

View File

@@ -130,4 +130,15 @@
(nth i2.imageScales i2.pinnedImageIndex))
(if (hasComponent e Scale)
(readComponent e Scale)
1.0)))
1.0)))
(function addConnections [:nat.Archive archive :nat.Entry e :Array<Entry> entriesToConnect]
(if (hasComponent e Connections)
(withWritableComponents archive e [conn Connections]
(doFor e2 entriesToConnect (dictSet conn e2.id 1)))
(addComponent archive e Connections (for e2 entriesToConnect =>e2.id 1))))
(function removeConnections [:nat.Archive archive :nat.Entry e :Array<Entry> entriesToRemove]
(when (hasComponent e Connections)
(withWritableComponents archive e [conn Connections]
(doFor e2 entriesToRemove (conn.remove e2.id)))))