-
Notifications
You must be signed in to change notification settings - Fork 0
Add World
and related tech.
#25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Refactor enemy spawner factory to be an `IEnemyFactory`, able to customize multiple virtual functions.
Delegate inspection and auto-spawn to spawner / factory.
@swagween This is a big and somewhat complex one, so not belabouring you with a review on it, but tagged you here anyway in case you want to take a look / have questions / etc. |
using Spawn = std::function<std::unique_ptr<Enemy>()>; | ||
|
||
explicit EnemySpawner(Spawn spawn, bave::ParticleEmitter explode); | ||
explicit EnemySpawner(std::unique_ptr<IEnemyFactory> factory); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the need for EnemySpawner
, IEnemyFactory
, and EnemyFactoryBuilder
? what's the difference between all of these? I get that the spawner just handles the gameplay aspects and doesn't worry about how the memory is managed and stuff, but I'm more confused about the latter two.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spawner - which is not customizable - uses a customizable factory to drive itself. The factory builder converts JSON data into a concrete factory.
using bave::Seconds; | ||
using bave::Shader; | ||
|
||
namespace { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the unnamed namespace here? are these just World
helper functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah they are helper functions that are only used in this cpp file, so putting them in an unnamed namespace gives them internal linkage (visible only to this cpp file) and the compiler a better opportunity to optimize them.
|
||
namespace spaced { | ||
struct WorldSpec { | ||
struct Player { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be something like PlayerSpec
to avoid confusion? Although I suppose it is a bit redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it could be argued that way for sure. I didn't use the suffix because like you said it's already in the enclosing class (WorldSpec::Player
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some small questions
Close #16