diff options
Diffstat (limited to 'core/src/main/java/coffee/liz/ecs')
| -rw-r--r-- | core/src/main/java/coffee/liz/ecs/DAGWorld.java | 10 | ||||
| -rw-r--r-- | core/src/main/java/coffee/liz/ecs/math/Vec2i.java | 10 |
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); } |
