MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / create

Method create

src/OpenLoco/src/Effects/VehicleCrashEffect.cpp:82–107  ·  view source on GitHub ↗

0x00440B0A

Source from the content-addressed store, hash-verified

80
81 // 0x00440B0A
82 VehicleCrashParticle* VehicleCrashParticle::create(const World::Pos3& loc, const ColourScheme colourScheme)
83 {
84 auto t = static_cast<VehicleCrashParticle*>(EntityManager::createEntityMisc());
85 if (t != nullptr)
86 {
87 t->colourScheme = colourScheme;
88 t->spriteWidth = 8;
89 t->spriteHeightNegative = 8;
90 t->spriteHeightPositive = 8;
91 t->baseType = EntityBaseType::effect;
92 t->moveTo(loc);
93 t->setSubType(EffectType::vehicleCrashParticle);
94
95 const auto rand = gPrng1().randNext();
96 t->frame = (rand & 0xFF) * 12;
97 t->timeToLive = 140 + (rand & 0x7F);
98 // rand value from 0 - 4 inclusive
99 t->crashedSpriteBase = (((rand >> 23) & 0xFF) * 5) >> 8;
100
101 t->accelerationX = static_cast<int16_t>(rand & 0xFFFF) * 4;
102 t->accelerationY = static_cast<int16_t>((rand >> 16) & 0xFFFF) * 4;
103 t->accelerationZ = ((rand >> 8) & 0xFFFF) * 4 + 0x10000;
104 t->velocity = { 0, 0, 0 };
105 }
106 return t;
107 }
108}

Callers

nothing calls this directly

Calls 4

createEntityMiscFunction · 0.85
moveToMethod · 0.80
setSubTypeMethod · 0.45
randNextMethod · 0.45

Tested by

no test coverage detected