junkdog / artemis-odb

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

[Question] @PooledWeaver and PooledComponents #582

Closed Mr00Anderson closed 5 years ago

Mr00Anderson commented 5 years ago

Without adding any additional systems are components able to be pooled without using @PooledWeaver ; by extending PooledComponent?

Additionally is @PooledWeaver work with inheritance, I feel like it doesnt based on analyzing the bytecode and decompiled classes after the weaver?

junkdog commented 5 years ago

Hmm, I guess it's beacause the IDE isn't applying the plugin. I honestly don't remember if this has always been the case, but I think not (I tend to only run the plugin on CI and from terminal). It should work when invoking maven/gradle manually.

The plugin prints a report upon running:

┌─ 20:16:01 junkdog@b1rb ~/opt/dev/artemis-odb/artemis-core/artemis-test (develop b1623fb5)
└─ [:(] $ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] --------------< net.onedaybeard.artemis:artemis-odb-test >--------------
[INFO] Building artemis-odb-integration-test 2.3.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ artemis-odb-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/junkdog/opt/dev/artemis-odb/artemis-core/artemis-test/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ artemis-odb-test ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- artemis-odb-maven-plugin:2.3.0-SNAPSHOT:artemis (default) @ artemis-odb-test ---
[info]
[info] CONFIGURATION
[info] ------------------------------------------------------------------------
[info] enablePooledWeaving ............................................... true
[info] generateLinkMutators .............................................. true
[info] optimizeEntitySystems ............................................. true
[info] ------------------------------------------------------------------------
[info]
[info] WOVEN COMPONENTS                                                    37ms
[info] ------------------------------------------------------------------------
[info] c.a.c.PolyConstructor ........................................... POOLED
[info] c.a.c.PooledAllFields ........................................... POOLED
[info] c.a.c.PooledCollections ......................................... POOLED
[info] c.a.c.PooledObjectPosition ...................................... POOLED
[info] c.a.c.PooledPosition ............................................ POOLED
[info] c.a.c.PooledString .............................................. POOLED
[info] c.a.c.PooledStructComponentA .................................... POOLED
[info] c.a.c.ReferencePooled ........................................... POOLED
[info] ------------------------------------------------------------------------
[info]
[info] ENTITY LINK MUTATORS                                                 9ms
[info] ------------------------------------------------------------------------
[info] c.a.c.EntityReferencing ....................... id, ids, entity, entiies
[info] c.a.c.l.EntityLink ............................................. otherId
[info] c.a.c.l.EntityLinkB .............................................. other
[info] c.a.c.l.EntityLinkC .............................................. other
[info] c.a.c.l.EntityLinkSkip ........................................... other
[info] c.a.c.l.MuchOfEverything .................. intIds, otherId, e, entities
[info] c.a.c.l.MultiLinkCheckAll ........................................ other
[info] c.a.c.l.MultiLinkSkip ............................................ other
[info] c.a.c.l.MultiLinkSkipTargetCheck ................................. other
[info] ------------------------------------------------------------------------
[info]
[info] OPTIMIZED ENTITY SYSTEMS                                             3ms
[info] ------------------------------------------------------------------------
[info] c.a.s.OptimizedSystem ............................................. FULL
[info] c.a.s.OptimizedSystemAdditional ................................... FULL
[info] c.a.s.OptimizedSystemSafe ......................................... SAFE
[info] c.a.s.ProfiledSystem .............................................. FULL
[info] c.a.s.i.IntOptimizedSystem ........................................ FULL
[info] c.a.s.i.IntOptimizedSystemAdditional .............................. FULL
[info] c.a.s.i.IntOptimizedSystemSafe .................................... SAFE
[info] c.a.s.i.IntProfiledSystem ......................................... FULL
[info] ------------------------------------------------------------------------
junkdog commented 5 years ago

are components able to be pooled without using @PooledWeaver ; by extending PooledComponent?

Yes, extending PooledComponent is enough. @PooledWeaver has the benefit of easily toggling between pooling and not pooling. It's usually the first thing I disable when something looks fishy as it's frequently a case of holding onto a component reference somewhere, forgetting to clean it up when the entity changes composition or is deleted.

Mr00Anderson commented 5 years ago

Thank you, much appreciated. Like the pooled weaver, just need to write some custom resets is all. I will update the wiki with this information that PooledComponent.class can be used without the @PooledWeaver.

**Edit: Before I do that I intend on separating the wiki out some pooled component will be a part, then with the introduction of Pooled Weaving and the benefits of using that over manually typing pooled components. I can say that the PooledComponent is all that is needed and the ECS will automatically pool or not pool without the need of Weaving. I do not wanna make anything wrong or no checked off, if it is more changes then a few spots.