So like always start with problem description: I have some pool of command represented as enumerator. Each of command can have unique data that size can be different. I wanted to create system that allow me in easy way iterate over them and execute. After some time I created this implementation: template<ECommands::enum cmd> bool execCommandTemp(ECommands::ENUM a_cmd, void* a_data) { if (a_cmd == cmd) { SCommand<cmd>::execute((SCommand ::SData*)a_data); return false; } return execCommandTemp<(ECommands::ENUM)(cmd+1)>(a_cmd, a_data); } template<> bool execCommandTemp<ECommands::WRAP>(ECommands::ENUM a_cmd, void* a_data) { return true; } bool execCommand( ECommands::ENUM a_cmd, void* a_data ) { return execCommandTemp<(ECommands::ENUM)0>(a_cmd, a_data); } where SCommand look in example such a way: template <> struct
This time light topic of UI designing :] But before this let's discuss how the hierarchy in the engine works. So it was easier to understand these, let's look at the tooling of it: We have there: World (ID:0) Loaded Stream (Citadel Island) Loaded SubStream (CI.Citadel) Unloaded SubStream (CI.Logic) Folders (f.ex. Park) Entities (f.ex. Ferry) If you are curious what a Stream is, you can think about it as a scene or a level. Now that we know all of this let's look a little bit closer at what we have. Streams and SubStreams are exactly the same I change the name based on their position in the hierarchy. The Folders may look different than Entities but they are exactly the same. They are Entities with a folder component. If we go this way streams are also just Entities with a Stream Component. This leaves us with a bunch of the entities under the World . Which as you can suspect is just an Entity with ID equal to 0. If everything is an entity, what was the reason I
Singleton pattern ... People love it or hate it. There are also group of people who don't mind them. I'm still try figure out which I'm :] I'm for sure not the one who love them. I'm also cannot say that I rally hate them because I still use them in code (It is like with my Facebook account. After I created one I try not complain about fb. ). So probably I'm best fit to don't mind group. But my past experience showing me that I have bigger tendency to removing them from code than adding new one. And probably some colleagues from work will be happy about this because we spend a lot of time discussing about problem. I remove them because I put even more effort in good design of systems. In a lot of cases thanks to changes I just don't need global objects. Which is good. It allow me to better utilize multithreading thanks to encapsulation. Today sadly I had problem where I still don't know cleaner solution than global state: ////////
Comments
Post a Comment