kevinresol / exp-ecs

Experimental macro-powered Entity-Component-System game engine
59 stars 5 forks source link

The sample does not compile `should be ecs.system.System<Unknown<0>>` #2

Closed Jarrio closed 5 years ago

Jarrio commented 5 years ago

https://github.com/kevinresol/ecs/blob/develop/sample/asteroid/src/Main.hx#L90 On this line the following error appears:

src/Main.hx:77: lines 77-80 : { system : system.MovementSystem<Unknown<1>>, before : Class<system.CollisionSystem> } should be ecs.system.System<Unknown<0>>
src/Main.hx:77: lines 77-80 : For optional function argument 'items' 

I think this might be an issue with haxe 4 as it seems to compile fine on haxe 3 (tested on a modified version of the sample on kha with a --haxe3 flag)

kevinresol commented 5 years ago

Hmm.. I can't reproduce that. I think I am having some issues with lix + openfl + haxe 4 preivew 4/5

Do you think you will be able to isolate a snippet that doesn't involve any game frameworks?

Jarrio commented 5 years ago

I think I figured out where this is going wrong

var sys:SystemInfo<Event> = {
    system: new RenderSystem(this)
}   
engine.states.add('playing', new ecs.state.State([sys]), ['gameover']);

That works as expected, below fails:

var state = new ecs.state.State([sys]);
engine.states.add('playing', {
    system: new RenderSystem(this)
}, ['gameover']);

I believe this is because haxe can't infer the type inference that SystemInfo requires

kevinresol commented 5 years ago

It would be nice if you can add a falling case in the test suite.

sh-dave commented 5 years ago

The asteroids example compiles fine for me with the bundled 4.0.0-preview.5+1aaf080 haxe in the current Kha extension pack 18.11.3. What version are you using?

I do get some warnings though:

...system/BulletAsteroidCollisionHandlerSystem.hx:11: characters 60-108 : Warning : This pattern is unused
...system/SpaceshipAsteroidCollisionHandlerSystem.hx:11: characters 46-80 : Warning : This pattern is unused

Also, (just from reading the code, i don't know what goes on) shouldn't you pass an array in the second example [{ system: new RenderSystem() }] or even wrap it in a State?

kevinresol commented 5 years ago

Yeah @sh-dave you are right, the correct version should be like this:

engine.states.add('playing', new EngineState([{
    system: new RenderSystem(this)
}]), ['gameover']);

As for the warnings, I think it is more a compiler issue. Because obviously there are no unused patterns.

Jarrio commented 5 years ago

This is on haxe preview 4 so maybe it gets fixed in preview 5. @sh-dave That was a mistake whilst made while editing the code on github.

image

image

In the first image the error occurs and in the second it doesn't. I will add a test when I get time to figure out how to do unit tests :sweat_smile:

kevinresol commented 5 years ago

I think it is working fine now