Skip to content

Commit 1073393

Browse files
committed
throw fix (again)
1 parent 464f4d5 commit 1073393

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

client/src/playback/Actions.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,10 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
569569
[schema.Action.ThrowRat]: class ThrowRatAction extends Action<schema.ThrowRat> {
570570
apply(round: Round): void {
571571
// maybe move rat to target loc
572-
const body = round.bodies.getById(this.robotId)
572+
const body = round.bodies.getById(this.actionData.id())
573573
const endLoc = round.map.indexToLocation(this.actionData.loc())
574-
if( body.carriedRobot !== undefined ) {
575-
const carrier = round.bodies.getById(body.carriedRobot)
574+
if( body.carrierRobot !== undefined && round.bodies.hasId(body.carrierRobot)) {
575+
const carrier = round.bodies.getById(body.carrierRobot)
576576
carrier.carriedRobot = undefined
577577
}
578578
body.carrierRobot = undefined
@@ -581,7 +581,8 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
581581
// body.pos = { ...endLoc }
582582
}
583583
draw(match: Match, ctx: CanvasRenderingContext2D): void {
584-
const body = match.currentRound.bodies.getById(this.robotId)
584+
if( !match.currentRound.bodies.hasId(this.actionData.id()) ) return
585+
const body = match.currentRound.bodies.getById(this.actionData.id())
585586
const pos = body.getInterpolatedCoords(match)
586587
const coords = renderUtils.getRenderCoords(pos.x, pos.y, match.map.dimension, true)
587588
const interp = match.getInterpolationFactor()

0 commit comments

Comments
 (0)