Move savePosition() out of EntrySprite into PlaygroundSystem

This commit is contained in:
2023-02-15 05:47:26 -07:00
parent 1604387dc0
commit 3a21c8b687
2 changed files with 7 additions and 3 deletions

View File

@@ -83,6 +83,12 @@
pos2 (dictGet (readComponent e2 Positions) _playgroundKey)] pos2 (dictGet (readComponent e2 Positions) _playgroundKey)]
(connectionProcessor archive e pos e2 pos2 ui)))))))) (connectionProcessor archive e pos e2 pos2 ui))))))))
(method savePosition [:Entry e :Float x :Float y &opt :Float z]
(withWritableComponents ui.controller.archive e [positions Positions]
(let [oldPos (dictGet positions _playgroundKey)]
(dictSet positions _playgroundKey
(objectWith [z (or z oldPos.z)] x y)))))
(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))

View File

@@ -83,9 +83,7 @@
(method savePos [] (method savePos []
(FlxG.camera.extendScrollBounds this PlayState.SCROLL_BOUND_MARGIN) (FlxG.camera.extendScrollBounds this PlayState.SCROLL_BOUND_MARGIN)
(withWritableComponents archive e [positions Positions] (system.savePosition e (cast this.x Float) (cast this.y Float)))
(let [pos (dictGet positions positionKey)]
(dictSet positions positionKey (object x (cast this.x Float) y (cast this.y Float) z pos.z)))))
(method &override :Void update [:Float elapsed] (method &override :Void update [:Float elapsed]
(super.update elapsed) (super.update elapsed)