diff --git a/CHANGELOG.md b/CHANGELOG.md
index aea3067..ad707a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,7 @@ Additions
- Added GetFlags and GetUniqueFlags to EnumHelper
- Added GetDownTime, GetUpTime, GetTimeSincePress, WasModifierDown and WasDown to Keybind and Combination
- Added the ability for UniformTextureAtlases to have padding for each region
+- Added UniformTextureAtlas methods ToList and ToDictionary
- **Added the ability to find paths to one of multiple goals using AStar**
Improvements
@@ -73,6 +74,7 @@ Additions
- Added data, from, and copy instructions to DataTextureAtlas
- Added the ability to add additional regions to a RuntimeTexturePacker after packing
- Added GetFlags, GetUniqueFlags and IsDefined to DynamicEnum
+- Added DataTextureAtlas.ToDictionary
Improvements
- Allow data texture atlas pivots and offsets to be negative
diff --git a/MLEM.Data/DataTextureAtlas.cs b/MLEM.Data/DataTextureAtlas.cs
index e163e72..d7ca8f8 100644
--- a/MLEM.Data/DataTextureAtlas.cs
+++ b/MLEM.Data/DataTextureAtlas.cs
@@ -72,6 +72,15 @@ namespace MLEM.Data {
this.Texture = texture;
}
+ ///
+ /// Converts this data texture atlas to a and returns the result.
+ /// The resulting dictionary will contain all named regions that this data texture atlas contains.
+ ///
+ /// The dictionary representation of this data texture atlas.
+ public Dictionary ToDictionary() {
+ return new Dictionary(this.regions);
+ }
+
///
/// Loads a from the given loaded texture and texture data file.
/// For more information on data texture atlases, see the type documentation.
diff --git a/MLEM/Textures/UniformTextureAtlas.cs b/MLEM/Textures/UniformTextureAtlas.cs
index a67867f..d91fabe 100644
--- a/MLEM/Textures/UniformTextureAtlas.cs
+++ b/MLEM/Textures/UniformTextureAtlas.cs
@@ -94,6 +94,32 @@ namespace MLEM.Textures {
public UniformTextureAtlas(Texture2D texture, int regionAmountX, int regionAmountY, int regionPadding = 0) :
this(new TextureRegion(texture), regionAmountX, regionAmountY, regionPadding) {}
+ ///
+ /// Converts this uniform texture atlas to a and returns the result.
+ /// The resulting list will contain all square 1x1 regions that this uniform texture atlas contains, based on and , with each index containing the at .
+ ///
+ /// The list representation of this uniform texture atlas.
+ public List ToList() {
+ var ret = new List();
+ for (var i = 0; i < this.RegionAmountX * this.RegionAmountY; i++)
+ ret.Add(this[i]);
+ return ret;
+ }
+
+ ///
+ /// Converts this uniform texture atlas to a and returns the result.
+ /// The resulting dictionary will contain all square 1x1 regions that this uniform texture atlas contains, based on and , wich each key containing the at .
+ ///
+ /// The dictionary representation of this uniform texture atlas.
+ public Dictionary ToDictionary() {
+ var ret = new Dictionary();
+ for (var x = 0; x < this.RegionAmountX; x++) {
+ for (var y = 0; y < this.RegionAmountY; y++)
+ ret.Add(new Point(x, y), this[x, y]);
+ }
+ return ret;
+ }
+
private TextureRegion GetOrAddRegion(Rectangle rect) {
if (this.regions.TryGetValue(rect, out var region))
return region;