Restore size-based projectile draw order that was accidentally removed in the PMA patch

This commit is contained in:
Andrei Alexeyev 2018-08-12 03:10:21 +03:00
parent 95f652b311
commit d1b3e91abb
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4

View file

@ -197,6 +197,12 @@ complex projectile_graze_size(Projectile *p) {
return 0;
}
static double projectile_rect_area(Projectile *p) {
double w, h;
projectile_size(p, &w, &h);
return w * h;
}
static Projectile* _create_projectile(ProjArgs *args) {
if(IN_DRAW_CODE) {
log_fatal("Tried to spawn a projectile while in drawing code");
@ -240,6 +246,23 @@ static Projectile* _create_projectile(ProjArgs *args) {
log_fatal("Tried to spawn a projectile with invalid size %f x %f", creal(p->size), cimag(p->size));
}
if(!(p->ent.draw_layer & LAYER_LOW_MASK)) {
switch(p->type) {
case EnemyProj:
case FakeProj: {
// Large projectiles go below smaller ones.
drawlayer_low_t sublayer = (LAYER_LOW_MASK - (drawlayer_low_t)projectile_rect_area(p));
// If specific blending order is required, then you should set up the sublayer manually.
p->ent.draw_layer |= sublayer;
break;
}
default: {
break;
}
}
}
ent_register(&p->ent, ENT_PROJECTILE);
// TODO: Maybe allow ACTION_DESTROY here?