private int supply_type_of_item(int typeIndex, Item_Data itemData)
        {
            int supply_type = 0;

            if (!itemData.is_weapon)
            {
                supply_type = 0;
            }
            else
            {
                WeaponType weapon_type = itemData.to_weapon.main_type();
                if (weapon_type.DisplayedInStatus)
                {
                    supply_type = weapon_type.Key;
                }
                else
                {
                    supply_type = 0;
                    if (Global.ActorConfig.ChildWeaponTypeAllowsParent && supply_type == 0)
                    {
                        if (typeIndex >= 0 && Global.weapon_types[SupplyWeaponTypes[typeIndex]]
                            .type_and_parents(Global.weapon_types)
                            .Skip(1)
                            .Contains(weapon_type))
                        {
                            supply_type = SupplyWeaponTypes[typeIndex];
                        }
                        else
                        {
                            foreach (var child_type in Global.weapon_types)
                            {
                                if (SupplyWeaponTypes.Contains(child_type.Key))
                                {
                                    if (child_type.type_and_parents(Global.weapon_types)
                                        .Skip(1)
                                        .Contains(weapon_type))
                                    {
                                        supply_type = child_type.Key;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (Global.ActorConfig.ParentWeaponTypeAllowsChild && supply_type == 0)
                    {
                        foreach (var parent_type in weapon_type
                                 .type_and_parents(Global.weapon_types)
                                 .Skip(1))
                        {
                            if (SupplyWeaponTypes.Contains(parent_type.Key))
                            {
                                supply_type = parent_type.Key;
                                break;
                            }
                        }
                    }
                }
            }

            return(SupplyWeaponTypes.IndexOf(supply_type));
        }