playground systems process connections
This commit is contained in:
@@ -6,6 +6,7 @@ import nat.System;
|
||||
import nat.components.Position;
|
||||
|
||||
typedef PlaygroundEntryProcessor = (Archive, Entry, Position, ?ArchiveUI) -> Dynamic; // Whatever value is returned will be dropped, but this is easier than requiring ->:Void
|
||||
typedef PlaygroundConnectionProcessor = (Archive, Entry, Position, Entry, Position, ?ArchiveUI) -> Dynamic; // Whatever value is returned will be dropped, but this is easier than requiring ->:Void
|
||||
|
||||
/**
|
||||
* Base class for Systems that process Entries in a playground view and displays them in an interactive form
|
||||
|
@@ -6,6 +6,7 @@
|
||||
(defNew [&prop :ArchiveUI ui
|
||||
:EntryChecker canProcess
|
||||
&prop :PlaygroundEntryProcessor processor
|
||||
&prop :PlaygroundConnectionProcessor connectionProcessor
|
||||
:EntryProcessor onRemoveEntry]
|
||||
|
||||
(super
|
||||
@@ -31,7 +32,14 @@
|
||||
(method :Void clear [])
|
||||
|
||||
(method &override :Void process [:Archive archive &opt :ArchiveUI ui]
|
||||
(when _playgroundKey (super.process archive ui)))
|
||||
(when _playgroundKey
|
||||
(super.process archive ui)
|
||||
(doFor e (entries.iterator)
|
||||
(let [pos (dictGet (readComponent e Positions) _playgroundKey)]
|
||||
(doFor =>e2id _ (readComponentOr e Connections (new Map<String,Int>))
|
||||
(whenLet [e2 (dictGet archive.entries e2id)
|
||||
pos2 (dictGet (readComponent e2 Positions) _playgroundKey)]
|
||||
(connectionProcessor archive e pos e2 pos2 ui)))))))
|
||||
|
||||
(method defaultPosition [:Entry e]
|
||||
(object x 0.0 y 0.0 z 0.0))
|
||||
|
@@ -17,6 +17,8 @@
|
||||
(let [sprite (new EntrySprite this _playgroundKey pos archive e controller)]
|
||||
(playState.entryGroup.add sprite)
|
||||
(dictSet sprites e.id sprite)))
|
||||
->[archive e pos e2 pos2 &opt ui]
|
||||
~"$e $e2"
|
||||
->[archive e &opt ui]
|
||||
{
|
||||
(whenLet [sprite (dictGet sprites e.id)]
|
||||
|
Reference in New Issue
Block a user