Example #1
0
        public void RemoveCustomTag(Asset asset, string tag)
        {
            if (asset == null || asset.prefab == null || tag.IsNullOrWhiteSpace())
            {
                return;
            }

            if (!asset.tagsCustom.Remove(tag))
            {
                return;
            }

            string name = Asset.GetName(asset.prefab);

            if (tagsCustomDictionary.ContainsKey(tag))
            {
                tagsCustomDictionary[tag]--;
                if (tagsCustomDictionary[tag] == 0)
                {
                    tagsCustomDictionary.Remove(tag);
                }
            }

            if (asset.tagsCustom.Count == 0)
            {
                CustomTagsLibrary.assetTags.Remove(name);
            }
            else
            {
                CustomTagsLibrary.assetTags[name] = string.Join(" ", asset.tagsCustom.OrderBy(s => s).ToArray <string>());
            }

            CustomTagsLibrary.Serialize();
        }
Example #2
0
        public void Init()
        {
            foreach (Asset asset in assets.Values)
            {
                asset.prefab = null;
            }

            tagsTitleDictionary.Clear();
            tagsDescDictionary.Clear();
            tagsCustomDictionary.Clear();

            GetPrefabs <BuildingInfo>();
            GetPrefabs <NetInfo>();
            GetPrefabs <PropInfo>();
            GetPrefabs <TreeInfo>();

            if (CustomTagsLibrary.assetTags.Count == 0)
            {
                CustomTagsLibrary.Deserialize();
            }

            foreach (Asset asset in assets.Values)
            {
                if (asset.prefab != null)
                {
                    asset.title     = Asset.GetLocalizedTitle(asset.prefab);
                    asset.tagsTitle = AddAssetTags(asset, tagsTitleDictionary, asset.title);

                    if (asset.steamID == 0)
                    {
                        int index = asset.prefab.name.IndexOf(".");
                        if (index >= 0)
                        {
                            asset.tagsTitle.UnionWith(AddAssetTags(asset, tagsTitleDictionary, asset.prefab.name.Substring(0, index)));
                        }
                    }

                    asset.tagsDesc = AddAssetTags(asset, tagsDescDictionary, Asset.GetLocalizedDescription(asset.prefab));

                    string name = Asset.GetName(asset.prefab);
                    if (CustomTagsLibrary.assetTags.ContainsKey(name))
                    {
                        asset.tagsCustom = AddAssetTags(asset, tagsCustomDictionary, CustomTagsLibrary.assetTags[name]);
                    }
                }
            }

            CleanDictionarys();
        }
Example #3
0
        public void AddCustomTags(Asset asset, string text)
        {
            if (asset == null || asset.prefab == null || text.IsNullOrWhiteSpace())
            {
                return;
            }

            string name = Asset.GetName(asset.prefab);

            asset.tagsCustom.UnionWith(AddAssetTags(asset, tagsCustomDictionary, text));

            if (asset.tagsCustom.Count > 0)
            {
                CustomTagsLibrary.assetTags[name] = string.Join(" ", asset.tagsCustom.OrderBy(s => s).ToArray <string>());
                CustomTagsLibrary.Serialize();
            }
        }
Example #4
0
        public void Init()
        {
            foreach (Asset asset in assets.Values)
            {
                asset.prefab = null;
            }

            tagsTitleDictionary.Clear();
            tagsDescDictionary.Clear();
            tagsCustomDictionary.Clear();
            assetCreatorDictionary.Clear();

            GetPrefabs <BuildingInfo>();
            GetPrefabs <NetInfo>();
            GetPrefabs <PropInfo>();
            GetPrefabs <TreeInfo>();

            if (CustomTagsLibrary.assetTags.Count == 0)
            {
                CustomTagsLibrary.Deserialize();
            }

            foreach (Asset asset in assets.Values)
            {
                if (asset.prefab != null)
                {
                    asset.title     = Asset.GetLocalizedTitle(asset.prefab);
                    asset.tagsTitle = AddAssetTags(asset, tagsTitleDictionary, asset.title);

                    if (asset.steamID == 0)
                    {
                        int index = asset.prefab.name.IndexOf(".");
                        if (index >= 0)
                        {
                            asset.tagsTitle.UnionWith(AddAssetTags(asset, tagsTitleDictionary, asset.prefab.name.Substring(0, index)));
                        }

                        // if steamID == 0, non-workshop, download time = 0
                        asset.downloadTime = 0;

                        if (asset.isCCP)
                        {
                            if (!assetCreatorDictionary.ContainsKey(asset.author))
                            {
                                assetCreatorDictionary.Add(asset.author, 1);
                            }
                            else
                            {
                                assetCreatorDictionary[asset.author] += 1;
                            }
                        }
                    }
                    else
                    {
                        if (downloadTimes.ContainsKey(asset.steamID))
                        {
                            asset.downloadTime = downloadTimes[asset.steamID];

                            if (authors.ContainsKey(asset.steamID))
                            {
                                if (!assetCreatorDictionary.ContainsKey(authors[asset.steamID]))
                                {
                                    assetCreatorDictionary.Add(authors[asset.steamID], 1);
                                }
                                else
                                {
                                    assetCreatorDictionary[authors[asset.steamID]] += 1;
                                }
                            }
                        }
                        else
                        {
                            asset.downloadTime = 0;
                        }
                    }

                    asset.tagsDesc = AddAssetTags(asset, tagsDescDictionary, Asset.GetLocalizedDescription(asset.prefab));

                    string name = Asset.GetName(asset.prefab);
                    if (CustomTagsLibrary.assetTags.ContainsKey(name))
                    {
                        asset.tagsCustom = AddAssetTags(asset, tagsCustomDictionary, CustomTagsLibrary.assetTags[name]);
                    }
                }
            }

            // Inherited from Find It 1. I don't know why this is needed. It only removes the 's' in a name tag
            // CleanDictionarys();
        }
