Fix for shoving NPCs

This commit is contained in:
Collin Smith 2019-11-21 02:00:14 -08:00
parent 2e264abb66
commit 354c715261

View File

@ -4,6 +4,7 @@ import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.riiablo.engine.component.Box2DComponent;
import com.riiablo.engine.component.VelocityComponent;
@ -20,5 +21,12 @@ public class Box2DBodySystem extends IteratingSystem {
VelocityComponent velocityComponent = this.velocityComponent.get(entity);
Box2DComponent box2DComponent = this.box2DComponent.get(entity);
box2DComponent.body.setLinearVelocity(velocityComponent.velocity);
// FIXME: This is a temp fix to prevent shoving NPCs -- need to explore Contact Filters
if (velocityComponent.velocity.isZero()) {
box2DComponent.body.setType(BodyDef.BodyType.StaticBody);
} else {
box2DComponent.body.setType(BodyDef.BodyType.DynamicBody);
}
}
}