junkdog / artemis-odb

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

EntitySubscription-centric manager for bootstrapping transient components #306

Closed junkdog closed 9 years ago

DaanVanYperen commented 9 years ago

Shouldn't a users systems/managers already do this by means of the existing create/update/delete callbacks? (populate transient aspects of component model?)

junkdog commented 9 years ago

More of a utility manager to cut down on some boilerplate. I think I had something more specific in mind, but can't remember what atm...

DaanVanYperen commented 9 years ago

Something like https://github.com/DaanVanYperen/artemis-odb-contrib/blob/develop/contrib-core/src/main/java/net/mostlyoriginal/api/manager/AssetManager.java ?

junkdog commented 9 years ago

yes, something similar - or go with DI.

I tend to keep the assets reference components. they're handy to keep when serializing.

junkdog commented 9 years ago

closing this as it's too easy to roll in project code; not all use-cases necessarily fit it, so I'll just leave it be. This is what I'm doing in the current project:

        util.subscription( // util = EntityUtil extends Manager
            all(Size.class, TextureReference.class),
            new SubscriptionAdapter(world) {
                @Override
                protected void inserted(Entity e) {
                    assignSprite(e, textureReferenceMapper.get(e));
                }
            });