playground systems process connections
This commit is contained in:
@@ -6,6 +6,7 @@ import nat.System;
|
|||||||
import nat.components.Position;
|
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 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
|
* 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
|
(defNew [&prop :ArchiveUI ui
|
||||||
:EntryChecker canProcess
|
:EntryChecker canProcess
|
||||||
&prop :PlaygroundEntryProcessor processor
|
&prop :PlaygroundEntryProcessor processor
|
||||||
|
&prop :PlaygroundConnectionProcessor connectionProcessor
|
||||||
:EntryProcessor onRemoveEntry]
|
:EntryProcessor onRemoveEntry]
|
||||||
|
|
||||||
(super
|
(super
|
||||||
@@ -31,7 +32,14 @@
|
|||||||
(method :Void clear [])
|
(method :Void clear [])
|
||||||
|
|
||||||
(method &override :Void process [:Archive archive &opt :ArchiveUI ui]
|
(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]
|
(method defaultPosition [:Entry e]
|
||||||
(object x 0.0 y 0.0 z 0.0))
|
(object x 0.0 y 0.0 z 0.0))
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
(let [sprite (new EntrySprite this _playgroundKey pos archive e controller)]
|
(let [sprite (new EntrySprite this _playgroundKey pos archive e controller)]
|
||||||
(playState.entryGroup.add sprite)
|
(playState.entryGroup.add sprite)
|
||||||
(dictSet sprites e.id sprite)))
|
(dictSet sprites e.id sprite)))
|
||||||
|
->[archive e pos e2 pos2 &opt ui]
|
||||||
|
~"$e $e2"
|
||||||
->[archive e &opt ui]
|
->[archive e &opt ui]
|
||||||
{
|
{
|
||||||
(whenLet [sprite (dictGet sprites e.id)]
|
(whenLet [sprite (dictGet sprites e.id)]
|
||||||
|
|||||||
Reference in New Issue
Block a user