All Downloads are FREE. Search and download functionalities are using the official Maven repository.

games.rednblack.editor.renderer.systems.render.logic.LightDrawableLogic Maven / Gradle / Ivy

The newest version!
package games.rednblack.editor.renderer.systems.render.logic;

import com.artemis.ComponentMapper;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import games.rednblack.editor.renderer.components.ParentNodeComponent;
import games.rednblack.editor.renderer.components.TintComponent;
import games.rednblack.editor.renderer.components.light.LightObjectComponent;

public class LightDrawableLogic implements DrawableLogic {

    protected ComponentMapper lightComponentMapper;
    protected ComponentMapper tintComponentMapper;
    protected ComponentMapper parentNodeComponentComponentMapper;

    private final Color tmpColor = new Color();

    @Override
    public void draw(Batch batch, int entity, float parentAlpha, RenderingType renderingType) {
        LightObjectComponent lightObjectComponent = lightComponentMapper.get(entity);
        TintComponent tint = tintComponentMapper.get(entity);

        tmpColor.set(tint.color);
        tmpColor.a *= tintComponentMapper.get(parentNodeComponentComponentMapper.get(entity).parentEntity).color.a;

        if (lightObjectComponent.lightObject != null)
            lightObjectComponent.lightObject.setColor(tmpColor);
    }

    @Override
    public void beginPipeline() {

    }

    @Override
    public void endPipeline() {

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy