示例#1
0
 private bool CheckNetworkFilter(Asset asset)
 {
     // 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);
             }
         }
     }
     return(true);
 }
示例#2
0
        /// <summary>
        /// Add Find It 2 description: asset type, sub-type, size, height
        /// </summary>
        public void SetFindIt2Description()
        {
            if (assetType == AssetType.Decal)
            {
                findIt2Description = Translations.Translate("FIF_SE_ID");
            }
            else if (assetType == AssetType.Network)
            {
                findIt2Description = $"{Translations.Translate("FIF_SE_IN")}, ";

                if (networkType == Asset.NetworkType.TinyRoads)
                {
                    findIt2Description += Translations.Translate("FIF_NET_TNR");
                }
                else if (networkType == Asset.NetworkType.SmallRoads)
                {
                    findIt2Description += Translations.Translate("FIF_NET_SMR");
                }
                else if (networkType == Asset.NetworkType.MediumRoads)
                {
                    findIt2Description += Translations.Translate("FIF_NET_MDR");
                }
                else if (networkType == Asset.NetworkType.LargeRoads)
                {
                    findIt2Description += Translations.Translate("FIF_NET_LGR");
                }
                else if (networkType == Asset.NetworkType.Highway)
                {
                    findIt2Description += Translations.Translate("FIF_NET_HGHW");
                }
                else if (networkType == Asset.NetworkType.Path)
                {
                    findIt2Description += Translations.Translate("FIF_NET_PATH");
                }
                else if (networkType == Asset.NetworkType.Fence)
                {
                    findIt2Description += Translations.Translate("FIF_NET_WALL");
                }
                else if (networkType == Asset.NetworkType.WaterStructures)
                {
                    findIt2Description += Translations.Translate("FIF_NET_WAT");
                }
                else if (networkType == Asset.NetworkType.Utility)
                {
                    findIt2Description += Translations.Translate("FIF_NET_UTI");
                }
                else if (networkType == Asset.NetworkType.Train)
                {
                    findIt2Description += Translations.Translate("FIF_NET_TRA");
                }
                else if (networkType == Asset.NetworkType.Unsorted)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_UNS");
                }

                if (UIFilterNetwork.IsNormalRoads(networkType))
                {
                    NetInfo info = prefab as NetInfo;
                    if (UIFilterNetwork.IsOneWay(info))
                    {
                        findIt2Description += ($", {Translations.Translate("FIF_NET_ONE")}");
                    }

                    if (UIFilterNetwork.HasParking(info))
                    {
                        findIt2Description += ($", {Translations.Translate("FIF_NET_PAR")}");
                    }
                    else
                    {
                        findIt2Description += ($", {Translations.Translate("FIF_NET_NOP")}");
                    }
                }
            }
            else if (assetType == AssetType.Growable || assetType == AssetType.Rico)
            {
                if (assetType == AssetType.Rico)
                {
                    findIt2Description = $"{Translations.Translate("FIF_SE_IR")}, ";
                }
                else
                {
                    findIt2Description = $"{Translations.Translate("FIF_SE_IG")}, ";
                }
                if (subService == ItemClass.SubService.ResidentialLow)
                {
                    findIt2Description += Translations.Translate("FIF_GR_LDR");
                }
                else if (subService == ItemClass.SubService.ResidentialHigh)
                {
                    findIt2Description += Translations.Translate("FIF_GR_HDR");
                }
                else if (subService == ItemClass.SubService.ResidentialLowEco)
                {
                    findIt2Description += Translations.Translate("FIF_GR_LDRE");
                }
                else if (subService == ItemClass.SubService.ResidentialHighEco)
                {
                    findIt2Description += Translations.Translate("FIF_GR_HDRE");
                }
                else if (subService == ItemClass.SubService.CommercialLow)
                {
                    findIt2Description += Translations.Translate("FIF_GR_LDC");
                }
                else if (subService == ItemClass.SubService.CommercialHigh)
                {
                    findIt2Description += Translations.Translate("FIF_GR_HDC");
                }
                else if (subService == ItemClass.SubService.CommercialEco)
                {
                    findIt2Description += Translations.Translate("FIF_GR_CE");
                }
                else if (subService == ItemClass.SubService.CommercialLeisure)
                {
                    findIt2Description += Translations.Translate("FIF_GR_LC");
                }
                else if (subService == ItemClass.SubService.CommercialTourist)
                {
                    findIt2Description += Translations.Translate("FIF_GR_TC");
                }
                else if (subService == ItemClass.SubService.IndustrialGeneric)
                {
                    findIt2Description += Translations.Translate("FIF_GR_GI");
                }
                else if (subService == ItemClass.SubService.IndustrialFarming)
                {
                    findIt2Description += Translations.Translate("FIF_GR_FAI");
                }
                else if (subService == ItemClass.SubService.IndustrialForestry)
                {
                    findIt2Description += Translations.Translate("FIF_GR_FOI");
                }
                else if (subService == ItemClass.SubService.IndustrialOil)
                {
                    findIt2Description += Translations.Translate("FIF_GR_OII");
                }
                else if (subService == ItemClass.SubService.IndustrialOre)
                {
                    findIt2Description += Translations.Translate("FIF_GR_ORI");
                }
                else if (subService == ItemClass.SubService.OfficeGeneric)
                {
                    findIt2Description += Translations.Translate("FIF_GR_O");
                }
                else if (subService == ItemClass.SubService.OfficeHightech)
                {
                    findIt2Description += Translations.Translate("FIF_GR_ITC");
                }
                else
                {
                    findIt2Description += Translations.Translate("FIF_PROP_UNS");
                }

                findIt2Description += $", {size.x}x{size.y}, {(int)buildingHeight} {Translations.Translate("FIF_EF_MET")} ({(int)(buildingHeight * 3.28084f)} {Translations.Translate("FIF_EF_FEE")})";
            }
            else if (assetType == AssetType.Prop)
            {
                findIt2Description = $"{Translations.Translate("FIF_SE_IPR")}, ";
                if (propType == Asset.PropType.PropsIndustrial)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_IND");
                }
                else if (propType == Asset.PropType.PropsParks)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_PAR");
                }
                else if (propType == Asset.PropType.PropsCommon)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_COM");
                }
                else if (propType == Asset.PropType.PropsResidential)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_RES");
                }
                else if (propType == Asset.PropType.PropsBillboards)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_BIL");
                }
                else if (propType == Asset.PropType.PropsSpecialBillboards)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_SPE");
                }
                else if (propType == Asset.PropType.PropsLights)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_LIG");
                }
                else if (propType == Asset.PropType.Natural)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_NAT");
                }
                else if (propType == Asset.PropType.Unsorted)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_UNS");
                }
                else if (propType == Asset.PropType.PropsMarker)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_MAR");
                }
                else if (propType == Asset.PropType.PropsUnsortedVehicle)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_VEH");
                }
                else if (propType == Asset.PropType.PropsTree)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_TRE");
                }
                else if (propType == Asset.PropType.PropsMoterVehicle)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_MOT");
                }
                else if (propType == Asset.PropType.PropsRailwayVehicle)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_RAI");
                }
                else if (propType == Asset.PropType.PropsAircraft)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_AIR");
                }
                else if (propType == Asset.PropType.PropsWaterCraft)
                {
                    findIt2Description += Translations.Translate("FIF_PROP_WAT");
                }

                PropInfo propInfo = m_prefab as PropInfo;
                // terrain conforming?
                if (propInfo.m_material?.shader == propFenceShader)
                {
                    findIt2Description += $", {Translations.Translate("FIF_PROP_TC")}";
                }
                else
                {
                    findIt2Description += $", {Translations.Translate("FIF_PROP_NTC")}";
                }
            }
            else if (assetType == AssetType.Tree)
            {
                findIt2Description = $"{Translations.Translate("FIF_SE_IT")}, ";
                if (treeType == Asset.TreeType.SmallTree)
                {
                    findIt2Description += Translations.Translate("FIF_TREE_SM");
                }
                else if (treeType == Asset.TreeType.MediumTree)
                {
                    findIt2Description += Translations.Translate("FIF_TREE_MD");
                }
                else if (treeType == Asset.TreeType.LargeTree)
                {
                    findIt2Description += Translations.Translate("FIF_TREE_LG");
                }
            }
            else if (assetType == AssetType.Ploppable)
            {
                findIt2Description = $"{Translations.Translate("FIF_SE_IP")}, ";

                if (service == ItemClass.Service.Electricity)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_E");
                }
                else if (service == ItemClass.Service.Water)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_W");
                }
                else if (service == ItemClass.Service.Garbage)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_G");
                }
                else if (service == ItemClass.Service.PlayerIndustry)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_I");
                }
                else if (service == ItemClass.Service.Fishing)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_FI");
                }
                else if (service == ItemClass.Service.HealthCare)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_H");
                }
                else if (service == ItemClass.Service.FireDepartment)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_F");
                }
                else if (service == ItemClass.Service.Disaster)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_D");
                }
                else if (service == ItemClass.Service.PoliceDepartment)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_P");
                }
                else if (service == ItemClass.Service.Education)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_ED");
                }
                else if (service == ItemClass.Service.PlayerEducation)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_C");
                }
                else if (service == ItemClass.Service.Museums)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_C");
                }
                else if (service == ItemClass.Service.VarsitySports)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_V");
                }
                else if (service == ItemClass.Service.PublicTransport)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_PT");
                }
                else if (service == ItemClass.Service.Tourism)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_PT");
                }
                else if (service == ItemClass.Service.Beautification)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_PPW");
                }
                else if (service == ItemClass.Service.Monument)
                {
                    findIt2Description += Translations.Translate("FIF_PLOP_U");
                }
                else
                {
                    findIt2Description += Translations.Translate("FIF_PROP_UNS");
                }

                findIt2Description += $", {size.x}x{size.y}, {(int)buildingHeight} {Translations.Translate("FIF_EF_MET")} ({(int)(buildingHeight * 3.28084f)} {Translations.Translate("FIF_EF_FEE")})";
            }

            findIt2Description += "\n";
        }
示例#3
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);
        }