package com.bellaire.aerbot.listeners;

import com.bellaire.aerbot.Environment;

public class AutonomousListener implements Listener {
    
	public static double WAIT_LENGTH = 0;
	
    private Environment env;
    private long time = -1;
    private long delay;
    
    public void init(Environment env) {
        this.env = env;
        delay = System.currentTimeMillis();
        time = -1;
    }

    public boolean isComplete() {
        return env.isOperatorControl();
    }

    public boolean shouldExecute() {
        return env.isAutonomous();
    }

    public void execute() {
        long now = System.currentTimeMillis();
        
        if(now - delay >= WAIT_LENGTH && time == -1)
        	time = System.currentTimeMillis();
        
        if(now - time < 2500 && time != -1) {
            env.getWheelSystem().drive(0.5, 0.007);
            env.getShooterSystem().open();
        } else if(now - time < 5500 && time != -1) {
            env.getWheelSystem().drive(0.1, 0);
            env.getIntakeSystem().setMotor(-1);
        }else {
        	env.getIntakeSystem().setMotor(0);
        	env.getWheelSystem().drive(0, 0);
        	env.getShooterSystem().close();
        }
    }
    
}

@@ -152,14 +152,17 @@
 tic 
-double
+final int
  WAI
@@ -172,16 +172,19 @@
 ENGTH = 
+750
 0;%0A%09%0A   
@@ -334,52 +334,8 @@
 nv;%0A
-        delay = System.currentTimeMillis();%0A
     
@@ -552,16 +552,18 @@
         
+/*
 long now
@@ -594,32 +594,86 @@
 lis();%0A        %0A
+        if(delay == 0)%0A        %09delay = now;%0A        %0A
         if(now -
@@ -868,24 +868,26 @@
             
+//
 env.getShoot
@@ -1162,24 +1162,26 @@
 );%0A        %09
+//
 env.getShoot
@@ -1205,24 +1205,26 @@
 );%0A        %7D
+*/
 %0A    %7D%0A    %0A

disable auton