| 13 | namespace Star { |
| 14 | |
| 15 | ItemDropPtr ItemDrop::createRandomizedDrop(ItemPtr const& item, Vec2F const& position, bool eternal) { |
| 16 | if (!item) |
| 17 | return {}; |
| 18 | |
| 19 | auto idconfig = Root::singleton().assets()->json("/itemdrop.config"); |
| 20 | |
| 21 | ItemDropPtr itemDrop = make_shared<ItemDrop>(item); |
| 22 | auto offset = Vec2F(idconfig.getFloat("randomizedDistance"), 0).rotate(Constants::pi * 2.0 * Random::randf()); |
| 23 | offset[1] = fabs(offset[1]); |
| 24 | itemDrop->setPosition(position + offset / TilePixels); |
| 25 | itemDrop->setVelocity(offset * idconfig.getFloat("randomizedSpeed")); |
| 26 | itemDrop->setEternal(eternal); |
| 27 | |
| 28 | return itemDrop; |
| 29 | } |
| 30 | |
| 31 | ItemDropPtr ItemDrop::createRandomizedDrop(ItemDescriptor const& descriptor, Vec2F const& position, bool eternal) { |
| 32 | if (!descriptor || descriptor.isEmpty()) |
nothing calls this directly
no test coverage detected