import polygons from ".";

setInterval(() => {
  const { position, dimension } = mp.players.local;
  
  polygons.pool.map((polygon) => {

    if (polygon.colliding) {
      if (!polygons.isPositionWithinPolygon(position, polygon, dimension)) {
        polygon.colliding = false;
        mp.events.call('playerLeavePolygon', polygon);
      }
    }
    else {
      if (polygons.isPositionWithinPolygon(position, polygon, dimension)) {
        polygon.colliding = true;
        mp.events.call('playerEnterPolygon', polygon);
      }
    }
  });

}, 100);