yyl
2026-02-11 3f2cd27c5dfb3b450245bf1a37fc1b3414031c7c
Main/System/Battle/BattleField/BattleField.cs
@@ -5,6 +5,7 @@
using DG.Tweening;
using System.IO;
using System.Linq;
using Cysharp.Threading.Tasks;
public class BattleField
@@ -87,7 +88,9 @@
    {
        guid = _guid;
        #pragma warning disable CS0618 // Obsolete — sync legacy constructor, use CreateAsync for new code
        GameObject go = ResManager.Instance.LoadAsset<GameObject>("Battle/Prefabs", "BattleRootNode");
        #pragma warning restore CS0618
        GameObject battleRootNodeGO = GameObject.Instantiate(go);
        battleRootNode = battleRootNodeGO.GetComponent<BattleRootNode>();
        battleRootNodeGO.name = this.GetType().Name;
@@ -98,6 +101,33 @@
        recordPlayer = new RecordPlayer();
        soundManager = new BattleSoundManager(this);
        processingDeathObjIds = new HashSet<uint>();
    }
    /// <summary>
    /// US2: Static async factory method. Creates BattleField with async resource loading.
    /// </summary>
    public static async UniTask<BattleField> CreateAsync(string _guid)
    {
        var field = new BattleField(_guid, skipResourceLoad: true);
        GameObject go = await ResManager.Instance.LoadAssetAsync<GameObject>("Battle/Prefabs", "BattleRootNode");
        GameObject battleRootNodeGO = GameObject.Instantiate(go);
        field.battleRootNode = battleRootNodeGO.GetComponent<BattleRootNode>();
        battleRootNodeGO.name = field.GetType().Name;
        return field;
    }
    /// <summary>
    /// US2: Protected constructor without resource loading (for async factory).
    /// </summary>
    protected BattleField(string _guid, bool skipResourceLoad)
    {
        guid = _guid;
        battleObjMgr = new BattleObjMgr();
        battleEffectMgr = new BattleEffectMgr();
        battleTweenMgr = new BattleTweenMgr();
        recordPlayer = new RecordPlayer();
        soundManager = new BattleSoundManager(this);
        processingDeathObjIds = new HashSet<uint>();
    }
@@ -302,7 +332,22 @@
        BattleMapConfig battleMapConfig = BattleMapConfig.Get(mapID);
        if (battleMapConfig != null)
        {
        #pragma warning disable CS0618 // Obsolete — sync legacy fallback, use LoadMapAsync
            Texture texture = ResManager.Instance.LoadAsset<Texture>("Texture/FullScreenBg", battleMapConfig.MapBg);
        #pragma warning restore CS0618
            battleRootNode.SetBackground(texture);
        }
    }
    /// <summary>
    /// US2: Async map loading.
    /// </summary>
    protected virtual async UniTask LoadMapAsync(int mapID)
    {
        BattleMapConfig battleMapConfig = BattleMapConfig.Get(mapID);
        if (battleMapConfig != null)
        {
            Texture texture = await ResManager.Instance.LoadAssetAsync<Texture>("Texture/FullScreenBg", battleMapConfig.MapBg);
            battleRootNode.SetBackground(texture);
        }
    }