ajout du déblocage/évolutions des plantes (#89) et fix divers

This commit is contained in:
2025-11-07 13:26:04 +01:00
parent 11ae967845
commit ed675ed532
54 changed files with 901 additions and 483 deletions

View File

@@ -1,7 +1,5 @@
extends Node
signal inspected_changed(info : Inspector.Info)
const DEFAULT_ACTION_COLOR = Color.WHITE
const ENERGY_ACTION_COLOR = Color("ffff2b")
const NO_ENERGY_ACTION_COLOR = Color.RED
@@ -9,12 +7,13 @@ const ZONE_OPACITY = 0.4
const ZONE_ACTIVATED_COLOR = Color.TURQUOISE
const ZONE_DEACTIVATED_COLOR = Color.REBECCA_PURPLE
const CARD_VISUALISATION_TIME = 1.0
const CARD_VISUALISATION_TIME = 0.5
@export var default_cursor : Texture2D
var current_inspect : Node = null
var inspected : Node = null
var last_inspected : Node = null
var inspected_card_info : CardInfo = null
var time_last_inspected : float = 0.
var player : Player # renseigné par Player
var can_interact : bool = false
@@ -38,7 +37,7 @@ func _input(_event):
if Input.is_action_just_pressed("action"):
if can_interact:
var interactable = inspected as Interactable
var interactable = current_inspect as Interactable
player.try_interact(interactable)
elif can_use_item:
player.try_use_item(
@@ -47,14 +46,15 @@ func _input(_event):
)
func _process(delta):
time_last_inspected += delta
if current_inspect != inspected:
time_last_inspected += delta
%Inspector.position = get_viewport().get_mouse_position()
if player:
can_interact = (
inspected
and inspected is Interactable
and player.can_interact(inspected)
current_inspect
and current_inspect is Interactable
and player.can_interact(current_inspect)
)
current_selected_item = player.data.inventory.get_item()
@@ -84,39 +84,42 @@ func _process(delta):
update_inspector()
func inspect(node : Node):
if inspected and inspected != node and inspected.has_method("inspect"):
inspected.inspect(false)
if current_inspect and current_inspect != node and current_inspect.has_method("inspect"):
current_inspect.inspect(false)
current_inspect = node
inspected = node
last_inspected = node
if inspected is InspectableEntity:
inspected_card_info = inspected.card_info()
time_last_inspected = 0
if inspected.has_method("inspect"):
inspected.inspect(true)
if current_inspect.has_method("inspect"):
current_inspect.inspect(true)
update_inspector()
func update_card():
if not last_inspected or time_last_inspected > CARD_VISUALISATION_TIME:
if not inspected or time_last_inspected > CARD_VISUALISATION_TIME:
%CardVisualiser.hide()
elif last_inspected != null and last_inspected is InspectableEntity:
%CardVisualiser.card_info = last_inspected.card_info()
elif inspected != null and inspected is InspectableEntity:
if inspected_card_info != %CardVisualiser.card_info:
%CardVisualiser.card_info = inspected_card_info
%CardVisualiser.show()
var camera = get_viewport().get_camera_2d()
var screen_size = get_viewport().get_visible_rect().size
%CardPosition.position = last_inspected.global_position - camera.global_position + screen_size / 2
%CardPosition.position = inspected.global_position - camera.global_position + screen_size / 2
if %CardVisualiser.is_mouse_over():
time_last_inspected = 0.
func update_inspector():
if player:
if can_interact and inspected and inspected is Interactable:
if can_interact and current_inspect and current_inspect is Interactable:
%Action.visible = true
%ActionText.text = inspected.interact_text()
%Action.modulate = DEFAULT_ACTION_COLOR if inspected.interaction_cost(player) == 0 else ENERGY_ACTION_COLOR
%ActionEnergyImage.visible = inspected.interaction_cost(player) != 0
%ActionText.text = current_inspect.interact_text()
%Action.modulate = DEFAULT_ACTION_COLOR if current_inspect.interaction_cost(player) == 0 else ENERGY_ACTION_COLOR
%ActionEnergyImage.visible = current_inspect.interaction_cost(player) != 0
elif current_selected_item and current_selected_item.use_text() != "":
%Action.visible = true
%ActionText.text = current_selected_item.use_text() + (" (no energy left)" if not have_energy_to_use_item else "")
@@ -134,6 +137,6 @@ func update_inspector():
func stop_inspect(node : Node):
if node.has_method("inspect"):
node.inspect(false)
if inspected == node:
inspected = null
if current_inspect == node:
current_inspect = null
update_inspector()