using System.Collections.Generic; using System.IO; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework; using System.Linq; namespace Sledgemapper { public static class ExtensionMethods { public static Dictionary LoadContentFolder(this ContentManager contentManager, string contentFolder) { DirectoryInfo dir = new(contentManager.RootDirectory + "/" + contentFolder); if (!dir.Exists) throw new DirectoryNotFoundException(); Dictionary result = new(); FileInfo[] files = dir.GetFiles("*.*"); foreach (FileInfo file in files) { result.Add(file.Name.Split('.')[0], contentManager.Load(contentFolder + "/" + file.Name.Split('.')[0])); } return result; } public static IEnumerable Split(this string str, int chunkSize) => Enumerable.Range(0, str.Length / chunkSize) .Select(i => str.Substring(i * chunkSize, chunkSize)); public static Point AbsPoint(this Point point) { return new Point(System.Math.Abs(point.X), System.Math.Abs(point.Y)); } } }