This repository has been archived on 2025-09-28. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
rectangular/main/menu/slot/slot.gd

31 lines
830 B
GDScript

extends Node2D
const COLOR_NORMAL = Color.DARK_SLATE_GRAY
const COLOR_USED = Color.WHITE
@export var slot_idx: int
@export var slot_label: String = ""
func update_color():
if Gamestate.is_slot_used(slot_idx):
$Platform/P.color = COLOR_USED
else:
$Platform/P.color = COLOR_NORMAL
func _ready() -> void:
$Label.text = str(slot_label)
update_color()
func _on_area_2d_load_body_entered(body: Node2D) -> void:
# load slot & start game
if body == NodeRegistry.player:
Gamestate.current_slot = slot_idx
Gamestate.load_slot()
LevelsCore.load_entrypoint(Gamestate.last_entrypoint)
func _on_area_2d_delete_body_entered(body: Node2D) -> void:
# reset slot on disk
if body == NodeRegistry.player:
Gamestate.reset_slot(slot_idx)
update_color()
NodeRegistry.player.position = self.global_position - Vector2(0, 32)