Refactor more stuff (Audio mostly)
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class InGameAudioLogic
|
||||
{
|
||||
public static class Output
|
||||
{
|
||||
#region BGM
|
||||
public readonly record struct PlayOverworldMusic;
|
||||
|
||||
public readonly record struct PlayDungeonThemeAMusic;
|
||||
#endregion
|
||||
|
||||
#region SFX
|
||||
public readonly record struct PlayPlayerAttackSound;
|
||||
|
||||
public readonly record struct PlayPlayerAttackWallSound;
|
||||
|
||||
public readonly record struct PlayMenuScrollSound;
|
||||
|
||||
public readonly record struct PlayEquipSound;
|
||||
|
||||
public readonly record struct PlayInventorySortedSound;
|
||||
|
||||
public readonly record struct PlayMenuBackSound;
|
||||
|
||||
public readonly record struct PlayHealingItemSound;
|
||||
|
||||
public readonly record struct PlayTeleportSound;
|
||||
#endregion
|
||||
|
||||
public readonly record struct PlayGameMusic;
|
||||
|
||||
public readonly record struct StopGameMusic;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://bfnbplmd35454
|
||||
@@ -0,0 +1,12 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class InGameAudioLogic
|
||||
{
|
||||
[Meta]
|
||||
public partial record State : StateLogic<State>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://c8cfpu81338hk
|
||||
@@ -0,0 +1,13 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
public interface IInGameAudioLogic : ILogicBlock<InGameAudioLogic.State>;
|
||||
|
||||
[Meta]
|
||||
[LogicBlock(typeof(State))]
|
||||
public partial class InGameAudioLogic :
|
||||
LogicBlock<InGameAudioLogic.State>, IInGameAudioLogic
|
||||
{
|
||||
public override Transition GetInitialState() => To<Enabled>();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://on5thilbaogw
|
||||
@@ -0,0 +1,11 @@
|
||||
using Chickensoft.Introspection;
|
||||
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class InGameAudioLogic
|
||||
{
|
||||
[Meta]
|
||||
public partial record Disabled : State
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://c02hwxip7xksf
|
||||
@@ -0,0 +1,74 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public partial class InGameAudioLogic
|
||||
{
|
||||
[Meta]
|
||||
public partial record Enabled : State
|
||||
{
|
||||
public Enabled()
|
||||
{
|
||||
OnAttach(() =>
|
||||
{
|
||||
var player = Get<IPlayer>();
|
||||
OnOverworldEntered();
|
||||
var gameEventDepot = Get<IGameEventDepot>();
|
||||
var gameRepo = Get<IGameRepo>();
|
||||
gameEventDepot.OverworldEntered += OnOverworldEntered;
|
||||
gameEventDepot.DungeonAThemeAreaEntered += OnDungeonAThemeEntered;
|
||||
gameEventDepot.MenuScrolled += OnMenuScrolled;
|
||||
gameEventDepot.MenuBackedOut += OnMenuBackedOut;
|
||||
player.EquippedWeapon.Changed += OnEquippedItem;
|
||||
player.EquippedArmor.Changed += OnEquippedItem;
|
||||
player.EquippedAccessory.Changed += OnEquippedItem;
|
||||
gameEventDepot.InventorySorted += OnInventorySorted;
|
||||
gameEventDepot.HealingItemConsumed += OnHealingItemConsumed;
|
||||
gameEventDepot.RestorativePickedUp += OnRestorativePickedUp;
|
||||
gameEventDepot.TeleportEntered += OnTeleportEntered;
|
||||
gameRepo.PlayerAttack += OnPlayerAttack;
|
||||
gameRepo.PlayerAttackedWall += OnPlayerAttackWall;
|
||||
});
|
||||
OnDetach(() =>
|
||||
{
|
||||
var gameEventDepot = Get<IGameEventDepot>();
|
||||
var player = Get<IPlayer>();
|
||||
var gameRepo = Get<IGameRepo>();
|
||||
gameEventDepot.OverworldEntered -= OnOverworldEntered;
|
||||
gameEventDepot.DungeonAThemeAreaEntered -= OnDungeonAThemeEntered;
|
||||
gameEventDepot.MenuScrolled -= OnMenuScrolled;
|
||||
gameEventDepot.MenuBackedOut -= OnMenuBackedOut;
|
||||
player.EquippedWeapon.Changed -= OnEquippedItem;
|
||||
player.EquippedArmor.Changed -= OnEquippedItem;
|
||||
player.EquippedAccessory.Changed -= OnEquippedItem;
|
||||
gameEventDepot.InventorySorted -= OnInventorySorted;
|
||||
gameEventDepot.TeleportEntered -= OnTeleportEntered;
|
||||
gameRepo.PlayerAttack -= OnPlayerAttack;
|
||||
gameRepo.PlayerAttackedWall -= OnPlayerAttackWall;
|
||||
});
|
||||
}
|
||||
|
||||
private void OnPlayerAttack() => Output(new Output.PlayPlayerAttackSound());
|
||||
|
||||
private void OnPlayerAttackWall() => Output(new Output.PlayPlayerAttackWallSound());
|
||||
|
||||
private void OnRestorativePickedUp(IHealthPack restorative) => Output(new Output.PlayHealingItemSound());
|
||||
|
||||
private void OnMenuBackedOut() => Output(new Output.PlayMenuBackSound());
|
||||
|
||||
private void OnHealingItemConsumed(InventoryItem stats) => Output(new Output.PlayHealingItemSound());
|
||||
|
||||
private void OnInventorySorted() => Output(new Output.PlayInventorySortedSound());
|
||||
|
||||
private void OnEquippedItem(InventoryItem equipableItem) => 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());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://ddvs2b5hjchag
|
||||
Reference in New Issue
Block a user