Beispiel #1
0
        static void load()
        {
            var fields = TypeLoader.GetFields(typeof(Settings), false);

            var nodes = TextNodeLoader.FromFile(FileExplorer.MainDirectory, "Settings.yaml");

            foreach (var node in nodes)
            {
                switch (node.Key)
                {
                case "Keys":
                    foreach (var key in node.Children)
                    {
                        KeyDictionary.Add(key.Key, KeyInput.ToKey(key.Value));
                    }
                    break;

                default:
                    // null is used for static classes.
                    TypeLoader.SetValue(null, fields, node);

                    break;
                }
            }
        }
Beispiel #2
0
        public static MapType FromSave(GameSave save)
        {
            var size = TextNodeLoader.FromFile(FileExplorer.Saves, save.MapSaveName + ".yaml").First(n => n.Key == "Size").Convert <MPos>();

            var type = save.CurrentMapType;
            var mapGeneratorInfos = type == null ? new IMapGeneratorInfo[0] : type.Generators;

            return(new MapType(save.MapSaveName, 0, size, Color.White, new[] { save.CurrentMission }, new[] { save.CurrentObjective }, -1, 0, int.MaxValue, new TerrainGeneratorInfo(0, new List <TextNode>()), mapGeneratorInfos, CPos.Zero, true, true, save.Script));
        }
        public static Piece ReloadPiece(string name)
        {
            var existingPiece = Pieces.FirstOrDefault(p => p.InnerName == name);

            if (existingPiece != null)
            {
                Pieces.Remove(existingPiece);
            }

            var path  = FileExplorer.FindPath(FileExplorer.Pieces, name, ".yaml");
            var nodes = TextNodeLoader.FromFile(path, name + ".yaml");

            var piece = new Piece(name, path, nodes);

            Pieces.Add(piece);

            return(piece);
        }
        static void searchFiles(string path)
        {
            var files = Directory.GetFiles(path).Where(s => s.EndsWith(".yaml"));

            foreach (var file in files)
            {
                var name = file.Remove(0, file.LastIndexOf(FileExplorer.Separator) + 1);
                name = name.Remove(name.Length - 5);

                var nodes = TextNodeLoader.FromFile(path + FileExplorer.Separator, name + ".yaml");

                Pieces.Add(new Piece(name, path, nodes));
            }

            foreach (var dir in Directory.GetDirectories(path))
            {
                searchFiles(dir);
            }
        }