From fe3c8a5515acdfcc50913d5b83de8f9504e95b73 Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Sat, 23 Dec 2023 23:21:22 +0000
Subject: [PATCH] Added map save/load + seed generation

---
 Assets/Scripts/Helpers/VectorHelper.cs |   89 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 76 insertions(+), 13 deletions(-)

diff --git a/Assets/Scripts/Helpers/VectorHelper.cs b/Assets/Scripts/Helpers/VectorHelper.cs
index 6e72915..75b92d0 100644
--- a/Assets/Scripts/Helpers/VectorHelper.cs
+++ b/Assets/Scripts/Helpers/VectorHelper.cs
@@ -1,5 +1,7 @@
 using System;
+using System.Collections.Generic;
 using System.Reflection;
+using Unity.VisualScripting.Dependencies.NCalc;
 using UnityEngine;
 using static UnityEngine.Rendering.DebugUI;
 
@@ -19,19 +21,6 @@
             result[0] = value.x;
             result[1] = value.y;
             result[2] = value.z;
-            return result;
-        }
-
-        /// <summary>
-        /// Will get a float array for a given vector2 value
-        /// </summary>
-        /// <param name="value"></param>
-        /// <returns>float[x,y]</returns>
-        public static float[] ConvertToFloatArray(this Vector2 value)
-        {
-            float[] result = new float[2];
-            result[0] = value.x;
-            result[1] = value.y;
             return result;
         }
 
@@ -57,6 +46,19 @@
         }
 
         /// <summary>
+        /// Will get a float array for a given vector2 value
+        /// </summary>
+        /// <param name="value"></param>
+        /// <returns>float[x,y]</returns>
+        public static float[] ConvertToFloatArray(this Vector2 value)
+        {
+            float[] result = new float[2];
+            result[0] = value.x;
+            result[1] = value.y;
+            return result;
+        }
+
+        /// <summary>
         /// Will get a vector2 for a given float array value
         /// </summary>
         /// <param name="value"></param>
@@ -75,5 +77,66 @@
             }
             return result;
         }
+
+        /// <summary>
+        /// Will get a float array for a given vector2 value
+        /// </summary>
+        /// <param name="value"></param>
+        /// <returns>float[x,y]</returns>
+        public static List<int[]> ConvertToListIntArray(this List<Vector3Int> value)
+        {
+            List<int[]> result = new List<int[]>();
+            for (int i = 0; i < value.Count; i++)
+            {
+                int[] intVector = new int[2];
+                intVector[0] = value[i].x;
+                intVector[1] = value[i].y;
+                result.Add(intVector);
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// Will get a vector2 for a given float array value
+        /// </summary>
+        /// <param name="value"></param>
+        /// <returns>Vector2</returns>
+        public static List<Vector3Int> ConvertToVector3Int(this List<int[]> value)
+        {
+            List<Vector3Int> result = new List<Vector3Int>();
+            if (value != null && value.Count > 0)
+            {
+                for (int i = 0; i < value.Count; i++)
+                {
+                    Vector3Int vector = new Vector3Int();
+                    vector.x = value[0][0];
+                    vector.y = value[0][1];
+                    result.Add(vector);
+                }
+
+            }
+            return result;
+        }
+
+        public static Vector3Int ConvertToVector3Int(this int[] value)
+        {
+            Vector3Int result = new Vector3Int();
+            switch (value.Length)
+            {
+                case 2:
+                    result.x = value[0];
+                    result.y = value[1];
+                    break;
+                case 3:
+                    result.x = value[0];
+                    result.y = value[1];
+                    result.z = value[2];
+                    break;
+                default:
+                    Debug.Assert(false, "ConvertToVector3Int() got wrong array size, expected size is 2 or 3. recieved size: " + value.Length);
+                    break;
+            }
+            return result;
+        }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3