MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / createRandomizedDrop

Method createRandomizedDrop

source/game/StarItemDrop.cpp:15–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13namespace Star {
14
15ItemDropPtr 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
31ItemDropPtr ItemDrop::createRandomizedDrop(ItemDescriptor const& descriptor, Vec2F const& position, bool eternal) {
32 if (!descriptor || descriptor.isEmpty())

Callers

nothing calls this directly

Calls 12

singletonClass · 0.85
randfFunction · 0.85
jsonMethod · 0.80
assetsMethod · 0.80
getFloatMethod · 0.80
setEternalMethod · 0.80
itemDatabaseMethod · 0.80
rotateMethod · 0.45
setPositionMethod · 0.45
setVelocityMethod · 0.45
isEmptyMethod · 0.45
itemMethod · 0.45

Tested by

no test coverage detected