]> git.localhorst.tv Git - blobs.git/commitdiff
load tile type yields from data
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 17 Nov 2017 19:09:52 +0000 (20:09 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 17 Nov 2017 19:09:52 +0000 (20:09 +0100)
assets
src/app/app.cpp

diff --git a/assets b/assets
index f20dde223f2424ca8c7d33702ebe03684b3fc673..f9f068f73b2fb5b0c134b40b16ed00118d775268 160000 (submodule)
--- a/assets
+++ b/assets
@@ -1 +1 @@
-Subproject commit f20dde223f2424ca8c7d33702ebe03684b3fc673
+Subproject commit f9f068f73b2fb5b0c134b40b16ed00118d775268
index a67d1a8286527d582de03627a7bbef6516c2f828..45a57cfde2bdc3458ffe2e7948561fb19d541258 100644 (file)
@@ -190,31 +190,6 @@ Assets::Assets()
                ReadTileTypes(tile_reader);
        }
 
-       data.tiles["algae"]   .resources.push_back({ data.resources["water"].id,   1.0  });
-       data.tiles["algae"]   .resources.push_back({ data.resources["biomass"].id, 0.5  });
-       data.tiles["desert"]  .resources.push_back({ data.resources["sand"].id,    1.0  });
-       data.tiles["forest"]  .resources.push_back({ data.resources["wood"].id,    1.0  });
-       data.tiles["forest"]  .resources.push_back({ data.resources["dirt"].id,    0.5  });
-       data.tiles["grass"]   .resources.push_back({ data.resources["dirt"].id,    0.5  });
-       data.tiles["grass"]   .resources.push_back({ data.resources["biomass"].id, 0.25 });
-       data.tiles["grass"]   .resources.push_back({ data.resources["water"].id,   0.25 });
-       data.tiles["ice"]     .resources.push_back({ data.resources["ice"].id,     1.0  });
-       data.tiles["ice"]     .resources.push_back({ data.resources["water"].id,   0.25 });
-       data.tiles["jungle"]  .resources.push_back({ data.resources["wood"].id,    0.5  });
-       data.tiles["jungle"]  .resources.push_back({ data.resources["biomass"].id, 0.5  });
-       data.tiles["mountain"].resources.push_back({ data.resources["rock"].id,    1.0  });
-       data.tiles["ocean"]   .resources.push_back({ data.resources["water"].id,   1.0  });
-       data.tiles["rock"]    .resources.push_back({ data.resources["rock"].id,    1.0  });
-       data.tiles["sand"]    .resources.push_back({ data.resources["sand"].id,    1.0  });
-       data.tiles["taiga"]   .resources.push_back({ data.resources["wood"].id,    1.0  });
-       data.tiles["taiga"]   .resources.push_back({ data.resources["water"].id,   0.5  });
-       data.tiles["tundra"]  .resources.push_back({ data.resources["rock"].id,    1.0  });
-       data.tiles["tundra"]  .resources.push_back({ data.resources["ice"].id,     0.5  });
-       data.tiles["water"]   .resources.push_back({ data.resources["water"].id,   1.0  });
-       data.tiles["water"]   .resources.push_back({ data.resources["biomass"].id, 0.25 });
-       data.tiles["wheat"]   .resources.push_back({ data.resources["biomass"].id, 1.0  });
-       data.tiles["wheat"]   .resources.push_back({ data.resources["water"].id,   0.25 });
-
        graphics::Format format;
        textures.tiles.Bind();
        textures.tiles.Reserve(256, 256, 14, format);
@@ -272,6 +247,31 @@ void Assets::ReadTileTypes(io::TokenStreamReader &in) {
                                in.ReadString(data.tiles[id].label);
                        } else if (name == "texture") {
                                data.tiles[id].texture = in.GetInt();
+                       } else if (name == "yield") {
+                               in.Skip(io::Token::BRACKET_OPEN);
+                               while (in.Peek().type != io::Token::BRACKET_CLOSE) {
+                                       world::TileType::Yield yield;
+                                       in.Skip(io::Token::ANGLE_BRACKET_OPEN);
+                                       while (in.Peek().type != io::Token::ANGLE_BRACKET_CLOSE) {
+                                               in.ReadIdentifier(name);
+                                               in.Skip(io::Token::EQUALS);
+                                               if (name == "resource") {
+                                                       in.ReadIdentifier(name);
+                                                       yield.resource = data.resources[name].id;
+                                               } else if (name == "ubiquity") {
+                                                       yield.ubiquity = in.GetDouble();
+                                               } else {
+                                                       throw std::runtime_error("unknown tile type yield property '" + name + "'");
+                                               }
+                                               in.Skip(io::Token::SEMICOLON);
+                                       }
+                                       in.Skip(io::Token::ANGLE_BRACKET_CLOSE);
+                                       data.tiles[id].resources.push_back(yield);
+                                       if (in.Peek().type == io::Token::COMMA) {
+                                               in.Skip(io::Token::COMMA);
+                                       }
+                               }
+                               in.Skip(io::Token::BRACKET_CLOSE);
                        } else {
                                throw std::runtime_error("unknown tile type property '" + name + "'");
                        }