Files
plugin-library/Assets/11.PointCloudTools/Runtime/Script/PointSystem/ZoneGatherData.cs

114 lines
3.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using Stary.Evo;
using UnityEngine;
namespace Main
{
public interface IZoneData
{
ZoneData[] GetZoneDataAll();
ZoneData GetZoneData(string domain);
PointData GetPointData(string zoneDomain, string pointDomain);
bool IsGizmo();
}
public class ZoneGatherData : IZoneData
{
private PointGatherData _pointGatherData;
public ZoneGatherData(PointGatherData pointGatherData)
{
_pointGatherData = pointGatherData;
}
/// <summary>
/// 通过id获取区域数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public ZoneData[] GetZoneDataAll()
{
if (_pointGatherData != null)
{
for (int i = 0; i < _pointGatherData.ZoneDatas.Count; i++)
{
return _pointGatherData.ZoneDatas.ToArray();
}
Debug.LogWarning($"UnityEvo:PointGatherData is null");
}
else
{
Debug.LogError("UnityEvo:PointGatherData is null");
}
return default;
}
public bool IsGizmo()
{
if (_pointGatherData != null)
{
return _pointGatherData.isGizmo;
}
return false;
}
/// <summary>
/// 通过id获取区域数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public ZoneData GetZoneData(string domain)
{
if (_pointGatherData != null)
{
for (int i = 0; i < _pointGatherData.ZoneDatas.Count; i++)
{
if (_pointGatherData.ZoneDatas[i].name == domain)
{
return _pointGatherData.ZoneDatas[i];
}
}
Debug.LogWarning($"UnityEvo:{domain}在PointGatherData is null");
}
else
{
Debug.LogError("UnityEvo:PointGatherData is null");
}
return default;
}
public PointData GetPointData(string zoneDomain, string pointDomain)
{
ZoneData zoneData = GetZoneData(zoneDomain);
if (zoneData.pointDatas != null)
{
for (int i = 0; i < zoneData.pointDatas.Count; i++)
{
if (zoneData.pointDatas[i].name == pointDomain)
{
return zoneData.pointDatas[i];
}
}
Debug.LogWarning($"UnityEvo:{pointDomain}在PointGatherData.zoneData.pointDatas is null");
}
else
{
Debug.LogError("UnityEvo:PointGatherData.zoneData.pointDatas is null");
}
return default;
}
}
}