Slick Forums

Discuss the Slick 2D Library
It is currently Sun May 26, 2013 12:12 am

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Wed Aug 29, 2012 9:32 pm 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
Two worthwhile features added:

1. Now possible to use @Mapper annotation to automagically inject a ComponentMapper into your system at runtime.
Code:
public class MyEntitySystem {
  @Mapper
  private ComponentMapper<Position> positionMapper; // all done
}



2. Now possible to exclude entities with an aspect.
Code:
public class RenderNonePhysicsEntitiesSystem {
   public RenderNonePhysicsEntitiesSystem() {
        super(Aspect.getAspectFor(Position.class, Sprite.class).exclude(Physics.class));
   }
}

Means all entities with Position.class and Sprite.class and NOT Physics.class will be processed by this system. You can add multiple exclusion components as well.


Top
 Profile  
 
PostPosted: Wed Aug 29, 2012 9:59 pm 
Offline

Joined: Sat Jun 02, 2012 7:41 am
Posts: 67
Whoa, now this is cool :D


Top
 Profile  
 
PostPosted: Thu Aug 30, 2012 12:09 pm 
Offline

Joined: Fri Apr 06, 2012 1:50 pm
Posts: 5
This is so great! I like where you are taking the framework style-wise. I just participated in Ludum Dare #24 using artemis and it hasn't let me down once again. I wouldn't give that source-code as an good example to anyone though. 48h makes you do a lot of ugly stuff to finish in time ;)
Thanks for making this framework even more awesome ;)


Top
 Profile  
 
PostPosted: Thu Aug 30, 2012 2:25 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1315
Location: Italy
I like new @Mapper annotation!

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
PostPosted: Thu Aug 30, 2012 2:59 pm 
Offline

Joined: Fri Jul 13, 2012 9:59 pm
Posts: 25
I'd love to have an OR function. That would be perfect. The exclude I've never used, but I've implemented a simple version of the OR function, but doing this with aspects would mean a better design.


Top
 Profile  
 
PostPosted: Thu Aug 30, 2012 5:12 pm 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
Shirkit wrote:
I'd love to have an OR function. That would be perfect. The exclude I've never used, but I've implemented a simple version of the OR function, but doing this with aspects would mean a better design.

I'll look into it.


Top
 Profile  
 
PostPosted: Fri Aug 31, 2012 3:27 pm 
Offline

Joined: Fri Jul 13, 2012 9:59 pm
Posts: 25
I don't mean something like parenthesis for now, like ((A ^ B) - D) + C, this could turn into a complex and unused feature. I can't think in systems that can do things like ((A^B)-C)+((A^B)-D). I'd start with no parenthesis at all, and then you rethink. Doing things like Aspect.aspectForAll(A,B).excluding(C) and Aspect.aspectForOneOfThem(A,B,C) seems to be a good starting point.


Top
 Profile  
 
PostPosted: Fri Aug 31, 2012 4:07 pm 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
Shirkit wrote:
I don't mean something like parenthesis for now, like ((A ^ B) - D) + C, this could turn into a complex and unused feature. I can't think in systems that can do things like ((A^B)-C)+((A^B)-D). I'd start with no parenthesis at all, and then you rethink. Doing things like Aspect.aspectForAll(A,B).excluding(C) and Aspect.aspectForOneOfThem(A,B,C) seems to be a good starting point.


You can also do:

world.setSystem(new ABCSystem(Aspect.getAspectFor(A.class)));
world.setSystem(new ABCSystem(Aspect.getAspectFor(B.class)));
world.setSystem(new ABCSystem(Aspect.getAspectFor(C.class)));

Creating three instances of the same system should work for this case.


Top
 Profile  
 
PostPosted: Fri Aug 31, 2012 4:35 pm 
Offline

Joined: Fri Jul 13, 2012 9:59 pm
Posts: 25
appel wrote:
You can also do:

world.setSystem(new ABCSystem(Aspect.getAspectFor(A.class)));
world.setSystem(new ABCSystem(Aspect.getAspectFor(B.class)));
world.setSystem(new ABCSystem(Aspect.getAspectFor(C.class)));

Creating three instances of the same system should work for this case.


I didn't knew I could do that, seems like hack ^^


Top
 Profile  
 
PostPosted: Fri Aug 31, 2012 4:54 pm 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
Shirkit wrote:
appel wrote:
You can also do:

world.setSystem(new ABCSystem(Aspect.getAspectFor(A.class)));
world.setSystem(new ABCSystem(Aspect.getAspectFor(B.class)));
world.setSystem(new ABCSystem(Aspect.getAspectFor(C.class)));

Creating three instances of the same system should work for this case.


I didn't knew I could do that, seems like hack ^^


Well, it's possible... only problem is you cannot retrieve the system from the world, it will return you the last inserted system:
Code:
ABCSystem abcSys = world.getSystem(ABCSystem.class); // returns the one for C.class


Better would be to create an abstract ABCSystem which has all the logic, and extend it with ASystem, BSystem and CSystem each defining their own aspect, and they would really only have a constructor. That way you can retrieve from world each system.

But frankly, Aspect.aspectForOneOfThem(A,B,C), seems like a hack too ^^


Top
 Profile  
 
PostPosted: Sat Sep 01, 2012 7:29 pm 
Offline

Joined: Fri Jul 13, 2012 9:59 pm
Posts: 25
appel wrote:
Shirkit wrote:
appel wrote:
You can also do:

world.setSystem(new ABCSystem(Aspect.getAspectFor(A.class)));
world.setSystem(new ABCSystem(Aspect.getAspectFor(B.class)));
world.setSystem(new ABCSystem(Aspect.getAspectFor(C.class)));

Creating three instances of the same system should work for this case.


I didn't knew I could do that, seems like hack ^^


Well, it's possible... only problem is you cannot retrieve the system from the world, it will return you the last inserted system:
Code:
ABCSystem abcSys = world.getSystem(ABCSystem.class); // returns the one for C.class


Better would be to create an abstract ABCSystem which has all the logic, and extend it with ASystem, BSystem and CSystem each defining their own aspect, and they would really only have a constructor. That way you can retrieve from world each system.

But frankly, Aspect.aspectForOneOfThem(A,B,C), seems like a hack too ^^


If it's officially supported by the framework, I don't see as hack ^^


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group