add gamestate, doc and fix
This commit is contained in:
@@ -10,7 +10,7 @@ extends Node3D
|
||||
@export_group("Ref")
|
||||
@export var rotation_target: Node3D
|
||||
|
||||
@onready var camera: Camera3D = $Camera3D
|
||||
@onready var camera: Camera3D = $%Camera3D
|
||||
|
||||
var total_yaw: float = 0.0
|
||||
var total_pitch: float = 0.0
|
||||
@@ -29,6 +29,8 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("toggle_photo_mode"):
|
||||
is_active = !is_active
|
||||
|
||||
get_tree().paused = is_active
|
||||
|
||||
if !is_active:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
else:
|
||||
@@ -38,7 +40,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
total_yaw -= event.relative.x * rotation_speed
|
||||
|
||||
if event.is_action_pressed("take_photo"):
|
||||
take_photo()
|
||||
take_photo_async()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if not rotation_target:
|
||||
@@ -66,13 +68,15 @@ func _process(delta: float) -> void:
|
||||
global_position = orbit_pos + final_pan_offset
|
||||
global_basis = rot_basis
|
||||
|
||||
func take_photo() -> void:
|
||||
func take_photo_async() -> void:
|
||||
if !is_active:
|
||||
return
|
||||
|
||||
var targets = get_tree().get_nodes_in_group("collectible")
|
||||
var space_state = get_world_3d().direct_space_state
|
||||
|
||||
await CollectionManager.save_photo_to_disk_async()
|
||||
|
||||
for target in targets:
|
||||
if not target.collectible_data:
|
||||
continue
|
||||
@@ -85,5 +89,6 @@ func take_photo() -> void:
|
||||
var result = space_state.intersect_ray(query)
|
||||
|
||||
if result and result.collider == target:
|
||||
CollectionManager.unlock_photo(target.collectible_data.id)
|
||||
print("Foto scattata a: ", target.collectible_data.id)
|
||||
CollectionManager.unlock_collectible(target.collectible_data.id)
|
||||
|
||||
GameState.save_game()
|
||||
|
||||
Reference in New Issue
Block a user