import { ResourceDescriptor, QueryDescriptor, Or, With } from 'thyseus';
import { GlobalTransform } from "@houseki-engine/scene";
import { Entity, Or, Query, Res, With } from "thyseus";
import { DynamicBody, KinematicBody, StaticBody } from "../../components";
import { PhysicsStore } from "../../resources";
export function rotateRigidBodies(store: Res<PhysicsStore>, bodies: Query<[
    Entity,
    GlobalTransform
], Or<With<StaticBody>, Or<With<KinematicBody>, With<DynamicBody>>>>) {
    for (const [entity, globalTransform] of bodies) {
        entity.deserialize();
        globalTransform.deserialize();
        const body = store.getRigidBody(entity.id);
        if (body) {
            body.setRotation(globalTransform.rotation, true);
        }
        entity.serialize();
        globalTransform.serialize();
    }
}
rotateRigidBodies.parameters = [new ResourceDescriptor(PhysicsStore), new QueryDescriptor([Entity, GlobalTransform], new Or(new With(StaticBody), new Or(new With(KinematicBody), new With(DynamicBody))))];
