mirror of
				https://github.com/DerTyp7/industrialize-unity.git
				synced 2025-10-31 05:17:10 +01:00 
			
		
		
		
	conveyorPO
This commit is contained in:
		| @@ -1,4 +1,5 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using UnityEngine; | ||||
|  | ||||
| public class Grid<TGridObject> | ||||
| @@ -47,6 +48,32 @@ public class Grid<TGridObject> | ||||
|  | ||||
|     } | ||||
|  | ||||
|     public List<TGridObject> GetGridObjectsAround(Vector3 position) | ||||
|     { | ||||
|         List<TGridObject> gridObjects = new List<TGridObject>(); | ||||
|  | ||||
|         GetXY(position, out int x, out int y); | ||||
|  | ||||
|         if (x - 1 >= 0) | ||||
|         { | ||||
|             gridObjects.Add(gridArray[x - 1, y]); | ||||
|         } | ||||
|         if (x + 1 < width) | ||||
|         { | ||||
|             gridObjects.Add(gridArray[x + 1, y]); | ||||
|         } | ||||
|         if (y - 1 >= 0) | ||||
|         { | ||||
|             gridObjects.Add(gridArray[x, y - 1]); | ||||
|         } | ||||
|         if (y + 1 < height) | ||||
|         { | ||||
|             gridObjects.Add(gridArray[x, y + 1]); | ||||
|         } | ||||
|  | ||||
|         return gridObjects; | ||||
|     } | ||||
|  | ||||
|     public Vector3 GetWorldPosition(int x, int y) | ||||
|     { | ||||
|         return new Vector3(x, y) * cellSize + originPosition; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Janis
					Janis