From fb6f3b3c13019f822c9f72da3dc7172c845a66b3 Mon Sep 17 00:00:00 2001 From: HungDK <> Date: Mon, 22 Dec 2025 17:49:59 +0700 Subject: [PATCH] Add CanTakeItem and FindMineTool method --- Assets/Scripts/CECHostPlayer.cs | 62 +++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index 5c026c763d..dd01450280 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -5295,5 +5295,67 @@ namespace BrewMonster CANDO_REBUILDPET = 19, CANDO_SWITCH_PARALLEL_WORLD = 20; } + public bool CanTakeItem(int idItem, int iAmount) + { + bool bCanPick = false; + + if (GPDataTypeHelper.ISMONEYTID(idItem)) + { + if (GetMoneyAmount() < GetMaxMoneyAmount()) + bCanPick = true; + } + else + { + if (PackInventory.CanAddItem(idItem, iAmount, false) >= 0) + bCanPick = true; + } + + return bCanPick; + } + public bool FindMineTool(int tidMine, ref int piPack, ref int piIndex, ref int pidTool) + { + if (tidMine == 0) + return false; + + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + object pDataPtr = ElementDataManProvider.GetElementDataMan().get_data_ptr((uint)tidMine, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + + if (DataType != DATA_TYPE.DT_MINE_ESSENCE) + { + //ASSERT(DataType != DATA_TYPE.DT_MINE_ESSENCE); + return false; + } + + MINE_ESSENCE pData = (MINE_ESSENCE)pDataPtr; + int idTool = (int)pData.id_equipment_required; + bool bRet = true; + + if (idTool != 0) + { + int iIndex = PackInventory.FindItem(idTool); + if (iIndex >= 0) + { + piPack = EC_Inventory.Inventory_type.IVTRTYPE_PACK; + piIndex = iIndex; + pidTool = idTool; + } + else if ((iIndex = TaskInventory.FindItem(idTool)) >= 0) + { + piPack = EC_Inventory.Inventory_type.IVTRTYPE_TASKPACK; + piIndex = iIndex; + pidTool = idTool; + } + else + bRet = false; + } + else + { + piPack = 0; + piIndex = 0; + pidTool = 0; + } + + return bRet; + } } } \ No newline at end of file