123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #include "server/Game.h"
- #include "commands/Commands.h"
- #include "memory/UniquePointer.h"
- #include "raw-terminal/RawReader.h"
- #include "server/world/WorldGenerator.h"
- #include "utils/List.h"
- static bool running = true;
- static RawReader<256, 10> reader{0, "> "};
- static List<UniquePointer<World>> worlds;
- Clock Game::ticksPerSecond;
- BlockRegistry Game::blocks;
- void Game::stop() {
- running = false;
- }
- bool Game::isRunning() {
- return running;
- }
- void Game::testWorld() {
- worlds.add(new World(blocks));
- WorldGenerator wg(blocks, *(worlds[0]));
- wg.generate();
- }
- World& Game::getTestWorld() {
- return *(worlds[0]);
- }
- static void handleCommands() {
- if(!reader.canRead()) {
- return;
- }
- const char* s = reader.readLine();
- if(s == nullptr) {
- return;
- }
- Commands::Raw raw(s);
- Commands::execute(raw);
- }
- void Game::tick() {
- ticksPerSecond.update();
- handleCommands();
- }
|