MiniRPG/scripts/loaders/MoveLoader.cs

19 lines
No EOL
512 B
C#

using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
public static class MoveLoader
{
public static List<Move> LoadMoves(string path)
{
if (!File.Exists(path)){
Console.WriteLine("Move data file not found!");
return new List<Move>();
}
string json = File.ReadAllText(path);
List<Move> moves = JsonConvert.DeserializeObject<List<Move>>(json) ?? new List<Move>();
return moves ?? new List<Move>();
}
}