Add callbacks to eden pillar attack

This commit is contained in:
2025-02-27 01:52:10 -08:00
parent 2589ed98d2
commit 9f3101b866

View File

@@ -51,32 +51,49 @@ public partial class EdenPillar : Enemy, IHasPrimaryAttack, IHasSecondaryAttack,
public void PrimaryAttack()
{
var target = new Vector3(_player.CurrentPosition.X, Position.Y, _player.CurrentPosition.Z);
_rotation.LookAt(target, Vector3.Up, true);
_rotation.RotateY(Rotation.Y + Mathf.DegToRad(_primaryAngle));
var rotationAngle = GetRotationAngle(Mathf.DegToRad(_primaryAngle));
var tweener = GetTree().CreateTween();
tweener.TweenMethod(Callable.From((float x) => RotateTowardsPlayer(x)), Rotation.Y, _rotation.Rotation.Y, 5f);
//tweener.TweenCallback(Callable.From(QueueFree));
tweener.TweenMethod(Callable.From((float x) => RotateTowardsPlayer(x)), Rotation.Y, rotationAngle, 5f);
tweener.TweenCallback(Callable.From(FirePrimaryShot));
}
public void SecondaryAttack()
{
var target = new Vector3(_player.CurrentPosition.X, Position.Y, _player.CurrentPosition.Z);
_rotation.LookAt(target, Vector3.Up, true);
_rotation.RotateY(Rotation.Y + Mathf.DegToRad(_secondaryAngle));
var rotationAngle = GetRotationAngle(Mathf.DegToRad(_secondaryAngle));
var tweener = GetTree().CreateTween();
tweener.TweenMethod(Callable.From((float x) => RotateTowardsPlayer(x)), Rotation.Y, _rotation.Rotation.Y, 5f);
//tweener.TweenCallback(Callable.From(QueueFree));
tweener.TweenMethod(Callable.From((float x) => RotateTowardsPlayer(x)), Rotation.Y, rotationAngle, 5f);
tweener.TweenCallback(Callable.From(FireSecondaryShot));
}
public void TertiaryAttack()
{
var rotationAngle = GetRotationAngle(Mathf.DegToRad(_tertiaryAngle));
var tweener = GetTree().CreateTween();
tweener.TweenMethod(Callable.From((float x) => RotateTowardsPlayer(x)), Rotation.Y, rotationAngle, 5f);
tweener.TweenCallback(Callable.From(FireTertiaryShot));
}
private void FirePrimaryShot()
{
GD.Print("Fire primary shot");
}
private void FireSecondaryShot()
{
GD.Print("Fire secondary shot");
}
private void FireTertiaryShot()
{
GD.Print("Fire tertiary shot");
}
private float GetRotationAngle(float angleOffsetInRadians)
{
var target = new Vector3(_player.CurrentPosition.X, Position.Y, _player.CurrentPosition.Z);
_rotation.LookAt(target, Vector3.Up, true);
_rotation.RotateY(Rotation.Y + Mathf.DegToRad(_tertiaryAngle));
var tweener = GetTree().CreateTween();
tweener.TweenMethod(Callable.From((float x) => RotateTowardsPlayer(x)), Rotation.Y, _rotation.Rotation.Y, 5f);
//tweener.TweenCallback(Callable.From(QueueFree));
_rotation.RotateY(Rotation.Y + angleOffsetInRadians);
return _rotation.Rotation.Y;
}
private void RotateTowardsPlayer(float angle) => Rotation = new Vector3(Rotation.X, angle, Rotation.Z);