@Override
    public void update(float tpf, Node root) {
        if (phases.get(currentPhase) instanceof HazardTrafficSignalPhase) {
            phases.get(currentPhase).update(tpf, root);
        } else {
            if (inPhase) {
                if (phases.get(currentPhase).getState() == TrafficSignalPhaseState.RED) {
                    inPhase = false;
                    timer = System.currentTimeMillis();
                } else {
                    phases.get(currentPhase).update(tpf, root);
                }
            }
            if (!inPhase && (System.currentTimeMillis() - timer >= 1000)) {
                currentPhase++;
                if (currentPhase >= phases.size()) {
                    currentPhase = 0;
                }
                phases.get(currentPhase).begin(root);
                inPhase = true;
            }
        }
    }