Disable audio by default

This commit is contained in:
2024-09-14 16:09:01 -07:00
parent cd8806a9fe
commit 096bcd6168
6 changed files with 69 additions and 45 deletions

View File

@@ -19,7 +19,6 @@ stretch = true
unique_name_in_owner = true unique_name_in_owner = true
transparent_bg = true transparent_bg = true
handle_input_locally = false handle_input_locally = false
audio_listener_enable_2d = true
size = Vector2i(1920, 1080) size = Vector2i(1920, 1080)
render_target_update_mode = 4 render_target_update_mode = 4

View File

@@ -9,47 +9,5 @@ public partial class InGameAudioLogic
[Meta] [Meta]
public partial record State : StateLogic<State> public partial record State : StateLogic<State>
{ {
public State()
{
OnAttach(() =>
{
var gameEventDepot = Get<IGameEventDepot>();
gameEventDepot.OverworldEntered += OnOverworldEntered;
gameEventDepot.DungeonAThemeAreaEntered += OnDungeonAThemeEntered;
gameEventDepot.MenuScrolled += OnMenuScrolled;
gameEventDepot.MenuBackedOut += OnMenuBackedOut;
gameEventDepot.EquippedItem += OnEquippedItem;
gameEventDepot.InventorySorted += OnInventorySorted;
gameEventDepot.HealingItemConsumed += OnHealingItemConsumed;
gameEventDepot.TeleportEntered += OnTeleportEntered;
});
OnDetach(() =>
{
var gameEventDepot = Get<IGameEventDepot>();
gameEventDepot.OverworldEntered -= OnOverworldEntered;
gameEventDepot.DungeonAThemeAreaEntered -= OnDungeonAThemeEntered;
gameEventDepot.MenuScrolled -= OnMenuScrolled;
gameEventDepot.MenuBackedOut -= OnMenuBackedOut;
gameEventDepot.EquippedItem -= OnEquippedItem;
gameEventDepot.InventorySorted -= OnInventorySorted;
gameEventDepot.TeleportEntered -= OnTeleportEntered;
});
}
private void OnMenuBackedOut() => Output(new Output.PlayMenuBackSound());
private void OnHealingItemConsumed(ConsumableItemStats stats) => Output(new Output.PlayHealingItemSound());
private void OnInventorySorted() => Output(new Output.PlayInventorySortedSound());
private void OnEquippedItem() => Output(new Output.PlayEquipSound());
private void OnOverworldEntered() => Output(new Output.PlayOverworldMusic());
private void OnDungeonAThemeEntered() => Output(new Output.PlayDungeonThemeAMusic());
private void OnMenuScrolled() => Output(new Output.PlayMenuScrollSound());
private void OnTeleportEntered() => Output(new Output.PlayTeleportSound());
} }
} }

View File

@@ -9,5 +9,5 @@ public interface IInGameAudioLogic : ILogicBlock<InGameAudioLogic.State>;
public partial class InGameAudioLogic : public partial class InGameAudioLogic :
LogicBlock<InGameAudioLogic.State>, IInGameAudioLogic LogicBlock<InGameAudioLogic.State>, IInGameAudioLogic
{ {
public override Transition GetInitialState() => To<State>(); public override Transition GetInitialState() => To<Disabled>();
} }

View File

@@ -0,0 +1,12 @@
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
namespace GameJamDungeon;
public partial class InGameAudioLogic
{
[Meta]
public partial record Disabled : State
{
}
}

View File

@@ -0,0 +1,56 @@
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
using System;
namespace GameJamDungeon;
public partial class InGameAudioLogic
{
[Meta]
public partial record Enabled : State
{
public Enabled()
{
OnAttach(() =>
{
OnOverworldEntered();
var gameEventDepot = Get<IGameEventDepot>();
gameEventDepot.OverworldEntered += OnOverworldEntered;
gameEventDepot.DungeonAThemeAreaEntered += OnDungeonAThemeEntered;
gameEventDepot.MenuScrolled += OnMenuScrolled;
gameEventDepot.MenuBackedOut += OnMenuBackedOut;
gameEventDepot.EquippedItem += OnEquippedItem;
gameEventDepot.InventorySorted += OnInventorySorted;
gameEventDepot.HealingItemConsumed += OnHealingItemConsumed;
gameEventDepot.TeleportEntered += OnTeleportEntered;
});
OnDetach(() =>
{
var gameEventDepot = Get<IGameEventDepot>();
gameEventDepot.OverworldEntered -= OnOverworldEntered;
gameEventDepot.DungeonAThemeAreaEntered -= OnDungeonAThemeEntered;
gameEventDepot.MenuScrolled -= OnMenuScrolled;
gameEventDepot.MenuBackedOut -= OnMenuBackedOut;
gameEventDepot.EquippedItem -= OnEquippedItem;
gameEventDepot.InventorySorted -= OnInventorySorted;
gameEventDepot.TeleportEntered -= OnTeleportEntered;
});
}
private void OnMenuBackedOut() => Output(new Output.PlayMenuBackSound());
private void OnHealingItemConsumed(ConsumableItemStats stats) => Output(new Output.PlayHealingItemSound());
private void OnInventorySorted() => Output(new Output.PlayInventorySortedSound());
private void OnEquippedItem() => Output(new Output.PlayEquipSound());
private void OnOverworldEntered() => Output(new Output.PlayOverworldMusic());
private void OnDungeonAThemeEntered() => Output(new Output.PlayDungeonThemeAMusic());
private void OnMenuScrolled() => Output(new Output.PlayMenuScrollSound());
private void OnTeleportEntered() => Output(new Output.PlayTeleportSound());
}
}

View File

@@ -103,7 +103,6 @@ public partial class Game : Node3D, IGame
GameLogic.Start(); GameLogic.Start();
GameLogic.Input(new GameLogic.Input.Initialize()); GameLogic.Input(new GameLogic.Input.Initialize());
InGameAudio.OverworldBgm.FadeIn();
this.Provide(); this.Provide();