From a5b794b1d1bc11a7e59655f3940b7e44abb103ea Mon Sep 17 00:00:00 2001 From: HENRY Benjamin Date: Sun, 20 Jun 2021 10:34:55 +0200 Subject: [PATCH] added ia to parser --- sources/Parser/ParserYaml.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sources/Parser/ParserYaml.cpp b/sources/Parser/ParserYaml.cpp index b3a6ce82..24075fce 100644 --- a/sources/Parser/ParserYaml.cpp +++ b/sources/Parser/ParserYaml.cpp @@ -87,6 +87,7 @@ namespace BBM { auto *bombHolder = entity.tryGetComponent(); auto *model = entity.tryGetComponent(); auto *speed = entity.tryGetComponent(); + auto *controllable = entity.tryGetComponent(); auto name = entity.getName(); if (!position || !bombHolder || !model || !speed) @@ -97,6 +98,7 @@ namespace BBM { _player << "max_bomb: " << std::to_string(bombHolder->maxBombCount) << std::endl << " "; _player << "explosion_radius: " << std::to_string(bombHolder->explosionRadius) << std::endl << " "; _player << "speed: " << std::to_string(speed->speed) << std::endl << " "; + _player << "ia: " << (controllable->layout == ControllableComponent::AI ? "true" : "false") << std::endl << " "; _player << "position: [" << std::to_string(position->getX()) << "," << std::to_string(position->getY()) << "," << std::to_string(position->getZ()) << "]"; } @@ -177,8 +179,8 @@ namespace BBM { }); if ((tmpAssets.find("red.png") == std::string::npos && tmpAssets.find("blue.png") == std::string::npos && - tmpAssets.find("green.png") == std::string::npos && tmpAssets.find("yellow.png") == std::string::npos && - tmpAssets.find("ai.png") == std::string::npos) || !std::filesystem::exists(tmpAssets)) { + tmpAssets.find("green.png") == std::string::npos && tmpAssets.find("yellow.png") == std::string::npos) + || !std::filesystem::exists(tmpAssets)) { throw (ParserError("One asset is invalid.")); } auto start = tmpAssets.find_last_of('/') + 1; @@ -194,7 +196,14 @@ namespace BBM { auto &ready = resumeScene->addEntity("ready") .addComponent(224 * (countPlayer + 1) + 200 * countPlayer, 1080 / 3, 0) .addComponent(); - playerLogo.addComponent(countPlayer, ready, playerTile, colors.at(colorStr)); + auto *lobby = playerLogo.addComponent(countPlayer, ready, playerTile, colors.at(colorStr)).tryGetComponent(); + if (node.getProperty("ia") == "true") { + auto *texture = dynamic_cast(ready.getComponent().drawable.get()); + lobby->ready = true; + lobby->layout = ControllableComponent::AI; + if (texture) + texture->use("assets/player/icons/ai.png"); + } } void ParserYAML::_loadPlayers(std::shared_ptr scene, Node &node)