using System.Collections; using System.Collections.Generic; using UnityEngine; public class BuildingGridNode { GridXZ grid; int x, z; private Transform transform; public BuildingGridNode(GridXZ grid, int x, int z) { this.grid = grid; this.x = x; this.z = z; } public void SetTransform(Transform transform) { this.transform = transform; grid.TriggerGridObjectChanged(x, z); } public void ClearTransform() { this.transform = null; grid.TriggerGridObjectChanged(x, z); } // Needs to be aböe to replace with corner transfom depending on other placed transform and the new one public bool CanBuild(PlacedObjectTypeSO newObject) { if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()) return false; // Check if over UI element /* This is not working, can't compare the rotations yet BuildingGridNode bgn = grid.GetGridObject(x, z); if (bgn != null) { Debug.Log("building Grid Node rotation" + bgn + " new Object Visual Rotation " + newObject.visual.rotation + " new Object Prefab Rotation " + newObject.prefab.rotation); } Debug.Log(transform != null ? transform.gameObject.GetType() : ""); if (transform != null) { if (transform.childCount > 0) { for (int i = 0; i < transform.childCount; i++) { if (transform.GetChild(i).rotation == newObject.prefab.transform.rotation) { Debug.Log("transform rotation " + transform.GetChild(i).rotation + " newObject rotation " + newObject.prefab.rotation); return false; } } return true; } } */ return transform == null; } public override string ToString() { return x + ", " + z + " \n" + transform; } }