Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [entity system framework] artemis-odb 0.5.0 and agrotera 0.3.0  (Read 1411 times)
0 Members and 1 Guest are viewing this topic.
Offline junkdog
« Posted 2013-11-28 10:20:09 »

Introduction
If you haven't heard of artemis or entity systems before, the blurb:

Quote
Artemis is a high performance Entity System framework for games, written in Java, and is a framework to manage entities in a game world. It is inspired by Entity Systems are the future of MMORPG blog series by Adam Martin. We also borrowed ideas from Ted Brown who implemented a simple high-performance Entity System in Processing based on Adam Martin's blog.

The framework is based on the concept that entities in a game world exist as pure identifiers, their components contain only data, and systems process entities based on their aspects. This promotes separation of concern and simplifies game design tremendously.

artemis-odb aims to preserve the simplicity of the original artemis framework while at the same time extending it with new features. The recently released 0.5.0 introduces "packed" components and pooling of entities and optionally components.

agrotera is a small annotation-driven compile-time plugin for reducing boilerplate associated with configuring EntitySystems, Managers and - new in 0.3.0 - general classes. Since agrotera solely relies on compile-time weaving, there is no performance or memory cost associated with its features.


artemis-odb compared to original artemis:
- All known bugs present in original artemis have been resolved.
- Less object allocation.
- New component types:
  - PooledComponent: automatically recycled.
  - PackedComponent: single instance component backed by a static array
- Optional compile-time bytecode weaving: @PooledWeaver and @PackedWeaver annotations rewrites normal com.artemis.Component classes into the requested type.
  - Since weaving takes place during compile-time, this works on android too.

The PackedComponent implementation, while harboring noble ideals, is somewhat naive at the moment:
 - Requires setters/getters for all values (I personally much prefer direct field access for components).
 - Assumes that the component will be present in all entities (internally, the entity id is used as index in the component's backing array). Still applicable for Position and similarly ommipresent properties.
 - @PackedWeaver requires that all fields share the same primitive type.

Future releases will offer more flexibility in regard to automatically weaving packed components (see here).

The benefit of using the @*Weaver annotations is that the components still look like "normal" POJO components and hence are less prone to mundane errors. Additionally, it may make debugging slightly easier since reverting a woven component back to a normal is a simple as removing the annotation.

agrotera

agrotera removes nearly all boilerplate from systems (well, it could be argued that it's simply been moved to annotations instead, but the net result is less code):

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
// inject profiling, invoked at start of begin() and before any exit points in end()
@Profile(using=Profiler.class, enabled=Profiler.PERF_PROFILE)
// Injects ComponentMapper fields for all referenced component types
// and any referenced systems and managers.
// Eclipse's editor/compiler is aware of any injected fields.
@ArtemisSystem(
    requires={Position.class, Thrust.class, PrecomputedThrust.class, GravityAffected.class, RepulseAffected.class},
    systems=GravityFieldComputer.class)
public final class PrecomputedThrustSystem extends EntityProcessingSystem
{
    public PrecomputedThrustSystem()
    {
        // null is replaced with the appropriate Aspect, deduced from @ArtemisSystem
       super(null);
    }
   
    @Override
    protected void process(Entity e)
    {
        Position position = positionMapper.get(e);
        Thrust thrust = thrustMapper.get(e);
       
        gravityFieldComputer.cachedGravity(thrust, position.x(), position.y());
    }
}


From the annotated classes, agrotera can generate a system overview from artemis' point-of-view:


Bytecode weaving - for both artemis and agrotera - is quite fast. On my laptop (i7 @ 3ghz):
1  
2  
3  
4  
[INFO] --- artemis-odb-maven-plugin:0.5.0:artemis (default) @ hallucinolog-core ---
[INFO] Processed 10 PackedComponents and 11 PooledComponents in 67ms.
[INFO] --- agrotera-maven-plugin:0.3.0:agrotera (default) @ hallucinolog-core ---
[INFO] Processed 25 EntitySystems, 5 Managers and 1 Injected types in 75ms.


Caveats
- There's a pretty heavy reliance on maven (for bytecode weaving), although most things can still work outside a maven context, as an eclipse builder or as part of an ant script.

- (only agrotera) lombok-pg and lombok aren't compatible, and lombok-pg hasn't been updated for some time. I've seen some forks that have been busy keeping lombok-pg up to date with lombok - should look into those in the future. lombok-pg is responsible for injecting fields early enough for Eclipse to see them.

- (also mostly agrotera) Eclipse is the only IDE officially "supported", with projects preferably setup as maven modules. Furthermore, lombok-pg (a fork of the my all-time favorite Project Lombok) is required to make agrotera fly. I'm not sure to what degree other IDE:s are used, but let me know if you think I should add support for others.

artemis-odb: bugfixing and performance optimized fork of artemis ECS
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (41 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!