diff --git a/Assets/Scripts/BuildingManager.cs b/Assets/Scripts/BuildingManager.cs
index 1d48091..20f8778 100644
--- a/Assets/Scripts/BuildingManager.cs
+++ b/Assets/Scripts/BuildingManager.cs
@@ -185,7 +185,7 @@ namespace Northbound
///
/// 건물 배치 요청 (클라이언트에서 호출)
///
- public void RequestPlaceBuilding(int buildingIndex, Vector3 position, int rotation)
+ public void RequestPlaceBuilding(string buildingDataName, Vector3 position, int rotation)
{
if (!NetworkManager.Singleton.IsClient)
{
@@ -194,11 +194,11 @@ namespace Northbound
}
ulong clientId = NetworkManager.Singleton.LocalClientId;
- PlaceBuildingServerRpc(buildingIndex, position, rotation, clientId);
+ PlaceBuildingServerRpc(buildingDataName, position, rotation, clientId);
}
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
- private void PlaceBuildingServerRpc(int buildingIndex, Vector3 position, int rotation, ulong requestingClientId)
+ private void PlaceBuildingServerRpc(string buildingDataName, Vector3 position, int rotation, ulong requestingClientId)
{
// 보안 검증 1: 유효한 클라이언트인지 확인
if (!NetworkManager.Singleton.ConnectedClients.ContainsKey(requestingClientId))
@@ -206,17 +206,18 @@ namespace Northbound
return;
}
- // 보안 검증 2: 건물 인덱스 유효성 확인
- if (buildingIndex < 0 || buildingIndex >= availableBuildings.Count)
+ // 보안 검증 2: 건물 데이터 찾기 (이름으로 검색)
+ TowerData data = availableBuildings.Find(b => b != null && b.name == buildingDataName);
+ if (data == null)
{
+ Debug.LogWarning($"[BuildingManager] 건물 데이터를 찾을 수 없습니다: {buildingDataName}");
return;
}
- TowerData data = availableBuildings[buildingIndex];
-
- // 보안 검증 3: 건물 데이터 유효성 확인
- if (data == null || data.prefab == null)
+ // 보안 검증 3: 프리팹 확인
+ if (data.prefab == null)
{
+ Debug.LogWarning($"[BuildingManager] 건물 프리팹이 없습니다: {buildingDataName}");
return;
}
@@ -342,7 +343,7 @@ namespace Northbound
///
/// 건물 토대 배치 요청 (클라이언트에서 호출)
///
- public void RequestPlaceFoundation(int buildingIndex, Vector3 position, int rotation)
+ public void RequestPlaceFoundation(string buildingDataName, Vector3 position, int rotation)
{
if (!NetworkManager.Singleton.IsClient)
{
@@ -351,11 +352,11 @@ namespace Northbound
}
ulong clientId = NetworkManager.Singleton.LocalClientId;
- PlaceFoundationServerRpc(buildingIndex, position, rotation, clientId);
+ PlaceFoundationServerRpc(buildingDataName, position, rotation, clientId);
}
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
- private void PlaceFoundationServerRpc(int buildingIndex, Vector3 position, int rotation, ulong requestingClientId)
+ private void PlaceFoundationServerRpc(string buildingDataName, Vector3 position, int rotation, ulong requestingClientId)
{
// 보안 검증 1: 유효한 클라이언트인지 확인
if (!NetworkManager.Singleton.ConnectedClients.ContainsKey(requestingClientId))
@@ -363,17 +364,11 @@ namespace Northbound
return;
}
- // 보안 검증 2: 건물 인덱스 유효성 확인
- if (buildingIndex < 0 || buildingIndex >= availableBuildings.Count)
- {
- return;
- }
-
- TowerData data = availableBuildings[buildingIndex];
-
- // 보안 검증 3: 건물 데이터 유효성 확인
+ // 보안 검증 2: 건물 데이터 찾기 (이름으로 검색)
+ TowerData data = availableBuildings.Find(b => b != null && b.name == buildingDataName);
if (data == null)
{
+ Debug.LogWarning($"[BuildingManager] 건물 데이터를 찾을 수 없습니다: {buildingDataName}");
return;
}
diff --git a/Assets/Scripts/BuildingPlacement.cs b/Assets/Scripts/BuildingPlacement.cs
index 24cb728..f2643c4 100644
--- a/Assets/Scripts/BuildingPlacement.cs
+++ b/Assets/Scripts/BuildingPlacement.cs
@@ -603,7 +603,7 @@ namespace Northbound
var coreResourceManager = CoreResourceManager.Instance;
if (coreResourceManager == null || coreResourceManager.CanAfford(selectedData.mana))
{
- BuildingManager.Instance.RequestPlaceFoundation(selectedBuildingIndex, groundPosition, currentRotation);
+ BuildingManager.Instance.RequestPlaceFoundation(selectedData.name, groundPosition, currentRotation);
}
}
}
@@ -620,7 +620,7 @@ namespace Northbound
foreach (var position in dragBuildingPositions)
{
- BuildingManager.Instance.RequestPlaceFoundation(selectedBuildingIndex, position, currentRotation);
+ BuildingManager.Instance.RequestPlaceFoundation(selectedData.name, position, currentRotation);
}
}
@@ -659,8 +659,8 @@ namespace Northbound
if (BuildingManager.Instance.IsValidPlacement(selectedData, hit.point, currentRotation, out Vector3 groundPosition))
{
- // 토대 배치 요청
- BuildingManager.Instance.RequestPlaceFoundation(selectedBuildingIndex, groundPosition, currentRotation);
+ // 토대 배치 요청 (건물 이름 사용)
+ BuildingManager.Instance.RequestPlaceFoundation(selectedData.name, groundPosition, currentRotation);
}
}
}