64 lines
1.5 KiB
C#
64 lines
1.5 KiB
C#
using cfg.CampCfg;
|
|
using Cysharp.Threading.Tasks;
|
|
using Framework;
|
|
using Gameplay.Common;
|
|
using PhxhSDK;
|
|
using PhxhSDK.Res;
|
|
using System.Collections.Generic;
|
|
using TGS;
|
|
using UnityEngine;
|
|
|
|
namespace Gameplay.Camp
|
|
{
|
|
/// <summary>
|
|
/// 营地
|
|
/// </summary>
|
|
public sealed partial class Camp
|
|
{
|
|
/// <summary>
|
|
/// 营地物件根节点
|
|
/// </summary>
|
|
private Transform tsCampObjectRoot;
|
|
|
|
public Camp()
|
|
{
|
|
InitCell();
|
|
InitLoad();
|
|
InitUnit();
|
|
InitEdit();
|
|
}
|
|
|
|
public async UniTask SetInfo(SceneHandle sceneHandle)
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
|
|
SetInfoByCell(terrainGridSystem);
|
|
await SetInfoByLoad();
|
|
}
|
|
|
|
public void Exit()
|
|
{
|
|
ExitEdit();
|
|
ExitUnit();
|
|
ExitLoad();
|
|
ExitCell();
|
|
|
|
tsCampObjectRoot = null;
|
|
}
|
|
}
|
|
} |