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

Method sparkBlock

source/game/StarProjectile.cpp:495–524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

493}
494
495List<Particle> Projectile::sparkBlock(World* world, Vec2I const& position, Vec2F const& damageSource) {
496 auto& root = Root::singleton();
497 auto assets = root.assets();
498 auto materialDatabase = root.materialDatabase();
499
500 auto blockDamageParticle = Particle(assets->json("/client.config:blockDamageParticle"));
501 auto blockDamageVariance = Particle(assets->json("/client.config:blockDamageParticleVariance"));
502
503 List<Particle> result;
504 for (auto layer : {TileLayer::Background, TileLayer::Foreground}) {
505 auto material = world->material(position, layer);
506 auto hueShift = world->materialHueShift(position, layer);
507 if (isRealMaterial(material)) {
508 auto particle = blockDamageParticle;
509 particle.position += centerOfTile(position);
510 particle.velocity = particle.velocity.magnitude() * vnorm(world->geometry().diff(damageSource, particle.position));
511 particle.color = materialDatabase->materialParticleColor(material, hueShift);
512 particle.applyVariance(blockDamageVariance);
513
514 particle.approach += Vec2F(0.0f, 5.0f);
515 particle.velocity += Vec2F(Random::randf() - 0.5f, 5.0f + Random::randf());
516 particle.velocity += 10.0f * Vec2F(1.0f - 2.0f * Random::randf(), 1.0f - 2.0f * Random::randf());
517 particle.finalVelocity = 0.5f * (particle.finalVelocity + Vec2F(Random::randf() - 0.5f, -20.0f + Random::randf()));
518 particle.trail = true;
519
520 result.append(std::move(particle));
521 }
522 }
523 return result;
524}
525
526int Projectile::getFrame() const {
527 float time_per_frame = m_animationCycle / m_config->frameNumber;

Callers

nothing calls this directly

Calls 15

singletonClass · 0.85
ParticleClass · 0.85
isRealMaterialFunction · 0.85
centerOfTileFunction · 0.85
vnormFunction · 0.85
randfFunction · 0.85
assetsMethod · 0.80
materialDatabaseMethod · 0.80
jsonMethod · 0.80
materialParticleColorMethod · 0.80
applyVarianceMethod · 0.80
materialMethod · 0.45

Tested by

no test coverage detected