File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import type { Node } from "@xyflow/react" ;
22import { create } from "zustand" ;
33
4+ /**
5+ * Clipboard state interface for managing copied nodes and their last paste position.
6+ */
47interface ClipboardState {
58 copiedNodes : Node [ ] ;
69 lastPastePosition : { x : number ; y : number } | null ;
@@ -9,6 +12,11 @@ interface ClipboardState {
912 hasCopiedNodes : ( ) => boolean ;
1013}
1114
15+ /**
16+ * Clipboard state management using Zustand.
17+ * This store manages copied nodes and their last paste position.
18+ * It provides methods to set copied nodes, clear the clipboard, and check if there are copied
19+ */
1220export const useClipboardStore = create < ClipboardState > ( ( set , get ) => ( {
1321 copiedNodes : [ ] ,
1422 lastPastePosition : null ,
Original file line number Diff line number Diff line change @@ -14,6 +14,11 @@ interface GameState {
1414 init : ( level : LevelId ) => void ;
1515}
1616
17+ /**
18+ * Game state management using Zustand.
19+ * This store manages the game state, including pause/play status,
20+ * current level, level completion status, and dialog visibility.
21+ */
1722export const useGameStore = create < GameState > ( ( set , get ) => ( {
1823 isPaused : false ,
1924 pause : ( ) => set ( { isPaused : true } ) ,
Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ interface KeyState {
99 setKeyReleasedFunction : ( keyFunction : ( key : string ) => boolean ) => void ;
1010}
1111
12+ /**
13+ * This store allows us the make key events more flexible.
14+ * It allows us to set custom functions for key down, pressed, and released events.
15+ */
1216export const useKeyStore = create < KeyState > ( ( set ) => ( {
1317 isKeyDown : ( ) => false ,
1418 setKeyDownFunction : ( keyFunction ) => set ( { isKeyDown : keyFunction } ) ,
Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ interface MouseState {
66 setMousePosFunction : ( mouseFunction : ( ) => Vec2 ) => void ;
77}
88
9+ /**
10+ * Unified mouse position management using Zustand.
11+ * This store allows us to set a custom function to retrieve the mouse position,
12+ */
913export const useMouseStore = create < MouseState > ( ( set ) => ( {
1014 getMousePos : ( ) => ( { x : 0 , y : 0 } ) as Vec2 ,
1115 setMousePosFunction : ( mouseFunction ) => set ( { getMousePos : mouseFunction } ) ,
Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ interface TimeState {
77 setDeltaTimeFunction : ( timeFunction : ( ) => number ) => void ;
88}
99
10+ /**
11+ * This store allows re-exports of the time functions from the game engine.
12+ */
1013export const useTimeStore = create < TimeState > ( ( set ) => ( {
1114 getTime : ( ) => 0 ,
1215 setTimeFunction : ( timeFunction ) => set ( { getTime : timeFunction } ) ,
You can’t perform that action at this time.
0 commit comments