Files
kiss-vscode/projects/nat-flixel-desktop-playground/source/EntrySpriteSystem.kiss

33 lines
1.3 KiB
Plaintext

(loadFrom "nat-archive-tool" "src/nat/Lib.kiss")
(prop :Map<String,EntrySprite> sprites (new Map))
(defNew [:String tagFilterString
&prop :String positionKey
:PlayState playState
&prop :ArchiveController controller]
(super
->[archive e]
?(and (tagsMatch e tagFilterString) (hasComponent e Images))
->[archive e &opt ui]
(unless (sprites.exists e.id)
(when !(hasComponent e Positions)
(addComponent archive e Positions (new Map)))
(withWritableComponents archive e [positions Positions]
(when !(positions.exists positionKey)
(dictSet positions positionKey (object x 0.0 y 0.0 z 0.0))))
(let [sprite (new EntrySprite this positionKey archive e controller)]
(playState.entryGroup.add sprite)
(dictSet sprites e.id sprite))))
(set onRemoveEntry
->[archive e &opt ui]
{
(.kill (dictGet sprites e.id))
(sprites.remove e.id)
// When an Entry is hidden, we can bet the user doesn't want it selected anymore
(controller.DeSelectEntry e)
}))
(method getSelectedSprites []
(filter (for e (controller.getSelectedEntries) (dictGet sprites e.id))))