diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-03-22 11:50:31 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-03-22 11:50:31 +0000 |
commit | 9fd25e8b10b1291525a18c8b3e34256ca6151dd6 (patch) | |
tree | c483b55010f310ed60cb7381130feedd2b3980a9 /application | |
parent | Support resizing the main window (diff) | |
download | ilt-9fd25e8b10b1291525a18c8b3e34256ca6151dd6.tar.bz2 ilt-9fd25e8b10b1291525a18c8b3e34256ca6151dd6.tar.xz ilt-9fd25e8b10b1291525a18c8b3e34256ca6151dd6.zip |
Add ManyPtr which tracks specified subclasses
This removes the need to repeated dynamic_cast the pointer.
Provides interface which enforces the fastest option for the required
types.
Diffstat (limited to 'application')
-rw-r--r-- | application/main.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/application/main.cpp b/application/main.cpp index 723f3d2..514fab6 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -86,7 +86,7 @@ public: } const std::shared_ptr<Train> train = world.create<Train>(l3, 800000); - auto b47 = std::dynamic_pointer_cast<RailVehicleClass>(assets.at("brush-47")); + auto b47 = assets.at("brush-47").dynamicCast<RailVehicleClass>(); for (int N = 0; N < 6; N++) { train->create<RailVehicle>(b47); } @@ -101,8 +101,9 @@ public: std::uniform_int_distribution<int> treeVariantDistribution {1, 4}; for (auto x = 311000000; x < 311830000; x += 5000) { for (auto y = 491100000; y < 491130000; y += 5000) { - world.create<Plant>(std::dynamic_pointer_cast<Foliage>(assets.at(std::format("Tree-{:#02}-{}", - treeDistribution(randomdev), treeVariantDistribution(randomdev)))), + world.create<Plant>(assets.at(std::format("Tree-{:#02}-{}", treeDistribution(randomdev), + treeVariantDistribution(randomdev))) + .dynamicCast<Foliage>(), Location {terrain->positionAt({{x + positionOffsetDistribution(randomdev), y + positionOffsetDistribution(randomdev)}}), {0, rotationDistribution(randomdev), 0}}); |