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
132 stars 10 forks source link

Using diff update rates for Systems #6

Open cchandel opened 2 years ago

cchandel commented 2 years ago

Hi, Is there a way I can use different updates rates for systems ?

For eg, the movement system might need updating every 33 ms, but say the inventory system might only need to be updated on an event like the player firing a gun. Another system - say fuel system - might need updating only every 5 secs.

How do I achieve this?

Thanks

zllangct commented 2 years ago
func (f *FakeSystem) Update(e ecs.Event) {
    f.elapse += e.Delta
    if f.elapse < time.Second * 5 {
        return
    } else {
        f.elapse = 0
    }

    //TODO something you want to do

}
cchandel commented 2 years ago

Thanks.