60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using Chickensoft.AutoInject;
|
|
using Chickensoft.Introspection;
|
|
using Godot;
|
|
using System.Collections.Immutable;
|
|
using System.Linq;
|
|
using Zennysoft.Ma.Adapter;
|
|
|
|
namespace Zennysoft.Game.Ma;
|
|
|
|
[Meta(typeof(IAutoNode))]
|
|
public partial class Altar : Node3D, 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!;
|
|
|
|
public ImmutableList<IDungeonRoom> Rooms => [];
|
|
|
|
[Export] public Resource Dialogue { get; set; } = default!;
|
|
|
|
public bool FloorIsLoaded { get; set; }
|
|
|
|
public void OnResolved()
|
|
{
|
|
Show();
|
|
Exit.AreaEntered += Exit_AreaEntered;
|
|
NoExitArea.AreaEntered += NoExitArea_AreaEntered;
|
|
FloorIsLoaded = true;
|
|
}
|
|
|
|
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();
|
|
public void InitializeDungeon() { return; }
|
|
|
|
public (Vector3 Rotation, Vector3 Position) GetPlayerSpawnPoint() { return (PlayerSpawnPoint.Rotation, new Vector3(PlayerSpawnPoint.GlobalPosition.X, 0, PlayerSpawnPoint.GlobalPosition.Z)); }
|
|
}
|