2025-03-05 15:38:52 +01:00
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2025-02-13 13:44:44 +01:00
|
|
|
|
using Godot;
|
2025-03-05 15:38:52 +01:00
|
|
|
|
using GTweens.Builders;
|
|
|
|
|
|
using GTweens.Easings;
|
|
|
|
|
|
using GTweens.Tweens;
|
|
|
|
|
|
using GTweensGodot.Extensions;
|
2025-02-13 13:44:44 +01:00
|
|
|
|
|
|
|
|
|
|
namespace Cirno.Scripts.Activables;
|
|
|
|
|
|
|
|
|
|
|
|
public partial class PlayerMover : ChainActivable
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
private GameManager _gameManager;
|
|
|
|
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
|
|
public Vector2 RelativeTargetPosition = Vector2.Zero;
|
|
|
|
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
|
|
public float MovementTime = 1f;
|
|
|
|
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
|
|
public Tween.EaseType EaseType = Tween.EaseType.InOut;
|
|
|
|
|
|
|
|
|
|
|
|
[Export]
|
2025-03-05 15:38:52 +01:00
|
|
|
|
public Tween.TransitionType TransitionType { get; private set; } = Tween.TransitionType.Linear;
|
|
|
|
|
|
|
|
|
|
|
|
[Export] public GTweens.Easings.Easing GTweenEasing { get; private set; } = Easing.Linear;
|
2025-02-13 13:44:44 +01:00
|
|
|
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
|
|
{
|
|
|
|
|
|
base._Ready();
|
|
|
|
|
|
|
|
|
|
|
|
_gameManager = this.GetGameManager();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-09 21:58:25 +01:00
|
|
|
|
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
2025-02-13 13:44:44 +01:00
|
|
|
|
{
|
2025-03-09 21:58:25 +01:00
|
|
|
|
if (_gameManager.Player is null) return false;
|
2025-02-13 13:44:44 +01:00
|
|
|
|
|
|
|
|
|
|
_ = MovePlayer();
|
2025-03-09 21:58:25 +01:00
|
|
|
|
|
|
|
|
|
|
return true;
|
2025-02-13 13:44:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async Task MovePlayer()
|
|
|
|
|
|
{
|
2025-03-02 11:58:30 +01:00
|
|
|
|
//_gameManager.Player.RequestMovementDisable(true);
|
2025-03-05 10:55:14 +01:00
|
|
|
|
_gameManager.Player.SetState(PlayerState.Cutscene);
|
2025-02-13 13:44:44 +01:00
|
|
|
|
|
2025-03-05 15:38:52 +01:00
|
|
|
|
var gtween = GTweenSequenceBuilder.New()
|
|
|
|
|
|
.Append(_gameManager.Player.MainObject.TweenGlobalPosition(
|
|
|
|
|
|
_gameManager.Player.MainObject.GlobalPosition + RelativeTargetPosition, MovementTime)
|
|
|
|
|
|
.SetEasing(GTweenEasing)
|
|
|
|
|
|
//.
|
|
|
|
|
|
)
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
await gtween.PlayAsync(CancellationToken.None);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tween tween = GetTree().CreateTween();
|
|
|
|
|
|
// tween.SetEase(EaseType);
|
|
|
|
|
|
// tween.SetTrans(TransitionType);
|
|
|
|
|
|
// tween.TweenProperty(_gameManager.Player, "global_position", _gameManager.Player.GlobalPosition + RelativeTargetPosition, MovementTime);
|
|
|
|
|
|
//
|
|
|
|
|
|
// // Wait for the tween to finish
|
|
|
|
|
|
// await ToSignal(tween, "finished");
|
2025-02-13 13:44:44 +01:00
|
|
|
|
|
2025-03-02 11:58:30 +01:00
|
|
|
|
//_gameManager.Player.RequestMovementDisable(false);
|
2025-03-05 10:55:14 +01:00
|
|
|
|
_gameManager.Player.SetState(PlayerState.Cutscene);
|
2025-02-13 13:44:44 +01:00
|
|
|
|
|
|
|
|
|
|
ActivateTargets();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|