src/entities/Enemy.js
/**
	* Updates the vision component of this game entity and stores
	* the result in the respective memory system.
	*
	* @return {Enemy} A reference to this game entity.
	*/
Updates the vision component of this game entity and stores
the result in the respective memory system.

@return {Enemy} A reference to this game entity.
Updates the vision component of this game entity and stores the result in the respective memory system . @return { Enemy } A reference to this game entity .
updateVision() {
		const memorySystem = this.memorySystem;
		const vision = this.vision;
		const competitors = this.world.competitors;
		for ( let i = 0, l = competitors.length; i < l; i ++ ) {
			const competitor = competitors[ i ];
			if ( competitor === this || competitor.status !== STATUS_ALIVE ) continue;
			if ( memorySystem.hasRecord( competitor ) === false ) {
				memorySystem.createRecord( competitor );
			}
			const record = memorySystem.getRecord( competitor );
			competitor.head.getWorldPosition( worldPosition );
			if ( vision.visible( worldPosition ) === true && competitor.active ) {
				record.timeLastSensed = this.currentTime;
				record.lastSensedPosition.copy( competitor.position ); 
				if ( record.visible === false ) record.timeBecameVisible = this.currentTime;
				record.visible = true;
			} else {
				record.visible = false;
			}
		}
		return this;
	}
updateVision ( ) { const memorySystem = this . memorySystem ; const vision = this . vision ; const competitors = this . world . competitors ; for ( let i = 0 , l = competitors . length ; i < l ; i ++ ) { const competitor = competitors [ i ] ; if ( competitor === this || competitor . status !== STATUS_ALIVE ) continue ; if ( memorySystem . hasRecord ( competitor ) === false ) { memorySystem . createRecord ( competitor ) ; } const record = memorySystem . getRecord ( competitor ) ; competitor . head . getWorldPosition ( worldPosition ) ; if ( vision . visible ( worldPosition ) === true && competitor . active ) { record . timeLastSensed = this . currentTime ; record . lastSensedPosition . copy ( competitor . position ) ; if ( record . visible === false ) record . timeBecameVisible = this . currentTime ; record . visible = true ; } else { record . visible = false ; } } return this ; }
Updates the vision component of this game entity and stores
 the result in the respective memory system.
Updates the vision component of this game entity and stores the result in the respective memory system .
// ignore own entity and consider only living enemies // it's intended to use the body's position here