artemis


Artemis - how to delete all entities from world


I want to delete all entities from world. And if a tag or a group is registered for the entity, I want to remove them too. Like there was no such entity at all. It is much like World.delete function, but you should loop on all entities. I can't find a way. And can't believe the designers didn't prepare such functionality for clearing the world from entities. Do I miss something?
There's no default way of deleting all entities from the World - typically this is done by disposing and recreating the world - but it can be easily achieved by adding a custom manager:
public final class EntityTracker extends Manager {
private Bag<Entity> entities = new Bag<Entity>();
#Override
public void added(Entity e) {
entities.add(e);
}
#Override
public void deleted(Entity e) {
entities.remove(e);
}
public void deleteAllEntities() {
for (Entity e : entities)
e.deleteFromWorld();
}
}
In recent versions of artemis-odb it's easier to use the AspectSubscriptionManager:
IntBag entities = world.getAspectSubscriptionManager()
.get(Aspect.all())
.getEntities();
int[] ids = entities.getData();
for (int i = 0, s = entities.size(); s > i; i++) {
world.delete(ids[i]);
}
edit: The above code assumes artemis-odb; I'm not sure whether vanilla artemis' TagManager and GroupManager automatically removes entities upon deletion.

Related Links

Artemis - how to delete all entities from world

Categories

HOME
uml
url-redirection
phantom-dsl
assembly
google-spreadsheet
object
zend-framework
composite-primary-key
appcelerator
nstableheaderview
nfs
augeas
symbol
dreamweaver
google-data-studio
video-editing
bourbon
apache2.4
rubymotion
libigl
href
tosca
dapper-extensions
apktool
linked-data
user-defined-functions
calculation
dotspatial
xbox
cognos-bi
testbed
playstation-portable
erb
sendbird
baidu-map
mnist
alphabetical
openproject
css-position
levenshtein-distance
apollostack
avcapturedevice
file-sharing
strftime
x++
linter
tf
bluez
wpas
git-flow
excel-dna
arules
er-diagram
mach-o
baidu
choice
gets
taocp
node-request
omxplayer
hadoop-2.7.2
signalr.client
swizzling
turbo-prolog
httpruntime.cache
java-money
file-move
canalyzer
kubuntu
shopizer
broadband
mobility
ignite-ui
verold
jquery-slider
gwt-openlayers
visual-studio-express
inappsettingskit
flex++
route-provider
virtual-pc
sqlclr
midlet
web-farm
subgraph
objectquery
apache-whirr
jquery-address
promotion-code
android-holo-everywhere
event-receiver
cdonts
nhprof
maven-1
hbm2java
zend-rest
application-verifier
sqlobject
unmanagedresources
wcf-proxy

Resources

Encrypt Message