use of ilargia.egdx.logicbricks.component.actuator.CameraActuator 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.actuator.CameraActuator in project Entitas-Java by Rubentxu.
the class ActuatorSystem method execute.
@Override
public void execute(float deltaTime) {
for (ActuatorEntity e : groupTexture.getEntities()) {
if (e.getLink().isOpen) {
TextureActuator textureActuator = e.getTextureActuator();
textureActuator.actuator.execute(e.getLink().ownerEntity);
}
}
for (ActuatorEntity e : groupVelocity.getEntities()) {
if (e.getLink().isOpen) {
VelocityActuator velocityActuator = e.getVelocityActuator();
velocityActuator.actuator.execute(e.getLink().ownerEntity);
}
}
for (ActuatorEntity e : groupCamera.getEntities()) {
if (e.getLink().isOpen) {
CameraActuator cameraActuator = e.getCameraActuator();
cameraActuator.actuator.execute(e.getLink().ownerEntity);
}
}
for (ActuatorEntity e : groupEffect.getEntities()) {
if (e.getLink().isOpen) {
ParticleEffectActuator effectActuator = e.getParticleEffectActuator();
effectActuator.actuator.execute(e.getLink().ownerEntity);
}
}
}
use of ilargia.egdx.logicbricks.component.actuator.CameraActuator 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;
}
Aggregations