aozhiwei c5485b58a3 1
2024-01-11 13:49:43 +08:00

52 lines
1.5 KiB
C++

#pragma once
#include "attrdefine.h"
#include "weakptr.h"
class Ability
{
public:
Ability(CreatureWeakPtr owner);
~Ability();
void IncImmuneTimes(int tag);
void DecImmuneTimes(int tag);
bool CanImmune(int tag);
bool CanImmune(const std::set<int>& tags);
void IncSwitch(int type);
void DecSwitch(int type);
int GetSwitchTimes(int type);
AttrHandle AddAttr(int attr_id, float val);
void RemoveAttr(AttrHandle handler);
float GetAttr(int attr_id);
bool HasAttr(int attr_id);
float GetAttrAddition(int attr_id);
float GetAttrRuduce(int attr_id);
bool HasAddAttr(int attr_id);
bool HasDecAttr(int attr_id);
void GMDelAttr(int attr_id, int idx);
void GMClearAttr();
std::vector<std::string> GMShowAttrs();
void SetSource(AttrHandle handle, std::shared_ptr<std::function<std::string()>> cb);
private:
void Clear();
void RecalcAttrAddition(int attr_id);
void RecalcAttrRuduce(int attr_id);
private:
CreatureWeakPtr owner_;
std::array<std::tuple<float, list_head>, kHAT_End> attr_add_ = {};
std::array<std::tuple<float, list_head>, kHAT_End> attr_dec_ = {};
std::array<list_head, kHAT_End> attr_list_ = {};
std::array<std::tuple<float, list_head>, kHVAT_End - kHVAT_Begin> vattr_add_ = {};
std::array<std::tuple<float, list_head>, kHVAT_End - kHVAT_Begin> vattr_dec_ = {};
std::array<list_head, kHVAT_End - kHVAT_Begin> vattr_list_ = {};
std::array<int, kSwitchTimeEnd> switch_times_ = {};
std::map<int, int> immune_tags_;
friend class PBUtils;
};