This commit is contained in:
aozhiwei 2023-02-26 17:00:53 +08:00
parent c0a93635a4
commit cdcd828893
3 changed files with 10 additions and 4 deletions

View File

@ -17,6 +17,7 @@
#include "bullet.h" #include "bullet.h"
#include "glmhelper.h" #include "glmhelper.h"
#include "pbutils.h" #include "pbutils.h"
#include "creature.h"
#include "mt/Param.h" #include "mt/Param.h"
#include "mt/Buff.h" #include "mt/Buff.h"
@ -40,6 +41,9 @@ void Buff::Init()
INIT_LIST_HEAD(&depend_entry); INIT_LIST_HEAD(&depend_entry);
INIT_LIST_HEAD(&cond_entry); INIT_LIST_HEAD(&cond_entry);
INIT_LIST_HEAD(&on_remove_contexts); INIT_LIST_HEAD(&on_remove_contexts);
for (int effect_id : meta->_effect_list) {
effect_list_.push_back(owner->AddEffect(effect_id));
}
} }
void Buff::UnInit() void Buff::UnInit()
@ -59,6 +63,10 @@ void Buff::UnInit()
list_del_init(&cb->entry); list_del_init(&cb->entry);
} }
ClearEventHandlers(); ClearEventHandlers();
for (auto& effect : effect_list_) {
owner->RemoveEffect(effect);
}
effect_list_.clear();
} }
int Buff::GetLeftTime() int Buff::GetLeftTime()

View File

@ -66,7 +66,7 @@ protected:
std::list<Weapon> hold_weapons_; std::list<Weapon> hold_weapons_;
std::list<std::weak_ptr<EventHandlerPtr>> event_handlers_; std::list<std::weak_ptr<EventHandlerPtr>> event_handlers_;
CreatureWeakPtr caster_; CreatureWeakPtr caster_;
std::list<std::shared_ptr<Effect>> effect_list_; std::list<std::weak_ptr<Effect>> effect_list_;
friend class PBUtils; friend class PBUtils;
}; };

View File

@ -30,11 +30,9 @@ namespace mt
{ {
std::vector<std::string> strings; std::vector<std::string> strings;
a8::Split(effect_list(), strings, '|'); a8::Split(effect_list(), strings, '|');
#if 0
for (auto& str : strings) { for (auto& str : strings) {
_child_buff_list.push_back(a8::XValue(str)); _effect_list.push_back(a8::XValue(str));
} }
#endif
} }
{ {
std::vector<std::string> strings; std::vector<std::string> strings;