Комментарии:
Thanks for having me CppCon! I hope folks enjoy this pattern! :)
ОтветитьInheritance bad REEEEE
ОтветитьMy gripe is not with running interspersed updates and renders (which you admit is a problem) but with keeping all game objects as `Rc<dyn GameObject>`.
Wouldn't keeping objects of the same concrete type in individual dense non-dynamic collections (whether all together like in your prototype or split into Components within Systems) rather than a single collection of heterogenous dynamic objects always win?
I honestly don't think this is a good example of a use case for the factory pattern. In games you're more likely to use(and you should probably use) an ecs.
In what case it can be useful in in games is in combination with a state pattern. That's pretty much the only instance where we use factories in our real-time applications.
Really enjoyed the talk Mike.
You should do the State design pattern next as that is one I have trouble understanding😉
Is there any way in C++ to write this code using a generic like you might in C#? Like instead of Factory::Create(“ant”, 5, 5) could you do Factory::Create<Ant>(5, 5) ?
ОтветитьA great approach for mimicking somehow a virtual constructor in the abstract class and allowing for the run time object creation. I think using modern features of c++ like std::function, lamda, code injection (or the old feature, macro), we can make it more general. So that we can auto generate the required static members and methods. We also can generat various constructor intrefaces for the object.
ОтветитьWhy was the singleton create method required? Wouldn't it be likely that one would create more than one instance of ant?
ОтветитьI tried to extend your fancy registration style factory pattern. I wanted just two things: 1. Don’t force the concrete create method to obey a fixed constructor function signature (use variadic template). 2. Use std::function…
I flamed out miserably, perhaps because I was running on 5 hours of sleep and 3 cups of coffee…
I try with lambda is working well, better make it whole class as templates with function type or something like that.
ОтветитьMike is a fantastic educator and I think if this talk was just in the back to basics track, and not the software design track, there would have been a lot less annoying nitpicky comments/“questions” from professionals with their egos hurt by being taught something they already know.
Ответить