1
This commit is contained in:
parent
a9d476c33d
commit
bef1496890
@ -86,13 +86,29 @@ void Explosion::ProcDamage()
|
||||
}
|
||||
if (type_ == kExplosionEnemyAndObstacle) {
|
||||
if (sender_.Get() && sender_.Get()->IsProperTarget(c)) {
|
||||
if (center_.Distance(c->GetPos()) < explosion_range_) {
|
||||
objects.insert(c);
|
||||
if (custom_check_cb_) {
|
||||
bool is_hit = false;
|
||||
custom_check_cb_({&is_hit, (Entity*)c});
|
||||
if (is_hit) {
|
||||
objects.insert(c);
|
||||
}
|
||||
} else {
|
||||
if (center_.Distance(c->GetPos()) < explosion_range_) {
|
||||
objects.insert(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (center_.Distance(c->GetPos()) < explosion_range_) {
|
||||
objects.insert(c);
|
||||
if (custom_check_cb_) {
|
||||
bool is_hit = false;
|
||||
custom_check_cb_({&is_hit, (Entity*)c});
|
||||
if (is_hit) {
|
||||
objects.insert(c);
|
||||
}
|
||||
} else {
|
||||
if (center_.Distance(c->GetPos()) < explosion_range_) {
|
||||
objects.insert(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -112,8 +128,16 @@ void Explosion::ProcDamage()
|
||||
if (!entity->ReceiveExplosionDmg(this)) {
|
||||
return;
|
||||
}
|
||||
if (center_.Distance(entity->GetPos()) < explosion_range_) {
|
||||
objects.insert(entity);
|
||||
if (custom_check_cb_) {
|
||||
bool is_hit = false;
|
||||
custom_check_cb_({&is_hit, entity});
|
||||
if (is_hit) {
|
||||
objects.insert(entity);
|
||||
}
|
||||
} else {
|
||||
if (center_.Distance(entity->GetPos()) < explosion_range_) {
|
||||
objects.insert(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -18,6 +18,7 @@ class Explosion : public std::enable_shared_from_this<Explosion>
|
||||
int GetExplosionEffect() { return explosion_effect_; };
|
||||
void SetDamageDelay(int delay) { explosion_damage_delay_ = delay; };
|
||||
void SetHitCb(CommonCbProc cb) { hit_cb_ = cb; };
|
||||
void SetCustomCheckCb(CommonCbProc cb) { custom_check_cb_ = cb; };
|
||||
void SetThrough(bool through) { through_ = through; };
|
||||
bool IsThrough() { return through_; };
|
||||
|
||||
@ -52,6 +53,7 @@ protected:
|
||||
a8::Vec2 center_;
|
||||
long long special_damage_type_ = 0;
|
||||
long long create_frameno_ = 0;
|
||||
CommonCbProc custom_check_cb_;
|
||||
CommonCbProc hit_cb_;
|
||||
bool through_ = false;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user