Search in sources :

Example 1 with BehaviorComponent

use of org.terasology.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.logic.behavior.Interpreter) EntityRef(org.terasology.entitySystem.entity.EntityRef) BehaviorComponent(org.terasology.logic.behavior.BehaviorComponent)

Aggregations

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