Exemplo n.º 1
0
 public ModMaterial(ModSlot owner)
 {
     Owner       = owner;
     Textures    = new List<ModTex>();
     Colors      = new List<ModCol>();
     Values      = new List<ModValue>();
 }
Exemplo n.º 2
0
        public static ModSrcFile FromFile(string file)
        {
            var data    = new ModSrcFile() { FileName= file };
            var lines   = File.ReadAllLines(file, Encoding.UTF8);
            var delim   = " \t".ToArray();

            foreach(var i in lines)
            {
                var line    = i.Trim();
                var enabled = true;

                if(line.StartsWith("//"))
                {
                    enabled = false;
                    line    = line.Substring(2).Trim();
                }

                var t       = line.Trim().Split(delim, StringSplitOptions.RemoveEmptyEntries);

                if(t.Length == 0)
                    continue;

                switch(t[0])
                {
                case "アイテム変更":
                    break;

                case "スロット名":
                    var slot= new ModSlot(data) { Name= t[1] };
                    data.Slots.Add(slot);
                    break;

                case "マテリアル番号":
                    var mtrl= new ModMaterial(data.CurrentSlot) { No= int.Parse(t[1]) };
                    data.CurrentSlot.Materials.Add(mtrl);
                    break;

                case "テクスチャ設定":
                    var tex = new ModTex()
                    {
                        Enabled = enabled,
                        Name    = t[1],
                        Texture = t[2]
                    };
                    data.CurrentMaterial.Textures.Add(tex);
                    break;

                case "色設定":
                    var col = new ModCol()
                    {
                        Enabled = enabled,
                        Name    = t[1],
                        R       = int.Parse(t[2]),
                        G       = int.Parse(t[3]),
                        B       = int.Parse(t[4]),
                        A       = int.Parse(t[5])
                    };
                    data.CurrentMaterial.Colors.Add(col);
                    break;

                case "数値設定":
                    var val = new ModValue()
                    {
                        Enabled = enabled,
                        Name    = t[1],
                        Value   = decimal.Parse(t[2])
                    };
                    data.CurrentMaterial.Values.Add(val);
                    break;

                default:
                    if(t.Length >= 2)
                        data.Descriptions.Add(t[0], string.Join(" ", t.Skip(1).ToArray()));

                    break;
                }
            }

            return data;
        }