Compare commits

...

2 Commits

Author SHA1 Message Date
d7099548b5 Update .gitignore 2026-10-10 13:11:29 +02:00
cb9954e45f Poprawka po smeirci gracza 2026-10-10 13:11:04 +02:00
4 changed files with 24 additions and 1 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
# Godot 4+ specific ignores
.godot/
/android/
export_presets.cfg
Randoloot.console.exe
Randoloot.exe

View File

@ -1,6 +1,7 @@
extends Node
var selected_ship_path: String = ""
var restart_inventory: Dictionary = {}
func _ready() -> void:
var game_window := get_tree().root

View File

@ -66,6 +66,10 @@ func _ready() -> void:
_sprite.texture = ship_texture
var largest_dimension := maxf(ship_texture.get_width(), ship_texture.get_height())
_sprite.scale = Vector2.ONE * (64.0 / largest_dimension)
# Inventory children have already applied the restored equipment bonuses.
hull = max_hull
shields = max_shields
energy = max_energy
_update_shield_visual()
func _ensure_input_action(action_name: StringName, physical_key: Key) -> void:
@ -125,6 +129,7 @@ func _destroy_ship() -> void:
func _restart_level_after_destruction() -> void:
await get_tree().create_timer(1.1).timeout
if is_inside_tree():
$ShipInventory.preserve_for_restart()
get_tree().reload_current_scene()
func _physics_process(delta: float) -> void:

View File

@ -18,7 +18,13 @@ func _ready() -> void:
cargo.resize(CARGO_SIZE)
weapon_slots.resize(WEAPON_SLOT_COUNT)
module_slots.resize(MODULE_SLOT_COUNT)
if GameState.restart_inventory.is_empty():
_add_starter_items()
else:
cargo.assign(GameState.restart_inventory["cargo"])
weapon_slots.assign(GameState.restart_inventory["weapon"])
module_slots.assign(GameState.restart_inventory["module"])
GameState.restart_inventory.clear()
_recalculate_ship_stats()
inventory_changed.emit()
@ -29,6 +35,14 @@ func get_cargo_used() -> int:
used += 1
return used
func preserve_for_restart() -> void:
# Copy the slot arrays; resources retain levels and individual modifiers.
GameState.restart_inventory = {
"cargo": cargo.duplicate(),
"weapon": weapon_slots.duplicate(),
"module": module_slots.duplicate(),
}
func get_item(slot_kind: String, index: int) -> ItemInstance:
var slots := _get_slots(slot_kind)
if index < 0 or index >= slots.size():