This commit is contained in:
aozhiwei 2022-10-10 17:28:57 +08:00
parent 0fae7e9da2
commit 7e7e3e9b2d
4 changed files with 8 additions and 9 deletions

View File

@ -50,7 +50,9 @@ class Car : public Creature
virtual void SendDebugMsg(const std::string& debug_msg) override;
virtual void SetAttackDir(const a8::Vec2& attack_dir) override;
virtual void DropItems(Obstacle* obstacle) override;
virtual const a8::Vec2& GetShotDir() { return curr_shot_dir_; };
void OnKillTarget(Creature* target);
void SetShotDir(const a8::Vec2& dir) { curr_shot_dir_ = dir; };
private:
int AllocSeat();
@ -69,5 +71,6 @@ class Car : public Creature
int cur_buff_id_ = 0;
int cur_buff_idx_ = -1;
float cur_oil_ = 0;
a8::Vec2 curr_shot_dir_;
CircleCollider* self_collider_ = nullptr;
};

View File

@ -328,7 +328,7 @@ void InternalShot(Creature* c,
++bulletIdx;
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
a8::Vec2 bullet_born_pos = c->GetPos() + c->shoot_offset + bullet_born_offset;
a8::Vec2 bullet_dir = c->GetAttackDir();
a8::Vec2 bullet_dir = c->GetShotDir();
float bullet_angle = std::get<2>(tuple);
if (weapon_meta->i->bullet_angle() >= 0.10f) {
int angle = (int)weapon_meta->i->bullet_angle() * 1000;
@ -354,13 +354,6 @@ void InternalShot(Creature* c,
auto transform = glm::rotate(hero_transform,
bullet_born_angle * A8_PI,
glm::vec3(0.0, 1.0, 0.0));
#if 1
if (c->IsCar()) {
transform = glm::rotate(hero_transform,
0 * A8_PI,
glm::vec3(0.0, 1.0, 0.0));
}
#endif
glm::vec4 gun_muzzle_position(0.0, 0.0, 0.0, 0.0);
CalcGunMuzzlePosition(c, weapon_meta, shot_animi, gun_muzzle_position, bulletIdx, bulletNum);
glm::vec4 v = transform * gun_muzzle_position;

View File

@ -28,6 +28,7 @@ class MoveableEntity : public RoomEntity
virtual void SetMoveDir(const a8::Vec2& move_dir);
virtual const a8::Vec2& GetAttackDir() { return attack_dir_; };
virtual void SetAttackDir(const a8::Vec2& attack_dir);
virtual const a8::Vec2& GetShotDir() { return attack_dir_; };
int GetChgMoveDirTimes() { return chg_move_dir_times_; }
int GetChgAttackDirTimes() { return chg_attack_dir_times_; }
float GetAttackDirRotate();

View File

@ -313,14 +313,16 @@ void Player::UpdateShot()
GetCar()->shoot_offset = shoot_offset;
GetCar()->shot_hole = GetSeat();
GetCar()->shot_passenger = this;
GetCar()->SetAttackDir(GetAttackDir());
GetCar()->SetShotDir(GetAttackDir());
GetCar()->Shot(target_dir, shot_ok, fly_distance, 0);
if (!moving && GetCar()->IsDriver(this)) {
GetCar()->SetMoveDir(GetAttackDir());
}
#if 0
if (!GetCar()->IsDriver(this)) {
GetCar()->SetAttackDir(old_car_attack_dir);
}
#endif
GetCar()->shot_hole = old_car_shot_hole;
GetCar()->shoot_offset = old_car_shoot_offset;
GetCar()->shot_passenger = old_car_shot_passenger;