コード例 #1
0
        public ITable[] GetRecords(Type type, RAFFileEntry[] entries)
        {
            List <ITable> records = new List <ITable>();

            foreach (var entry in entries)
            {
                var inibin = new InibinFile(new MemoryStream(entry.GetContent(true)));

                var record = (ITable)Activator.CreateInstance(type);
                foreach (var property in type.GetProperties())
                {
                    var attribute2 = property.GetCustomAttribute <InibinFieldFileName>();

                    if (attribute2 != null)
                    {
                        property.SetValue(record, Convert.ChangeType(Path.GetFileNameWithoutExtension(entry.Path), property.PropertyType));
                    }

                    var attribute = property.GetCustomAttribute <InibinFieldAttribute>();

                    if (attribute != null)
                    {
                        foreach (InibinFlags flag in Enum.GetValues(typeof(InibinFlags)))
                        {
                            if (inibin.Sets.ContainsKey(flag))
                            {
                                if (inibin.Sets[flag].Properties.ContainsKey((uint)attribute.hash))
                                {
                                    var value = inibin.Sets[flag].Properties[(uint)attribute.hash];
                                    value = FieldSanitizer.Sanitize(value.ToString(), property.PropertyType);

                                    try
                                    {
                                        property.SetValue(record, Convert.ChangeType(value.ToString(), property.PropertyType));
                                    }
                                    catch
                                    {
                                        logger.Write("Unable to assign field (" + property.Name + ") to value :" + value + " for " + Path.GetFileNameWithoutExtension(entry.Path), MessageState.WARNING);
                                    }
                                }
                                else
                                {
                                    //   logger.Write(entry.Path + " has no value for" + property.Name, MessageState.WARNING);
                                }
                            }
                        }
                    }
                }

                records.Add(record);
            }

            return(records.ToArray());
        }
コード例 #2
0
        static void InibinTest()
        {
            InibinFile inibin = new InibinFile("Aatrox_Skin02_Passive_Death_Activate.troybin");

            inibin.AddValue("Attack", "e-xrgba", 5);
            inibin.AddValue("Attack", "kek", 10);
            inibin.AddValue("Attack", "lol", 25d);
            inibin.AddValue("Attack", "chewy", true);
            inibin.AddValue("Attack", "crauzer", false);
            inibin.AddValue("Attack", "vector3", new float[3]);
            inibin.Write("bestInibinMapskins.inibin");
        }
コード例 #3
0
        private void GenerateModelDefinitions(Logger logger)
        {
            foreach (RAFFileListEntry f in inibins)
            {
                InibinFile iniFile    = new InibinFile();
                bool       readResult = InibinReader.Read(f, ref iniFile, logger);

                if (readResult == true)
                {
                    // Add the models from this .inibin file
                    List <ModelDefinition> modelDefs = iniFile.GetModelStrings();
                    for (int j = 0; j < modelDefs.Count; ++j)
                    {
                        // Name the model after the parent directory
                        // of the .inibin plus the name from the .inibin.
                        // Some things overlap without both.

                        string   path      = f.FileName;
                        string[] splitPath = path.Split('/');

                        string directoryName = splitPath[splitPath.Length - 2];
                        if (directoryName.Contains("Base") == true ||
                            directoryName.Contains("Skin") == true)
                        {
                            // The directory structure for this case will be something like
                            // "*/ChampionName/Skins/Base/".
                            // We just want the "ChampionName".
                            directoryName = splitPath[splitPath.Length - 4];
                        }

                        // Sometimes the name from the .inibin file is "".
                        // So, just name it after the directory
                        String name = modelDefs[j].name;
                        if (name == "")
                        {
                            name = directoryName + "/" + directoryName;
                        }
                        else
                        {
                            name = directoryName + "/" + name;
                        }

                        try
                        {
                            LOLModel model;
                            bool     storeResult = StoreModel(modelDefs[j], out model, logger);

                            if (storeResult == true)
                            {
                                // Try to store animations for model as well
                                storeResult = StoreAnimations(ref model, logger);
                            }

                            if (storeResult == true)
                            {
                                if (models.ContainsKey(name) == false)
                                {
                                    logger.Event("Adding model definition: " + name);
                                    models.Add(name, model);
                                }
                                else
                                {
                                    logger.Warning("Duplicate model definition: " + name);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            logger.Error("Unable to store model definition: " + name);
                            logger.Error(e.Message);
                        }
                    }
                }
            }
        }