Search in sources :

Example 1 with LocationResynchEvent

use of org.terasology.logic.location.LocationResynchEvent in project Terasology by MovingBlocks.

the class PhysicsSystem method sendSyncMessages.

private void sendSyncMessages() {
    Iterator<EntityRef> iter = physics.physicsEntitiesIterator();
    while (iter.hasNext()) {
        EntityRef entity = iter.next();
        if (entity.hasComponent(NetworkComponent.class)) {
            // TODO after implementing rigidbody interface
            RigidBody body = physics.getRigidBody(entity);
            if (body.isActive()) {
                entity.send(new LocationResynchEvent(body.getLocation(new Vector3f()), body.getOrientation(new Quat4f())));
                entity.send(new PhysicsResynchEvent(body.getLinearVelocity(new Vector3f()), body.getAngularVelocity(new Vector3f())));
            }
        }
    }
}
Also used : Vector3f(org.terasology.math.geom.Vector3f) PhysicsResynchEvent(org.terasology.physics.events.PhysicsResynchEvent) LocationResynchEvent(org.terasology.logic.location.LocationResynchEvent) EntityRef(org.terasology.entitySystem.entity.EntityRef) Quat4f(org.terasology.math.geom.Quat4f)

Aggregations

EntityRef (org.terasology.entitySystem.entity.EntityRef)1 LocationResynchEvent (org.terasology.logic.location.LocationResynchEvent)1 Quat4f (org.terasology.math.geom.Quat4f)1 Vector3f (org.terasology.math.geom.Vector3f)1 PhysicsResynchEvent (org.terasology.physics.events.PhysicsResynchEvent)1