Search in sources :

Example 1 with CameraActuator

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

the class ActuatorEntity method replaceCameraActuator.

public ActuatorEntity replaceCameraActuator(Camera camera, short height, float damping, float minDistanceX, float minDistanceY, String followTagEntity) {
    CameraActuator component = (CameraActuator) recoverComponent(ActuatorComponentsLookup.CameraActuator);
    if (component == null) {
        component = new CameraActuator(camera, height, damping, minDistanceX, minDistanceY, followTagEntity);
    } else {
        component.actuator = (indexOwner) -> {
            Set<GameEntity> followEntities = Indexed.getTagEntities(followTagEntity);
            for (GameEntity followEntity : followEntities) {
                RigidBody rc = followEntity.getRigidBody();
                Transform transform = rc.body.getTransform();
                Vector3 position = camera.position;
                position.x += (transform.getPosition().x + minDistanceX - position.x) * damping;
                position.y += (transform.getPosition().y + minDistanceY - position.y) * height;
            }
        };
    }
    replaceComponent(ActuatorComponentsLookup.CameraActuator, component);
    return this;
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) CameraActuator(ilargia.egdx.logicbricks.component.actuator.CameraActuator) Vector3(com.badlogic.gdx.math.Vector3) RigidBody(ilargia.egdx.logicbricks.component.game.RigidBody) Transform(com.badlogic.gdx.physics.box2d.Transform)

Example 2 with CameraActuator

use of ilargia.egdx.logicbricks.component.actuator.CameraActuator 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 3 with CameraActuator

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

the class ActuatorEntity method addCameraActuator.

public ActuatorEntity addCameraActuator(Camera camera, short height, float damping, float minDistanceX, float minDistanceY, String followTagEntity) {
    CameraActuator component = (CameraActuator) recoverComponent(ActuatorComponentsLookup.CameraActuator);
    if (component == null) {
        component = new CameraActuator(camera, height, damping, minDistanceX, minDistanceY, followTagEntity);
    } else {
        component.actuator = (indexOwner) -> {
            Set<GameEntity> followEntities = Indexed.getTagEntities(followTagEntity);
            for (GameEntity followEntity : followEntities) {
                RigidBody rc = followEntity.getRigidBody();
                Transform transform = rc.body.getTransform();
                Vector3 position = camera.position;
                position.x += (transform.getPosition().x + minDistanceX - position.x) * damping;
                position.y += (transform.getPosition().y + minDistanceY - position.y) * height;
            }
        };
    }
    addComponent(ActuatorComponentsLookup.CameraActuator, component);
    return this;
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) CameraActuator(ilargia.egdx.logicbricks.component.actuator.CameraActuator) Vector3(com.badlogic.gdx.math.Vector3) RigidBody(ilargia.egdx.logicbricks.component.game.RigidBody) Transform(com.badlogic.gdx.physics.box2d.Transform)

Aggregations

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