65 lines
1.7 KiB
C#
65 lines
1.7 KiB
C#
using Chickensoft.AutoInject;
|
|
using Chickensoft.Introspection;
|
|
using Godot;
|
|
using System.Linq;
|
|
using Zennysoft.Game.Abstractions;
|
|
using Zennysoft.Ma.Adapter;
|
|
|
|
namespace Zennysoft.Game.Ma;
|
|
|
|
[Meta(typeof(IAutoNode))]
|
|
public partial class Altar : SpecialFloor, IDungeonFloor
|
|
{
|
|
public override void _Notification(int what) => this.Notify(what);
|
|
|
|
[Dependency] protected IGame Game => this.DependOn<IGame>();
|
|
|
|
[Dependency] protected IPlayer _player => this.DependOn(() => GetParent().GetChildren().OfType<IPlayer>().Single());
|
|
|
|
[Node] private Area3D Exit { get; set; } = default!;
|
|
|
|
[Node] private Marker3D PlayerSpawnPoint { get; set; } = default!;
|
|
|
|
[Node] private Area3D NoExitArea { get; set; } = default!;
|
|
|
|
[Node] private Node DimmableAudio { get; set; } = default!;
|
|
|
|
[Export] public Resource Dialogue { get; set; } = default!;
|
|
|
|
public void OnResolved()
|
|
{
|
|
Show();
|
|
Exit.AreaEntered += Exit_AreaEntered;
|
|
NoExitArea.AreaEntered += NoExitArea_AreaEntered;
|
|
FloorIsLoaded = true;
|
|
var dimmableAudio = DimmableAudio.GetChildren().OfType<IDimmableAudioStreamPlayer>();
|
|
foreach (var dimmable in dimmableAudio)
|
|
dimmable.FadeIn();
|
|
}
|
|
|
|
public override void FadeOutAudio()
|
|
{
|
|
var dimmableAudio = DimmableAudio.GetChildren().OfType<IDimmableAudioStreamPlayer>();
|
|
foreach (var dimmable in dimmableAudio)
|
|
dimmable.FadeOut();
|
|
}
|
|
|
|
private void _player_PointUpFinished()
|
|
{
|
|
_player.Activate();
|
|
}
|
|
|
|
private void NoExitArea_AreaEntered(Area3D area)
|
|
{
|
|
DialogueController.ShowDialogue(Dialogue, "no_exit");
|
|
}
|
|
|
|
private void Exit_AreaEntered(Area3D area)
|
|
{
|
|
if (area.GetOwner() is IPlayer)
|
|
ExitReached();
|
|
}
|
|
|
|
public void ExitReached() => Game.FloorExitReached();
|
|
}
|