예제 #1
0
        private bool CheckAssetFilters(Asset asset, UISearchBox.DropDownOptions filter)
        {
            if (!CheckAssetTypeFilter(asset, filter))
            {
                return(false);
            }

            if (filter == UISearchBox.DropDownOptions.Growable || filter == UISearchBox.DropDownOptions.Rico || filter == UISearchBox.DropDownOptions.GrwbRico)
            {
                if (!CheckGrowableRICOFilter(asset, filter))
                {
                    return(false);
                }
            }
            else if (filter == UISearchBox.DropDownOptions.Ploppable)
            {
                if (!CheckPloppableFilter(asset))
                {
                    return(false);
                }
            }
            else if (filter == UISearchBox.DropDownOptions.Prop)
            {
                // filter by prop type
                if (!UIFilterProp.instance.IsAllSelected())
                {
                    UIFilterProp.Category category = UIFilterProp.GetCategory(asset.propType);
                    if (category == UIFilterProp.Category.None || !UIFilterProp.instance.IsSelected(category))
                    {
                        return(false);
                    }
                }
            }
            else if (filter == UISearchBox.DropDownOptions.Tree)
            {
                // filter by tree type
                if (!UIFilterTree.instance.IsAllSelected())
                {
                    UIFilterTree.Category category = UIFilterTree.GetCategory(asset.treeType);
                    if (category == UIFilterTree.Category.None || !UIFilterTree.instance.IsSelected(category))
                    {
                        return(false);
                    }
                }
            }
            else if (filter == UISearchBox.DropDownOptions.Network)
            {
                if (!CheckNetworkFilter(asset))
                {
                    return(false);
                }
            }

            // filter out marker prop if not in editor mode
            if ((!FindIt.inEditor && !Settings.showPropMarker) && (asset.propType == Asset.PropType.PropsMarker))
            {
                return(false);
            }

            try
            {
                // check vanila & workshop filters
                if (!CheckVanillaWorkshopFilter(asset))
                {
                    return(false);
                }

                // filter out assets without matching custom tag
                if (UISearchBox.instance?.tagPanel != null)
                {
                    if (UISearchBox.instance.tagPanel.tagDropDownCheckBox.isChecked && UISearchBox.instance.tagPanel.customTagListStrArray.Length > 0)
                    {
                        if (!asset.tagsCustom.Contains(UISearchBox.instance.tagPanel.GetDropDownListKey()))
                        {
                            return(false);
                        }
                    }
                }

                // extra filters check
                if (UISearchBox.instance?.extraFiltersPanel != null)
                {
                    if (UISearchBox.instance.extraFiltersPanel.optionDropDownCheckBox.isChecked)
                    {
                        if (!CheckExtraFilters(asset))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if (asset.isSubBuilding)
                        {
                            return(false);
                        }
                    }
                }
                // skip sub-buildings if not using the extra filters panel
                else
                {
                    if (asset.isSubBuilding)
                    {
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                Debugging.LogException(e);
            }

            return(true);
        }
예제 #2
0
        /// <summary>
        /// return true if the asset type matches UISearchbox filter dropdown options
        /// </summary>
        private bool CheckAssetFilter(Asset asset, UISearchBox.DropDownOptions filter)
        {
            if (asset.assetType != Asset.AssetType.Network && filter == UISearchBox.DropDownOptions.Network)
            {
                return(false);
            }
            if (asset.assetType != Asset.AssetType.Prop && filter == UISearchBox.DropDownOptions.Prop)
            {
                return(false);
            }
            if (asset.assetType != Asset.AssetType.Rico && filter == UISearchBox.DropDownOptions.Rico)
            {
                return(false);
            }
            if (asset.assetType != Asset.AssetType.Ploppable && filter == UISearchBox.DropDownOptions.Ploppable)
            {
                return(false);
            }
            if (asset.assetType != Asset.AssetType.Growable && filter == UISearchBox.DropDownOptions.Growable)
            {
                return(false);
            }
            if (asset.assetType != Asset.AssetType.Tree && filter == UISearchBox.DropDownOptions.Tree)
            {
                return(false);
            }
            if (asset.assetType != Asset.AssetType.Decal && filter == UISearchBox.DropDownOptions.Decal)
            {
                return(false);
            }
            if ((asset.assetType != Asset.AssetType.Rico && asset.assetType != Asset.AssetType.Growable) && filter == UISearchBox.DropDownOptions.GrwbRico)
            {
                return(false);
            }

            if (filter == UISearchBox.DropDownOptions.Growable || filter == UISearchBox.DropDownOptions.Rico || filter == UISearchBox.DropDownOptions.GrwbRico)
            {
                BuildingInfo buildingInfo = asset.prefab as BuildingInfo;

                // Distinguish growable and rico
                if ((filter == UISearchBox.DropDownOptions.Growable) && (asset.assetType == Asset.AssetType.Rico))
                {
                    return(false);
                }
                if ((filter == UISearchBox.DropDownOptions.Rico) && (asset.assetType == Asset.AssetType.Growable))
                {
                    return(false);
                }

                // filter by size
                if (!CheckBuildingSize(asset.size, UISearchBox.instance.buildingSizeFilterIndex))
                {
                    return(false);
                }

                // filter by growable type
                if (!UIFilterGrowable.instance.IsAllSelected())
                {
                    UIFilterGrowable.Category category = UIFilterGrowable.GetCategory(buildingInfo.m_class);
                    if (category == UIFilterGrowable.Category.None || !UIFilterGrowable.instance.IsSelected(category))
                    {
                        return(false);
                    }
                }
            }
            else if (filter == UISearchBox.DropDownOptions.Ploppable)
            {
                BuildingInfo buildingInfo = asset.prefab as BuildingInfo;

                // filter by size
                if (!CheckBuildingSize(asset.size, UISearchBox.instance.buildingSizeFilterIndex))
                {
                    return(false);
                }

                // filter by ploppable type
                if (!UIFilterPloppable.instance.IsAllSelected())
                {
                    UIFilterPloppable.Category category = UIFilterPloppable.GetCategory(buildingInfo.m_class);
                    if (category == UIFilterPloppable.Category.None || !UIFilterPloppable.instance.IsSelected(category))
                    {
                        return(false);
                    }
                }
            }
            else if (filter == UISearchBox.DropDownOptions.Prop)
            {
                // filter by prop type
                if (!UIFilterProp.instance.IsAllSelected())
                {
                    UIFilterProp.Category category = UIFilterProp.GetCategory(asset.propType);
                    if (category == UIFilterProp.Category.None || !UIFilterProp.instance.IsSelected(category))
                    {
                        return(false);
                    }
                }
            }
            else if (filter == UISearchBox.DropDownOptions.Tree)
            {
                // filter by tree type
                if (!UIFilterTree.instance.IsAllSelected())
                {
                    UIFilterTree.Category category = UIFilterTree.GetCategory(asset.treeType);
                    if (category == UIFilterTree.Category.None || !UIFilterTree.instance.IsSelected(category))
                    {
                        return(false);
                    }
                }
            }
            else if (filter == UISearchBox.DropDownOptions.Network)
            {
                // filter by network type
                if (!UIFilterNetwork.instance.IsAllSelected())
                {
                    UIFilterNetwork.Category category = UIFilterNetwork.GetCategory(asset.networkType);
                    NetInfo info = asset.prefab as NetInfo;
                    if (info == null)
                    {
                        return(false);
                    }

                    // not mutually exclusive with other categories. Handle them differently.
                    if (UIFilterNetwork.instance.IsOnlySelected(UIFilterNetwork.Category.OneWay))
                    {
                        if (!UIFilterNetwork.IsNormalRoads(asset.networkType))
                        {
                            return(false);
                        }
                        if (!UIFilterNetwork.IsOneWay(info))
                        {
                            return(false);
                        }
                    }
                    else if (UIFilterNetwork.instance.IsOnlySelected(UIFilterNetwork.Category.Parking))
                    {
                        if (!UIFilterNetwork.IsNormalRoads(asset.networkType))
                        {
                            return(false);
                        }
                        if (!UIFilterNetwork.HasParking(info))
                        {
                            return(false);
                        }
                    }
                    else if (UIFilterNetwork.instance.IsOnlySelected(UIFilterNetwork.Category.NoParking))
                    {
                        if (!UIFilterNetwork.IsNormalRoads(asset.networkType))
                        {
                            return(false);
                        }
                        if (UIFilterNetwork.HasParking(info))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if (category == UIFilterNetwork.Category.None || !UIFilterNetwork.instance.IsSelected(category))
                        {
                            return(false);
                        }
                    }
                }
            }

            // filter out marker prop if not in editor mode
            if ((!FindIt.inEditor && !Settings.showPropMarker) && (asset.propType == Asset.PropType.PropsMarker))
            {
                return(false);
            }

            try
            {
                if (UISearchBox.instance?.workshopFilter != null && UISearchBox.instance?.vanillaFilter != null)
                {
                    // filter out custom asset
                    if (asset.prefab.m_isCustomContent && !UISearchBox.instance.workshopFilter.isChecked)
                    {
                        return(false);
                    }

                    // filter out vanilla asset. will not filter out content creater pack assets
                    if (!asset.prefab.m_isCustomContent && !UISearchBox.instance.vanillaFilter.isChecked && !asset.isCCP)
                    {
                        return(false);
                    }

                    // filter out assets without matching custom tag
                    if (UISearchBox.instance?.tagPanel != null)
                    {
                        if (UISearchBox.instance.tagPanel.tagDropDownCheckBox.isChecked && UISearchBox.instance.tagPanel.customTagListStrArray.Length > 0)
                        {
                            if (!asset.tagsCustom.Contains(UISearchBox.instance.tagPanel.GetDropDownListKey()))
                            {
                                return(false);
                            }
                        }
                    }

                    // extra filters check
                    if (UISearchBox.instance?.extraFiltersPanel != null)
                    {
                        if (UISearchBox.instance.extraFiltersPanel.optionDropDownCheckBox.isChecked)
                        {
                            // filter asset by asset creator
                            if (UISearchBox.instance.extraFiltersPanel.optionDropDownMenu.selectedIndex == (int)UIFilterExtra.DropDownOptions.AssetCreator)
                            {
                                if (asset.author != UISearchBox.instance.extraFiltersPanel.GetAssetCreatorDropDownListKey())
                                {
                                    return(false);
                                }
                            }
                            // filter asset by building height
                            else if (UISearchBox.instance.extraFiltersPanel.optionDropDownMenu.selectedIndex == (int)UIFilterExtra.DropDownOptions.BuildingHeight)
                            {
                                if (asset.assetType == Asset.AssetType.Ploppable || asset.assetType == Asset.AssetType.Rico || asset.assetType == Asset.AssetType.Growable)
                                {
                                    if (asset.buildingHeight > UISearchBox.instance.extraFiltersPanel.maxBuildingHeight)
                                    {
                                        return(false);
                                    }
                                    if (asset.buildingHeight < UISearchBox.instance.extraFiltersPanel.minBuildingHeight)
                                    {
                                        return(false);
                                    }
                                }
                                else
                                {
                                    return(false);
                                }
                            }

                            // filter asset by building level
                            else if (UISearchBox.instance.extraFiltersPanel.optionDropDownMenu.selectedIndex == (int)UIFilterExtra.DropDownOptions.BuildingLevel)
                            {
                                if (!(asset.prefab is BuildingInfo))
                                {
                                    return(false);
                                }
                                BuildingInfo    info  = asset.prefab as BuildingInfo;
                                ItemClass.Level level = (ItemClass.Level)UISearchBox.instance.extraFiltersPanel.buildingLevelDropDownMenu.selectedIndex;
                                if (info.m_class.m_level != level)
                                {
                                    return(false);
                                }
                            }

                            // only show unused assets
                            else if (UISearchBox.instance.extraFiltersPanel.optionDropDownMenu.selectedIndex == (int)UIFilterExtra.DropDownOptions.UnusedAssets)
                            {
                                if (prefabInstanceCountDictionary.ContainsKey(asset.prefab))
                                {
                                    if (prefabInstanceCountDictionary[asset.prefab] > 0)
                                    {
                                        return(false);
                                    }
                                }
                                if (FindIt.isPOEnabled && Settings.includePOinstances)
                                {
                                    if (FindIt.instance.POTool.GetPrefabInstanceCount(asset.prefab) > 0)
                                    {
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debugging.LogException(e);
            }

            return(true);
        }