updateVisibilityData() {
        const entity = this.entity;
        if (!('visibility' in entity.data)) {
            entity.data.visibility = {
                visible: false, // ghost is visible (even partially) ?
                offset: 0, // last rendered position of the ghost sprite
                size: 0, // apparent size of ghost
                distance: 0, // distance from player to ghost
            };
        }
        const vis = entity.data.visibility;
        // visible or not visible ?
        const bVisible = vis.visible = !!entity.sector && this.engine.raycaster.visibleCells.isMarked(entity.sector.x, entity.sector.y);
        if (!bVisible) {
            // no need to proceed
            return;
        }
        // distance from player to ghost
        const oPlayerPos = this.target.position;
        const oGhostPos = entity.position;
        vis.distance = Geometry.distance(oPlayerPos.x, oPlayerPos.y, oGhostPos.x, oGhostPos.y);

        // ghost position on screen
        const r = entity.sprite.lastRendered;
        vis.offset = r.dx;
        vis.size = r.dw;
    }
/**
     * Updates ghost visibility data
     * That means, all data aimed at resolving how many energy a ghost worth
     */
Updates ghost visibility data
That means, all data aimed at resolving how many energy a ghost worth
Updates ghost visibility data That means all data aimed at resolving how many energy a ghost worth
updateVisibilityData() {
        const entity = this.entity;
        if (!('visibility' in entity.data)) {
            entity.data.visibility = {
                visible: false, 
                offset: 0, 
                size: 0, 
                distance: 0, 
            };
        }
        const vis = entity.data.visibility;
        const bVisible = vis.visible = !!entity.sector && this.engine.raycaster.visibleCells.isMarked(entity.sector.x, entity.sector.y);
        if (!bVisible) {
            return;
        }
        const oPlayerPos = this.target.position;
        const oGhostPos = entity.position;
        vis.distance = Geometry.distance(oPlayerPos.x, oPlayerPos.y, oGhostPos.x, oGhostPos.y);
        const r = entity.sprite.lastRendered;
        vis.offset = r.dx;
        vis.size = r.dw;
    }
updateVisibilityData ( ) { const entity = this . entity ; if ( ! ( 'visibility' in entity . data ) ) { entity . data . visibility = { visible : false , offset : 0 , size : 0 , distance : 0 , } ; } const vis = entity . data . visibility ; const bVisible = vis . visible = ! ! entity . sector && this . engine . raycaster . visibleCells . isMarked ( entity . sector . x , entity . sector . y ) ; if ( ! bVisible ) { return ; } const oPlayerPos = this . target . position ; const oGhostPos = entity . position ; vis . distance = Geometry . distance ( oPlayerPos . x , oPlayerPos . y , oGhostPos . x , oGhostPos . y ) ; const r = entity . sprite . lastRendered ; vis . offset = r . dx ; vis . size = r . dw ; }
Updates ghost visibility data
 That means, all data aimed at resolving how many energy a ghost worth
Updates ghost visibility data That means all data aimed at resolving how many energy a ghost worth
// ghost is visible (even partially) ? // last rendered position of the ghost sprite // apparent size of ghost // distance from player to ghost // visible or not visible ? // no need to proceed // distance from player to ghost // ghost position on screen