use of ilargia.egdx.logicbricks.component.game.RigidBody in project Entitas-Java by Rubentxu.
the class CreateNearSensorSystem method execute.
@Override
protected void execute(List<SensorEntity> entities) {
for (SensorEntity e : entities) {
GameEntity gameEntity = Indexed.getInteractiveEntity(e.getLink().ownerEntity);
RigidBody rigidBody = gameEntity.getRigidBody();
NearSensor nearSensor = e.getNearSensor();
if (nearSensor.distance > 0) {
FixtureDef nearFixture = bodyBuilder.fixtureDefBuilder().circleShape(nearSensor.distance).sensor().build();
rigidBody.body.createFixture(nearFixture).setUserData("NearSensor");
if (nearSensor.resetDistance > nearSensor.distance) {
FixtureDef nearResetFixture = bodyBuilder.fixtureDefBuilder().circleShape(nearSensor.resetDistance).sensor().build();
rigidBody.body.createFixture(nearResetFixture).setUserData("ResetNearSensor");
}
}
}
}
use of ilargia.egdx.logicbricks.component.game.RigidBody 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;
}
use of ilargia.egdx.logicbricks.component.game.RigidBody 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;
}
use of ilargia.egdx.logicbricks.component.game.RigidBody in project Entitas-Java by Rubentxu.
the class GameEntity method addRigidBody.
public GameEntity addRigidBody(Body body) {
RigidBody component = (RigidBody) recoverComponent(GameComponentsLookup.RigidBody);
if (component == null) {
component = new RigidBody();
}
component.body = body;
addComponent(GameComponentsLookup.RigidBody, component);
return this;
}
use of ilargia.egdx.logicbricks.component.game.RigidBody in project Entitas-Java by Rubentxu.
the class CreateRadarSensorSystem method execute.
@Override
protected void execute(List<SensorEntity> entities) {
Vector2[] vertices = new Vector2[8];
vertices[0] = new Vector2();
for (SensorEntity e : entities) {
GameEntity gameEntity = Indexed.getInteractiveEntity(e.getLink().ownerEntity);
RigidBody rigidBody = gameEntity.getRigidBody();
RadarSensor radarSensor = e.getRadarSensor();
if (radarSensor.angle < 180) {
for (int i = 0; i < 7; i++) {
float angle = (float) (i / 6.0 * radarSensor.angle) - (radarSensor.angle / 2) + (radarSensor.axis2D.ordinal() * 90);
vertices[i + 1] = new Vector2(radarSensor.distance * MathUtils.cosDeg(angle), radarSensor.distance * MathUtils.sinDeg(angle));
}
FixtureDef radarFixture = bodyBuilder.fixtureDefBuilder().polygonShape(vertices).sensor().build();
rigidBody.body.createFixture(radarFixture).setUserData("RadarSensor");
}
}
}
Aggregations