Search in sources :

Example 1 with VelocityActuator

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

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

the class ActuatorEntity method replaceVelocityActuator.

public ActuatorEntity replaceVelocityActuator(Vector2 velocity, float angularVelocity) {
    VelocityActuator component = (VelocityActuator) recoverComponent(ActuatorComponentsLookup.VelocityActuator);
    if (component == null) {
        component = new VelocityActuator(velocity, angularVelocity);
    } else {
        component.actuator = (indexOwner) -> {
            GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
            RigidBody rigidBody = owner.getRigidBody();
            rigidBody.body.setLinearVelocity(velocity);
            rigidBody.body.setAngularVelocity(angularVelocity);
        };
    }
    replaceComponent(ActuatorComponentsLookup.VelocityActuator, component);
    return this;
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) RigidBody(ilargia.egdx.logicbricks.component.game.RigidBody) VelocityActuator(ilargia.egdx.logicbricks.component.actuator.VelocityActuator)

Example 3 with VelocityActuator

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

the class ActuatorEntity method addVelocityActuator.

public ActuatorEntity addVelocityActuator(Vector2 velocity, float angularVelocity) {
    VelocityActuator component = (VelocityActuator) recoverComponent(ActuatorComponentsLookup.VelocityActuator);
    if (component == null) {
        component = new VelocityActuator(velocity, angularVelocity);
    } else {
        component.actuator = (indexOwner) -> {
            GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
            RigidBody rigidBody = owner.getRigidBody();
            rigidBody.body.setLinearVelocity(velocity);
            rigidBody.body.setAngularVelocity(angularVelocity);
        };
    }
    addComponent(ActuatorComponentsLookup.VelocityActuator, component);
    return this;
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) RigidBody(ilargia.egdx.logicbricks.component.game.RigidBody) VelocityActuator(ilargia.egdx.logicbricks.component.actuator.VelocityActuator)

Aggregations

VelocityActuator (ilargia.egdx.logicbricks.component.actuator.VelocityActuator)3 RigidBody (ilargia.egdx.logicbricks.component.game.RigidBody)2 GameEntity (ilargia.egdx.logicbricks.gen.game.GameEntity)2 CameraActuator (ilargia.egdx.logicbricks.component.actuator.CameraActuator)1 ParticleEffectActuator (ilargia.egdx.logicbricks.component.actuator.ParticleEffectActuator)1 TextureActuator (ilargia.egdx.logicbricks.component.actuator.TextureActuator)1 ActuatorEntity (ilargia.egdx.logicbricks.gen.actuator.ActuatorEntity)1