Search in sources :

Example 1 with ParticleEffectActuator

use of ilargia.egdx.logicbricks.component.actuator.ParticleEffectActuator in project Entitas-Java by Rubentxu.

the class ActuatorEntity method addParticleEffectActuator.

public ActuatorEntity addParticleEffectActuator(ParticleEffect effect, boolean autoStart, float locaPosX, float locaPosY) {
    ParticleEffectActuator component = (ParticleEffectActuator) recoverComponent(ActuatorComponentsLookup.ParticleEffectActuator);
    if (component == null) {
        component = new ParticleEffectActuator(effect, autoStart, locaPosX, locaPosY);
    } else {
        component.particleEffect = effect;
        component.actuator = (indexOwner) -> {
            GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
            RigidBody rc = owner.getRigidBody();
            Transform transform = rc.body.getTransform();
            effect.setPosition(transform.getPosition().x + locaPosX, transform.getPosition().y + locaPosY);
            effect.update(Gdx.graphics.getDeltaTime());
            if (autoStart && effect.isComplete())
                effect.start();
        };
    }
    addComponent(ActuatorComponentsLookup.ParticleEffectActuator, component);
    return this;
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) ParticleEffectActuator(ilargia.egdx.logicbricks.component.actuator.ParticleEffectActuator) RigidBody(ilargia.egdx.logicbricks.component.game.RigidBody) Transform(com.badlogic.gdx.physics.box2d.Transform)

Example 2 with ParticleEffectActuator

use of ilargia.egdx.logicbricks.component.actuator.ParticleEffectActuator in project Entitas-Java by Rubentxu.

the class TextureRendererSystem method render.

@Override
public void render() {
    batch.setProjectionMatrix(cam.combined);
    batch.begin();
    for (GameEntity e : groupTextureView.getEntities()) {
        TextureView view = e.getTextureView();
        Body body = e.getRigidBody().body;
        processTextureFlip(view);
        batch.setColor(1f, 1f, 1f, 1f);
        if (view.opacity < 1)
            batch.setColor(1f, 1f, 1f, view.opacity);
        batch.draw(view.texture, body.getPosition().x - view.bounds.extentsX, body.getPosition().y - view.bounds.extentsY, view.bounds.extentsX, view.bounds.extentsY, view.bounds.extentsX * 2, view.bounds.extentsY * 2, 1, 1, MathUtils.radiansToDegrees * body.getTransform().getRotation());
    }
    for (ActuatorEntity e : groupEffect.getEntities()) {
        if (e.getLink().isOpen) {
            ParticleEffectActuator effectActuator = e.getParticleEffectActuator();
            effectActuator.particleEffect.draw(batch);
        }
    }
    batch.end();
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) ParticleEffectActuator(ilargia.egdx.logicbricks.component.actuator.ParticleEffectActuator) TextureView(ilargia.egdx.logicbricks.component.game.TextureView) Body(com.badlogic.gdx.physics.box2d.Body) ActuatorEntity(ilargia.egdx.logicbricks.gen.actuator.ActuatorEntity)

Example 3 with ParticleEffectActuator

use of ilargia.egdx.logicbricks.component.actuator.ParticleEffectActuator in project Entitas-Java by Rubentxu.

the class ActuatorSystem method execute.

@Override
public void execute(float deltaTime) {
    for (ActuatorEntity e : groupTexture.getEntities()) {
        if (e.getLink().isOpen) {
            TextureActuator textureActuator = e.getTextureActuator();
            textureActuator.actuator.execute(e.getLink().ownerEntity);
        }
    }
    for (ActuatorEntity e : groupVelocity.getEntities()) {
        if (e.getLink().isOpen) {
            VelocityActuator velocityActuator = e.getVelocityActuator();
            velocityActuator.actuator.execute(e.getLink().ownerEntity);
        }
    }
    for (ActuatorEntity e : groupCamera.getEntities()) {
        if (e.getLink().isOpen) {
            CameraActuator cameraActuator = e.getCameraActuator();
            cameraActuator.actuator.execute(e.getLink().ownerEntity);
        }
    }
    for (ActuatorEntity e : groupEffect.getEntities()) {
        if (e.getLink().isOpen) {
            ParticleEffectActuator effectActuator = e.getParticleEffectActuator();
            effectActuator.actuator.execute(e.getLink().ownerEntity);
        }
    }
}
Also used : ParticleEffectActuator(ilargia.egdx.logicbricks.component.actuator.ParticleEffectActuator) CameraActuator(ilargia.egdx.logicbricks.component.actuator.CameraActuator) TextureActuator(ilargia.egdx.logicbricks.component.actuator.TextureActuator) ActuatorEntity(ilargia.egdx.logicbricks.gen.actuator.ActuatorEntity) VelocityActuator(ilargia.egdx.logicbricks.component.actuator.VelocityActuator)

Example 4 with ParticleEffectActuator

use of ilargia.egdx.logicbricks.component.actuator.ParticleEffectActuator in project Entitas-Java by Rubentxu.

the class ActuatorEntity method replaceParticleEffectActuator.

public ActuatorEntity replaceParticleEffectActuator(ParticleEffect effect, boolean autoStart, float locaPosX, float locaPosY) {
    ParticleEffectActuator component = (ParticleEffectActuator) recoverComponent(ActuatorComponentsLookup.ParticleEffectActuator);
    if (component == null) {
        component = new ParticleEffectActuator(effect, autoStart, locaPosX, locaPosY);
    } else {
        component.particleEffect = effect;
        component.actuator = (indexOwner) -> {
            GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
            RigidBody rc = owner.getRigidBody();
            Transform transform = rc.body.getTransform();
            effect.setPosition(transform.getPosition().x + locaPosX, transform.getPosition().y + locaPosY);
            effect.update(Gdx.graphics.getDeltaTime());
            if (autoStart && effect.isComplete())
                effect.start();
        };
    }
    replaceComponent(ActuatorComponentsLookup.ParticleEffectActuator, component);
    return this;
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) ParticleEffectActuator(ilargia.egdx.logicbricks.component.actuator.ParticleEffectActuator) RigidBody(ilargia.egdx.logicbricks.component.game.RigidBody) Transform(com.badlogic.gdx.physics.box2d.Transform)

Aggregations

ParticleEffectActuator (ilargia.egdx.logicbricks.component.actuator.ParticleEffectActuator)4 GameEntity (ilargia.egdx.logicbricks.gen.game.GameEntity)3 Transform (com.badlogic.gdx.physics.box2d.Transform)2 RigidBody (ilargia.egdx.logicbricks.component.game.RigidBody)2 ActuatorEntity (ilargia.egdx.logicbricks.gen.actuator.ActuatorEntity)2 Body (com.badlogic.gdx.physics.box2d.Body)1 CameraActuator (ilargia.egdx.logicbricks.component.actuator.CameraActuator)1 TextureActuator (ilargia.egdx.logicbricks.component.actuator.TextureActuator)1 VelocityActuator (ilargia.egdx.logicbricks.component.actuator.VelocityActuator)1 TextureView (ilargia.egdx.logicbricks.component.game.TextureView)1