Search in sources :

Example 1 with EntityFactory

use of ilargia.egdx.api.factories.EntityFactory in project Entitas-Java by Rubentxu.

the class SceneManagerGDX method initialize.

@Override
public void initialize() {
    if (engine.getManager(PhysicsManagerGDX.class) == null)
        throw new EntitasException("SceneManagerGDX", "SceneManagerGDX needs load PhysicsManagerGDX on the engine");
    physics = engine.getManager(PhysicsManagerGDX.class);
    rayHandler = new RayHandler(physics.getPhysics());
    PreferencesManagerGDX preferences = engine.getManager(PreferencesManagerGDX.class);
    rayHandler.setAmbientLight(preferences.AMBIENT_LIGHT);
    rayHandler.setBlur(preferences.BLUR);
    rayHandler.setCulling(preferences.CULLING);
    rayHandler.setGammaCorrection(preferences.GAMMA_CORRECTION);
    rayHandler.setBlurNum(preferences.BLUR_NUM);
    rayHandler.setShadows(preferences.SHADOWS);
    rayHandler.useDiffuseLight(preferences.USE_DIFFUSE_LIGHT);
    //rayHandler.update();
    AssetsManagerGDX assetsManager = engine.getManager(AssetsManagerGDX.class);
    for (EntityFactory factory : entityFactories.values()) {
        factory.loadAssets(engine);
    }
    assetsManager.finishLoading();
    addLightFactory(PointLight.class, (SceneManager sceneManager, IComponent c) -> {
        CPointLight component = (CPointLight) c;
        return new PointLight(rayHandler, component.raysNum, component.color, component.distance, component.position.x, component.position.y);
    });
    addLightFactory(DirectionalLight.class, (SceneManager sceneManager, IComponent c) -> {
        LogManagerGDX.debug("SceneManager", "create directional ligth");
        CDirectionalLight component = (CDirectionalLight) c;
        return new DirectionalLight(rayHandler, component.raysNum, component.color, component.direcction);
    });
    addLightFactory(ChainLight.class, (SceneManager sceneManager, IComponent c) -> {
        LogManagerGDX.debug("SceneManager", "create ChainLight");
        CChainLight component = (CChainLight) c;
        return new ChainLight(rayHandler, component.raysNum, component.color, component.distance, component.rayDirecction, component.chain);
    });
    addLightFactory(ConeLight.class, (SceneManager sceneManager, IComponent c) -> {
        LogManagerGDX.debug("SceneManager", "create ConeLight");
        CConeLight component = (CConeLight) c;
        return new ConeLight(rayHandler, component.raysNum, component.color, component.distance, component.position.x, component.position.y, component.directionDegree, component.coneDegree);
    });
}
Also used : CConeLight(ilargia.egdx.logicbricks.component.scene.CConeLight) SceneManager(ilargia.egdx.api.managers.SceneManager) IComponent(ilargia.entitas.api.IComponent) CChainLight(ilargia.egdx.logicbricks.component.scene.CChainLight) CChainLight(ilargia.egdx.logicbricks.component.scene.CChainLight) CDirectionalLight(ilargia.egdx.logicbricks.component.scene.CDirectionalLight) CConeLight(ilargia.egdx.logicbricks.component.scene.CConeLight) EntitasException(ilargia.entitas.api.entitas.EntitasException) CPointLight(ilargia.egdx.logicbricks.component.scene.CPointLight) CPointLight(ilargia.egdx.logicbricks.component.scene.CPointLight) EntityFactory(ilargia.egdx.api.factories.EntityFactory) CDirectionalLight(ilargia.egdx.logicbricks.component.scene.CDirectionalLight)

Aggregations

EntityFactory (ilargia.egdx.api.factories.EntityFactory)1 SceneManager (ilargia.egdx.api.managers.SceneManager)1 CChainLight (ilargia.egdx.logicbricks.component.scene.CChainLight)1 CConeLight (ilargia.egdx.logicbricks.component.scene.CConeLight)1 CDirectionalLight (ilargia.egdx.logicbricks.component.scene.CDirectionalLight)1 CPointLight (ilargia.egdx.logicbricks.component.scene.CPointLight)1 IComponent (ilargia.entitas.api.IComponent)1 EntitasException (ilargia.entitas.api.entitas.EntitasException)1