| 493 | } |
| 494 | |
| 495 | List<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 | |
| 526 | int Projectile::getFrame() const { |
| 527 | float time_per_frame = m_animationCycle / m_config->frameNumber; |
nothing calls this directly
no test coverage detected