From 10904e93e97e5171e9fdea519aa8fac6781c6b58 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 1 Jul 2022 23:37:37 +0000 Subject: [PATCH] forgot to add EntrySpriteDepthSystem --- .../source/EntrySpriteDepthSystem.hx | 13 ++++++++ .../source/EntrySpriteDepthSystem.kiss | 33 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 projects/nat-flixel-desktop-playground/source/EntrySpriteDepthSystem.hx create mode 100644 projects/nat-flixel-desktop-playground/source/EntrySpriteDepthSystem.kiss diff --git a/projects/nat-flixel-desktop-playground/source/EntrySpriteDepthSystem.hx b/projects/nat-flixel-desktop-playground/source/EntrySpriteDepthSystem.hx new file mode 100644 index 00000000..b601405d --- /dev/null +++ b/projects/nat-flixel-desktop-playground/source/EntrySpriteDepthSystem.hx @@ -0,0 +1,13 @@ +package; + +import kiss.Prelude; +import kiss.List; +import nat.Entry; +import nat.System; +import nat.BoolExpInterp; +import nat.ArchiveController; +import nat.components.Positions; +import flixel.FlxG; + +@:build(kiss.Kiss.build()) +class EntrySpriteDepthSystem extends System {} diff --git a/projects/nat-flixel-desktop-playground/source/EntrySpriteDepthSystem.kiss b/projects/nat-flixel-desktop-playground/source/EntrySpriteDepthSystem.kiss new file mode 100644 index 00000000..d7084cfe --- /dev/null +++ b/projects/nat-flixel-desktop-playground/source/EntrySpriteDepthSystem.kiss @@ -0,0 +1,33 @@ +(loadFrom "nat-archive-tool" "src/nat/Lib.kiss") + +(method z [:Entry e] + .z (dictGet (readComponent e Positions) spriteSystem.positionKey)) + +(method :Array collectOverlapping [:EntrySprite s &opt :Array overlapping] + (unless overlapping (set overlapping [])) + (overlapping.push s) + (FlxG.overlap s state.entryGroup + ->[_ s2] + (unless (contains overlapping s2) + (collectOverlapping s2 overlapping))) + overlapping) + +(defNew [&prop :PlayState state + &prop :EntrySpriteSystem spriteSystem] + (super + ->[archive e] + ?(and + (spriteSystem.sprites.exists e.id) + !(= 0 (z e))) + ->[archive e &opt ui] + (let [:Array inOrder + ~(sortBy + (collectOverlapping (dictGet spriteSystem.sprites e.id)) + ->s (- (z s.e)))] + // Looping twice avoids having to splice() the group + (doFor s inOrder + // This will leave null holes + (state.entryGroup.remove s)) + (doFor s inOrder + // this will fill the null holes in the right order + (state.entryGroup.add s))))) \ No newline at end of file