Skip to content

Commit c6635d5

Browse files
committed
cat waypoint visualization fix
1 parent d24649b commit c6635d5

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

client/src/playback/Brushes.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,13 @@ export class CatBrush extends SymmetricMapEditorBrush<StaticMap> {
476476
public symmetricApply(x: number, y: number, fields: Record<string, MapEditorBrushField>, robotOne: boolean) {
477477
const isCat: boolean = fields.isCat.value
478478
const selectedBodyID = GameRenderer.getSelectedRobot()
479+
let lastSelectedCatLoc: Vector | null = null
479480

480481
if (selectedBodyID !== null && selectedBodyID !== undefined) {
481482
const body = this.bodies.bodies.get(selectedBodyID)
482483
if (body && body.robotType === schema.RobotType.CAT) {
483484
this.lastSelectedCat = selectedBodyID
485+
lastSelectedCatLoc = this.bodies.getById(this.lastSelectedCat)?.pos
484486
}
485487
}
486488

@@ -491,6 +493,7 @@ export class CatBrush extends SymmetricMapEditorBrush<StaticMap> {
491493
if (!robotOne) {
492494
const symmetricPoint = this.map.applySymmetryCat(this.bodies.getById(this.lastSelectedCat)!.pos)
493495
currentCat = this.bodies.getBodyAtLocation(symmetricPoint.x, symmetricPoint.y)!.id
496+
lastSelectedCatLoc = this.map.applySymmetry(lastSelectedCatLoc!)
494497
}
495498

496499
// if undoing a waypoint addition
@@ -518,6 +521,9 @@ export class CatBrush extends SymmetricMapEditorBrush<StaticMap> {
518521
return null
519522
}
520523

524+
if (!this.map.catWaypoints.has(currentCat)) {
525+
this.map.catWaypoints.set(currentCat, [lastSelectedCatLoc!])
526+
}
521527
this.map.catWaypoints.get(currentCat)?.push({ x, y })
522528

523529
return () => {
@@ -535,7 +541,6 @@ export class CatBrush extends SymmetricMapEditorBrush<StaticMap> {
535541

536542
const id = this.bodies.getNextID()
537543
this.bodies.spawnBodyFromValues(id, schema.RobotType.CAT, team, pos, 0, robotOne ? 0 : 1)
538-
this.map.catWaypoints.set(id, [{ x: x, y: y }]) // add initial waypoint at spawn location
539544

540545
return id
541546
}
@@ -580,7 +585,12 @@ export class CatBrush extends SymmetricMapEditorBrush<StaticMap> {
580585

581586
undoFunctions.push(undo0)
582587

583-
const symmetryPoint = this.map.applySymmetryCat({ x: x, y: y })
588+
let symmetryPoint: { x: number; y: number }
589+
if (fields.catOrWaypointMode.value === 1) {
590+
symmetryPoint = this.map.applySymmetry({ x: x, y: y })
591+
} else {
592+
symmetryPoint = this.map.applySymmetryCat({ x: x, y: y })
593+
}
584594
if (symmetryPoint.x != x || symmetryPoint.y != y) {
585595
const undo1 = this.symmetricApply(symmetryPoint.x, symmetryPoint.y, fields, !robotOne)
586596

client/src/playback/Map.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ export class CurrentMap {
261261
ctx.fill()
262262
})
263263
waypoints?.forEach((waypoint, idx) => {
264-
let prevWaypoint = bodies.getById(selectedBodyID).pos
265-
if (idx > 0) {
264+
let prevWaypoint = waypoints[0]
265+
if (idx > 1) {
266266
prevWaypoint = waypoints[idx - 1]
267267
}
268268
const startCoords = renderUtils.getRenderCoords(prevWaypoint.x, prevWaypoint.y, this.dimension)

0 commit comments

Comments
 (0)