ajout des actions demandant un clic long et dev des region modifier

This commit is contained in:
2026-02-27 13:45:31 +01:00
parent e942250918
commit 8879c9d42b
18 changed files with 334 additions and 78 deletions

View File

@@ -9,7 +9,7 @@ const ZONE_DEACTIVATED_COLOR = Color.REBECCA_PURPLE
const CARD_VISUALISATION_TIME = 0.3
const CARD_UP_PADDING = 50
@export var default_cursor : Texture2D
var current_inspect : Node = null
@@ -22,58 +22,23 @@ var current_selected_item : Item = null
var have_energy_to_use_item : bool = false
var could_use_item : bool = false
var can_use_item : bool = false
var press_time := 0.
var press_action_done := false
func _ready():
Input.set_custom_mouse_cursor(default_cursor)
%Action.visible = false
func _input(_event):
if player:
if Input.is_action_just_pressed("move_pointer"):
player.try_move(
player.get_global_mouse_position()
)
if Input.is_action_just_pressed("drop"):
player.drop_item()
if Input.is_action_just_pressed("action"):
if current_inspect is InventoryGuiItemMouseDetector:
GameInfo.game_data.player_data.inventory.set_current_item(inspected.index)
elif can_interact:
var interactable = current_inspect as Interactable
player.try_interact(interactable)
elif can_use_item:
player.try_use_item(
player.data.inventory.get_item(),
player.get_global_mouse_position()
)
func _process(delta):
if player:
process_player_actions(delta)
else :
%ActionProgressBar.value = 0.
if current_inspect != inspected:
time_last_inspected += delta
%Inspector.position = get_viewport().get_mouse_position()
if player:
can_interact = (
current_inspect
and current_inspect is Interactable
and player.can_interact(current_inspect)
)
current_selected_item = player.data.inventory.get_item()
could_use_item = (
current_selected_item
and player.preview_could_use_item(current_selected_item)
)
have_energy_to_use_item = (
current_selected_item
and player.has_energy_to_use_item(current_selected_item)
)
can_use_item = could_use_item and have_energy_to_use_item
if current_selected_item and SceneManager.actual_scene.scene_id == "REGION":
%ActionZone.radius = current_selected_item.usage_zone_radius
%ActionZone.color = ZONE_ACTIVATED_COLOR if can_use_item else ZONE_DEACTIVATED_COLOR
@@ -86,6 +51,75 @@ func _process(delta):
update_inspector()
func process_player_actions(delta : float):
can_interact = (
current_inspect
and current_inspect is Interactable
and player.can_interact(current_inspect)
)
current_selected_item = player.data.inventory.get_item()
could_use_item = (
current_selected_item
and player.preview_could_use_item(current_selected_item)
)
have_energy_to_use_item = (
current_selected_item
and player.has_energy_to_use_item(current_selected_item)
)
can_use_item = could_use_item and have_energy_to_use_item
if Input.is_action_pressed("move_pointer"):
player.try_move(
player.get_global_mouse_position()
)
if Input.is_action_just_pressed("drop"):
player.drop_item()
if (
Input.is_action_pressed("action")
):
if (
can_use_item
and current_selected_item.is_action_need_press_time()
and not press_action_done
and not can_interact
and not current_inspect is InventoryGuiItemMouseDetector
):
press_time += delta
%ActionProgressBar.value = press_time/current_selected_item.get_action_press_time() * 100
if not %ActionProgressPlayer.playing:
%ActionProgressPlayer.play()
%ActionProgressPlayer.pitch_scale = 1. / (current_selected_item.get_action_press_time() / %ActionProgressPlayer.stream.get_length())
if press_time > current_selected_item.get_action_press_time():
player.try_use_item(
current_selected_item,
player.get_global_mouse_position()
)
press_action_done = true
else:
press_action_done = false
press_time = 0
%ActionProgressPlayer.playing = false
%ActionProgressBar.value = 0.
if Input.is_action_just_pressed("action"):
if current_inspect is InventoryGuiItemMouseDetector:
GameInfo.game_data.player_data.inventory.set_current_item(inspected.index)
elif can_interact:
var interactable = current_inspect as Interactable
player.try_interact(interactable)
elif can_use_item and not current_selected_item.is_action_need_press_time():
player.try_use_item(
current_selected_item,
player.get_global_mouse_position()
)
func inspect(node: Node):
if current_inspect and current_inspect != node and current_inspect.has_method("inspect"):
current_inspect.inspect(false)
@@ -131,7 +165,7 @@ func update_card():
func update_inspector():
if player:
if player and not get_tree().paused:
if can_interact and current_inspect and current_inspect is Interactable:
%Action.visible = true
%ActionText.text = current_inspect.interact_text()