You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
3.0 KiB
97 lines
3.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using AOT;
|
|
using Entitas;
|
|
using UnityEngine;
|
|
|
|
namespace CoreGame.Render
|
|
{
|
|
public struct MainAssetParam
|
|
{
|
|
public string path;
|
|
public string parentNodeName;
|
|
public float scaleParam;
|
|
public ReuseGoData reuseGoData;
|
|
public bool hideStateBar;
|
|
}
|
|
|
|
public class SubAssetData : ISptPool
|
|
{
|
|
public int ownerEid;
|
|
public FName path;
|
|
public BindPointType bindPointType;
|
|
public ReuseGoData reuseGoData;
|
|
public readonly List<Type> fillEntTypes = new();
|
|
|
|
public void Awake(int ownerEid, string path, BindPointType bindPointType, ReuseGoData reuseGoData)
|
|
{
|
|
Awake(ownerEid, UnrealNames.GetFName(path), bindPointType, reuseGoData);
|
|
}
|
|
|
|
public void Awake(int ownerEid, FName path, BindPointType bindPointType, ReuseGoData reuseGoData)
|
|
{
|
|
this.ownerEid = ownerEid;
|
|
this.path = path;
|
|
this.bindPointType = bindPointType;
|
|
this.reuseGoData = reuseGoData;
|
|
}
|
|
public void Reset()
|
|
{
|
|
fillEntTypes.Clear();
|
|
}
|
|
}
|
|
|
|
[Combat]
|
|
public class AssetComponent : IComponent, IReset
|
|
{
|
|
public MainAssetParam mainAssetParam;
|
|
public List<Type> ignoreTypes;
|
|
// 已经加载好的子对象
|
|
private readonly List<SubAssetData> m_SubAssetParams = new();
|
|
// 需要加载的子对象
|
|
internal readonly Queue<SubAssetData> needLoadSubAssets = new();
|
|
// 被关联的子实体,比如武器
|
|
internal readonly List<int> linkAssetEidsRecorder = new();
|
|
|
|
// 不能单独驱动ReactiveSyste
|
|
public void PushMainPartAsset(ref SubAssetData subAssetData)
|
|
{
|
|
needLoadSubAssets.Enqueue(subAssetData);
|
|
}
|
|
public void PushSubAsset(ref SubAssetData subAssetData)
|
|
{
|
|
m_SubAssetParams.Add(subAssetData);
|
|
}
|
|
|
|
public void HideMainAsset()
|
|
{
|
|
mainAssetParam.reuseGoData?.go.SetActiveWrap(false);
|
|
}
|
|
|
|
public void RecordLinkEnt(int eid)
|
|
{
|
|
if (linkAssetEidsRecorder.Contains(eid))
|
|
return;
|
|
linkAssetEidsRecorder.Add(eid);
|
|
}
|
|
|
|
public void UnRecordLinkEnt(int eid)
|
|
{
|
|
linkAssetEidsRecorder.Remove(eid);
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
for (var i = 0; i < m_SubAssetParams.Count; i++)
|
|
{
|
|
// 需要改成entity release, 这样也没问题
|
|
var subAssetParam = m_SubAssetParams[i];
|
|
GoPoolDic.GetPool(subAssetParam.path.GetDisplayString()).ReleaseGo(subAssetParam.reuseGoData);
|
|
SptPool<SubAssetData>.Free(ref subAssetParam);
|
|
}
|
|
m_SubAssetParams.Clear();
|
|
ListPool<Type>.Push(ref ignoreTypes);
|
|
GoPoolDic.GetPool(mainAssetParam.path).ReleaseGo(mainAssetParam.reuseGoData);
|
|
}
|
|
}
|
|
}
|