Permalink
Browse files

Add node to family before adding it to the nodelist. Fixes issue #3.

  • Loading branch information...
1 parent 4665395 commit 6e7615ffc90cc8fd3eda902ea01929a65736da4a @richardlord committed Mar 5, 2012
Showing with 6 additions and 5 deletions.
  1. +6 −5 src/net/richardlord/ash/core/Family.as
@@ -64,28 +64,29 @@ package net.richardlord.ash.core
{
node[components[componentClass]] = entity.get( componentClass );
}
- nodes.add( node );
entities[entity] = node;
entity.componentRemoved.add( componentRemoved );
+ nodes.add( node );
}
}
internal function remove( entity : Entity ) : void
{
if( entities[entity] )
{
+ var node : Node = entities[entity];
entity.componentRemoved.remove( componentRemoved );
- nodes.remove( entities[entity] );
+ delete entities[entity];
+ nodes.remove( node );
if( game.updating )
{
- nodePool.cache( entities[entity] );
+ nodePool.cache( node );
game.updateComplete.add( releaseNodePoolCache );
}
else
{
- nodePool.dispose( entities[entity] );
+ nodePool.dispose( node );
}
- delete entities[entity];
}
}

0 comments on commit 6e7615f

Please sign in to comment.