Search in sources :

Example 1 with BehaviorComponent

use of org.terasology.engine.logic.behavior.BehaviorComponent in project Terasology by MovingBlocks.

the class BehaviorEditorScreen method onAssignPressed.

private void onAssignPressed() {
    if (selectedTree != null && selectedInterpreter != null) {
        EntityRef minion = selectedInterpreter.actor().getEntity();
        minion.removeComponent(BehaviorComponent.class);
        BehaviorComponent component = new BehaviorComponent();
        component.tree = selectedTree;
        minion.addComponent(component);
        List<Interpreter> interpreter = behaviorSystem.getInterpreters();
        selectEntity.setSelection(null);
        for (Interpreter i : interpreter) {
            if (i.actor().getEntity() == minion) {
                selectEntity.setSelection(i);
                break;
            }
        }
    }
}
Also used : Interpreter(org.terasology.engine.logic.behavior.Interpreter) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) BehaviorComponent(org.terasology.engine.logic.behavior.BehaviorComponent)

Aggregations

EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)1 BehaviorComponent (org.terasology.engine.logic.behavior.BehaviorComponent)1 Interpreter (org.terasology.engine.logic.behavior.Interpreter)1