@@ -175,9 +175,8 @@ export default class EntityManager {
175175 }
176176 }
177177 }
178-
178+
179179 public hibernateEntities ( ) {
180- let entitySleepCount = 0 ; // remove this, just for testing
181180 for ( let id = 1 ; id <= this . lastId ; ++ id ) {
182181 const entity = this . inner [ id ] as ObjectEntity ;
183182 if ( ! entity || entity . hash === 0 || ! entity . isPhysical || ! entity . canSleep ) continue ;
@@ -186,35 +185,15 @@ export default class EntityManager {
186185 const camera = client . camera ;
187186 if ( ! camera ) continue ;
188187
189- const cameraData = camera . cameraData . values ;
190-
191- const fov = cameraData . FOV ;
192- const width = ( 1920 / fov ) + ClientCamera . VISION_BUFFER ;
193- const height = ( 1080 / fov ) + ClientCamera . VISION_BUFFER ;
194-
195- const l = cameraData . cameraX - width ;
196- const r = cameraData . cameraX + width ;
197- const t = cameraData . cameraY - height ;
198- const b = cameraData . cameraY + height ;
199-
200- const entityWidth = entity . physicsData . values . sides === 2 ? entity . physicsData . values . size / 2 : entity . physicsData . values . size ;
201- const entitySize = entity . physicsData . values . sides === 2 ? entity . physicsData . values . width / 2 : entity . physicsData . values . size ;
202-
203- if ( entity . positionData . values . x - entityWidth < r &&
204- entity . positionData . values . y + entitySize > t &&
205- entity . positionData . values . x + entityWidth > l &&
206- entity . positionData . values . y - entitySize < b
207- ) {
188+ if ( camera [ "view" ] . includes ( entity ) ) {
208189 entity . isSleeping = false ;
209190 continue ;
210191 }
211192
212193 entity . setVelocity ( 0 , 0 ) ;
213194 entity . isSleeping = true ;
214- entitySleepCount ++ ; // remove this, just for testing
215195 }
216196 }
217- console . log ( entitySleepCount , "entities going to sleep" ) ; // remove this, just for testing
218197 }
219198
220199 /** Ticks all entities in the game. */
0 commit comments