ronscript ronscript - 1 month ago 18
Java Question

libgdx (Ashley Framework ECS) - What is the proper way of talking system to another system?

System
to
System


Currently I'm developing
CharacterSystem
,
GunSystem
,
BulletSystem
using ashley framework. My problem is I dont know if this is the proper way of talking
system
to other
system
.

My
CharacterSystem
method
onProcessEntity
when the
character
attack
is triggered I used
getEngine().getSystem(GunSystem.class).trigger(true)
and inside the
GunSystem
I have a method the Generate entity of a
Bullet
. While the
BulletSystem
handles the freeing of bodies, when outside the camera.

sub-question What is the proper way of creating
Bullet
class
with ECS framework?

Answer

I never used Ashley as ECS but usually Systems should not communicate with each other.

Reason: When Systems would communicate they would not be independent of each other. Independent Systems allow you to freely add and remove them without having to worry the code breaks. The game logic probably breaks of course when a important Systems are missing.

Have a Factory (class) which does create the bullet entity. Then use the Factory in each System which can built new bullet entity.