Rename some variables in Component

And add more virtuals
This commit is contained in:
David Markowitz
2023-06-06 18:59:53 -07:00
parent b589755655
commit 716a5fcf37
54 changed files with 602 additions and 580 deletions

View File

@@ -76,7 +76,7 @@ void Inventory::SetSize(const uint32_t value) {
size = value;
GameMessages::SendSetInventorySize(component->GetParent(), type, static_cast<int>(size));
GameMessages::SendSetInventorySize(component->GetOwningEntity(), type, static_cast<int>(size));
}
int32_t Inventory::FindEmptySlot() {

View File

@@ -92,7 +92,7 @@ Item::Item(
inventory->AddManagedItem(this);
auto* entity = inventory->GetComponent()->GetParent();
auto* entity = inventory->GetComponent()->GetOwningEntity();
GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, static_cast<int>(this->count), subKey, lootSourceType);
if (isModMoveAndEquip) {
@@ -100,7 +100,7 @@ Item::Item(
Game::logger->Log("Item", "Move and equipped (%i) from (%i)", this->lot, this->inventory->GetType());
EntityManager::Instance()->SerializeEntity(inventory->GetComponent()->GetParent());
EntityManager::Instance()->SerializeEntity(inventory->GetComponent()->GetOwningEntity());
}
}
@@ -136,7 +136,7 @@ Inventory* Item::GetInventory() const {
return inventory;
}
LWOOBJID Item::GetParent() const {
LWOOBJID Item::GetOwningEntity() const {
return parent;
}
@@ -166,7 +166,7 @@ void Item::SetCount(const uint32_t value, const bool silent, const bool disassem
}
if (!silent) {
auto* entity = inventory->GetComponent()->GetParent();
auto* entity = inventory->GetComponent()->GetOwningEntity();
if (value > count) {
GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, delta, LWOOBJID_EMPTY, lootSourceType);
@@ -262,7 +262,7 @@ bool Item::Consume() {
Game::logger->LogDebug("Item", "Consumed LOT (%i) itemID (%llu). Success=(%d)", lot, id, success);
GameMessages::SendUseItemResult(inventory->GetComponent()->GetParent(), lot, success);
GameMessages::SendUseItemResult(inventory->GetComponent()->GetOwningEntity(), lot, success);
if (success) {
inventory->GetComponent()->RemoveItem(lot, 1);
@@ -284,7 +284,7 @@ void Item::UseNonEquip(Item* item) {
return;
}
auto* playerEntity = playerInventoryComponent->GetParent();
auto* playerEntity = playerInventoryComponent->GetOwningEntity();
if (!playerEntity) {
Game::logger->LogDebug("Item", "no player entity attached to inventory? item id is %llu", this->GetId());
return;
@@ -314,8 +314,8 @@ void Item::UseNonEquip(Item* item) {
auto success = !packages.empty();
if (success) {
if (this->GetPreconditionExpression()->Check(playerInventoryComponent->GetParent())) {
auto* entityParent = playerInventoryComponent->GetParent();
if (this->GetPreconditionExpression()->Check(playerInventoryComponent->GetOwningEntity())) {
auto* entityParent = playerInventoryComponent->GetOwningEntity();
// Roll the loot for all the packages then see if it all fits. If it fits, give it to the player, otherwise don't.
std::unordered_map<LOT, int32_t> rolledLoot{};
for (auto& pack : packages) {
@@ -331,15 +331,15 @@ void Item::UseNonEquip(Item* item) {
}
}
if (playerInventoryComponent->HasSpaceForLoot(rolledLoot)) {
LootGenerator::Instance().GiveLoot(playerInventoryComponent->GetParent(), rolledLoot, eLootSourceType::CONSUMPTION);
LootGenerator::Instance().GiveLoot(playerInventoryComponent->GetOwningEntity(), rolledLoot, eLootSourceType::CONSUMPTION);
item->SetCount(item->GetCount() - 1);
} else {
success = false;
}
} else {
GameMessages::SendUseItemRequirementsResponse(
playerInventoryComponent->GetParent()->GetObjectID(),
playerInventoryComponent->GetParent()->GetSystemAddress(),
playerInventoryComponent->GetOwningEntity()->GetObjectID(),
playerInventoryComponent->GetOwningEntity()->GetSystemAddress(),
eUseItemResponse::FailedPrecondition
);
success = false;
@@ -347,7 +347,7 @@ void Item::UseNonEquip(Item* item) {
}
}
Game::logger->LogDebug("Item", "Player %llu %s used item %i", playerEntity->GetObjectID(), success ? "successfully" : "unsuccessfully", thisLot);
GameMessages::SendUseItemResult(playerInventoryComponent->GetParent(), thisLot, success);
GameMessages::SendUseItemResult(playerInventoryComponent->GetOwningEntity(), thisLot, success);
}
}
@@ -360,7 +360,7 @@ void Item::Disassemble(const eInventoryType inventoryType) {
if (GetInventory()) {
auto inventoryComponent = GetInventory()->GetComponent();
if (inventoryComponent) {
auto entity = inventoryComponent->GetParent();
auto entity = inventoryComponent->GetOwningEntity();
if (entity) entity->SetVar<std::string>(u"currentModifiedBuild", modStr);
}
}

View File

@@ -150,7 +150,7 @@ public:
* Returns the parent of this item, e.g. for proxy items
* @return the parent of this item
*/
LWOOBJID GetParent() const;
LWOOBJID GetOwningEntity() const;
/**
* Sets the subkey for this item, e.g. for pets

View File

@@ -15,7 +15,7 @@ ItemSet::ItemSet(const uint32_t id, InventoryComponent* inventoryComponent) {
this->m_ID = id;
this->m_InventoryComponent = inventoryComponent;
this->m_PassiveAbilities = ItemSetPassiveAbility::FindAbilities(id, m_InventoryComponent->GetParent(), this);
this->m_PassiveAbilities = ItemSetPassiveAbility::FindAbilities(id, m_InventoryComponent->GetOwningEntity(), this);
auto query = CDClientDatabase::CreatePreppedStmt(
"SELECT skillSetWith2, skillSetWith3, skillSetWith4, skillSetWith5, skillSetWith6, itemIDs FROM ItemSets WHERE setID = ?;");
@@ -125,8 +125,8 @@ void ItemSet::OnEquip(const LOT lot) {
return;
}
auto* skillComponent = m_InventoryComponent->GetParent()->GetComponent<SkillComponent>();
auto* missionComponent = m_InventoryComponent->GetParent()->GetComponent<MissionComponent>();
auto* skillComponent = m_InventoryComponent->GetOwningEntity()->GetComponent<SkillComponent>();
auto* missionComponent = m_InventoryComponent->GetOwningEntity()->GetComponent<MissionComponent>();
for (const auto skill : skillSet) {
auto* skillTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();
@@ -135,7 +135,7 @@ void ItemSet::OnEquip(const LOT lot) {
missionComponent->Progress(eMissionTaskType::USE_SKILL, skill);
skillComponent->HandleUnmanaged(behaviorId, m_InventoryComponent->GetParent()->GetObjectID());
skillComponent->HandleUnmanaged(behaviorId, m_InventoryComponent->GetOwningEntity()->GetObjectID());
}
}
@@ -158,14 +158,14 @@ void ItemSet::OnUnEquip(const LOT lot) {
return;
}
const auto& skillComponent = m_InventoryComponent->GetParent()->GetComponent<SkillComponent>();
const auto& skillComponent = m_InventoryComponent->GetOwningEntity()->GetComponent<SkillComponent>();
for (const auto skill : skillSet) {
auto* skillTable = CDClientManager::Instance().GetTable<CDSkillBehaviorTable>();
const auto behaviorId = skillTable->GetSkillByID(skill).behaviorID;
skillComponent->HandleUnCast(behaviorId, m_InventoryComponent->GetParent()->GetObjectID());
skillComponent->HandleUnCast(behaviorId, m_InventoryComponent->GetOwningEntity()->GetObjectID());
}
}