aozhiwei c1d79c7dd2 1
2023-04-06 14:52:53 +08:00

96 lines
2.2 KiB
C++

#pragma once
#include "weakptr.h"
namespace MetaData
{
struct Equip;
struct Skill;
}
namespace cs
{
struct CMJoin;
}
class Room;
class Buff;
class Creature;
struct AddItemDTO
{
int uniid = 0;
int item_id = 0;
int count = 0;
int item_level = 0;
const mt::Equip* item_meta = nullptr;
bool handled = false;
};
struct BulletCheckResult
{
float flyed_distance = 0.0f;
int c_hit_num = 0;
int t_hit_num = 0;
int o_hit_num = 0;
bool eat = false;
std::set<Entity*> objects;
};
class ITask
{
public:
virtual void Update(int delta_time) = 0;
virtual bool IsDone() = 0;
};
class DelayAddBuffHandle
{
public:
std::function<void(Creature*)> pre_add_cb;
std::function<void(Creature*, int)> post_add_cb;
};
struct Position
{
void SetX(float x) { loc_.x = x; };
void SetY(float y) { loc_.y = y; };
void SetZ(float z) { loc_.z = z; };
float GetX() const { return loc_.x; };
float GetY() const { return loc_.y; };
float GetZ() const { return loc_.z; };
float Distance2D2(const Position& pos) const;
float DistanceGlmVec3(const glm::vec3& v) const;
float ManhattanDistance2D(const Position& target_pos) const;
glm::vec3 CalcDir(const Position& target_pos) const;
void FromGlmVec3(const glm::vec3 v) { loc_ = v; };
glm::vec3 ToGlmVec3() const { return loc_; };
const Position& AddGlmVec3(const glm::vec3& v) { loc_ += v; return *this; };
private:
glm::vec3 loc_ = glm::vec3(0.0, 0.0, 0.0);
};
class IBullet
{
public:
virtual const Position& GetPos() = 0;
virtual const glm::vec3& GetDir() = 0;
virtual float GetStrengthenWall() = 0;
virtual long long GetWeaponUniId() = 0;
virtual const mt::Skill* GetSkillMeta() = 0;
virtual const mt::Equip* GetGunMeta() = 0;
virtual const mt::Equip* GetBulletMeta() = 0;
virtual CreatureWeakPtr GetSender() = 0;
virtual CreatureWeakPtr GetPassenger() = 0;
virtual bool IsBomb() = 0;
virtual bool IsPreBattleBullet() = 0;
virtual Room* GetRoom() = 0;
virtual float GetHitRadius() = 0;
virtual void ProcRequestBulletDmg(int shield_hit, int strength_wall_uniid, int target_uniid, const glm::vec3& pos) = 0;
};