bsimser / artemis-framework

Artemis is a high performance Entity System framework for games.
MIT License
2 stars 0 forks source link

Components removed from ComponentMapper before remove() is invoked #10

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Subclass and add an EntityProcessingSystem with a ComponentMapper field 
which has a generic type of a Component matched by the System's Aspect.
2. Add a Component of the mapped type to an Entity, inserted() is invoked and 
the component is present in the ComponentMapper.
3. When a Component of the mapped type is removed from an entity, removed() is 
invoked, but ComponentMapper<>#get(e) returns null.

What is the expected output? What do you see instead?
In removed(), ComponentMapper<>#get(e) should return the component that is 
being removed.

What version of the product are you using? On what operating system?
artemis-a609b2076aacc0ef5ecf0b390205d01bb88ceae2.jar
OS X 10.8.4
Please provide any additional information below.

Original issue reported on code.google.com by olbart...@gmail.com on 13 Sep 2013 at 5:04

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I'm experiencing a similar issue, where I'm creating a new entity in the 
overridden removed() method. The entity that gets created has the same id as 
the one that is passed into removed.

The problem happens when the componentManager cleans up all the deleted 
entities after notifying the systems, and cleans up the newly created 
components for the new entity created in removed().

Original comment by apota...@gmail.com on 27 Sep 2013 at 7:28

GoogleCodeExporter commented 8 years ago
I agree with this. 
In my current project, I have a Physics component which creates a box2d body in 
the overridden inserted(Entity e) method.

When an entity is removed from the world via world.deleteEntity(e), in 
removed(Entity e) I clean up and remove the box2d body (since the physics 
component returns OK).

However, if I removed the physics component via 
e.removeComponent(Physics.class), then call e.changedInWorld() the removed 
method returns null when I get the Physics component.

This is a bit of a problem for me, since it works unpredictably depending on 
how you remove the component or entity.

Original comment by rend...@gmail.com on 29 Dec 2013 at 11:19