use of ilargia.egdx.logicbricks.component.sensor.CollisionSensor in project Entitas-Java by Rubentxu.
the class SensorEntity method addCollisionSensor.
public SensorEntity addCollisionSensor(String targetTag) {
CollisionSensor component = (CollisionSensor) recoverComponent(SensorComponentsLookup.CollisionSensor);
if (component == null) {
component = new CollisionSensor(targetTag);
} else {
component.targetTag = targetTag;
component.collisionSignal = false;
}
addComponent(SensorComponentsLookup.CollisionSensor, component);
return this;
}
use of ilargia.egdx.logicbricks.component.sensor.CollisionSensor in project Entitas-Java by Rubentxu.
the class SensorEntity method replaceCollisionSensor.
public SensorEntity replaceCollisionSensor(String targetTag) {
CollisionSensor component = (CollisionSensor) recoverComponent(SensorComponentsLookup.CollisionSensor);
if (component == null) {
component = new CollisionSensor(targetTag);
} else {
component.targetTag = targetTag;
component.collisionSignal = false;
}
replaceComponent(SensorComponentsLookup.CollisionSensor, component);
return this;
}
use of ilargia.egdx.logicbricks.component.sensor.CollisionSensor in project Entitas-Java by Rubentxu.
the class CollisionSensorSystem method processCollision.
@Override
public void processCollision(Fixture colliderA, Fixture colliderB, boolean collisionSignal) {
Integer indexEntityA = (Integer) colliderA.getBody().getUserData();
Integer indexEntityB = (Integer) colliderB.getBody().getUserData();
if (indexEntityA != null && indexEntityB != null) {
GameEntity entityA = Indexed.getInteractiveEntity(indexEntityA);
GameEntity entityB = Indexed.getInteractiveEntity(indexEntityB);
if (entityA != null && entityB != null) {
for (SensorEntity entity : sensorGroup.getEntities()) {
CollisionSensor collision = entity.getCollisionSensor();
if (entityB.getTags().values.contains(collision.targetTag)) {
if (collisionSignal) {
Indexed.addEntityInSensor(entity, entityB);
} else {
Indexed.removeEntityInSensor(entity, entityB);
}
collision.collisionSignal = collisionSignal;
}
}
}
}
}
Aggregations