@@ -99,10 +99,8 @@ export default class Bodies {
9999
100100 return body
101101 }
102+
102103 checkBodyCollisionAtLocation ( type : schema . RobotType , pos : Vector ) : boolean {
103- const bodyClass = BODY_DEFINITIONS [ type ] ?? assert . fail ( `Body type ${ type } not found in BODY_DEFINITIONS` )
104- const tempBody = new bodyClass ( this . game , pos , this . game . getTeamByID ( 1 ) , 0 )
105- const bodySize = tempBody . size
106104 const occupiedSpaces : Vector [ ] = [ ]
107105
108106 for ( const otherBody of this . bodies . values ( ) ) {
@@ -154,6 +152,34 @@ export default class Bodies {
154152 return false
155153 }
156154
155+ checkBodyOutofBoundsAtLocation ( type : schema . RobotType , pos : Vector ) : boolean {
156+ const map = this . game . currentMatch ?. map
157+ if ( ! map ) return false
158+
159+ const dimension = map . dimension
160+ const occupiedSpaces : Vector [ ] = [ ]
161+
162+ if ( type == schema . RobotType . RAT ) {
163+ if ( ! map . inBounds ( pos . x , pos . y ) ) return false
164+ }
165+ if ( type == schema . RobotType . CAT ) {
166+ for ( let xoff = 0 ; xoff <= 1 ; xoff ++ ) {
167+ for ( let yoff = 0 ; yoff <= 1 ; yoff ++ ) {
168+ if ( ! map . inBounds ( pos . x + xoff , pos . y + yoff ) ) return false
169+ }
170+ }
171+ }
172+ if ( type == schema . RobotType . RAT_KING ) {
173+ for ( let xoff = - 1 ; xoff <= 1 ; xoff ++ ) {
174+ for ( let yoff = - 1 ; yoff <= 1 ; yoff ++ ) {
175+ if ( ! map . inBounds ( pos . x + xoff , pos . y + yoff ) ) return false
176+ }
177+ }
178+ }
179+
180+ return true
181+ }
182+
157183 markBodyAsDead ( id : number ) : void {
158184 const body = this . getById ( id )
159185 body . dead = true
0 commit comments