blob: 03af83539c1a6f00d72a9db0c7b47db4fcd5c793 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package coffee.liz.ecs.physics
import coffee.liz.ecs.World
internal class IntegrationTick<Outside> {
fun runTick(world: World<Outside>) {
world.query(Velocity::class, Acceleration::class).forEach { entity ->
val velocity = entity.get(Velocity::class)
val acceleration = entity.get(Acceleration::class)
entity.add(
Velocity(
vec2 = velocity.vec2.plus(acceleration.vec2)
)
)
}
world.query(Position::class, Velocity::class).forEach { entity ->
val position = entity.get(Position::class)
val velocity = entity.get(Acceleration::class)
entity.add(
Position(
vec2 = position.vec2.plus(velocity.vec2)
)
)
}
}
}
|