@@ -4,10 +4,10 @@ import SceneRenderer from "../scene/SceneRenderer"
44import MatchMode from "./MatchMode"
55import SimulationSystem from "@/systems/simulation/SimulationSystem"
66
7- const PENALTY_COOLDOWN = 1000
7+ const BUFFER_HEIGHT = 0.1
88
99class RobotDimensionTracker {
10- private static _robotHeightPenalties : Map < number , number > = new Map ( )
10+ private static _robotLastFramePenalty : Map < number , boolean > = new Map ( )
1111 private static _ignoreRotation : boolean = true
1212 private static _maxHeight : number = Infinity
1313 private static _heightPenalty : number = 0
@@ -28,11 +28,13 @@ class RobotDimensionTracker {
2828 robots . forEach ( robot => {
2929 const dimensions = this . _ignoreRotation ? robot . getDimensionsWithoutRotation ( ) : robot . getDimensions ( )
3030
31- if ( dimensions . height > this . _maxHeight ) {
32- if ( ( this . _robotHeightPenalties . get ( robot . id ) ?? 0 ) < Date . now ( ) - PENALTY_COOLDOWN ) {
33- this . _robotHeightPenalties . set ( robot . id , Date . now ( ) + this . _heightPenalty )
31+ if ( dimensions . height > this . _maxHeight + BUFFER_HEIGHT ) {
32+ if ( ! ( this . _robotLastFramePenalty . get ( robot . id ) ?? false ) ) {
3433 SimulationSystem . robotPenalty ( robot , this . _heightPenalty , "Height Expansion Limit" )
3534 }
35+ this . _robotLastFramePenalty . set ( robot . id , true )
36+ } else {
37+ this . _robotLastFramePenalty . set ( robot . id , false )
3638 }
3739 } )
3840 }
0 commit comments