use of ilargia.egdx.logicbricks.component.game.RigidBody in project Entitas-Java by Rubentxu.
the class ActuatorEntity method addCameraActuator.
public ActuatorEntity addCameraActuator(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;
}
};
}
addComponent(ActuatorComponentsLookup.CameraActuator, component);
return this;
}
use of ilargia.egdx.logicbricks.component.game.RigidBody 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.component.game.RigidBody 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.component.game.RigidBody 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.component.game.RigidBody in project Entitas-Java by Rubentxu.
the class GameEntity method replaceRigidBody.
public GameEntity replaceRigidBody(Body body) {
RigidBody component = (RigidBody) recoverComponent(GameComponentsLookup.RigidBody);
if (component == null) {
component = new RigidBody();
}
component.body = body;
replaceComponent(GameComponentsLookup.RigidBody, component);
return this;
}
Aggregations