Ajout de la cinématique de début et refonte du système audio

Et toujours un peu de correction de bug par ci par là
This commit is contained in:
2026-02-11 21:11:32 +01:00
parent 4b8e59ee56
commit c992950789
54 changed files with 1186 additions and 882 deletions

View File

@@ -0,0 +1,38 @@
extends Area3D
class_name Interactable3D
@export var interactable = true
signal clicked
@export var hover_animation_player : AnimationPlayer
@export var audio_player : AudioStreamPlayer3D
func click():
clicked.emit()
func _ready():
if audio_player:
var default_volume := audio_player.volume_db
audio_player.volume_db += GameInfo.settings_data.sfx_volume
GameInfo.settings_data.sound_changed.connect(
func(settings : SettingsData):
audio_player.volume_db = default_volume + settings.sfx_volume
)
func play_audio():
if audio_player:
audio_player.play()
func stop_audio():
if audio_player:
audio_player.stop()
func _on_mouse_entered():
if hover_animation_player:
hover_animation_player.play("hover")
func _on_mouse_exited():
if hover_animation_player:
hover_animation_player.stop()

View File

@@ -0,0 +1 @@
uid://bj4d1x8n8ina

View File

@@ -41,9 +41,11 @@ func card_info() -> CardInfo:
return item.card_info()
func interact(player : Player) -> bool:
player.pick_item(item)
await pickup_animation(player)
pickup_animation(player)
queue_free()
player.pick_item(item)
return true
@@ -51,14 +53,10 @@ func pickup_animation(player : Player):
available = false
var tween : Tween = get_tree().create_tween()
tween.tween_property(self, "position", player.position, 0.2)
tween.tween_callback(
func():
Pointer.stop_inspect(self)
queue_free()
)
if object_sprite:
object_sprite.pickup_animation()
await tween.tween_property(self, "position", player.position, 0.2).finished
Pointer.stop_inspect(self)
func generate_sprite() -> ItemObjectSprite:
var sprite_node = SPRITE_SCENE.instantiate() as ItemObjectSprite

View File

@@ -16,5 +16,5 @@ func appear():
func interact(p : Player):
p.region.save()
SceneManager.change_scene("COCKPIT")
SceneManager.change_to_scene_id("COCKPIT")
return true

View File

@@ -42,10 +42,6 @@ static func generate_random() -> Seed:
PlantArchetype.get_random(),
[]
)
if randf() > MUTATION_PROBABILITY:
new_seed.plant_mutations.append(
new_seed.plant_archetype.available_mutations.pick_random().duplicate_deep()
)
return new_seed
func get_item_name() -> String:

View File

@@ -126,26 +126,31 @@ func try_move(move_to : Vector2):
func pick_item(item : Item) -> Item:
AudioManager.play_sfx("PickUp")
if data.inventory.is_full():
drop_item()
await drop_item()
var current_item : Item = null
var available_slot_ind = data.inventory.get_best_available_slot_ind()
if (
available_slot_ind == data.inventory.current_item_ind
&& data.inventory.items[available_slot_ind] != null
):
var current_item : Item = data.inventory.get_item()
current_item = data.inventory.get_item()
data.inventory.set_item(item, available_slot_ind)
return current_item
else :
if data.inventory.set_item(item, available_slot_ind):
data.inventory.set_current_item(available_slot_ind);
return null
# Save after a timer to let the time to the item to disappear
get_tree().create_timer(0.1).timeout.connect(region.save)
return current_item
func drop_item():
var item_to_drop = data.inventory.pop_item()
if item_to_drop:
terrain.drop_item(item_to_drop, global_position)
AudioManager.play_sfx("Drop")
region.save()
func delete_item(item: Item):
data.inventory.remove_item(item)
@@ -182,7 +187,7 @@ func use_item(item : Item):
data.energy -= item.energy_usage
if item.is_one_time_use():
data.inventory.remove_item(item)
region.save()
get_tree().create_timer(0.1).timeout.connect(region.save)
func upgrade_max_energy(amount = 1):
data.max_energy += amount

View File

@@ -10,7 +10,7 @@
size = Vector2(2, 2)
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_eodxe"]
radius = 0.46868896
radius = 0.5854492
height = 1.7342377
[node name="Player3D" type="CharacterBody3D" unique_id=549819967 node_paths=PackedStringArray("pointer_texture_rect")]

View File

@@ -1,4 +1,5 @@
extends CharacterBody3D
class_name Player3D
const POINTER_TEXTURE = preload("res://common/icons/focus.svg")
const POINTER_ACTION_TEXTURE = preload("res://common/icons/hand-stop.svg")
@@ -9,9 +10,19 @@ const SPEED = 4.0
const MOUSE_SENSIVITY = 0.002
const RAY_LENGTH = 10.
var cockpit_action_hovered : CockpitAction = null
var cockpit_action_hovered : Interactable3D = null
var query_mouse := false
func _ready():
Dialogic.timeline_started.connect(
func():
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
)
Dialogic.timeline_ended.connect(
func():
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
)
func _input(event):
if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
rotate_y(-event.relative.x * MOUSE_SENSIVITY)
@@ -61,7 +72,7 @@ func update_mouse_hovered_cockpit_actions() -> void:
query.collide_with_areas = true
var result = space_state.intersect_ray(query)
if result and result.collider and result.collider is CockpitAction and result.collider.pickable:
if result and result.collider and result.collider is Interactable3D and result.collider.interactable:
if cockpit_action_hovered and cockpit_action_hovered != result.collider:
cockpit_action_hovered._on_mouse_exited()
cockpit_action_hovered = result.collider