Skip to content

Commit

Permalink
Merge pull request #153 from Saibot393/master
Browse files Browse the repository at this point in the history
Allow undo for movementHUD
  • Loading branch information
theripper93 authored Mar 10, 2024
2 parents 76c98d0 + ace377c commit 05298e2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/core/components/main/movementHud.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class MovementHud extends ArgonComponent {
}

set movementUsed(value) {
this._movementUsed = value;
this._movementUsed = Math.max(value, 0);
}

get movementMax() { }
Expand All @@ -26,15 +26,20 @@ export class MovementHud extends ArgonComponent {
return movementColors[Math.min(Math.floor((this.movementUsed) / this.movementMax), 2)];
}

onTokenUpdate(updates) {
onTokenUpdate(updates, context) {
if (updates.x === undefined && updates.y === undefined) return;
const ray = new Ray({ x: this.token.x, y: this.token.y }, { x: updates.x ?? this.token.x, y: updates.y ?? this.token.y });
const segments = [{ ray }];
const distance = Math.floor(
canvas.grid.measureDistances(segments, { gridSpaces: true }) /
canvas.dimensions.distance
);
this.movementUsed += distance;
if (context?.isUndo) {
this.movementUsed -= distance;
}
else {
this.movementUsed += distance;
}
this.updateMovement();
}

Expand Down

0 comments on commit 05298e2

Please sign in to comment.