game2006/server/gameserver/virtualbullet.h
aozhiwei 0f82887e44 1
2023-01-01 14:44:05 +08:00

62 lines
1.8 KiB
C++

#pragma once
struct GridCell;
class Entity;
class Room;
class Obstacle;
class VirtualBullet : public IBullet, public ITask
{
public:
int bullet_uniid = 0;
long long weapon_uniid = 0;
const mt::Skill* skill_meta = nullptr;
const mt::Equip* gun_meta = nullptr;
const mt::Equip* bullet_meta = nullptr;
CreatureWeakPtr sender;
CreatureWeakPtr passenger;
Room* room = nullptr;
bool is_pre_battle_bullet = false;
glm::vec3 dir = GlmHelper::ZERO;
Position born_pos;
glm::vec3 born_dir = GlmHelper::ZERO;
float strengthen_wall = 0;
virtual float GetStrengthenWall() override;
virtual long long GetWeaponUniId() override;
virtual const mt::Skill* GetSkillMeta() override;
virtual const mt::Equip* GetGunMeta() override;
virtual const mt::Equip* GetBulletMeta() override;
virtual CreatureWeakPtr GetSender() override;
virtual CreatureWeakPtr GetPassenger() override;
virtual bool IsBomb() override;
virtual bool IsPreBattleBullet() override;
virtual Room* GetRoom() override;
virtual float GetHitRadius() override;
virtual void Update(int delta_time) override;
virtual bool IsDone() override;
void Init();
void SetPos(Position pos) { pos_ = pos; };
virtual const Position& GetPos() override { return pos_; }
Position& GetMutablePos() { return pos_; };
private:
void Check(float distance);
void ForceRemove();
void OnHit(std::set<Entity*>& objects);
std::set<GridCell*>& GetGridList() { return grid_list_; };
void OnStrengthen(Obstacle* ob);
void OnKillTarget(Entity* target);
void GetHitThings(BulletCheckResult& result);
void GetHitCreatures(BulletCheckResult& result);
private:
bool later_removed_ = false;
Position pos_;
std::set<GridCell*> grid_list_;
std::set<int> hit_objects_;
float strengthened_ = 0.0f;
};