So I'm currently implementing a RTS type game (Think Supreme Commander), which can have thousands of units in play.
In general I like the concept of the Game Event Management system documented in the book, however the book suggests an ActorMove event shoudl be fired whenever an actor (Unit) moves.... in my case I could easily have 1000+ units moving at once, at 60+ frames per second, so that's potentially 60,000 ActorMove events per second.
Then technically each unit potentially needs to know about other units, so all 1000+ units will need to register for the Move events for all the other units. So for each unit that moves that's 999+ delegate functions that are called.
All in all this adds up to 60 * 1000 * 1000 = 60 million event delegate function calls per second!
Of course you could trim this down significantly by making it so that units only register an interest in other units within a certain distance (If you divide the map into a grid or zones then you could have events for Enter\Leave zone, which other units can use to decide if the units are close enough to warrant an interest in the units move events). However, we'd still be talking about pretty large numbers of delegate calls.
In my case, would it not just be better for each unit to not register for ActorMove events of the other units, and instead in the Units Update method it could access the list of other Units (And their position) and take appropriate action?
I hope that question makes sense?
Thanks
Ben
In general I like the concept of the Game Event Management system documented in the book, however the book suggests an ActorMove event shoudl be fired whenever an actor (Unit) moves.... in my case I could easily have 1000+ units moving at once, at 60+ frames per second, so that's potentially 60,000 ActorMove events per second.
Then technically each unit potentially needs to know about other units, so all 1000+ units will need to register for the Move events for all the other units. So for each unit that moves that's 999+ delegate functions that are called.
All in all this adds up to 60 * 1000 * 1000 = 60 million event delegate function calls per second!
Of course you could trim this down significantly by making it so that units only register an interest in other units within a certain distance (If you divide the map into a grid or zones then you could have events for Enter\Leave zone, which other units can use to decide if the units are close enough to warrant an interest in the units move events). However, we'd still be talking about pretty large numbers of delegate calls.
In my case, would it not just be better for each unit to not register for ActorMove events of the other units, and instead in the Units Update method it could access the list of other Units (And their position) and take appropriate action?
I hope that question makes sense?
Thanks
Ben