There's two good examples that I can think of for doing this, and it comes mainly from working with Artemis in my most recent project.
The first way I learned from the one game example link they have on their websitehttp://code.google.com/p/spaceship-warrior/
In that one, anything that's collidable have a "Bounds" property and is either a player or enemy. On every update cycle, it checks all entities, if it's a player it iterates through the enemy list to find which one it collided with and interacts directly with it within the system, and vise versa if it was a player. I did this approach with my own vertical shooter because it works rather well.
The other way I can think of would be good if you were doing something like a turn-based RPG, where you have something like an "Attack" component that could look like this
public class Attack
final Entity target;
public Attack(Entity target)
this.target = target;
Whenever you would set a target you would then add the component to the actor attacking.
Be sure to use e.changedInWorld() to ensure all systems in the world have their lists updated so they know it has the attack component now. Then you have an AttackSystem that'll process everything with Attack Components
public class AttackSystem extends EntityProcessingSystem
@Mapper ComponentMapper<Attack> attacksMap;
protected void process(Entity e)
Attack a = attacksMap.get(e);
Strength str = e.getComponent(Strength.class);
Defense def = a.target.getComponent(Defense.class);
int dmg = Math.max(str.value-def.value, 0);
Health hp = a.target.getComponent(Health.class);
hp.value -= dmg;
I can't stress enough that the second way is not something you would want to do in a real-time interaction scenario. Adding and removing components, and having to update the world and all systems to recognize that change is extremely expensive. In fact, it's probably not a good idea to use for such a heavily hit system as the example provides.
Nevertheless, it does show how to do a level of interactive one-way coupling of entities. By linking using components, you can actually reference the other entity even outside of systems by just getting the component from the parent entity using the getComponent method.
I hope those two ways help you in understanding Artemis