frcol
Sorry for the delay ! 'Hope this is still useful -
The goal being to maximise reusability, I see mostly 2 scenarios. I work with the assumption that all levels follow roughly the same structure in terms of logic, but require some amount of customisation for gameplay events. I've highlighted the difference between the two approaches, where dynamically generating function names can be useful
1. Lots of levels (layouts), each pointing to a specific event sheet
The shareable bits are all demoted into a shared event sheet, which is included in all the levels event sheets. For a multiplayer game, the structure becomes something like (example) :
Shared ES :
- Common (host/peer) init
- Host-specific init (creation of peer objects, spawn and scale enemies to numbers of players, etc.)
- Host-specific entity management (collision, behaviours, damage, etc.)
- Host-specific gameplay triggers & callbacks (e.g. "Call PlayersDead()" when all players are dead)
- Peer-specific init
- Peer-specific entity management (reacting to objects being created, etc.)
- Peer message processing
- Common (host/peer) logic, if any
Level ES
- Set level options : enemy types, scaling of spawners, etc. whatever is relevant to the gameplay and has been factored out
- Include the shared ES
- Implement the logic for the triggers : "on PlayersDead()" (some levels might force you to restart from the beginning, some might let you continue where you died, etc.)
Here, we always call the same functions, and let the level-specific ES provide the implementation
2. Lots of levels (layouts), each pointing to the same event sheet
We still want to provide custom implementation for specific triggers on a per level basis, but the same event sheet is used as entry points by all the levels. We can't call the same trigger functions anymore, but we can generate names dynamically :
Main ES :
- Set level options : enemy types, scaling of spawners, etc. whatever is relevant to the gameplay that can be tweaked
- Common (host/peer) init
- Host-specific init (creation of peer objects, spawn and scale enemies to numbers of players, etc.)
- Host-specific entity management (collision, behaviours, damage, etc.)
- Host-specific gameplay triggers & callbacks (e.g. "Call LayoutName & "_PlayersDead()"" when all players are dead)
- Peer-specific init
- Peer-specific entity management (reacting to objects being created, etc.)
- Peer message processing
- Common (host/peer) logic, if any
- Implement the logic for the triggers, using specific layout name : "on DeathStar_PlayersDead()", "on StarField_PlayersDead()" etc/ (some levels might force you to restart from the beginning, some might let you continue where you died, etc.)