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() public void PrimaryAttack()
{ {
var target = new Vector3(_player.CurrentPosition.X, Position.Y, _player.CurrentPosition.Z); var rotationAngle = GetRotationAngle(Mathf.DegToRad(_primaryAngle));
_rotation.LookAt(target, Vector3.Up, true);
_rotation.RotateY(Rotation.Y + Mathf.DegToRad(_primaryAngle));
var tweener = GetTree().CreateTween(); var tweener = GetTree().CreateTween();
tweener.TweenMethod(Callable.From((float x) => RotateTowardsPlayer(x)), Rotation.Y, _rotation.Rotation.Y, 5f); tweener.TweenMethod(Callable.From((float x) => RotateTowardsPlayer(x)), Rotation.Y, rotationAngle, 5f);
//tweener.TweenCallback(Callable.From(QueueFree)); tweener.TweenCallback(Callable.From(FirePrimaryShot));
} }
public void SecondaryAttack() public void SecondaryAttack()
{ {
var target = new Vector3(_player.CurrentPosition.X, Position.Y, _player.CurrentPosition.Z); var rotationAngle = GetRotationAngle(Mathf.DegToRad(_secondaryAngle));
_rotation.LookAt(target, Vector3.Up, true);
_rotation.RotateY(Rotation.Y + Mathf.DegToRad(_secondaryAngle));
var tweener = GetTree().CreateTween(); var tweener = GetTree().CreateTween();
tweener.TweenMethod(Callable.From((float x) => RotateTowardsPlayer(x)), Rotation.Y, _rotation.Rotation.Y, 5f); tweener.TweenMethod(Callable.From((float x) => RotateTowardsPlayer(x)), Rotation.Y, rotationAngle, 5f);
//tweener.TweenCallback(Callable.From(QueueFree)); tweener.TweenCallback(Callable.From(FireSecondaryShot));
} }
public void TertiaryAttack() 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); var target = new Vector3(_player.CurrentPosition.X, Position.Y, _player.CurrentPosition.Z);
_rotation.LookAt(target, Vector3.Up, true); _rotation.LookAt(target, Vector3.Up, true);
_rotation.RotateY(Rotation.Y + Mathf.DegToRad(_tertiaryAngle)); _rotation.RotateY(Rotation.Y + angleOffsetInRadians);
var tweener = GetTree().CreateTween(); return _rotation.Rotation.Y;
tweener.TweenMethod(Callable.From((float x) => RotateTowardsPlayer(x)), Rotation.Y, _rotation.Rotation.Y, 5f);
//tweener.TweenCallback(Callable.From(QueueFree));
} }
private void RotateTowardsPlayer(float angle) => Rotation = new Vector3(Rotation.X, angle, Rotation.Z); private void RotateTowardsPlayer(float angle) => Rotation = new Vector3(Rotation.X, angle, Rotation.Z);