건설 인터랙션 관련 버그 수정 및 건설 데이터 구조 개선
건설 인터랙션 시 움직이지 못하는 문제 수정 2개로 분리되어 있던 타워 데이터를 하나로 통합 - 대신 타워가 아닌 건물도 공격력 등을 정의할 수 있음
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
using Northbound.Data;
|
||||
|
||||
namespace Northbound
|
||||
{
|
||||
@@ -13,7 +14,7 @@ namespace Northbound
|
||||
public LayerMask groundLayer;
|
||||
|
||||
[Header("Building Database")]
|
||||
public List<BuildingData> availableBuildings = new List<BuildingData>();
|
||||
public List<TowerData> availableBuildings = new List<TowerData>();
|
||||
|
||||
[Header("Foundation Settings")]
|
||||
public GameObject foundationPrefab; // 토대 프리팹 (Inspector에서 할당)
|
||||
@@ -58,7 +59,7 @@ namespace Northbound
|
||||
);
|
||||
}
|
||||
|
||||
public bool IsValidPlacement(BuildingData data, Vector3 position, int rotation, out Vector3 groundPosition)
|
||||
public bool IsValidPlacement(TowerData data, Vector3 position, int rotation, out Vector3 groundPosition)
|
||||
{
|
||||
groundPosition = position;
|
||||
|
||||
@@ -71,7 +72,7 @@ namespace Northbound
|
||||
Vector3 snappedPosition = SnapToGrid(groundPosition);
|
||||
groundPosition = snappedPosition; // Update groundPosition to snapped value
|
||||
|
||||
// Overlap check using GRID SIZE from BuildingData (not actual colliders)
|
||||
// Overlap check using GRID SIZE from TowerData (not actual colliders)
|
||||
Vector3 gridSize = data.GetSize(rotation);
|
||||
|
||||
// 프리팹의 실제 배치 위치 계산 (placementOffset 포함)
|
||||
@@ -130,7 +131,7 @@ namespace Northbound
|
||||
/// Get the grid bounds for a building at a given position
|
||||
/// Useful for preview visualization
|
||||
/// </summary>
|
||||
public Bounds GetPlacementBounds(BuildingData data, Vector3 position, int rotation)
|
||||
public Bounds GetPlacementBounds(TowerData data, Vector3 position, int rotation)
|
||||
{
|
||||
Vector3 gridSize = data.GetSize(rotation);
|
||||
// position은 이미 placementOffset이 적용된 위치
|
||||
@@ -183,7 +184,7 @@ namespace Northbound
|
||||
return;
|
||||
}
|
||||
|
||||
BuildingData data = availableBuildings[buildingIndex];
|
||||
TowerData data = availableBuildings[buildingIndex];
|
||||
|
||||
// 보안 검증 3: 건물 데이터 유효성 확인
|
||||
if (data == null || data.prefab == null)
|
||||
@@ -335,7 +336,7 @@ namespace Northbound
|
||||
return;
|
||||
}
|
||||
|
||||
BuildingData data = availableBuildings[buildingIndex];
|
||||
TowerData data = availableBuildings[buildingIndex];
|
||||
|
||||
// 보안 검증 3: 건물 데이터 유효성 확인
|
||||
if (data == null)
|
||||
@@ -427,8 +428,8 @@ namespace Northbound
|
||||
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
|
||||
public void SpawnCompletedBuildingServerRpc(string buildingDataName, Vector3Int gridPosition, int rotation, ulong ownerId, TeamType team)
|
||||
{
|
||||
// BuildingData 찾기
|
||||
BuildingData data = availableBuildings.Find(b => b.name == buildingDataName);
|
||||
// TowerData 찾기
|
||||
TowerData data = availableBuildings.Find(b => b.name == buildingDataName);
|
||||
if (data == null || data.prefab == null)
|
||||
{
|
||||
Debug.LogError($"<color=red>[BuildingManager] 건물 데이터를 찾을 수 없습니다: {buildingDataName}</color>");
|
||||
|
||||
Reference in New Issue
Block a user