use of ilargia.egdx.logicbricks.component.sensor.RaySensor in project Entitas-Java by Rubentxu.
the class RaySensorSystem method query.
@Override
protected boolean query(SensorEntity sensorEntity, float deltaTime) {
RaySensor sensor = sensorEntity.getRaySensor();
sensor.rayContactList.clear();
sensor.collisionSignal = false;
Link link = sensorEntity.getLink();
float angle = sensor.axis2D.ordinal() * 90.0f;
GameEntity originEntity = Indexed.getInteractiveEntity(link.ownerEntity);
Vector2 point1 = originEntity.getRigidBody().body.getPosition();
Vector2 point2 = point1.cpy().add(new Vector2((float) MathUtils.cosDeg(angle), MathUtils.sinDeg(angle)).scl(sensor.range));
physics.rayCast((fixture, point, normal, fraction) -> reportRayFixture(sensor, fixture), point1, point2);
return sensor.collisionSignal;
}
use of ilargia.egdx.logicbricks.component.sensor.RaySensor in project Entitas-Java by Rubentxu.
the class SensorEntity method replaceRaySensor.
public SensorEntity replaceRaySensor(String targetTag, Axis2D axis2D, float range, boolean xRayMode) {
RaySensor component = (RaySensor) recoverComponent(SensorComponentsLookup.RaySensor);
if (component == null) {
component = new RaySensor(targetTag, axis2D, range, xRayMode);
} else {
component.targetTag = targetTag;
component.axis2D = axis2D;
component.range = range;
component.xRayMode = xRayMode;
component.collisionSignal = false;
component.rayContactList = EntitasCollections.createSet(Integer.class);
}
replaceComponent(SensorComponentsLookup.RaySensor, component);
return this;
}
use of ilargia.egdx.logicbricks.component.sensor.RaySensor in project Entitas-Java by Rubentxu.
the class SensorEntity method addRaySensor.
public SensorEntity addRaySensor(String targetTag, Axis2D axis2D, float range, boolean xRayMode) {
RaySensor component = (RaySensor) recoverComponent(SensorComponentsLookup.RaySensor);
if (component == null) {
component = new RaySensor(targetTag, axis2D, range, xRayMode);
} else {
component.targetTag = targetTag;
component.axis2D = axis2D;
component.range = range;
component.xRayMode = xRayMode;
component.collisionSignal = false;
component.rayContactList = EntitasCollections.createSet(Integer.class);
}
addComponent(SensorComponentsLookup.RaySensor, component);
return this;
}
Aggregations