123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- using Fort23.Core;
- #if !COMBAT_SERVER
- using CombatLibrary.CombatLibrary.CombatCore.GPool;
- using UnityEngine;
- #endif
- namespace Fort23.UTool
- {
- public class GameObjectPool : IGObjectPoolInterface
- {
- public string poolObjName { get; set; }
- public bool isUse { get; set; }
- public bool isDestroy { get; }
- #if !COMBAT_SERVER
- public AssetHandle AssetHandle { get; set; }
- private DelayHide _loopDelayHide;
- public GameObject own
- {
- get { return _own; }
- }
- private GameObject _own;
- public TimerEntity DestroyTimer { get; set; }
- #endif
-
- public void SetPosition(Vector3 pos)
- {
- _pos = pos;
- #if !COMBAT_SERVER
- _own.transform.position = pos;
- #endif
- }
- public void SetScale(Vector3 scale)
- {
- _scale = scale;
- #if !COMBAT_SERVER
- _own.transform.localScale = scale;
- #endif
- }
- public void SetRotation(Vector3 rotation)
- {
- _rotation = rotation;
- #if !COMBAT_SERVER
- _own.transform.eulerAngles = rotation;
- #endif
- }
- protected Vector3 _pos;
- protected Vector3 _scale;
- protected Vector3 _rotation;
- 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 async CTask DelayHide()
- {
- #if !COMBAT_SERVER
- if (_loopDelayHide != null)
- {
- await TimerComponent.Instance.WaitAsync((int) (_loopDelayHide.delayTime * 1000));
- }
- #endif
- }
- public virtual void ResetData()
- {
- #if !COMBAT_SERVER
- own.transform.SetParent(null);
- #endif
- }
- public virtual void ActiveObj()
- {
- #if !COMBAT_SERVER
- _loopDelayHide = own.GetComponent<DelayHide>();
- own.SetActive(true);
- #endif
- }
- public virtual void DormancyObj()
- {
- #if !COMBAT_SERVER
- own.SetActive(false);
- #endif
- }
- public virtual void DestroyObj()
- {
- #if !COMBAT_SERVER
- AssetHandle?.Release();
- #endif
- }
- #if !COMBAT_SERVER
- public virtual void SetGameObject(GameObject gameObject)
- {
- _own = gameObject;
- }
- #endif
- public virtual void Preset()
- {
- }
- public virtual void Dispose()
- {
- #if !COMBAT_SERVER
- _own = null;
- #endif
- }
- }
- }
|