Search in sources :

Example 1 with AComponent

use of com.talosvfx.talos.editor.addons.scene.logic.components.AComponent in project talos by rockbite.

the class SceneEditorWorkspace method notifyAssetPathChanged.

private void notifyAssetPathChanged(Array<AComponent> list, GameObject gameObject, AssetPathChanged event) {
    Iterable<AComponent> components = gameObject.getComponents();
    for (AComponent component : components) {
        boolean affected = component.notifyAssetPathChanged(event.oldRelativePath, event.newRelativePath);
        if (affected) {
            list.add(component);
        }
    }
    Array<GameObject> gameObjects = gameObject.getGameObjects();
    if (gameObjects != null) {
        for (GameObject child : gameObjects) {
            notifyAssetPathChanged(list, child, event);
        }
    }
}
Also used : AComponent(com.talosvfx.talos.editor.addons.scene.logic.components.AComponent)

Example 2 with AComponent

use of com.talosvfx.talos.editor.addons.scene.logic.components.AComponent in project talos by rockbite.

the class SceneEditorWorkspace method initComponentsFromTemplate.

private void initComponentsFromTemplate(GameObject gameObject, XmlReader.Element template) {
    XmlReader.Element container = template.getChildByName("components");
    Array<XmlReader.Element> componentsXMLArray = container.getChildrenByName("component");
    for (XmlReader.Element componentXML : componentsXMLArray) {
        String className = componentXML.getAttribute("className");
        String classPath = templateListPopup.componentClassPath;
        try {
            Class clazz = ClassReflection.forName(classPath + "." + className);
            Object instance = ClassReflection.newInstance(clazz);
            AComponent component = (AComponent) instance;
            gameObject.addComponent(component);
        } catch (Exception e) {
        }
    }
}
Also used : AComponent(com.talosvfx.talos.editor.addons.scene.logic.components.AComponent) IOException(java.io.IOException)

Example 3 with AComponent

use of com.talosvfx.talos.editor.addons.scene.logic.components.AComponent in project talos by rockbite.

the class SceneEditorWorkspace method makeGizmosFor.

private void makeGizmosFor(GameObject gameObject) {
    if (gizmoMap.containsKey(gameObject))
        return;
    Iterable<AComponent> components = gameObject.getComponents();
    for (AComponent component : components) {
        Array<Gizmo> gizmos = GizmoRegister.makeGizmosFor(component);
        for (Gizmo gizmo : gizmos) {
            if (gizmo != null) {
                gizmo.setGameObject(gameObject);
                Array<Gizmo> list = gizmoMap.get(gameObject);
                if (list == null)
                    list = new Array<>();
                gizmoMap.put(gameObject, list);
                if (gizmo != null) {
                    gizmoList.add(gizmo);
                    list.add(gizmo);
                }
            }
        }
    }
}
Also used : TransformGizmo(com.talosvfx.talos.editor.addons.scene.widgets.gizmos.TransformGizmo) Gizmo(com.talosvfx.talos.editor.addons.scene.widgets.gizmos.Gizmo) AComponent(com.talosvfx.talos.editor.addons.scene.logic.components.AComponent)

Example 4 with AComponent

use of com.talosvfx.talos.editor.addons.scene.logic.components.AComponent in project talos by rockbite.

the class SceneEditorWorkspace method onComponentUpdated.

@EventHandler
public void onComponentUpdated(ComponentUpdated event) {
    AComponent component = event.getComponent();
    sceneEditorAddon.propertyPanel.propertyProviderUpdated(component);
    if (!event.wasRapid()) {
        TalosMain.Instance().ProjectController().setDirty();
    }
}
Also used : AComponent(com.talosvfx.talos.editor.addons.scene.logic.components.AComponent) EventHandler(com.talosvfx.talos.editor.notifications.EventHandler)

Example 5 with AComponent

use of com.talosvfx.talos.editor.addons.scene.logic.components.AComponent in project talos by rockbite.

the class GameObject method write.

@Override
public void write(Json json) {
    json.writeValue("name", name);
    json.writeArrayStart("components");
    for (AComponent component : components) {
        json.writeValue(component, AComponent.class);
    }
    json.writeArrayEnd();
    if (children != null) {
        json.writeArrayStart("children");
        for (GameObject child : children) {
            json.writeValue(child, GameObject.class);
        }
        json.writeArrayEnd();
    }
}
Also used : AComponent(com.talosvfx.talos.editor.addons.scene.logic.components.AComponent)

Aggregations

AComponent (com.talosvfx.talos.editor.addons.scene.logic.components.AComponent)6 Gizmo (com.talosvfx.talos.editor.addons.scene.widgets.gizmos.Gizmo)1 TransformGizmo (com.talosvfx.talos.editor.addons.scene.widgets.gizmos.TransformGizmo)1 EventHandler (com.talosvfx.talos.editor.notifications.EventHandler)1 IOException (java.io.IOException)1