2021-12-05 17:54:36 +00:00
|
|
|
#include "ItemSetPassiveAbility.h"
|
|
|
|
|
|
|
|
#include "DestroyableComponent.h"
|
|
|
|
#include "SkillComponent.h"
|
|
|
|
#include "ItemSet.h"
|
2023-01-22 23:38:47 +00:00
|
|
|
#include "eItemSetPassiveAbilityID.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
ItemSetPassiveAbility::ItemSetPassiveAbility(PassiveAbilityTrigger trigger, Entity* parent, ItemSet* itemSet) {
|
|
|
|
m_Trigger = trigger;
|
|
|
|
m_Parent = parent;
|
|
|
|
m_ItemSet = itemSet;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
m_Cooldown = 0.0f;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
ItemSetPassiveAbility::~ItemSetPassiveAbility() {
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-12-24 02:05:30 +00:00
|
|
|
void ItemSetPassiveAbility::Trigger(PassiveAbilityTrigger trigger, Entity* target) {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (m_Trigger != trigger || m_Cooldown > 0.0f) {
|
|
|
|
return;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-12-24 02:05:30 +00:00
|
|
|
Activate(target);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void ItemSetPassiveAbility::Update(float deltaTime) {
|
|
|
|
if (m_Cooldown > 0.0f) {
|
|
|
|
m_Cooldown -= deltaTime;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-12-24 02:05:30 +00:00
|
|
|
void ItemSetPassiveAbility::Activate(Entity* target) {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (m_Trigger == PassiveAbilityTrigger::EnemySmashed) {
|
2022-12-24 02:05:30 +00:00
|
|
|
OnEnemySmshed(target);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
|
|
|
|
auto* skillComponent = m_Parent->GetComponent<SkillComponent>();
|
|
|
|
|
|
|
|
if (destroyableComponent == nullptr || skillComponent == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EntityManager::Instance()->SerializeEntity(m_Parent);
|
|
|
|
|
2023-01-22 23:38:47 +00:00
|
|
|
const auto id = static_cast<eItemSetPassiveAbilityID>(m_ItemSet->GetID());
|
2022-07-28 13:39:57 +00:00
|
|
|
const auto parentID = m_Parent->GetObjectID();
|
|
|
|
const auto equippedCount = m_ItemSet->GetEquippedCount();
|
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
// Assembly
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::InventorRank1:
|
|
|
|
case eItemSetPassiveAbilityID::SummonerRank1:
|
|
|
|
case eItemSetPassiveAbilityID::EngineerRank1: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
m_Cooldown = 11.0f;
|
|
|
|
skillComponent->CalculateBehavior(394, 4401, parentID);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::InventorRank2:
|
|
|
|
case eItemSetPassiveAbilityID::SummonerRank2:
|
|
|
|
case eItemSetPassiveAbilityID::EngineerRank2: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
m_Cooldown = 11.0f;
|
|
|
|
skillComponent->CalculateBehavior(581, 9433, parentID);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::InventorRank3:
|
|
|
|
case eItemSetPassiveAbilityID::SummonerRank3:
|
|
|
|
case eItemSetPassiveAbilityID::EngineerRank3: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
m_Cooldown = 11.0f;
|
|
|
|
skillComponent->CalculateBehavior(582, 9435, parentID);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sentinel
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::KnightRank1: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
m_Cooldown = 11.0f;
|
|
|
|
skillComponent->CalculateBehavior(559, 8884, parentID);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::KnightRank2: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
m_Cooldown = 11.0f;
|
|
|
|
skillComponent->CalculateBehavior(560, 8885, parentID);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::KnightRank3: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
m_Cooldown = 11.0f;
|
|
|
|
skillComponent->CalculateBehavior(561, 8890, parentID);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SpaceRangerRank1: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
m_Cooldown = 11.0f;
|
|
|
|
skillComponent->CalculateBehavior(1101, 24612, parentID);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SpaceRangerRank2: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
m_Cooldown = 11.0f;
|
|
|
|
skillComponent->CalculateBehavior(1102, 24617, parentID);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SpaceRangerRank3: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
m_Cooldown = 11.0f;
|
|
|
|
skillComponent->CalculateBehavior(1103, 24622, parentID);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SamuraiRank1: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
m_Cooldown = 11.0f;
|
|
|
|
skillComponent->CalculateBehavior(562, 8899, parentID);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SamuraiRank2: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
m_Cooldown = 11.0f;
|
|
|
|
skillComponent->CalculateBehavior(563, 8904, parentID);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SamuraiRank3: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
m_Cooldown = 11.0f;
|
|
|
|
skillComponent->CalculateBehavior(564, 8909, parentID);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
std::vector<ItemSetPassiveAbility> ItemSetPassiveAbility::FindAbilities(uint32_t itemSetID, Entity* parent, ItemSet* itemSet) {
|
|
|
|
std::vector<ItemSetPassiveAbility> abilities;
|
|
|
|
|
2023-01-22 23:38:47 +00:00
|
|
|
switch (static_cast<eItemSetPassiveAbilityID>(itemSetID)) {
|
2022-07-28 13:39:57 +00:00
|
|
|
// Assembly
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SummonerRank1:
|
|
|
|
case eItemSetPassiveAbilityID::SummonerRank2:
|
|
|
|
case eItemSetPassiveAbilityID::SummonerRank3:
|
|
|
|
case eItemSetPassiveAbilityID::InventorRank1:
|
|
|
|
case eItemSetPassiveAbilityID::InventorRank2:
|
|
|
|
case eItemSetPassiveAbilityID::InventorRank3:
|
|
|
|
case eItemSetPassiveAbilityID::EngineerRank1:
|
|
|
|
case eItemSetPassiveAbilityID::EngineerRank2:
|
|
|
|
case eItemSetPassiveAbilityID::EngineerRank3: {
|
2022-07-28 13:39:57 +00:00
|
|
|
abilities.emplace_back(PassiveAbilityTrigger::AssemblyImagination, parent, itemSet);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Sentinel
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::KnightRank1:
|
|
|
|
case eItemSetPassiveAbilityID::KnightRank2:
|
|
|
|
case eItemSetPassiveAbilityID::KnightRank3:
|
|
|
|
case eItemSetPassiveAbilityID::SpaceRangerRank1:
|
|
|
|
case eItemSetPassiveAbilityID::SpaceRangerRank2:
|
|
|
|
case eItemSetPassiveAbilityID::SpaceRangerRank3:
|
|
|
|
case eItemSetPassiveAbilityID::SamuraiRank1:
|
|
|
|
case eItemSetPassiveAbilityID::SamuraiRank2:
|
|
|
|
case eItemSetPassiveAbilityID::SamuraiRank3: {
|
2022-07-28 13:39:57 +00:00
|
|
|
abilities.emplace_back(PassiveAbilityTrigger::SentinelArmor, parent, itemSet);
|
|
|
|
abilities.emplace_back(PassiveAbilityTrigger::EnemySmashed, parent, itemSet);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Paradox
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::BatLord:
|
|
|
|
case eItemSetPassiveAbilityID::SpaceMarauderRank1:
|
|
|
|
case eItemSetPassiveAbilityID::SpaceMarauderRank2:
|
|
|
|
case eItemSetPassiveAbilityID::SpaceMarauderRank3:
|
|
|
|
case eItemSetPassiveAbilityID::SorcererRank1:
|
|
|
|
case eItemSetPassiveAbilityID::SorcererRank2:
|
|
|
|
case eItemSetPassiveAbilityID::SorcererRank3:
|
|
|
|
case eItemSetPassiveAbilityID::ShinobiRank1:
|
|
|
|
case eItemSetPassiveAbilityID::ShinobiRank2:
|
|
|
|
case eItemSetPassiveAbilityID::ShinobiRank3: {
|
2022-07-28 13:39:57 +00:00
|
|
|
abilities.emplace_back(PassiveAbilityTrigger::EnemySmashed, parent, itemSet);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return abilities;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-12-24 02:05:30 +00:00
|
|
|
void ItemSetPassiveAbility::OnEnemySmshed(Entity* target) {
|
2022-07-28 13:39:57 +00:00
|
|
|
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
|
|
|
|
auto* skillComponent = m_Parent->GetComponent<SkillComponent>();
|
|
|
|
|
|
|
|
if (destroyableComponent == nullptr || skillComponent == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EntityManager::Instance()->SerializeEntity(m_Parent);
|
|
|
|
|
2023-01-22 23:38:47 +00:00
|
|
|
const auto id = static_cast<eItemSetPassiveAbilityID>(m_ItemSet->GetID());
|
2022-07-28 13:39:57 +00:00
|
|
|
const auto parentID = m_Parent->GetObjectID();
|
|
|
|
const auto equippedCount = m_ItemSet->GetEquippedCount();
|
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
// Bat Lord
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::BatLord: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 5) return;
|
|
|
|
destroyableComponent->Heal(3);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Sentinel
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::KnightRank1: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 5) return;
|
|
|
|
destroyableComponent->Repair(1);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::KnightRank2: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 5) return;
|
|
|
|
destroyableComponent->Repair(1);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::KnightRank3: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 5) return;
|
|
|
|
destroyableComponent->Repair(1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SpaceRangerRank1: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 5) return;
|
|
|
|
destroyableComponent->Repair(1);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SpaceRangerRank2: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 5) return;
|
|
|
|
destroyableComponent->Repair(1);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SpaceRangerRank3: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 5) return;
|
|
|
|
destroyableComponent->Repair(1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SamuraiRank1: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 5) return;
|
|
|
|
destroyableComponent->Repair(1);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SamuraiRank2: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 5) return;
|
|
|
|
destroyableComponent->Repair(1);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SamuraiRank3: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 5) return;
|
|
|
|
destroyableComponent->Repair(1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Paradox
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SpaceMarauderRank1: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
destroyableComponent->Imagine(1);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SpaceMarauderRank2: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
destroyableComponent->Imagine(2);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SpaceMarauderRank3: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
destroyableComponent->Imagine(3);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::ShinobiRank1: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
destroyableComponent->Imagine(1);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::ShinobiRank2: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
destroyableComponent->Imagine(2);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::ShinobiRank3: {
|
|
|
|
if (equippedCount < 4) return;
|
|
|
|
destroyableComponent->Imagine(3);
|
2022-07-28 13:39:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SorcererRank1: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
destroyableComponent->Imagine(1);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SorcererRank2: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
destroyableComponent->Imagine(2);
|
|
|
|
break;
|
|
|
|
}
|
2023-01-22 23:38:47 +00:00
|
|
|
case eItemSetPassiveAbilityID::SorcererRank3: {
|
2022-07-28 13:39:57 +00:00
|
|
|
if (equippedCount < 4) return;
|
|
|
|
destroyableComponent->Imagine(3);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|