1 #include "ServerState.hpp"
3 #include "../app/Environment.hpp"
4 #include "../app/TextureIndex.hpp"
5 #include "../net/io.hpp"
13 ServerState::ServerState(
14 HeadlessEnvironment &env,
15 const Generator::Config &gc,
16 const World::Config &wc,
18 const Server::Config &sc
22 , world(block_types, wc)
24 , chunk_loader(world.Chunks(), generator, ws)
26 , spawner(world, skeletons, gc.seed)
29 TextureIndex tex_index;
30 env.loader.LoadBlockTypes("default", block_types, tex_index);
31 skeletons.LoadHeadless();
35 std::cout << "listening on UDP port " << sc.port << std::endl;
39 void ServerState::Handle(const SDL_Event &event) {
40 if (event.type == SDL_QUIT) {
46 void ServerState::Update(int dt) {
47 loop_timer.Update(dt);
50 while (loop_timer.HitOnce()) {
51 spawner.Update(loop_timer.Interval());
52 world.Update(loop_timer.Interval());
53 world_dt += loop_timer.Interval();
54 loop_timer.PopIteration();
56 chunk_loader.Update(dt);
58 server.Update(world_dt);
63 void ServerState::Render(Viewport &viewport) {