@@ -317,6 +317,15 @@ export class WallsBrush extends SymmetricMapEditorBrush<StaticMap> {
317317 const cheeseMine = this . map . cheeseMines . findIndex ( ( l ) => squareIntersects ( l , pos , 2 ) )
318318 const dirt = this . map . initialDirt [ idx ]
319319
320+ for ( const waypoints of this . map . catWaypoints . values ( ) ) {
321+ for ( const waypoint of waypoints ) {
322+ if ( waypoint . x === pos . x && waypoint . y === pos . y ) return true
323+ for ( let nei of this . map . getNeighbors ( waypoint . x , waypoint . y ) ) {
324+ if ( nei . x === pos . x && nei . y === pos . y ) return true
325+ }
326+ }
327+ }
328+
320329 if ( cheeseMine !== - 1 || dirt ) return true
321330
322331 this . map . walls [ idx ] = 1
@@ -551,23 +560,27 @@ export class CatBrush extends SymmetricMapEditorBrush<StaticMap> {
551560 if ( ! body ) return null
552561
553562 const team = body . team
563+ const pos = body . pos
554564 this . bodies . removeBody ( body . id )
555565 const waypoints = this . map . catWaypoints . get ( body . id )
556566 this . map . catWaypoints . delete ( body . id )
557567
558- return { team, waypoints }
568+ return { team, waypoints, pos }
559569 }
560-
561570 if ( isCat ) {
562571 // shouldnt matter which team we add to since cats are neutral
563572 const id = add ( x , y , this . bodies . game . teams [ 0 ] )
564573 if ( id ) return ( ) => this . bodies . removeBody ( id )
565574 return null
566575 } else {
567- const { team, waypoints } = remove ( x , y ) !
576+ const removed = remove ( x , y )
577+ if ( ! removed ) return null
578+
579+ const { team, waypoints, pos } = removed
568580 if ( ! team ) return null
581+
569582 return ( ) => {
570- add ( x , y , team )
583+ add ( pos . x , pos . y , team )
571584 if ( waypoints ) {
572585 this . map . catWaypoints . set ( this . bodies . getBodyAtLocation ( x , y ) ! . id , waypoints )
573586 }
@@ -578,6 +591,10 @@ export class CatBrush extends SymmetricMapEditorBrush<StaticMap> {
578591 // Override default symmetric apply behavior because cats occupy a 2x2 footprint
579592 public apply ( x : number , y : number , fields : Record < string , MapEditorBrushField > , robotOne : boolean ) : UndoFunction {
580593 const undoFunctions : UndoFunction [ ] = [ ]
594+
595+ const body = this . bodies . getBodyAtLocation ( x , y )
596+ const anchor = body ?. pos
597+
581598 const undo0 = this . symmetricApply ( x , y , fields , robotOne )
582599
583600 // Return early if brush could not be applied
@@ -589,7 +606,7 @@ export class CatBrush extends SymmetricMapEditorBrush<StaticMap> {
589606 if ( fields . catOrWaypointMode . value === 1 ) {
590607 symmetryPoint = this . map . applySymmetry ( { x : x , y : y } )
591608 } else {
592- symmetryPoint = this . map . applySymmetryCat ( { x : x , y : y } )
609+ symmetryPoint = ! anchor ? this . map . applySymmetryCat ( { x : x , y : y } ) : this . map . applySymmetryCat ( anchor )
593610 }
594611 if ( symmetryPoint . x != x || symmetryPoint . y != y ) {
595612 const undo1 = this . symmetricApply ( symmetryPoint . x , symmetryPoint . y , fields , ! robotOne )
0 commit comments