1
This commit is contained in:
parent
38876e9ede
commit
490491df00
@ -55,10 +55,29 @@ void HoldShieldBuff::Activate()
|
||||
},
|
||||
&xtimer_attacher);
|
||||
}
|
||||
handlers_.push_back(owner->GetTrigger()->AddListener
|
||||
(
|
||||
kDownedEvent,
|
||||
[this] (const a8::Args& args)
|
||||
{
|
||||
if (owner->IsHuman()) {
|
||||
owner->AsHuman()->ShiledBreak();
|
||||
}
|
||||
}));
|
||||
handlers_.push_back(owner->GetTrigger()->AddListener
|
||||
(
|
||||
kDieEvent,
|
||||
[this] (const a8::Args& args)
|
||||
{
|
||||
if (owner->IsHuman()) {
|
||||
owner->AsHuman()->ShiledBreak();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
void HoldShieldBuff::Deactivate()
|
||||
{
|
||||
owner->GetTrigger()->RemoveEventHandlers(handlers_);
|
||||
}
|
||||
|
||||
void HoldShieldBuff::OnEnemyHit(Creature* enemy)
|
||||
|
@ -15,4 +15,5 @@ class HoldShieldBuff : public Buff
|
||||
private:
|
||||
float check_distance_ = 0.0f;
|
||||
float check_interval_time_ = 0.0f;
|
||||
std::vector<std::weak_ptr<EventHandlerPtr>> handlers_;
|
||||
};
|
||||
|
@ -395,6 +395,7 @@ void Human::DecHP(float dec_hp, int killer_id, const std::string killer_name, in
|
||||
&xtimer_attacher);
|
||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||
TryAddBuff(this, kDownBuffId);
|
||||
GetTrigger()->Downed();
|
||||
} else {
|
||||
BeKill(killer_id, killer_name, weapon_id, real_killer_id, real_killer_name);
|
||||
}
|
||||
@ -3336,3 +3337,15 @@ void Human::ProcLoveItem(AddItemDTO& dto)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Human::ShiledBreak()
|
||||
{
|
||||
Buff* hold_shield_buff = GetBuffByEffectId(kBET_HoldShield);
|
||||
if (hold_shield_buff) {
|
||||
GetTrigger()->ShieldDestory();
|
||||
if (hold_shield_buff->meta->_buff_param1_int_list.size() > 0) {
|
||||
TryAddBuff(this, hold_shield_buff->meta->_buff_param1_int_list[0]);
|
||||
}
|
||||
RemoveBuffByUniId(hold_shield_buff->buff_uniid);
|
||||
}
|
||||
}
|
||||
|
@ -255,6 +255,7 @@ class Human : public Creature
|
||||
void CalcAssists(Human* target);
|
||||
void ProcThrowDmg(int throw_uniid);
|
||||
void CalcStats();
|
||||
void ShiledBreak();
|
||||
|
||||
protected:
|
||||
void ProcLootWeapon(AddItemDTO& dto);
|
||||
|
@ -1386,6 +1386,9 @@ void Player::_CMRequestBulletDmg(f8::MsgHdr& hdr, const cs::CMRequestBulletDmg&
|
||||
c->shield_hp_);
|
||||
if (c->shield_hp_ <= 0) {
|
||||
c->GetTrigger()->ShieldDestory();
|
||||
if (hold_shield_buff->meta->_buff_param1_int_list.size() > 0) {
|
||||
TryAddBuff(this, hold_shield_buff->meta->_buff_param1_int_list[0]);
|
||||
}
|
||||
c->RemoveBuffByUniId(hold_shield_buff->buff_uniid);
|
||||
}
|
||||
shield = true;
|
||||
|
@ -438,6 +438,13 @@ void Trigger::RemoveEventHandler(std::weak_ptr<EventHandlerPtr> handler)
|
||||
}
|
||||
}
|
||||
|
||||
void Trigger::RemoveEventHandlers(std::vector<std::weak_ptr<EventHandlerPtr>> handlers)
|
||||
{
|
||||
for (auto handler : handlers) {
|
||||
RemoveEventHandler(handler);
|
||||
}
|
||||
}
|
||||
|
||||
void Trigger::DispatchEvent(int event_id, const std::vector<std::any>& param)
|
||||
{
|
||||
auto itr = listeners_hash_.find(event_id);
|
||||
@ -539,3 +546,8 @@ void Trigger::BulletKill(IBullet* bullet, Creature* target)
|
||||
{
|
||||
DispatchEvent(kBulletKill, {bullet, target});
|
||||
}
|
||||
|
||||
void Trigger::Downed()
|
||||
{
|
||||
DispatchEvent(kDownedEvent, {});
|
||||
}
|
||||
|
@ -43,7 +43,8 @@ enum EventId_e
|
||||
kEndJump,
|
||||
kTakeonWeaponEvent,
|
||||
kBulletKill,
|
||||
kAttackTargetEvent
|
||||
kAttackTargetEvent,
|
||||
kDownedEvent
|
||||
};
|
||||
|
||||
class Weapon;
|
||||
@ -86,9 +87,11 @@ public:
|
||||
void BulletBlock(IBullet* bullet, const glm::vec3& pos);
|
||||
void StartJump(Creature* sender);
|
||||
void EndJump(Creature* sender);
|
||||
void Downed();
|
||||
|
||||
std::weak_ptr<EventHandlerPtr> AddListener(int event_id, a8::CommonCbProc cb);
|
||||
void RemoveEventHandler(std::weak_ptr<EventHandlerPtr> handler_ptr);
|
||||
void RemoveEventHandlers(std::vector<std::weak_ptr<EventHandlerPtr>> handlers);
|
||||
void DispatchEvent(int event_id, const std::vector<std::any>& params);
|
||||
bool HasCondBuff(int cond);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user