continuing to switch to MapCell orientation

This commit is contained in:
2026-07-03 02:16:29 -04:00
parent e6355167e3
commit 336b72e4cb
13 changed files with 81 additions and 82 deletions
+6 -11
View File
@@ -18,28 +18,23 @@ public partial class ShootShortbow : PegAction
public override Tween CreateAnimation(Peg PEG)
{
Vector2 target = PEG._pegController._playArea._map.GetCellPositionFromAddress(Target(PEG));
MapCell target = Target(PEG);
Tween subtween = CreateTween();
subtween.TweenProperty(_image, "visible", true, 0.0f);
subtween.TweenProperty(_image, "rotation", PEG.GetAngleTo(target), 0.0f);
subtween.TweenProperty(_image, "global_position", target, 0.5f);
subtween.TweenProperty(_image, "rotation", PEG.GetAngleTo(target.GlobalPosition), 0.0f);
subtween.TweenProperty(_image, "global_position", target.GlobalPosition, 0.5f);
subtween.TweenCallback(Callable.From(() =>
{
PEG._pegController._playerController.ChangeHealth(-1, this);
((Peg)target._occupant)._pegController._playerController.ChangeHealth(-2, this);
Position = Vector2.Zero;
Visible = false;
}));
return subtween;
}
public override Vector2I Target(Peg PEG)
public override MapCell Target(Peg PEG)
{
List<Vector2I> closest = [.. PEG.GetVisibleCells().Where(c => (int)PEG._pegController._playArea._map.GetCellTileData(c).GetCustomData("disposition") == -PEG._disposition).OrderBy(c => (c - PEG._address).Length())];
if (closest.Count == 0)
{
return -Vector2I.One;
}
return closest[0]; // return PEG._pegController._playerController._towers.OrderBy(t => (t.GlobalPosition - GlobalPosition).Length()).ToList()[0].GlobalPosition;
return PEG.Goal();
}
}