richardlord / Ash

An Actionscript 3 entity system framework for game development
http://www.richardlord.net/ash/
Other
447 stars 95 forks source link

entity.asNode(); #21

Closed mikecann closed 10 years ago

mikecann commented 11 years ago

It would be nice if it was possible to get an entity as a particular type. So for example:

var e : Entity = creator.createPlayer(); var p : PlayerNode = e.asNode(PlayerNode); var c : CollisionNode = e.asNode(CollisionNode);

This would save having to pull out each component individually from the entity before using it as you could pull it out as a node then use it as normal.

If the entity doesn't have all the components required to satisfy that node then it should return null.

It may be nice if the method returned * rather than Node so that continual casting is not required just like the get() method.

richardlord commented 10 years ago

I see little value in this. To include such a method would suggest that developers should be using it, which they probably shouldn't. In the absence of comments from others I'm closing this request.