RapidGameFramework
Reusable Godot managers for data-driven small games
Loading...
Searching...
No Matches
game_state.gd
Go to the documentation of this file.
1extends Node
2
3
9
10const SAVE_PATH := "user://reflecting_pool_save.cfg"
11
12var start_new_game_requested := false
13var save_path := SAVE_PATH
14var card_save_slot := 1
15var card_new_game_requested := false
16var project_alchemy_save_slot := 1
17var project_alchemy_new_game_requested := false
18var project_alchemy_save_path := "user://project_alchemy_save.cfg"
19var platformer_level_id := ""
20var menu_return_screen := ""
21
22
23
24func request_new_game() -> void:
25 start_new_game_requested = true
26
27
28
29func consume_new_game_request() -> bool:
30 var requested = start_new_game_requested
31 start_new_game_requested = false
32 return requested
33
34
35
36func has_saved_game() -> bool:
37 return FileAccess.file_exists(save_path)
38
39
40
41func clear_saved_game() -> void:
42 if FileAccess.file_exists(save_path):
43 DirAccess.remove_absolute(ProjectSettings.globalize_path(save_path))
44
45
46
47func select_card_save_slot(slot:int, start_new:bool = false) -> void:
48 card_save_slot = clampi(slot, 1, 3)
49 card_new_game_requested = start_new
50
51
52
53func get_card_save_slot() -> int:
54 return clampi(card_save_slot, 1, 3)
55
56
57
58func consume_card_new_game_request() -> bool:
59 var requested = card_new_game_requested
60 card_new_game_requested = false
61 return requested
62
63
64
65func get_card_save_path(slot:int = -1) -> String:
66 var resolved_slot = get_card_save_slot() if slot < 1 else clampi(slot, 1, 3)
67 return "user://emoji_card_collector_slot_%d.cfg" % resolved_slot
68
69
70
71func has_card_save(slot:int) -> bool:
72 return FileAccess.file_exists(get_card_save_path(slot))
73
74
75
76func clear_card_save(slot:int) -> void:
77 var path = get_card_save_path(slot)
78 if FileAccess.file_exists(path):
79 DirAccess.remove_absolute(ProjectSettings.globalize_path(path))
80
81
82
83func request_project_alchemy_new_game() -> void:
84 project_alchemy_new_game_requested = true
85
86
87
88func select_project_alchemy_save_slot(slot:int, start_new:bool = false) -> void:
89 project_alchemy_save_slot = clampi(slot, 1, 3)
90 project_alchemy_save_path = get_project_alchemy_save_path(slot)
91 project_alchemy_new_game_requested = start_new
92
93
94
95func consume_project_alchemy_new_game_request() -> bool:
96 var requested = project_alchemy_new_game_requested
97 project_alchemy_new_game_requested = false
98 return requested
99
100
101
102func get_project_alchemy_save_path(slot:int = -1) -> String:
103 if slot > 0:
104 return "user://project_alchemy_slot_%d.cfg" % clampi(slot, 1, 3)
105 return project_alchemy_save_path
106
107
108
109func set_project_alchemy_save_path(path:String) -> void:
110 if path.strip_edges() != "":
111 project_alchemy_save_path = path
112
113
114
115func has_project_alchemy_save(slot:int = -1) -> bool:
116 return FileAccess.file_exists(get_project_alchemy_save_path(slot))
117
118
119
120func clear_project_alchemy_save() -> void:
121 var path = get_project_alchemy_save_path()
122 if FileAccess.file_exists(path):
123 DirAccess.remove_absolute(ProjectSettings.globalize_path(path))
124
125
126
127func clear_project_alchemy_save_slot(slot:int) -> void:
128 var path = get_project_alchemy_save_path(slot)
129 if FileAccess.file_exists(path):
130 DirAccess.remove_absolute(ProjectSettings.globalize_path(path))
131
132
133
134func select_platformer_level(level_id:String) -> void:
135 platformer_level_id = level_id.strip_edges()
136
137
138
139func consume_platformer_level() -> String:
140 var level_id = platformer_level_id
141 platformer_level_id = ""
142 return level_id
143
144
145
146func set_menu_return_screen(screen_id:String) -> void:
147 menu_return_screen = screen_id
148
149
150
151func consume_menu_return_screen() -> String:
152 var screen_id = menu_return_screen
153 menu_return_screen = ""
154 return screen_id