+ //Check if center of this block is on screen.
+ //Don't update if not, because there is no light off screen.
+ float screen_left = Sector::current()->camera->get_translation().x;
+ float screen_top = Sector::current()->camera->get_translation().y;
+ float screen_right = screen_left+ SCREEN_WIDTH;
+ float screen_bottom = screen_top + SCREEN_HEIGHT;
+ if((center.x > screen_right ) || ( center.y > screen_bottom) ||
+ ( center.x < screen_left) || ( center.y < screen_top)) {
+ switch_delay = SWITCH_DELAY;
+ return;
+ }
+
+ bool lighting_ok;
+ if(black) {
+ lighting_ok = (light.red >= trigger_red || light.green >= trigger_green
+ || light.blue >= trigger_blue);
+ }else{
+ lighting_ok = (light.red >= trigger_red && light.green >= trigger_green
+ && light.blue >= trigger_blue);
+ }
+
+ // overrule lighting_ok if switch_delay has not yet passed
+ if (lighting_ok == is_solid) {
+ switch_delay = SWITCH_DELAY;