This commit is contained in:
aozhiwei 2023-03-15 18:01:23 +08:00
parent 23142ccbfd
commit 0e8d740d6f
4 changed files with 44 additions and 2 deletions

View File

@ -506,6 +506,32 @@ void CallFuncBuff::ProcLightCircle()
}
}
);
owner->GetTrigger()->AddListener
(
kStartJump,
[this, context] (const a8::Args& args) mutable
{
if (context->keep_buff_uniid) {
owner->RemoveBuffByUniId(context->keep_buff_uniid);
context->keep_buff_uniid = 0;
}
}
);
owner->GetTrigger()->AddListener
(
kEndJump,
[this, context] (const a8::Args& args) mutable
{
if (context->keep_buff_uniid) {
owner->RemoveBuffByUniId(context->keep_buff_uniid);
context->keep_buff_uniid = 0;
}
context->keep_buff_uniid = owner->TryAddBuff(GetCaster().Get(), meta->_int_buff_param4, skill_meta);
}
);
}
{
context->keep_buff_uniid = owner->TryAddBuff(GetCaster().Get(), meta->_int_buff_param4, skill_meta);

View File

@ -5,10 +5,11 @@
#include "creature.h"
#include "human.h"
#include "room.h"
#include "trigger.h"
void JumpBuff::Activate()
{
owner->GetTrigger()->StartJump(owner);
}
void JumpBuff::Deactivate()
@ -22,6 +23,7 @@ void JumpBuff::Deactivate()
if (a8::TIMER_EXEC_EVENT == event) {
if (c.Get()) {
c.Get()->OnLand();
c.Get()->GetTrigger()->EndJump(c.Get());
}
}
},

View File

@ -496,3 +496,13 @@ void Trigger::BulletBlock(IBullet* bullet, const glm::vec3& pos)
{
DispatchEvent(kBulletBlockEvent, {bullet, pos});
}
void Trigger::StartJump(Creature* sender)
{
DispatchEvent(kStartJump, {});
}
void Trigger::EndJump(Creature* sender)
{
DispatchEvent(kEndJump, {});
}

View File

@ -38,7 +38,9 @@ enum EventId_e
kDmgOutEvent,
kHpChgEvent,
kRevive,
kAttacked
kAttacked,
kStartJump,
kEndJump,
};
class Weapon;
@ -78,6 +80,8 @@ public:
void Attacked(Creature* sender);
void DmgOut(Creature* target, float dmg);
void BulletBlock(IBullet* bullet, const glm::vec3& pos);
void StartJump(Creature* sender);
void EndJump(Creature* sender);
std::weak_ptr<EventHandlerPtr> AddListener(int event_id, a8::CommonCbProc cb);
void RemoveEventHandler(std::weak_ptr<EventHandlerPtr> handler_ptr);