Basic implementation for acquiring affinity sigil from Sarco
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using DialogueManagerRuntime;
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Zennysoft.Game.Ma;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Sarco : Node3D
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency] protected IPlayer _player => this.DependOn(() => GetParent().GetChildren().OfType<IPlayer>().Single());
|
||||
|
||||
[Dependency] public IGame _game => this.DependOn<IGame>();
|
||||
|
||||
[Dependency] private IGameRepo _gameRepo => this.DependOn<IGameRepo>();
|
||||
|
||||
[Export]
|
||||
public ElementType Affinity { get; set; }
|
||||
|
||||
[Export]
|
||||
public Resource Dialogue { get; set; }
|
||||
|
||||
[Node] public AnimationPlayer AnimationPlayer { get; set; }
|
||||
|
||||
[Node] public Area3D InteractZone { get; set; }
|
||||
|
||||
private bool _isInInteractZone = false;
|
||||
|
||||
private bool _interactionComplete = false;
|
||||
|
||||
public string AffinityString => Affinity.ToString();
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
SetPhysicsProcess(true);
|
||||
InteractZone.BodyEntered += InteractZone_BodyEntered;
|
||||
InteractZone.BodyExited += InteractZone_BodyExited;
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
_interactionComplete = _game.SarcoData.IgneousSarcoAcquired;
|
||||
if (_interactionComplete)
|
||||
ShowFlower();
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (Dialogue != null && @event.IsActionPressed(GameInputs.Interact) && _isInInteractZone && !_interactionComplete)
|
||||
{
|
||||
GetTree().Paused = true;
|
||||
DialogueController.ShowDialogue(Dialogue, "general", [this]);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task EquipAffinity()
|
||||
{
|
||||
_player.SetSigil(new Sigil() { ElementType = Affinity });
|
||||
}
|
||||
|
||||
public async Task ShowFlower()
|
||||
{
|
||||
AnimationPlayer.Play("fade_in");
|
||||
}
|
||||
|
||||
public async Task Finish()
|
||||
{
|
||||
GetTree().Paused = false;
|
||||
_interactionComplete = true;
|
||||
_game.SarcoData.IgneousSarcoAcquired = true;
|
||||
await _game.Save();
|
||||
}
|
||||
|
||||
private void InteractZone_BodyEntered(Node3D body)
|
||||
{
|
||||
_isInInteractZone = true;
|
||||
}
|
||||
|
||||
private void InteractZone_BodyExited(Node3D body)
|
||||
{
|
||||
_isInInteractZone = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user