diff --git a/rpg/src/System/Physics.hs b/rpg/src/System/Physics.hs index e03f379..753f897 100644 --- a/rpg/src/System/Physics.hs +++ b/rpg/src/System/Physics.hs @@ -172,13 +172,13 @@ applyVelocity'' = do fractions' = filter (not . isNaN . (^. _2)) clampedFractions (info, minTime) = minimumBy order ((Nothing, remainingTime) : fractions') - forM_ allEntities \entity1 -> do - (position1, velocity1, body1) <- AE.get @w @(PositionComponent, Maybe VelocityComponent, Maybe BodyComponent) entity1 + AE.cmap @w @(PositionComponent, AABBComponent, Maybe BodyComponent, Maybe VelocityComponent) @PositionComponent \(position1, _, body1, velocity1) -> let velocity1' = fromMaybe (Velocity $ pure 0) velocity1 - - unless (unVelocity velocity1' == pure 0 || maybe False (^. immovable) body1) $ - AE.set @w entity1 (Position $ position1.position + unVelocity velocity1' * pure (clampDown minTime)) + in + if unVelocity velocity1' == pure 0 || maybe False (^. immovable) body1 + then position1 + else Position $ position1.position + unVelocity velocity1' * pure (clampDown minTime) case info of Just ((entityA, positionA, velocityA, aabbA, bodyA), (entityB, positionB, velocityB, aabbB, bodyB)) -> do do