[Library] tiny-ecs - Fast Simple Entity Component System

Showcase your libraries, tools and other projects that help your fellow love users.
Zireael
Party member
Posts: 139
Joined: Fri Sep 02, 2016 10:52 am

Re: [Library] tiny-ecs - Fast Simple Entity Component System

Post by Zireael » Thu Feb 23, 2017 11:46 am

Are the two demos by bakpakin the only examples of how to use it? I wanted to change parts of my existing project to a component structure since I'm having problems with loops/diamond problem when using inheritance...

User avatar
emanevitaerc
Prole
Posts: 16
Joined: Sun Mar 13, 2016 7:21 am

Re: [Library] tiny-ecs - Fast Simple Entity Component System

Post by emanevitaerc » Thu Mar 16, 2017 5:59 pm

How can I make a sorted processing system re-sort its entities? I'm using one to sort drawn entities by depth to get them in a proper draw order, but it only sorts them once upon their addition, so after their depth changes they stay in the same position in the draw system's entity list.

User avatar
bakpakin
Party member
Posts: 110
Joined: Sun Mar 15, 2015 9:29 am
Location: Boston

Re: [Library] tiny-ecs - Fast Simple Entity Component System

Post by bakpakin » Sat Mar 18, 2017 4:56 pm

Try calling sortedSystem:onModify(). This is called once every time new items are added, and resorts the system.
((_((_CRAYOLA_((_((_> GitHub <_((_((_CRAYOLA_((_(()

User avatar
emanevitaerc
Prole
Posts: 16
Joined: Sun Mar 13, 2016 7:21 am

Re: [Library] tiny-ecs - Fast Simple Entity Component System

Post by emanevitaerc » Sat Mar 18, 2017 9:27 pm

bakpakin wrote:
Sat Mar 18, 2017 4:56 pm
Try calling sortedSystem:onModify(). This is called once every time new items are added, and resorts the system.
EDIT: Misread your comment, this does work for my intentions. Thanks!

User avatar
HanaIndiana
Prole
Posts: 5
Joined: Fri Jul 10, 2015 12:48 am
Location: Northern CA
Contact:

Re: [Library] tiny-ecs - Fast Simple Entity Component System

Post by HanaIndiana » Wed Sep 13, 2017 4:40 am

Does anyone have an example of using the world:removeEntity(entity) function? I'm either not using it right, or it's working in a way I'm not expecting. I'm wondering if the system:onRemove(entity) needs to always be included as well. Either way, I'm lost.
The two demos bakpakin has in git (kibbles and weregoat), while helpful, don't use either of these functions.

Here is a short example of one thing I've tried.
If I have an entity called "Word", added to the world like this:
world:add(Word(100,50,assets.lrgfont,"Game Title"))

To remove this entity, would I use this syntax?
world:removeEntity(Word)

I also have a system that uses this Entity, called "WordSystem". And I have a function belonging to this system called:
function WordSystem:onRemove(entity)
But the function doesn't appear to be called when the removeEntity function is used.
Any help is appreciated!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests