junkdog / artemis-odb

A continuation of the popular Artemis ECS framework
BSD 2-Clause "Simplified" License
779 stars 112 forks source link

Dependency Injection improvements #535

Closed DaanVanYperen closed 5 years ago

DaanVanYperen commented 6 years ago

Small extension to DI. Alternatively we could integrate Dagger 2?

@all(chicken.class, enemy.class)
@exclude(exploding.class)
private EntitySubscription enemyChickens;

Edit: See @AspectDescriptor, it already allows injecting Archetype, Aspect, Aspect.Builder, EntitySubscription, EntityTransmuter instances.

class MapSystem ... {
   @Provides(fieldName="solidMask")
   public MapMask getMask() {  ... }
   @Provides
   public MapMask getMask(String fieldName) {  ... }
}

Lazily resolve tag in world.

private Lazy<Entity> player; mPos(player.get());
private Lazy<E> player; player.get().pos.x;

see #532 Query API .

DaanVanYperen commented 5 years ago

Oops. Forgot the Lazy part. Should double-take if this goes to far out of scope for odb.

DaanVanYperen commented 5 years ago

Singleton plugin solves this use-case. Closing. https://github.com/DaanVanYperen/artemis-odb-contrib/tree/develop/contrib-plugin-singleton