From cf34fb791a3d604d5b23900fe07960dbd197af34 Mon Sep 17 00:00:00 2001 From: Tyler Lentz Date: Wed, 5 Jun 2024 17:15:14 -0700 Subject: [PATCH] assign models to players upon DM assignment --- src/server/server.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/server/server.cpp b/src/server/server.cpp index 7eb96733..534e246b 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -302,6 +302,29 @@ std::chrono::milliseconds Server::doTick() { sendUpdateToAllClients(Event(this->world_eid, EventType::LoadGameState, LoadGameStateEvent(partial_update))); } + + int player_idx = 0; // only increment when assigning a model + + auto players = this->state.objects.getPlayers(); + for (int i = 0; i < players.size(); i++) { + auto player = players.get(i); + if (player == nullptr) continue; + + if (player_idx == 0) { + player->modelType = ModelType::PlayerFire; + } else if (player_idx == 1) { + player->modelType = ModelType::PlayerLightning; + } else if (player_idx == 2) { + player->modelType = ModelType::PlayerWater; + } + + player_idx++; + + if (player_idx > 2) { + player_idx = 0; + } + } + std::cout << "Assigned player " + std::to_string(index) + " to be the DM" << std::endl; std::cout << "Starting game!" << std::endl; }