zllangct / ecs

A Go-implementation of the ECS (Entity-Component-System), focus on the development of game server.
BSD 3-Clause "New" or "Revised" License
137 stars 10 forks source link

Observer Pattern #5

Open cchandel opened 2 years ago

cchandel commented 2 years ago

Hi, Is there a way to use event subscription to call system functions? Thanks

zllangct commented 2 years ago

I think we should change the mode of thinking, this is ECS, not OOP. this rep is a concurrency system with lock-free, all logic drived by "frame", ecs benifit from the the independent "system", your system can call diffrent function by changing component field, a system shoud not communicate with others directly. you can add a new single-use component with some data what you want to send to the system when you want to publish an event.

cchandel commented 2 years ago

Ok, That makes sense.

Could you provide example of how both options would work?

Thanks.

zllangct commented 2 years ago

Good idea, I'm planning to do it, the way to program is very different from what we used before, we need more examples

cchandel commented 2 years ago

For Eg, Lets say the game has the ability to change its speed - which means at speed 2 every thing becomes 2 times as fast, actor movement, game time etc.

How would this be handled in your view?

zllangct commented 2 years ago

I see, you want to modify system by event,such as the time-scale of system and other system field, i think u r right, it's very useful. I will add this capability in future. Thanks.

cchandel commented 2 years ago

Hi, Thank you for the fake_game example and for adding events to the ECS system. Regards

zllangct commented 2 years ago

Hi, this rep's apis are unstable, will be optimized or changed continuously before release version, Thanks for your proposal.

zllangct commented 2 years ago

fake_game_server example is incomplete, more usages will be added to this example.

cchandel commented 2 years ago

Sure. Understood.