aozhiwei a1636c4ed4 1
2023-03-16 21:00:29 +08:00

70 lines
2.4 KiB
C++

#pragma once
#include "creature.h"
class Human;
class Room;
class Car : public Creature
{
public:
int car_uniid = 0;
const mt::Equip* meta = nullptr;
const mt::Hero* hero_meta_ = nullptr;
Car();
virtual ~Car() override;
virtual void Initialize() override;
virtual void FillMFObjectPart(Room* room, Human* hum, cs::MFObjectPart* part_data) override;
virtual void FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data) override;
virtual void OnBulletHit(IBullet* bullet) override;
virtual void OnExplosionHit(Explosion* e) override;
virtual std::string GetName() override;
virtual const mt::Hero* GetHeroMeta() override { return hero_meta_; };
bool IsDriver(Human* hum) { return driver_ == hum && driver_; }
Human* GetPassengerBySeat(int seat);
void GetDown(Human* passenger);
void GetOn(Human* passenger);
void SwitchSeat(Human* passenger, int seat);
bool CanShot(Human* passenger);
void SyncPos();
float GetCurOil() { return cur_oil_; };
float GetMaxOil();
bool HasOil() { return cur_oil_ >= 0.00000001f; };
void DecOil(float dec_oil);
bool HasPassenter() { return !passengers_.empty();};
virtual float GetRadius() override;
virtual float GetSpeed() override;
virtual void DecHP(float dec_hp,
int killer_id, const std::string killer_name, int weapon_id,
int real_killer_id, const std::string real_killer_name,
float& real_dmg_out) override;
virtual void SendDebugMsg(const std::string& debug_msg) override;
virtual void SetAttackDir(const glm::vec3& attack_dir) override;
virtual void DropItems(Obstacle* obstacle) override;
virtual const glm::vec3& GetShotDir() { return curr_shot_dir_; };
void OnKillTarget(Creature* target);
void SetShotDir(const glm::vec3& dir) { curr_shot_dir_ = dir; };
bool IsSingle();
private:
int AllocSeat();
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
bool IsPassenger(Human* hum);
bool NeedCreatureCollision();
void CheckCreatureCollision();
void RemoveFromScene();
private:
long long born_frameno_ = 0;
bool later_removed_ = false;
Human* driver_ = nullptr;
std::set<Human*> passengers_;
int cur_buff_id_ = 0;
int cur_buff_idx_ = -1;
float cur_oil_ = 0;
glm::vec3 curr_shot_dir_ = GlmHelper::ZERO;
friend class PBUtils;
};