건설 인터랙션 관련 버그 수정 및 건설 데이터 구조 개선
건설 인터랙션 시 움직이지 못하는 문제 수정 2개로 분리되어 있던 타워 데이터를 하나로 통합 - 대신 타워가 아닌 건물도 공격력 등을 정의할 수 있음
This commit is contained in:
@@ -123,10 +123,9 @@ namespace Northbound.Editor
|
||||
}
|
||||
|
||||
// If towers were imported, auto-configure BuildingManager
|
||||
// TowerData now extends BuildingData, so it can be used directly!
|
||||
if (typeName == "Tower")
|
||||
{
|
||||
Debug.Log($"<color=cyan>[CSVToSOImporter] Tower import complete, TowerData extends BuildingData now!</color>");
|
||||
Debug.Log($"<color=cyan>[CSVToSOImporter] Tower import complete!</color>");
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -203,10 +202,10 @@ namespace Northbound.Editor
|
||||
}
|
||||
|
||||
// Now set the prefab reference on data
|
||||
if (data is BuildingData buildingData)
|
||||
if (data is TowerData towerData)
|
||||
{
|
||||
buildingData.prefab = prefabObj;
|
||||
Debug.Log($"[CSVToSOImporter] Set prefab reference: {buildingData.name} -> {prefabObj.name}");
|
||||
towerData.prefab = prefabObj;
|
||||
Debug.Log($"[CSVToSOImporter] Set prefab reference: {towerData.name} -> {prefabObj.name}");
|
||||
}
|
||||
|
||||
// Save data asset
|
||||
@@ -236,9 +235,9 @@ namespace Northbound.Editor
|
||||
return;
|
||||
}
|
||||
|
||||
// Load TowerData (which extends BuildingData)
|
||||
// Load TowerData
|
||||
string[] towerDataGuids = AssetDatabase.FindAssets("t:TowerData", new[] { "Assets/Data/ScriptableObjects" });
|
||||
List<BuildingData> allTowers = new List<BuildingData>();
|
||||
List<TowerData> allTowers = new List<TowerData>();
|
||||
|
||||
Debug.Log($"<color=cyan>[CSVToSOImporter] Found {towerDataGuids.Length} TowerData assets</color>");
|
||||
|
||||
|
||||
@@ -84,6 +84,15 @@ namespace Northbound.Editor
|
||||
Debug.Log($"[PlayerPrefabSetup] Updated PlayerResourceInventory: maxResourceCapacity={playerData.capacity}");
|
||||
}
|
||||
|
||||
var playerInteraction = prefab.GetComponent<PlayerInteraction>();
|
||||
if (playerInteraction != null)
|
||||
{
|
||||
SerializedObject so = new SerializedObject(playerInteraction);
|
||||
so.FindProperty("workPower").floatValue = playerData.manpower;
|
||||
so.ApplyModifiedProperties();
|
||||
Debug.Log($"[PlayerPrefabSetup] Updated PlayerInteraction: workPower={playerData.manpower}");
|
||||
}
|
||||
|
||||
EditorUtility.SetDirty(prefab);
|
||||
PrefabUtility.SavePrefabAsset(prefab);
|
||||
Debug.Log($"[PlayerPrefabSetup] Player prefab updated successfully from {playerData.name}");
|
||||
|
||||
@@ -159,9 +159,6 @@ namespace Northbound.Editor
|
||||
if (go.GetComponent<Building>() == null)
|
||||
go.AddComponent<Building>();
|
||||
|
||||
if (go.GetComponent<TowerDataComponent>() == null)
|
||||
go.AddComponent<TowerDataComponent>();
|
||||
|
||||
if (go.GetComponent<BoxCollider>() == null)
|
||||
{
|
||||
BoxCollider collider = go.AddComponent<BoxCollider>();
|
||||
|
||||
@@ -30,10 +30,10 @@ namespace Northbound.Editor
|
||||
{
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
|
||||
TowerDataComponent tower = prefab?.GetComponent<TowerDataComponent>();
|
||||
string towerStatus = tower != null && tower.towerData != null ? "<color=green>✓</color>" : "<color=red>✗</color>";
|
||||
string towerDataName = tower?.towerData?.name ?? "MISSING";
|
||||
Debug.Log($" {towerStatus} {prefab.name} - TowerDataComponent: {tower != null}, TowerData: {towerDataName}");
|
||||
Building building = prefab?.GetComponent<Building>();
|
||||
string towerStatus = building != null && building.buildingData != null ? "<color=green>✓</color>" : "<color=red>✗</color>";
|
||||
string towerDataName = building?.buildingData?.name ?? "MISSING";
|
||||
Debug.Log($" {towerStatus} {prefab.name} - Building: {building != null}, TowerData: {towerDataName}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,24 +20,9 @@ namespace Northbound.Editor
|
||||
return;
|
||||
}
|
||||
|
||||
var towerDataComponent = prefab.GetComponent<TowerDataComponent>();
|
||||
if (towerDataComponent == null)
|
||||
{
|
||||
towerDataComponent = prefab.AddComponent<TowerDataComponent>();
|
||||
Debug.Log($"[TowerPrefabSetup] Added TowerDataComponent component");
|
||||
}
|
||||
|
||||
if (towerDataComponent != null)
|
||||
{
|
||||
towerDataComponent.towerData = towerData;
|
||||
}
|
||||
|
||||
// TowerData now extends BuildingData, so set prefab reference
|
||||
// Set prefab reference
|
||||
towerData.prefab = prefab;
|
||||
|
||||
// Ensure TowerData fields are synced to BuildingData
|
||||
towerData.EnsureSynced();
|
||||
|
||||
Transform modelTransform = null;
|
||||
|
||||
if (!string.IsNullOrEmpty(towerData.modelPath))
|
||||
|
||||
Reference in New Issue
Block a user