aozhiwei 0cb5ef7fcd 1
2024-03-06 19:46:04 +08:00

85 lines
1.9 KiB
C++

#pragma once
#include "weakptr.h"
#include "weapon.h"
namespace cs
{
class MFBuff;
}
struct RemoveBuffCbConext
{
list_head** next;
list_head entry;
};
class Human;
class Creature;
class Bullet;
class Effect;
class EventHandler;
class Buff
{
public:
int buff_uniid = 0;
Creature* owner = nullptr;
const mt::Buff* meta = nullptr;
const mt::Skill* skill_meta = nullptr;
a8::Attacher xtimer_attacher;
long long add_frameno = 0;
list_head effect_entry;
list_head depend_entry;
list_head cond_entry;
list_head on_remove_contexts;
a8::XTimerWp remover_timer;
std::shared_ptr<a8::Args> init_args;
float res_scale = 1;
long long res_scale_frameno = 0;
std::shared_ptr<std::vector<float>> buff_vars;
Buff();
virtual ~Buff();
void Init();
void UnInit();
int GetLeftTime();
int GetLastingTime();
bool NeedSync(Human* hum);
void FillMFBuff(cs::MFBuff* buff_pb);
bool FreezeOperate();
CreatureWeakPtr& GetCaster();
void SetCaster(Creature* caster);
virtual bool IsValid() { return is_valid_; };
int IncV(int key, int val);
int DecV(int key, int val);
int GetV(int key);
void SetV(int key, int val);
void CalcPassengerShotOffset();
void PreProcess();
virtual void Activate();
virtual void Deactivate();
virtual void PreExec(const a8::Args* args);
virtual void PostExec(const a8::Args* args);
protected:
void ClearEventHandlers();
void InternalTimerAddBuff();
void RecoverHoldWeapons();
void ProcSputteringFunc(Bullet* bullet);
protected:
bool is_valid_ = true;
int hold_curr_weapon_idx_ = 0;
std::list<Weapon> hold_weapons_;
std::list<std::weak_ptr<EventHandler>> event_handlers_;
CreatureWeakPtr caster_;
std::list<std::weak_ptr<Effect>> effect_list_;
std::shared_ptr<std::map<int, int>> dyn_data_;
friend class PBUtils;
};