| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 | using Fort23.Core;using Fort23.UTool;#if !COMBAT_SERVERusing UnityEngine;#endifnamespace Fort23.UTool{    /// <summary>    /// 基础的池子    /// </summary>    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<DelayHide>();        }#endif        public T GetComponent<T>()        {#if !COMBAT_SERVER            if (_own != null)            {              return  _own.GetComponent<T>();            }            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()        {        }    }}
 |