From aa84cb62bebb9c8a4e586bcc1ec28eb7a16a8860 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期一, 26 一月 2026 18:10:34 +0800
Subject: [PATCH] 422 子 【内政】命格系统 / 【内政】命格系统-客户端

---
 Main/System/Battle/BattleObject/BattleObjectFactory.cs |   48 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/Main/System/Battle/BattleObject/BattleObjectFactory.cs b/Main/System/Battle/BattleObject/BattleObjectFactory.cs
index e9668f3..d991f1d 100644
--- a/Main/System/Battle/BattleObject/BattleObjectFactory.cs
+++ b/Main/System/Battle/BattleObject/BattleObjectFactory.cs
@@ -1,4 +1,3 @@
-
 using System.Collections.Generic;
 using System;
 using UnityEngine;
@@ -11,7 +10,7 @@
 
     private static float m_modelScaleRate = 0f;
 
-    private static float modelScaleRate
+    public static float modelScaleRate
     {
         get
         {
@@ -25,16 +24,27 @@
     //  杩欓噷鎶ラ敊浜嗘鏌ヤ竴涓�
     public static BattleObject CreateBattleObject(BattleField _battleField, List<GameObject> posNodeList, TeamHero teamHero, BattleCamp _Camp)
     {
-        HeroSkinConfig skinCfg = teamHero.skinConfig;
+        var skinCfg = HeroSkinConfig.Get(teamHero.SkinID);
         if (skinCfg == null)
         {
-            Debug.LogError(teamHero.heroId + "BattleObjectFactory.CreateBattleObject: skinCfg is null for " + teamHero.SkinID);
+            Debug.LogError($"BattleObjectFactory: skinCfg is null for SkinID {teamHero.SkinID}");
             return null;
         }
 
+        // ===== 鐩存帴鍔犺浇璧勬簮锛堥潪棰勫姞杞界殑璧勬簮涓嶈蛋缂撳瓨绯荤粺锛�=====
+        SkeletonDataAsset skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>(
+            "Hero/SpineRes/", 
+            skinCfg.SpineRes
+        );
+        
+        if (skeletonDataAsset == null)
+        {
+            Debug.LogError($"BattleObjectFactory: Failed to load SkeletonDataAsset for {skinCfg.SpineRes}");
+            return null;
+        }
+        // ==============================================
+
         GameObject battleGO = ResManager.Instance.LoadAsset<GameObject>("Hero/SpineRes", "Hero_001"/*skinCfg.SpineRes*/);
-
-
 
         GameObject goParent = posNodeList[teamHero.positionNum];
         BattleObject battleObject = new BattleObject(_battleField);
@@ -43,24 +53,36 @@
         GameObject realGO = GameObject.Instantiate(battleGO, goParent.transform);
         SkeletonAnimation skeletonAnimation = realGO.GetComponentInChildren<SkeletonAnimation>(true);
 
-        var skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("Hero/SpineRes/", skinCfg.SpineRes);
-        if (skeletonDataAsset == null)
-        {
-            Debug.LogError("BattleObjectFactory.CreateBattleObject: skeletonDataAsset is null for " + skinCfg.SpineRes);
-            return null;
-        }
-
 
         float finalScaleRate = modelScaleRate * teamHero.modelScale;
 
+        skeletonAnimation.initialSkinName = skinCfg.InitialSkinName;
         skeletonAnimation.skeletonDataAsset = skeletonDataAsset;
         skeletonAnimation.Initialize(true);
+
+        // 鍒濆鍖栧畬鎴愬悗璁剧疆鐨偆
+        if (!string.IsNullOrEmpty(skinCfg.InitialSkinName))
+        {
+            var skeleton = skeletonAnimation.Skeleton;
+            skeleton.SetSkin(skinCfg.InitialSkinName);
+            skeleton.SetSlotsToSetupPose();
+            skeletonAnimation.Update(0);
+        }
+
         realGO.name = battleObject.ObjID.ToString();
         realGO.transform.localScale = new Vector3(finalScaleRate, finalScaleRate, finalScaleRate);
         RectTransform rectTrans = realGO.GetComponent<RectTransform>();
         rectTrans.anchoredPosition = Vector2.zero;
         battleObject.Init(realGO, teamHero, _Camp);
 
+#if UNITY_EDITOR
+        BattleDebug.LogError(
+            "鍒濆鍖� 鏈鍔�" +
+            (battleObject.Camp == BattleCamp.Red ? "銆愮孩鏂广��" : "銆愯摑鏂广�� ") +
+            $"姝﹀皢: {battleObject.teamHero.name}\n" +
+            $"褰撳墠琛�閲�: {battleObject.teamHero.curHp} -> 鏈�澶ц閲弡battleObject.teamHero.maxHp}\n"
+        );
+#endif
 
         return battleObject;
     }

--
Gitblit v1.8.0