extends Node @export var default_cursor : Texture2D var inspected_entity : InspectableEntity = null var player : Player :# renseigné par Player set(v): # if player: # player.player_updated.disconnect(update_inspector) player = v player.player_updated.connect( func(p): update_inspector() ) func _ready(): Input.set_custom_mouse_cursor(default_cursor) %InspectorText.visible = false %Interact.visible = false %Use.visible = false func _input(_event): if Input.is_action_just_pressed("interact"): $Audio/Click.play() if ( player != null and inspected_entity and inspected_entity is Interactable ): var interactable = inspected_entity as Interactable if interactable.can_interact(player): player.target_interactable = interactable func _process(_delta): %Inspector.position = get_viewport().get_mouse_position() func inspect_entity(entity : InspectableEntity): if inspected_entity and inspected_entity != entity: inspected_entity.inspected = false inspected_entity = entity inspected_entity.inspected = true update_inspector() func update_inspector(): print("updated") %InspectorText.visible = inspected_entity != null if inspected_entity: %InspectorText.text = inspected_entity.inspected_text() if player: %Interact.visible = inspected_entity and inspected_entity is Interactable and inspected_entity.can_interact(player) if inspected_entity and inspected_entity is Interactable and inspected_entity.can_interact(player): %InspectorInteractionText.text = inspected_entity.interact_text() %Use.visible = player.can_use_item if player.inventory.get_item() and player.can_use_item: %InspectorUseText.text = player.inventory.get_item().use_text(player) else: %Interact.visible = false %Use.visible = false func stop_inspect_entity(entity : InspectableEntity): entity.inspected = false if inspected_entity == entity: inspected_entity = null update_inspector()