aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/java/coffee/liz/ecs
diff options
context:
space:
mode:
authorElizabeth Hunt <me@liz.coffee>2026-01-31 13:08:16 -0800
committerElizabeth Hunt <me@liz.coffee>2026-01-31 15:37:21 -0800
commitd8b40e4240fb7f8c62fcd60c567ab386024741d3 (patch)
treeb1028192a41f417820c9240cad1d12dd4c39f312 /core/src/main/java/coffee/liz/ecs
parent2e3d0963650d5f01163ffca1049a9886aa7489fa (diff)
downloadthe-abstraction-engine-v2-d8b40e4240fb7f8c62fcd60c567ab386024741d3.tar.gz
the-abstraction-engine-v2-d8b40e4240fb7f8c62fcd60c567ab386024741d3.zip
A sokoban inspired grid push demo
Diffstat (limited to 'core/src/main/java/coffee/liz/ecs')
-rw-r--r--core/src/main/java/coffee/liz/ecs/DAGWorld.java10
-rw-r--r--core/src/main/java/coffee/liz/ecs/math/Vec2i.java10
2 files changed, 9 insertions, 11 deletions
diff --git a/core/src/main/java/coffee/liz/ecs/DAGWorld.java b/core/src/main/java/coffee/liz/ecs/DAGWorld.java
index 716808a..f3ad30b 100644
--- a/core/src/main/java/coffee/liz/ecs/DAGWorld.java
+++ b/core/src/main/java/coffee/liz/ecs/DAGWorld.java
@@ -84,10 +84,11 @@ public class DAGWorld<T> implements World<T> {
@Override
public void update(final T state, final Duration duration) {
- refreshComponentCache();
systemExecutionOrder.forEach(system -> {
+ refreshComponentCache();
system.update(this, state, duration);
});
+ refreshComponentCache();
}
@SuppressWarnings("unchecked")
@@ -98,11 +99,8 @@ public class DAGWorld<T> implements World<T> {
private void refreshComponentCache() {
componentCache.clear();
- entities.forEach(entity -> {
- entity.getComponentMap().keySet().forEach(componentType -> {
- componentCache.computeIfAbsent(componentType, k -> new HashSet<>()).add(entity);
- });
- });
+ entities.forEach(entity -> entity.getComponentMap().keySet().forEach(
+ componentType -> componentCache.computeIfAbsent(componentType, _ -> new HashSet<>()).add(entity)));
}
private List<System<T>> buildExecutionOrder(final Collection<System<T>> systems) {
diff --git a/core/src/main/java/coffee/liz/ecs/math/Vec2i.java b/core/src/main/java/coffee/liz/ecs/math/Vec2i.java
index c7f9c83..b07e481 100644
--- a/core/src/main/java/coffee/liz/ecs/math/Vec2i.java
+++ b/core/src/main/java/coffee/liz/ecs/math/Vec2i.java
@@ -57,9 +57,9 @@ public final class Vec2i implements Vec2<Integer> {
return (float) sqrt(x * x + y * y);
}
- public static final Vec2i NORTH = new Vec2i(0, -1);
- public static final Vec2i SOUTH = new Vec2i(0, 1);
- public static final Vec2i EAST = new Vec2i(1, 0);
- public static final Vec2i WEST = new Vec2i(-1, 0);
- public static final Vec2i ZERO = new Vec2i(0, 0);
+ public static final Vec2<Integer> NORTH = new Vec2i(0, 1);
+ public static final Vec2<Integer> SOUTH = new Vec2i(0, -1);
+ public static final Vec2<Integer> EAST = new Vec2i(1, 0);
+ public static final Vec2<Integer> WEST = new Vec2i(-1, 0);
+ public static final Vec2<Integer> ZERO = new Vec2i(0, 0);
}