NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Camp/Camp.cs

64 lines
1.5 KiB
C#
Raw Normal View History

2024-12-10 15:07:14 +08:00
using cfg.CampCfg;
2024-12-10 13:11:17 +08:00
using Cysharp.Threading.Tasks;
2024-12-10 15:07:14 +08:00
using Framework;
using Gameplay.Common;
2024-12-06 18:06:09 +08:00
using PhxhSDK;
2024-12-10 15:07:14 +08:00
using PhxhSDK.Res;
2024-12-06 18:06:09 +08:00
using System.Collections.Generic;
using TGS;
using UnityEngine;
namespace Gameplay.Camp
{
/// <summary>
2024-12-09 13:25:09 +08:00
/// 营地
2024-12-06 18:06:09 +08:00
/// </summary>
2024-12-11 14:07:44 +08:00
public sealed partial class Camp
2024-12-06 18:06:09 +08:00
{
2024-12-10 15:07:14 +08:00
/// <summary>
/// 营地物件根节点
/// </summary>
private Transform tsCampObjectRoot;
2024-12-09 13:25:09 +08:00
2024-12-10 13:11:17 +08:00
public Camp()
2024-12-06 18:06:09 +08:00
{
2024-12-11 15:37:18 +08:00
InitCell();
2024-12-11 14:07:44 +08:00
InitLoad();
InitUnit();
2024-12-11 15:37:18 +08:00
InitEdit();
2024-12-10 13:11:17 +08:00
}
2024-12-11 14:07:44 +08:00
public async UniTask SetInfo(SceneHandle sceneHandle)
2024-12-10 13:11:17 +08:00
{
2024-12-10 15:07:14 +08:00
TerrainGridSystem terrainGridSystem = SceneHandle.GetSceneRootComponent<TerrainGridSystem>(sceneHandle.Scene);
if (null == terrainGridSystem)
{
DebugUtil.LogError($"场景中没有{nameof(TerrainGridSystem)}");
return;
}
GameObject[] gameObjects = sceneHandle.Scene.GetRootGameObjects();
foreach (GameObject goRoot in gameObjects)
{
if ("CampObjects" == goRoot.name)
{
tsCampObjectRoot = goRoot.transform;
break;
}
}
2024-12-11 15:37:18 +08:00
SetInfoByCell(terrainGridSystem);
await SetInfoByLoad();
2024-12-10 17:13:46 +08:00
}
2024-12-11 15:37:18 +08:00
public void Exit()
2024-12-10 15:07:14 +08:00
{
2024-12-11 15:37:18 +08:00
ExitEdit();
ExitUnit();
ExitLoad();
ExitCell();
2024-12-10 15:07:14 +08:00
2024-12-10 17:13:46 +08:00
tsCampObjectRoot = null;
2024-12-10 15:07:14 +08:00
}
2024-12-06 18:06:09 +08:00
}
}