mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-24 06:27:24 +00:00
891648288a
Probably the third or fourth pass of this darn header... Just keep making it better every time Rename some functions to make more sense to a reader Use different method for Observing/subscribing to component events Get rid of abomination of overloading GetParentUser
26 lines
850 B
C++
26 lines
850 B
C++
#include "CoilBackpackBase.h"
|
|
|
|
#include "Entity.h"
|
|
#include "SkillComponent.h"
|
|
|
|
void CoilBackpackBase::OnFactionTriggerItemEquipped(Entity* itemOwner, LWOOBJID itemObjId) {
|
|
itemOwner->Subscribe(this, "HitOrHealResult");
|
|
itemOwner->SetVar<uint8_t>(u"coilCount", 0);
|
|
}
|
|
|
|
void CoilBackpackBase::NotifyHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) {
|
|
if (damage > 0) {
|
|
self->SetVar<uint8_t>(u"coilCount", self->GetVar<uint8_t>(u"coilCount") + 1);
|
|
if (self->GetVar<uint8_t>(u"coilCount") > 4) {
|
|
auto* skillComponent = self->GetComponent<SkillComponent>();
|
|
if (!skillComponent) return;
|
|
skillComponent->CastSkill(m_SkillId);
|
|
self->SetVar<uint8_t>(u"coilCount", 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
void CoilBackpackBase::OnFactionTriggerItemUnequipped(Entity* itemOwner, LWOOBJID itemObjId) {
|
|
itemOwner->Unsubscribe(this, "HitOrHealResult");
|
|
}
|