use of ilargia.egdx.logicbricks.gen.game.GameEntity in project Entitas-Java by Rubentxu.
the class ActuatorEntity method replaceParticleEffectActuator.
public ActuatorEntity replaceParticleEffectActuator(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();
};
}
replaceComponent(ActuatorComponentsLookup.ParticleEffectActuator, component);
return this;
}
use of ilargia.egdx.logicbricks.gen.game.GameEntity 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;
}
use of ilargia.egdx.logicbricks.gen.game.GameEntity 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;
}
use of ilargia.egdx.logicbricks.gen.game.GameEntity in project Entitas-Java by Rubentxu.
the class NearSensorSystem method processCollision.
@Override
public void processCollision(Fixture colliderA, Fixture colliderB, boolean collisionSignal) {
if (colliderA.isSensor() && !colliderB.isSensor()) {
Integer indexEntityA = (Integer) colliderA.getBody().getUserData();
Integer indexEntityB = (Integer) colliderB.getBody().getUserData();
String tagSensorA = (String) colliderA.getUserData();
Body bodyB = colliderB.getBody();
for (Fixture fixture : bodyB.getFixtureList()) {
if (fixture.isSensor())
return;
}
if (indexEntityA != null && indexEntityB != null && tagSensorA != null) {
GameEntity entityA = Indexed.getInteractiveEntity(indexEntityA);
GameEntity entityB = Indexed.getInteractiveEntity(indexEntityB);
if (entityA != null && entityB != null && tagSensorA != null) {
for (SensorEntity entity : sensorGroup.getEntities()) {
if (entity.getLink().ownerEntity == indexEntityA) {
NearSensor sensor = entity.getNearSensor();
if (sensor.targetTag != null && entityB.getTags().values.contains(sensor.targetTag)) {
if (collisionSignal) {
if (tagSensorA.equals("NearSensor")) {
sensor.distanceContactList.add(indexEntityB);
if (entity.getLink().sensorReference.contains("RadialGravity")) {
bodyB.setGravityScale(0);
bodyB.resetMassData();
}
} else if (tagSensorA.equals("ResetNearSensor")) {
sensor.resetDistanceContactList.add(indexEntityB);
}
} else {
if (tagSensorA.equals("NearSensor")) {
sensor.distanceContactList.remove(indexEntityB);
if (entity.getLink().sensorReference.contains("RadialGravity")) {
bodyB.setGravityScale(1);
bodyB.resetMassData();
}
} else if (tagSensorA.equals("ResetNearSensor")) {
sensor.resetDistanceContactList.remove(indexEntityB);
}
}
}
}
}
}
}
}
}
use of ilargia.egdx.logicbricks.gen.game.GameEntity in project Entitas-Java by Rubentxu.
the class PointerOverSensorSystem method isOver.
private boolean isOver(PointerOverSensor sensor, int pointer) {
PointerState<Vector2, Vector3> touchState = inputManager.getTouchState(pointer);
if (touchState.down) {
Set<GameEntity> targets = Indexed.getTagEntities(sensor.targetTag);
for (GameEntity target : targets) {
TextureView view = target.getTextureView();
RigidBody rigidBody = target.getRigidBody();
if (view != null && rigidBody != null) {
testRectangle.setPosition(rigidBody.body.getPosition().x, rigidBody.body.getPosition().y);
testRectangle.setSize(view.bounds.extentsX * 2, view.bounds.extentsY * 2);
return testRectangle.contains(touchState.coordinates.x, touchState.coordinates.y);
}
}
}
return false;
}
Aggregations