#include "Behaviors/StateMachine.h"

$nodeclass Lab5Part3 : VisualRoutinesStateNode {
    $nodeclass FindShapes : MapBuilderNode($,MapBuilderRequest::worldMap) : doStart {
        mapreq.addObjectColor(lineDataType, "blue");
    }
    $nodeclass ProcessAndReport : VisualRoutinesStateNode : doStart {
        NEW_SHAPEVEC(lines, LineData, select_type<LineData>(worldShS));
	if (lines.size() == 0) {
	    cout << "No line found." << endl;
	    postStateFailure();
	    return;
	}
	NEW_SHAPE(e1, EllipseData, new EllipseData(worldShS, lines[0]->end1Pt(),25,25,1));
	NEW_SHAPE(e2, EllipseData, new EllipseData(worldShS, lines[0]->end2Pt(),25,25,1));
	VRmixin::drawShapes.push_back(e1);
	VRmixin::drawShapes.push_back(e2);
    }
    $setupmachine {
        FindShapes =C=> ProcessAndReport
    }
}

REGISTER_BEHAVIOR(Lab5Part3);