Fix up special floors
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System;
|
||||
using Zennysoft.Game.Ma;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Cellular : SpecialFloor
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node] private Area3D Exit { get; set; } = default!;
|
||||
|
||||
[Dependency] protected IGame Game => this.DependOn<IGame>();
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
Show();
|
||||
Exit.AreaEntered += Exit_AreaEntered;
|
||||
FloorIsLoaded = true;
|
||||
}
|
||||
|
||||
private void Exit_AreaEntered(Area3D area)
|
||||
{
|
||||
if (area.GetOwner() is IPlayer)
|
||||
ExitReached();
|
||||
}
|
||||
|
||||
public void ExitReached() => Game.FloorExitReached();
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
Exit.AreaEntered -= Exit_AreaEntered;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user