1
This commit is contained in:
parent
cfefed6fcc
commit
88667d4015
@ -100,7 +100,9 @@ void Bullet::ProcBomb()
|
|||||||
}
|
}
|
||||||
c4_target = c->AsCar();
|
c4_target = c->AsCar();
|
||||||
}
|
}
|
||||||
if (TestCollision(room, c)) {
|
AabbCollider aabb_box;
|
||||||
|
c->GetHitAabbBox(aabb_box);
|
||||||
|
if (TestCollision(room, &aabb_box)) {
|
||||||
objects.insert(c);
|
objects.insert(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ void Car::Initialize()
|
|||||||
if (!hero_meta_) {
|
if (!hero_meta_) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
RecalcSelfCollider();
|
||||||
MetaData::Equip* weapon_meta = MetaMgr::Instance()->GetEquip(hero_meta_->i->default_weapon());
|
MetaData::Equip* weapon_meta = MetaMgr::Instance()->GetEquip(hero_meta_->i->default_weapon());
|
||||||
if (weapon_meta) {
|
if (weapon_meta) {
|
||||||
weapons[GUN_SLOT1].weapon_idx = GUN_SLOT1;
|
weapons[GUN_SLOT1].weapon_idx = GUN_SLOT1;
|
||||||
@ -374,6 +375,17 @@ void Car::GetAabbBox(AabbCollider& aabb_box)
|
|||||||
aabb_box._max.y = hero_meta_->i->radius();
|
aabb_box._max.y = hero_meta_->i->radius();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Car::GetHitAabbBox(AabbCollider& aabb_box)
|
||||||
|
{
|
||||||
|
aabb_box.active = true;
|
||||||
|
aabb_box.owner = this;
|
||||||
|
aabb_box._min.x = -hero_meta_->i->hit_radius();
|
||||||
|
aabb_box._min.y = -hero_meta_->i->hit_radius();
|
||||||
|
aabb_box._max.x = hero_meta_->i->hit_radius();
|
||||||
|
aabb_box._max.y = hero_meta_->i->hit_radius();
|
||||||
|
aabb_box.MoveCenter(hero_meta_->i->hit_offset_x(), hero_meta_->i->hit_offset_y());
|
||||||
|
}
|
||||||
|
|
||||||
void Car::SendDebugMsg(const std::string& debug_msg)
|
void Car::SendDebugMsg(const std::string& debug_msg)
|
||||||
{
|
{
|
||||||
#if 1
|
#if 1
|
||||||
@ -419,3 +431,14 @@ void Car::DropItems(Obstacle* obstacle)
|
|||||||
room->ScatterDrop(obstacle->GetPos(), obstacle->meta->i->drop());
|
room->ScatterDrop(obstacle->GetPos(), obstacle->meta->i->drop());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Car::RecalcSelfCollider()
|
||||||
|
{
|
||||||
|
if (!self_collider_) {
|
||||||
|
self_collider_ = new CircleCollider();
|
||||||
|
self_collider_->owner = this;
|
||||||
|
AddEntityCollider(self_collider_);
|
||||||
|
}
|
||||||
|
self_collider_->pos = a8::Vec2(hero_meta_->i->move_offset_x(), hero_meta_->i->move_offset_y());
|
||||||
|
self_collider_->rad = hero_meta_->i->radius();
|
||||||
|
}
|
||||||
|
@ -12,6 +12,7 @@ namespace MetaData
|
|||||||
|
|
||||||
class Human;
|
class Human;
|
||||||
class Room;
|
class Room;
|
||||||
|
class CircleCollider;
|
||||||
class Car : public Creature
|
class Car : public Creature
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -26,6 +27,7 @@ class Car : public Creature
|
|||||||
virtual void FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data) override;
|
virtual void FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data) override;
|
||||||
virtual void OnBulletHit(Bullet* bullet) override;
|
virtual void OnBulletHit(Bullet* bullet) override;
|
||||||
virtual void GetAabbBox(AabbCollider& aabb_box) override;
|
virtual void GetAabbBox(AabbCollider& aabb_box) override;
|
||||||
|
virtual void GetHitAabbBox(AabbCollider& aabb_box) override;
|
||||||
|
|
||||||
bool IsDriver(Human* hum) { return driver_ == hum && driver_; }
|
bool IsDriver(Human* hum) { return driver_ == hum && driver_; }
|
||||||
Human* GetPassengerBySeat(int seat);
|
Human* GetPassengerBySeat(int seat);
|
||||||
@ -50,6 +52,8 @@ class Car : public Creature
|
|||||||
int AllocSeat();
|
int AllocSeat();
|
||||||
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
|
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
|
||||||
bool IsPassenger(Human* hum);
|
bool IsPassenger(Human* hum);
|
||||||
|
void RecalcSelfCollider();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long long born_frameno_ = 0;
|
long long born_frameno_ = 0;
|
||||||
bool later_removed_ = false;
|
bool later_removed_ = false;
|
||||||
@ -58,4 +62,5 @@ class Car : public Creature
|
|||||||
int cur_buff_id_ = 0;
|
int cur_buff_id_ = 0;
|
||||||
int cur_buff_idx_ = -1;
|
int cur_buff_idx_ = -1;
|
||||||
float cur_oil_ = 0;
|
float cur_oil_ = 0;
|
||||||
|
CircleCollider* self_collider_ = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -175,7 +175,7 @@ void Hero::RecalcSelfCollider()
|
|||||||
self_collider_->owner = this;
|
self_collider_->owner = this;
|
||||||
AddEntityCollider(self_collider_);
|
AddEntityCollider(self_collider_);
|
||||||
}
|
}
|
||||||
self_collider_->pos = a8::Vec2();
|
self_collider_->pos = a8::Vec2(meta->i->move_offset_x(), meta->i->move_offset_y());
|
||||||
self_collider_->rad = meta->i->radius();
|
self_collider_->rad = meta->i->radius();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +215,7 @@ void Hero::GetHitAabbBox(AabbCollider& aabb_box)
|
|||||||
aabb_box._min.y = -GetHitRadius();
|
aabb_box._min.y = -GetHitRadius();
|
||||||
aabb_box._max.x = GetHitRadius();
|
aabb_box._max.x = GetHitRadius();
|
||||||
aabb_box._max.y = GetHitRadius();
|
aabb_box._max.y = GetHitRadius();
|
||||||
|
aabb_box.MoveCenter(meta->i->hit_offset_x(), meta->i->hit_offset_y());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hero::DetachFromMaster()
|
void Hero::DetachFromMaster()
|
||||||
|
@ -491,7 +491,7 @@ void Human::RecalcSelfCollider()
|
|||||||
self_collider_->owner = this;
|
self_collider_->owner = this;
|
||||||
AddEntityCollider(self_collider_);
|
AddEntityCollider(self_collider_);
|
||||||
}
|
}
|
||||||
self_collider_->pos = a8::Vec2();
|
self_collider_->pos = a8::Vec2(meta->i->move_offset_x(), meta->i->move_offset_y());
|
||||||
self_collider_->rad = meta->i->radius();
|
self_collider_->rad = meta->i->radius();
|
||||||
Buff* buff = GetBuffByEffectId(kBET_Car);
|
Buff* buff = GetBuffByEffectId(kBET_Car);
|
||||||
if (buff) {
|
if (buff) {
|
||||||
|
@ -877,6 +877,7 @@ bool Obstacle::ProcSpecEvent(Creature* c, ColliderComponent* collider)
|
|||||||
switch (meta->i->thing_type()) {
|
switch (meta->i->thing_type()) {
|
||||||
case kObstacleSpring:
|
case kObstacleSpring:
|
||||||
{
|
{
|
||||||
|
return false;
|
||||||
if (c->IsHuman()) {
|
if (c->IsHuman()) {
|
||||||
if (!c->AsHuman()->GetCar()) {
|
if (!c->AsHuman()->GetCar()) {
|
||||||
AddObstacleBuff(c);
|
AddObstacleBuff(c);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user