|
@@ -70,7 +70,7 @@ public class GroundGridControllerScript : MonoBehaviour {
|
|
|
if (x >= 0 && z >= 0) {
|
|
if (x >= 0 && z >= 0) {
|
|
|
List<Vector2Int> gridPositionList = activePlacedObjectTypeSO.GetGridPositionList(new Vector2Int(x, z), dir);
|
|
List<Vector2Int> gridPositionList = activePlacedObjectTypeSO.GetGridPositionList(new Vector2Int(x, z), dir);
|
|
|
|
|
|
|
|
- if (gridPositionList.TrueForAll(p => ((BuildingGridNode)grid.GetGridObject(p.x, p.y)).CanBuild())) {
|
|
|
|
|
|
|
+ if (gridPositionList.TrueForAll(p => ((BuildingGridNode)grid.GetGridObject(p.x, p.y)).CanBuild(activePlacedObjectTypeSO))) {
|
|
|
Vector2Int rotationOffset = activePlacedObjectTypeSO.GetRotationOffset(dir);
|
|
Vector2Int rotationOffset = activePlacedObjectTypeSO.GetRotationOffset(dir);
|
|
|
Vector3 placedObejctWorldPosition = grid.GetWorldPosition(x, z) + new Vector3(rotationOffset.x, 0, rotationOffset.y) * grid.GetCellSize();
|
|
Vector3 placedObejctWorldPosition = grid.GetWorldPosition(x, z) + new Vector3(rotationOffset.x, 0, rotationOffset.y) * grid.GetCellSize();
|
|
|
|
|
|
|
@@ -87,7 +87,7 @@ public class GroundGridControllerScript : MonoBehaviour {
|
|
|
UtilsClass.CreateWorldTextPopup("Connot build here!", GetMousePosition3d());
|
|
UtilsClass.CreateWorldTextPopup("Connot build here!", GetMousePosition3d());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- } else if (Input.GetMouseButtonDown(1)) {
|
|
|
|
|
|
|
+ } else if (Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.Escape)) {
|
|
|
DeselectObjectType();
|
|
DeselectObjectType();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -101,7 +101,7 @@ public class GroundGridControllerScript : MonoBehaviour {
|
|
|
OnSelectedChanged?.Invoke(this, EventArgs.Empty);
|
|
OnSelectedChanged?.Invoke(this, EventArgs.Empty);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private Vector3 GetMousePosition3d() {
|
|
|
|
|
|
|
+ public Vector3 GetMousePosition3d() {
|
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
|
Physics.Raycast(ray, out RaycastHit raycastHit, 999f, mousePlaneLayerMask);
|
|
Physics.Raycast(ray, out RaycastHit raycastHit, 999f, mousePlaneLayerMask);
|
|
|
|
|
|