using Fort23.Core; using Fort23.UTool; #if !COMBAT_SERVER using UnityEngine; #endif namespace Fort23.UTool { /// /// 基础的池子 /// public class GObjectPoolBasic : IGObjectPoolInterface { protected Vector3 _pos; protected Vector3 _scale; protected Vector3 _rotation; #if !COMBAT_SERVER public Transform transform { get { if (own == null) { return null; } return own.transform; } } public GameObject gameObject { get { return own; } } public GameObject own { get { return _own; } } private GameObject _own; public AssetHandle AssetHandle { get; set; } private DelayHide delayHide; public TimerEntity DestroyTimer { get; set; } #endif public string poolObjName { get; set; } public bool isUse { get; set; } public bool isDestroy { get; } public virtual void ResetData() { ProResetData(); } public virtual void ActiveObj() { #if !COMBAT_SERVER own.SetActive(true); #endif ProActiveObj(); } public virtual async CTask DelayHide() { #if !COMBAT_SERVER if (own != null && delayHide != null) { await TimerComponent.Instance.WaitAsync((int)(delayHide.delayTime * 1000)); } #endif } public virtual void DormancyObj() { ProDormancyObj(); #if !COMBAT_SERVER own.SetActive(false); #endif } public void SetPosition(Vector3 pos) { _pos = pos; #if !COMBAT_SERVER if (_own != null) { _own.transform.position = pos; } #endif } public void SetScale(Vector3 scale) { _scale = scale; #if !COMBAT_SERVER if (_own != null) { _own.transform.localScale = scale; } #endif } #if !COMBAT_SERVER public void SetParent(Transform root) { if (_own != null) { _own.transform.SetParent(root); } } #endif public void SetRotation(Vector3 rotation) { _rotation = rotation; #if !COMBAT_SERVER if (_own != null) { _own.transform.eulerAngles = rotation; } #endif } public Vector3 GetPosition() { return _pos; } public Vector3 GetScale() { return _scale; } public Vector3 GettRotation() { return _rotation; } public void SetActive(bool isActive) { #if !COMBAT_SERVER _own.SetActive(isActive); #endif } public virtual void DestroyObj() { #if !COMBAT_SERVER AssetHandle?.Release(); #endif ProOnDestroy(); #if !COMBAT_SERVER _own = null; #endif } #if !COMBAT_SERVER public void SetGameObject(GameObject gameObject) { _own = gameObject; delayHide = own.GetComponent(); } #endif public T GetComponent() { #if !COMBAT_SERVER if (_own != null) { return _own.GetComponent(); } return default; #endif return default; } public virtual void Dispose() { } protected virtual void ProResetData() { //gameObject.SetActive(true); } protected virtual void ProOnDestroy() { } protected virtual void ProDormancyObj() { //gameObject.SetActive(true); } protected virtual void ProActiveObj() { } public virtual void Preset() { } } }