Search in sources :

Example 1 with GameEntity

use of ilargia.egdx.logicbricks.gen.game.GameEntity in project Entitas-Java by Rubentxu.

the class AnimationSystem method execute.

@Override
public void execute(float deltaTime) {
    for (GameEntity e : _groupAnimation.getEntities()) {
        Animations animations = e.getAnimations();
        TextureView view = e.getTextureView();
        animations.time += deltaTime;
        Animation<TextureRegion> animation = animations.currentAnimation;
        if (animation != null) {
            view.texture = animation.getKeyFrame(animations.time);
        }
    }
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Animations(ilargia.egdx.logicbricks.component.game.Animations) TextureView(ilargia.egdx.logicbricks.component.game.TextureView)

Example 2 with GameEntity

use of ilargia.egdx.logicbricks.gen.game.GameEntity in project Entitas-Java by Rubentxu.

the class DestroySystem method execute.

@Override
protected void execute(List<GameEntity> entities) {
    for (GameEntity e : entities) {
        if (e.hasRigidBody()) {
            Body body = e.getRigidBody().body;
            e.getRigidBody().body = null;
            body.setUserData(null);
            removeBodies.add(body);
        }
        context.destroyEntity(e);
    }
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) Body(com.badlogic.gdx.physics.box2d.Body)

Example 3 with GameEntity

use of ilargia.egdx.logicbricks.gen.game.GameEntity in project Entitas-Java by Rubentxu.

the class CreateRadialGravityActuatorSystem method execute.

@Override
protected void execute(List<ActuatorEntity> actuatorEntities) {
    for (ActuatorEntity e : actuatorEntities) {
        RadialGravityActuator actuator = e.getRadialGravityActuator();
        GameEntity owner = Indexed.getInteractiveEntity(e.getLink().ownerEntity);
        entitas.sensor.createEntity().addNearSensor("", actuator.radius, 0).addLink("RadialGravitySensor", owner.getCreationIndex());
    }
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) RadialGravityActuator(ilargia.egdx.logicbricks.component.actuator.RadialGravityActuator) ActuatorEntity(ilargia.egdx.logicbricks.gen.actuator.ActuatorEntity)

Example 4 with GameEntity

use of ilargia.egdx.logicbricks.gen.game.GameEntity in project Entitas-Java by Rubentxu.

the class RaySensorSystem method reportRayFixture.

float reportRayFixture(RaySensor sensor, Fixture fixture) {
    Integer indexEntity = (Integer) fixture.getBody().getUserData();
    sensor.collisionSignal = false;
    GameEntity entity = Indexed.getInteractiveEntity(indexEntity);
    if (sensor.targetTag != null && entity.getTags().values.contains(sensor.targetTag)) {
        sensor.rayContactList.add(indexEntity);
        sensor.collisionSignal = true;
    } else if (sensor.targetTag == null) {
        sensor.rayContactList.add(indexEntity);
        sensor.collisionSignal = true;
    }
    if (sensor.xRayMode)
        return 1;
    else
        return 0;
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity)

Example 5 with GameEntity

use of ilargia.egdx.logicbricks.gen.game.GameEntity in project Entitas-Java by Rubentxu.

the class RaySensorSystem method query.

@Override
protected boolean query(SensorEntity sensorEntity, float deltaTime) {
    RaySensor sensor = sensorEntity.getRaySensor();
    sensor.rayContactList.clear();
    sensor.collisionSignal = false;
    Link link = sensorEntity.getLink();
    float angle = sensor.axis2D.ordinal() * 90.0f;
    GameEntity originEntity = Indexed.getInteractiveEntity(link.ownerEntity);
    Vector2 point1 = originEntity.getRigidBody().body.getPosition();
    Vector2 point2 = point1.cpy().add(new Vector2((float) MathUtils.cosDeg(angle), MathUtils.sinDeg(angle)).scl(sensor.range));
    physics.rayCast((fixture, point, normal, fraction) -> reportRayFixture(sensor, fixture), point1, point2);
    return sensor.collisionSignal;
}
Also used : RaySensor(ilargia.egdx.logicbricks.component.sensor.RaySensor) GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) Vector2(com.badlogic.gdx.math.Vector2) Link(ilargia.egdx.logicbricks.component.sensor.Link)

Aggregations

GameEntity (ilargia.egdx.logicbricks.gen.game.GameEntity)27 RigidBody (ilargia.egdx.logicbricks.component.game.RigidBody)9 SensorEntity (ilargia.egdx.logicbricks.gen.sensor.SensorEntity)8 Vector2 (com.badlogic.gdx.math.Vector2)6 Body (com.badlogic.gdx.physics.box2d.Body)5 TextureView (ilargia.egdx.logicbricks.component.game.TextureView)5 Transform (com.badlogic.gdx.physics.box2d.Transform)4 ActuatorEntity (ilargia.egdx.logicbricks.gen.actuator.ActuatorEntity)4 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)3 Vector3 (com.badlogic.gdx.math.Vector3)3 ParticleEffectActuator (ilargia.egdx.logicbricks.component.actuator.ParticleEffectActuator)3 FixtureDef (com.badlogic.gdx.physics.box2d.FixtureDef)2 PhysicsManagerGDX (ilargia.egdx.impl.managers.PhysicsManagerGDX)2 CameraActuator (ilargia.egdx.logicbricks.component.actuator.CameraActuator)2 RadialGravityActuator (ilargia.egdx.logicbricks.component.actuator.RadialGravityActuator)2 TextureActuator (ilargia.egdx.logicbricks.component.actuator.TextureActuator)2 VelocityActuator (ilargia.egdx.logicbricks.component.actuator.VelocityActuator)2 NearSensor (ilargia.egdx.logicbricks.component.sensor.NearSensor)2 RadarSensor (ilargia.egdx.logicbricks.component.sensor.RadarSensor)2 Bounds (ilargia.egdx.logicbricks.data.Bounds)2