using BrewMonster.Scripts.Managers; using BrewMonster; using BrewMonster.Scripts; using ModelRenderer.Scripts.GameData; using ModelRenderer.Scripts.Common; using BrewMonster.Network; namespace BrewMonster.Scripts { public class EC_IvtrMaterial : EC_IvtrItem { protected MATERIAL_MAJOR_TYPE m_pDBMajorType; protected MATERIAL_SUB_TYPE m_pDBSubType; protected MATERIAL_ESSENCE m_pDBEssence; /// /// Not create logic yet (add summary later) /// /// Template id /// Expire date public EC_IvtrMaterial(int tid, int expire_date) : base(tid, expire_date) { m_iCID = (int)InventoryClassId.ICID_MATERIAL; elementdataman pDB = ElementDataManProvider.GetElementDataMan(); DATA_TYPE DataType = DATA_TYPE.DT_INVALID; m_pDBEssence = (MATERIAL_ESSENCE)pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); m_pDBMajorType = (MATERIAL_MAJOR_TYPE)pDB.get_data_ptr(m_pDBEssence.id_major_type, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); m_pDBSubType = (MATERIAL_SUB_TYPE)pDB.get_data_ptr(m_pDBEssence.id_sub_type, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); m_iPileLimit = m_pDBEssence.pile_num_max; m_iPrice = m_pDBEssence.price; m_iShopPrice = m_pDBEssence.shop_price; m_iProcType = (int)m_pDBEssence.proc_type; m_i64EquipMask = 0; m_bNeedUpdate = false; } public EC_IvtrMaterial(EC_IvtrMaterial other) : base(other) { m_pDBEssence = other.m_pDBEssence; m_pDBMajorType = other.m_pDBMajorType; m_pDBSubType = other.m_pDBSubType; } public override bool SetItemInfo(byte[] pInfoData, int iDataLen) { base.SetItemInfo(pInfoData, iDataLen); return true; } // Get item icon file name public override string GetIconFile() { return m_pDBEssence.FileIcon; } // Get item name public override string GetName() { // Try Unicode first (for Vietnamese/wide char names), then fallback to CP936 if (m_pDBEssence.name != null && m_pDBEssence.name.Length > 0) { string s = ByteToStringUtils.UshortArrayToUnicodeString(m_pDBEssence.name); if (!string.IsNullOrEmpty(s) && !string.IsNullOrWhiteSpace(s)) return s; // Fallback to legacy CP936 if Unicode was empty s = ByteToStringUtils.UshortArrayToCP936String(m_pDBEssence.name); if (!string.IsNullOrEmpty(s)) return s; } return base.GetName(); // Fallback to base class method } // Get item description text protected override string GetNormalDesc(bool bRepair) { m_strDesc = ""; // Try to build item description CECStringTab pDescTab = EC_Game.GetItemDesc(); int white = (int)DescriptipionMsg.ITEMDESC_COL_WHITE; int namecol = DecideNameCol(); if (m_iCount > 1) AddDescText(namecol, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAMENUMBER), GetName(), m_iCount); else AddDescText(namecol, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAME), GetName()); AddIDDescText(); AddExpireTimeDesc(); // Price AddPriceDesc(white, bRepair); // Extend description AddExtDescText(); return m_strDesc; } // Get drop model for shown public override string GetDropModel() { return m_pDBEssence.FileMatter; } } }