Esempio n. 1
0
        internal void RefreshGeneratorTypeDropdown()
        {
            Type baseGeneratorType = m_currentCategory.BaseContainedType;

            if (baseGeneratorType == null)
            {
                SL.LogError("No base type for subfolder: " + m_currentCategory);
                return;
            }

            m_genDropdown.options = new List <Dropdown.OptionData>();
            s_currentTemplateTypes.Clear();

            foreach (var type in s_templateTypes)
            {
                if (!baseGeneratorType.IsAssignableFrom(type))
                {
                    continue;
                }

                s_currentTemplateTypes.Add(type);
                m_genDropdown.options.Add(new Dropdown.OptionData {
                    text = type.Name
                });
            }

            m_genDropdown.value = 1;
            m_genDropdown.value = 0;

            m_generatorTitle.text = "Template Generator (" + m_currentCategory.FolderName + ")";
        }
        public override Dictionary <string, object> LoadContent(SLPack pack, bool isHotReload)
        {
            var dict = new Dictionary <string, object>();

            // AssetBundle does not use hot reload at the moment.
            if (isHotReload)
            {
                return(dict);
            }

            var dirPath = pack.GetPathForCategory <AssetBundleCategory>();

            if (!pack.DirectoryExists(dirPath))
            {
                return(dict);
            }

            var fileQuery = pack.GetFiles(dirPath)
                            .Where(x => !x.EndsWith(".meta") &&
                                   !x.EndsWith(".manifest"));

            foreach (var bundlePath in fileQuery)
            {
                try
                {
                    string name = Path.GetFileName(bundlePath);

                    if (pack.LoadAssetBundle(dirPath, name) is AssetBundle bundle)
                    {
                        pack.AssetBundles.Add(name, bundle);

                        dict.Add(bundlePath, bundle);
                        SL.Log("Loaded assetbundle " + name);
                    }
                    else
                    {
                        throw new Exception($"Unknown error (Bundle '{Path.GetFileName(bundlePath)}' was null)");
                    }
                }
                catch (Exception e)
                {
                    SL.LogError("Error loading asset bundle! Message: " + e.Message + "\r\nStack: " + e.StackTrace);
                }
            }

            return(dict);
        }
        public static void ParseAllEffects()
        {
            var parsedIdentifiers = new List <string>();

            string dir = Serializer.Folders.Effects;

            if (References.RPM_EFFECT_PRESETS is Dictionary <int, EffectPreset> dict)
            {
                SL.Log("Parsing " + dict.Count + " EffectPresets!");

                foreach (EffectPreset preset in dict.Values)
                {
                    if (preset is ImbueEffectPreset imbuePreset)
                    {
                        var name     = imbuePreset.Name?.Trim();
                        var template = DM_ImbueEffect.ParseImbueEffect(imbuePreset);
                        ListManager.ImbueEffects.Add(template.StatusID.ToString(), template);
                        Serializer.SaveToXml(dir, name, template);
                    }
                    else if (preset.GetComponent <StatusEffect>() is StatusEffect status)
                    {
                        if (string.IsNullOrEmpty(status.IdentifierName) || parsedIdentifiers.Contains(status.IdentifierName))
                        {
                            continue;
                        }
                        var name = status.IdentifierName;
                        parsedIdentifiers.Add(status.IdentifierName);

                        var template = ParseStatusEffect(status);
                        ListManager.Effects.Add(template.PresetID.ToString(), template);
                        Serializer.SaveToXml(dir, name, template);
                    }
                }
            }
            else
            {
                SL.LogError("Could not find Effect Prefabs!");
            }

            int manualID = 1000;

            if (References.RPM_STATUS_EFFECTS is Dictionary <string, StatusEffect> statusDict)
            {
                SL.Log("Parsing " + statusDict.Count + " StatusEffect Prefabs! (before dupe check)");

                foreach (var status in statusDict.Values)
                {
                    //SL.Log(status.name);

                    if (string.IsNullOrEmpty(status.IdentifierName) || parsedIdentifiers.Contains(status.IdentifierName))
                    {
                        continue;
                    }

                    var template = ParseStatusEffect(status);

                    if (!string.IsNullOrEmpty(template.Name?.Trim()))
                    {
                        if (template.PresetID == -1)
                        {
                            manualID++;
                            template.PresetID = manualID;
                        }

                        ListManager.Effects.Add(template.PresetID.ToString(), template);
                        Serializer.SaveToXml(dir, status.IdentifierName, template);
                    }
                }
            }
        }