tiwaz1994 / DynamicBulwarks

Fork with improvements for Dynamic Bulwark.
2 stars 1 forks source link

Improve/cleanup wave spawning system #46

Open ChronosWS opened 4 years ago

ChronosWS commented 4 years ago

There's a lot of code duplication in createWave/spawnWave. We should clean this up, factor out the .sqf files into well-named and categorized functions), and make the wave system more easily extensible. Thoughts on what that might look like - a wave could be defined by the following things (this is just a set of ideas/guidelines, not necessarily a final design):

  1. An Init phase, where anything which needs to be calculated/prepared for the wave can occur. This is called before the wave starts. For example, you might determine what sort of units are going to spawn based on faction lists and filters
  2. A Run phase, which is a function that will be spawned to handle the wave as it executes. Spawning would occur here by calling into the common spawning functions. Special events and what not would occur in here.
  3. A cleanup phase, which will remove anything the wave generated. The spawning system would keep track of normal units, but special spawned items would be cleaned up here.

The wave system would be responsible for calling each of these functions at the appropriate time. The wave would end when the Run phase function deliberately exits (checked via scriptDone, or if we have to force-terminate it for some reason using terminate).

Waves only need to implement the functions which matter to them, so for simple waves, they would just have a Run phase which submits the set of units to the common spawning system which will handle spawning and keeping track of spawned units and cleaning them up at the end.