Search in sources :

Example 11 with GameEntity

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

the class ActuatorEntity method replaceTextureActuator.

public ActuatorEntity replaceTextureActuator(Bounds bounds, int opacity, Boolean flipX, Boolean flipY, Color tint) {
    TextureActuator component = (TextureActuator) recoverComponent(ActuatorComponentsLookup.TextureActuator);
    if (component == null) {
        component = new TextureActuator(bounds, opacity, flipX, flipY, tint);
    } else {
        component.actuator = (indexOwner) -> {
            GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
            TextureView view = owner.getTextureView();
            if (bounds != null)
                view.bounds = bounds;
            if (flipX != null)
                view.flipX = flipX;
            if (flipY != null)
                view.flipY = flipY;
            if (opacity != -1)
                view.opacity = opacity;
            if (tint != null)
                view.tint = tint;
        };
    }
    replaceComponent(ActuatorComponentsLookup.TextureActuator, component);
    return this;
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) TextureView(ilargia.egdx.logicbricks.component.game.TextureView) TextureActuator(ilargia.egdx.logicbricks.component.actuator.TextureActuator)

Example 12 with GameEntity

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

the class InputManagerGDX method testPoint.

private void testPoint(Fixture fixture, PointerState<Vector2, Vector3> pointerState) {
    if (!fixture.testPoint(pointerState.coordinates.x, pointerState.coordinates.y))
        return;
    Integer index = (Integer) fixture.getBody().getUserData();
    GameEntity entity = Indexed.getInteractiveEntity(index);
    if (entity.isDraggable()) {
        jointDef.bodyB = fixture.getBody();
        jointDef.target.set(pointerState.coordinates.x, pointerState.coordinates.y);
        joints[pointerState.pointer] = (MouseJoint) physics.createJoint(jointDef);
    }
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity)

Example 13 with GameEntity

use of ilargia.egdx.logicbricks.gen.game.GameEntity 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 14 with GameEntity

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

the class Indexed method initialize.

public static void initialize(Entitas entitas) {
    _entitas = entitas;
    index = new KeyIndex(-1, null);
    // GameEntity contains Sensors entities
    _entitas.sensor.addEntityIndex(new PrimaryEntityIndex<SensorEntity, KeyIndex>(Indexed.SensorsEntityIndex, ((e, c) -> {
        if (c != null) {
            ilargia.egdx.logicbricks.component.sensor.Link link = (ilargia.egdx.logicbricks.component.sensor.Link) c;
            return new KeyIndex(link.ownerEntity, link.sensorReference);
        }
        return new KeyIndex(e.getLink().ownerEntity, e.getLink().sensorReference);
    }), _entitas.sensor.getGroup(SensorMatcher.Link())));
    // GameEntity contains Actuator entities
    _entitas.actuator.addEntityIndex(new PrimaryEntityIndex<ActuatorEntity, KeyIndex>(Indexed.ActuatorsEntityIndex, ((e, c) -> {
        if (c != null) {
            Link link = (Link) c;
            return new KeyIndex(link.ownerEntity, link.actuatorReference);
        }
        return new KeyIndex(e.getLink().ownerEntity, e.getLink().actuatorReference);
    }), _entitas.actuator.getGroup(ActuatorMatcher.Link())));
    // Interactive GameEntity index
    _entitas.game.addEntityIndex(new PrimaryEntityIndex<GameEntity, Integer>(Indexed.InteractiveEntityIndex, ((e, c) -> e.getCreationIndex()), _entitas.game.getGroup(GameMatcher.Interactive())));
    // Tags GameEntity index
    _entitas.game.addEntityIndex(new EntityIndex<GameEntity, String>(Indexed.TagEntityIndex, _entitas.game.getGroup(Matcher.AllOf(GameMatcher.Tags(), GameMatcher.Interactive())), ((e, c) -> e.getTags().values.toArray(new String[0]))));
    // Sensors context GameEntities
    _entitas.game.addEntityIndex(new EntityIndex<GameEntity, Integer>(Indexed.GameEntitiesInSensorIndex, _entitas.game.getGroup(GameMatcher.Interactive()), ((e, c) -> new Integer[0])));
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) SensorEntity(ilargia.egdx.logicbricks.gen.sensor.SensorEntity) Link(ilargia.egdx.logicbricks.component.actuator.Link) ActuatorEntity(ilargia.egdx.logicbricks.gen.actuator.ActuatorEntity)

Example 15 with GameEntity

use of ilargia.egdx.logicbricks.gen.game.GameEntity 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)

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