bugfix for adding units to every player from map scripts

This commit is contained in:
devZoGok
2023-12-30 12:19:45 +02:00
parent d1bd4cc052
commit f86edaf3c0
5 changed files with 28 additions and 27 deletions
+13 -14
View File
@@ -124,7 +124,7 @@ namespace battleship{
}
}
void Map::loadPlayerGameObjects(Player *player){
void Map::loadPlayerGameObjects(){
AssetManager *assetManager = AssetManager::getSingleton();
string path = GameManager::getSingleton()->getPath();
assetManager->load(path + DEFAULT_TEXTURE);
@@ -138,23 +138,22 @@ namespace battleship{
int numPlayers = SOL_LUA_VIEW["numPlayers"];
for(int i = 0; i < numPlayers; i++){
if(i == 0){
string resDepInd = "resourceDeposits";
SOL_LUA_VIEW.script("numResourceDeposits = #" + mapTable + "." + playerInd + "[" + to_string(i + 1) + "]." + resDepInd);
int numNpcObjs = SOL_LUA_VIEW["numResourceDeposits"];
string resDepInd = "resourceDeposits";
SOL_LUA_VIEW.script("numResourceDeposits = #" + mapTable + "." + playerInd + "[" + to_string(i + 1) + "]." + resDepInd);
int numNpcObjs = SOL_LUA_VIEW["numResourceDeposits"];
Player *player = Game::getSingleton()->getPlayer(i);
for(int j = 0; j < numNpcObjs; j++){
sol::table npcObjTable = SOL_LUA_VIEW[mapTable][playerInd][i + 1][resDepInd][j + 1];
int id = npcObjTable["id"];
for(int j = 0; j < numNpcObjs; j++){
sol::table npcObjTable = SOL_LUA_VIEW[mapTable][playerInd][i + 1][resDepInd][j + 1];
int id = npcObjTable["id"];
sol::table posTable = npcObjTable["pos"];
Vector3 pos = Vector3(posTable["x"], posTable["y"], posTable["z"]);
sol::table posTable = npcObjTable["pos"];
Vector3 pos = Vector3(posTable["x"], posTable["y"], posTable["z"]);
sol::table rotTable = npcObjTable["rot"];
Quaternion rot = Quaternion(rotTable["w"], rotTable["x"], rotTable["y"], rotTable["z"]);
sol::table rotTable = npcObjTable["rot"];
Quaternion rot = Quaternion(rotTable["w"], rotTable["x"], rotTable["y"], rotTable["z"]);
player->addResourceDeposit(GameObjectFactory::createResourceDeposit(player, id, pos, rot));
}
player->addResourceDeposit(GameObjectFactory::createResourceDeposit(player, id, pos, rot));
}
//int spawnPointId = SOL_LUA_STATE[mapTable]["spawnPointInd"][i + 1][spawnPointId];