Update AmTeapotServer.cpp (#949)

This commit is contained in:
David Markowitz 2023-01-17 04:07:34 -08:00 committed by GitHub
parent fbaf1cbb25
commit 7418e02365
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,14 +1,21 @@
#include "AmTeapotServer.h"
#include "InventoryComponent.h"
#include "GameMessages.h"
#include "Item.h"
void AmTeapotServer::OnUse(Entity* self, Entity* user) {
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
if (!inventoryComponent) return;
if (inventoryComponent->GetLotCount(BLUE_FLOWER_LEAVES) >= 10) {
inventoryComponent->RemoveItem(BLUE_FLOWER_LEAVES, 10);
auto* blueFlowerItem = inventoryComponent->FindItemByLot(BLUE_FLOWER_LEAVES, eInventoryType::ITEMS);
if (!blueFlowerItem) {
blueFlowerItem = inventoryComponent->FindItemByLot(BLUE_FLOWER_LEAVES, eInventoryType::VAULT_ITEMS);
if (!blueFlowerItem) return;
}
// The client allows you to use the teapot only if you have a stack of 10 leaves in some inventory somewhere.
if (blueFlowerItem->GetCount() >= 10) {
blueFlowerItem->SetCount(blueFlowerItem->GetCount() - 10);
inventoryComponent->AddItem(WU_S_IMAGINATION_TEA, 1);
}
GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID());