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;
}
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);
}
}
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;
}
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])));
}
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();
}
Aggregations