точно есть дэшм
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://b4qdee7if5hfy"
|
||||
path="res://.godot/imported/Bandit_228_-_Zimnij_diss_(Zvyki.com).mp3-a7aff52cd7e0c65652cebf6a8d6ce3a5.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sound/Bandit_228_-_Zimnij_diss_(Zvyki.com).mp3"
|
||||
dest_files=["res://.godot/imported/Bandit_228_-_Zimnij_diss_(Zvyki.com).mp3-a7aff52cd7e0c65652cebf6a8d6ce3a5.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
@@ -0,0 +1,102 @@
|
||||
extends Node
|
||||
|
||||
var player_a: AudioStreamPlayer
|
||||
var player_b: AudioStreamPlayer
|
||||
var current_player: AudioStreamPlayer
|
||||
|
||||
var max_volume: float = -5.0
|
||||
var min_volume: float = -80.0
|
||||
|
||||
var active_enemies: Array = []
|
||||
var current_track: AudioStream = null
|
||||
|
||||
# Словарь для сохранения позиции (секунды) каждого трека индивидуально
|
||||
var saved_positions: Dictionary = {}
|
||||
|
||||
func _ready() -> void:
|
||||
# Инициализируем аудио-плееры
|
||||
player_a = AudioStreamPlayer.new()
|
||||
player_b = AudioStreamPlayer.new()
|
||||
add_child(player_a)
|
||||
add_child(player_b)
|
||||
|
||||
# Принудительно подключаем к главному аудио-каналу Godot (Bus 0)
|
||||
if AudioServer.get_bus_count() > 0:
|
||||
player_a.bus = AudioServer.get_bus_name(0)
|
||||
player_b.bus = AudioServer.get_bus_name(0)
|
||||
|
||||
player_a.volume_db = min_volume
|
||||
player_b.volume_db = min_volume
|
||||
current_player = player_a
|
||||
|
||||
# Метод, вызываемый мобом, когда он ЗАМЕЧАЕТ игрока напрямую
|
||||
func register_enemy_vision(enemy: Node, track: AudioStream) -> void:
|
||||
if track == null: return
|
||||
|
||||
if not active_enemies.has(enemy):
|
||||
active_enemies.append(enemy)
|
||||
# Включаем трек последнего заметившего нас врага
|
||||
switch_to_track(track)
|
||||
|
||||
# Метод, вызываемый мобом, когда он ТЕРЯЕТ игрока или УМИРАЕТ
|
||||
func unregister_enemy_vision(enemy: Node, track: AudioStream) -> void:
|
||||
if active_enemies.has(enemy):
|
||||
active_enemies.erase(enemy)
|
||||
|
||||
if active_enemies.size() == 0:
|
||||
fade_out_current()
|
||||
else:
|
||||
# Если остались другие зоркие враги, включаем трек последнего активного моба
|
||||
var remaining_enemy = active_enemies[-1]
|
||||
if remaining_enemy and "custom_battle_music" in remaining_enemy and remaining_enemy.custom_battle_music:
|
||||
switch_to_track(remaining_enemy.custom_battle_music)
|
||||
|
||||
# Логика бесшовного переключения (Crossfade)
|
||||
func switch_to_track(new_track: AudioStream) -> void:
|
||||
if current_track == new_track and current_player.playing:
|
||||
return
|
||||
|
||||
# Запоминаем текущую секунду старого трека перед тем, как его приглушить
|
||||
if current_track != null and current_player.playing:
|
||||
saved_positions[current_track] = current_player.get_playback_position()
|
||||
|
||||
current_track = new_track
|
||||
|
||||
# Выбираем противоположный (свободный) плеер для кроссфейда
|
||||
var next_player = player_b if current_player == player_a else player_a
|
||||
next_player.stream = new_track
|
||||
|
||||
# Принудительно включаем встроенное зацикливание трека в Godot 4 через код
|
||||
if "loop" in next_player.stream:
|
||||
next_player.stream.loop = true
|
||||
elif next_player.stream is AudioStreamOggVorbis:
|
||||
next_player.stream.loop = true
|
||||
|
||||
# Выясняем, с какой секунды продолжить трек
|
||||
var start_pos = saved_positions.get(new_track, 0.0)
|
||||
next_player.play(start_pos)
|
||||
|
||||
# Запускаем плавное выравнивание громкости плееров за 1 секунду
|
||||
var tween = create_tween().set_parallel(true)
|
||||
tween.tween_property(current_player, "volume_db", min_volume, 1.0)
|
||||
tween.tween_property(next_player, "volume_db", max_volume, 1.0)
|
||||
|
||||
var old_player = current_player
|
||||
current_player = next_player
|
||||
|
||||
# Полностью останавливаем старый плеер только после завершения затухания
|
||||
tween.chain().tween_callback(func(): old_player.stop())
|
||||
print("[МУЗЫКА] Боевой режим! Трек запущен/продолжен с секунды: ", start_pos)
|
||||
|
||||
# Логика плавного выключения при выходе из боя
|
||||
func fade_out_current() -> void:
|
||||
current_track = null
|
||||
var tween = create_tween()
|
||||
tween.tween_property(current_player, "volume_db", min_volume, 2.0)
|
||||
tween.tween_callback(func():
|
||||
if active_enemies.size() == 0 and current_player.playing:
|
||||
if current_player.stream:
|
||||
saved_positions[current_player.stream] = current_player.get_playback_position()
|
||||
current_player.stop()
|
||||
print("[МУЗЫКА] Зона безопасна. Боевой трек поставлен на паузу.")
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dgg3biwjhbaeo
|
||||
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://kkoth74v40km"
|
||||
path="res://.godot/imported/Rep_Inkviziciya_Bandit_228_-_diss_na_hohlov_(SkySound.cc).mp3-29e3db274f2f71823d2d0fbd2a9f40a3.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sound/Rep_Inkviziciya_Bandit_228_-_diss_na_hohlov_(SkySound.cc).mp3"
|
||||
dest_files=["res://.godot/imported/Rep_Inkviziciya_Bandit_228_-_diss_na_hohlov_(SkySound.cc).mp3-29e3db274f2f71823d2d0fbd2a9f40a3.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://db15o7lfgctub"
|
||||
path="res://.godot/imported/ak.mp3-6cd21a0d108c1b3f0d4cf6a32d1880aa.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sound/effect/ak.mp3"
|
||||
dest_files=["res://.godot/imported/ak.mp3-6cd21a0d108c1b3f0d4cf6a32d1880aa.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://wqg8m4nlm87s"
|
||||
path="res://.godot/imported/pistol-loaded-to-fire.mp3-e9e11bfd2fd69f51fd339c5410620370.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sound/effect/pistol-loaded-to-fire.mp3"
|
||||
dest_files=["res://.godot/imported/pistol-loaded-to-fire.mp3-e9e11bfd2fd69f51fd339c5410620370.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://dreqp22wgbfnn"
|
||||
path="res://.godot/imported/pistol.mp3-2e921438494873e68984cf890b1ed590.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sound/effect/pistol.mp3"
|
||||
dest_files=["res://.godot/imported/pistol.mp3-2e921438494873e68984cf890b1ed590.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://b88waak17hcaf"
|
||||
path="res://.godot/imported/reloading-weapons.mp3-f84dd63e7502f84c94c1634a84827cf1.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sound/effect/reloading-weapons.mp3"
|
||||
dest_files=["res://.godot/imported/reloading-weapons.mp3-f84dd63e7502f84c94c1634a84827cf1.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
Reference in New Issue
Block a user