Skip to content

Commit

Permalink
Switch vehicle dragger to use car.moveToTrack
Browse files Browse the repository at this point in the history
  • Loading branch information
guysv committed Jan 1, 2025
1 parent c510fd2 commit 16a0236
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/services/vehicleDragger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const enum DragState
*/
interface DragPosition extends CoordsXYZ
{
track?: CarTrackLocation | null;
trackElementIndex?: number | null
progress?: number | null;
}

Expand Down Expand Up @@ -161,10 +161,8 @@ function getPositionFromTool(args: ToolEventArgs, vehicle: RideVehicle): DragPos
const trackType = element.trackType;
const subposition = vehicle._car().subposition;
const distances = getTrackTypeDistances(trackType, subposition, element.direction);
const origin = <CarTrackLocation>distances._origin(x, y, element.baseZ, sequence);

origin.trackType = trackType;
result.track = origin;
result.trackElementIndex = tileElementIndex;
result.progress = distances._sequences[sequence].progress;
}
}
Expand Down Expand Up @@ -208,15 +206,9 @@ function updateVehicleDrag(args: DragVehicleArgs): void
}

const position = args.position;
const track = position.track;
const progress = position.progress;
if (track && isNumber(progress))
{
track.x = alignWithMap(track.x);
track.y = alignWithMap(track.y);

car.trackLocation = track;
Log.debug("Travel to", JSON.stringify(position), "by:", progress, "-", car.trackProgress, "=", progress - car.trackProgress);
if (isNumber(position.trackElementIndex) && isNumber(progress)) {
car.moveToTrack({x: position.x-16, y: position.y-16}, position.trackElementIndex);
car.travelBy(getDistanceFromProgress(car, progress - car.trackProgress));
}
else
Expand Down

0 comments on commit 16a0236

Please sign in to comment.