hxE2 - Entity System Alpha Release

76 views
Skip to first unread message

PSvils

unread,
Jan 25, 2015, 11:18:26 AM1/25/15
to haxe...@googlegroups.com
Hey guys!

You can check out the new hxE2 here:
https://github.com/PDeveloper/hxE2

This is an evolution from hxE, and sets the architecture up to have multithreading support, though not currently implemented/tested.
In hxE, you had the System class, which was responsible for iterating a certain type of Entity (an Entity with Components A, B, C). In hxE2, the concept of a "System" is now completely detached. The EntityWorld is the entry point. To manage different sets of Entities, one uses the ViewX classes (View1, View2, View3, View4, View5). Using the ViewX class, you create a managed list of entities corresponding to the Component filter passed, ex:
var view = new View2(world, PositionComponent, DisplayComponent);
Where the actual logic happens is totally up to you. Further changes in hxE2 will reflect this approach, a detachment of Systems from the rest of the library. Right now, in the alpha stage, integration of Systems into the EntityWorld object may change, please use with care. (Utilities and helpers will be provided later to have a similar functionality)

All feedback is welcome! From my initial benchmarks, hxE2 is slightly slower than hxE due to its Entity/Component update mechanism. Further work will be done to detach the ComponentManager and EntityManager responsibilities from the EntityWorld, allowing users to swap functionality depending on their needs, as well as several types of View implementations. The main reason for the new update mechanism is to A) deliver updates to Views only when they are relevant; in hxE, updating an entity's A component would trigger an update in a System watching component B, and B) to implement multithreading support in the future; when implemented, Systems/Views will be able to run on different threads without any modification to user code, as long as the interaction with the Entity System is done through Views.

Any questions, feedback - Post here! Docs MAY be in the works, can't promise anything in the short term, but there is a simple sample that demonstrates how to use hxE2.

P.

Sven Bergström

unread,
Jan 25, 2015, 5:23:07 PM1/25/15
to haxe...@googlegroups.com
nice update! 

I wondered about the lines in the readme :
for (e in view.removedEntities) remove(e);
  for (e in view.addedEntities) add(e);
  for (e in view.updatedEntities) update(e);

I'd be curious why this isn't inside view.update() itself, and the user has to maintain state outside manually?

Even still, nice work.

PSvils

unread,
Jan 26, 2015, 4:17:03 AM1/26/15
to haxe...@googlegroups.com
Thanks! :)

view.update() is what populates the removed/added/updated arrays. It gives manual control over when to pump in new updates to the view, and gives a clear point in the update cycle as to when an entity counts as added, removed, or updated. This is also an API choice to lock it in for future multithreading support.
Cycling the removed/added/updated entities is for custom actions performed for the entities, and has nothing to do with the internal management of the view; All a view needs to do is the view.update() call, the rest is for the user code.

P.
Reply all
Reply to author
Forward
0 new messages