mirror of
https://github.com/DerTyp7/harvestdale-unity.git
synced 2025-10-29 20:52:10 +01:00
add gruid buildingsystem
This commit is contained in:
25
Assets/Scripts/BuildingManager.cs
Normal file
25
Assets/Scripts/BuildingManager.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Tilemaps;
|
||||
public class BuildingManager : MonoBehaviour
|
||||
{
|
||||
public static List<Building> buildings { get; private set; } = new List<Building>();
|
||||
|
||||
public static Building GetBuildingByGridPosition(Vector3Int tilePosition)
|
||||
{
|
||||
foreach (Building building in buildings)
|
||||
{
|
||||
PlaceableObject po = building.placeableObject;
|
||||
Vector3Int buildingPosition = building.GetGridPosition();
|
||||
BoundsInt area = new BoundsInt(buildingPosition, po.GetSizeVector());
|
||||
if (area.Contains(tilePosition))
|
||||
{
|
||||
return building;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user