Example #5
0
        public void Init()
        {
            foreach (Asset asset in assets.Values)
            {
                asset.prefab = null;
            }

            tagsTitleDictionary.Clear();
            tagsDescDictionary.Clear();
            tagsCustomDictionary.Clear();
            assetCreatorDictionary.Clear();

            GetPrefabs <BuildingInfo>();
            GetPrefabs <NetInfo>();
            GetPrefabs <PropInfo>();
            GetPrefabs <TreeInfo>();

            if (CustomTagsLibrary.assetTags.Count == 0)
            {
                CustomTagsLibrary.Deserialize();
            }

            foreach (Asset asset in assets.Values)
            {
                if (asset.prefab != null)
                {
                    asset.title     = Asset.GetLocalizedTitle(asset.prefab);
                    asset.tagsTitle = AddAssetTags(asset, tagsTitleDictionary, asset.title);


                    if (asset.steamID == 0)
                    {
                        int index = asset.prefab.name.IndexOf(".");
                        if (index >= 0)
                        {
                            asset.tagsTitle.UnionWith(AddAssetTags(asset, tagsTitleDictionary, asset.prefab.name.Substring(0, index)));
                        }

                        // if steamID == 0, non-workshop, download time = 0
                        asset.downloadTime = 0;

                        if (asset.isCCP)
                        {
                            if (asset.prefab.m_dlcRequired == SteamHelper.DLC_BitMask.ModderPack1)
                            {
                                asset.author = "Shroomblaze";
                            }
                            if (asset.prefab.m_dlcRequired == SteamHelper.DLC_BitMask.ModderPack2)
                            {
                                asset.author = "GCVos";
                            }
                            if (asset.prefab.m_dlcRequired == SteamHelper.DLC_BitMask.ModderPack3)
                            {
                                asset.author = "Avanya";
                            }
                            if (asset.prefab.m_dlcRequired == SteamHelper.DLC_BitMask.ModderPack4)
                            {
                                asset.author = "KingLeno";
                            }
                            if (asset.prefab.m_dlcRequired == SteamHelper.DLC_BitMask.ModderPack5)
                            {
                                asset.author = "AmiPolizeiFunk";
                            }
                            if (asset.prefab.m_dlcRequired == SteamHelper.DLC_BitMask.ModderPack6)
                            {
                                asset.author = "Ryuichi Kaminogi";
                            }

                            if (!assetCreatorDictionary.ContainsKey(asset.author))
                            {
                                assetCreatorDictionary.Add(asset.author, 1);
                            }
                            else
                            {
                                assetCreatorDictionary[asset.author] += 1;
                            }
                        }
                    }
                    else
                    {
                        if (downloadTimes.ContainsKey(asset.steamID))
                        {
                            asset.downloadTime = downloadTimes[asset.steamID];

                            if (authors.ContainsKey(asset.steamID))
                            {
                                if (!assetCreatorDictionary.ContainsKey(authors[asset.steamID]))
                                {
                                    assetCreatorDictionary.Add(authors[asset.steamID], 1);
                                }
                                else
                                {
                                    assetCreatorDictionary[authors[asset.steamID]] += 1;
                                }
                            }
                        }
                        else
                        {
                            asset.downloadTime = 0;
                        }
                    }

                    asset.tagsDesc = AddAssetTags(asset, tagsDescDictionary, Asset.GetLocalizedDescription(asset.prefab));

                    string name = Asset.GetName(asset.prefab);
                    if (CustomTagsLibrary.assetTags.ContainsKey(name))
                    {
                        asset.tagsCustom = AddAssetTags(asset, tagsCustomDictionary, CustomTagsLibrary.assetTags[name]);
                    }
                }
            }

            CleanDictionarys();
        }