58 lines
1.0 KiB
C#
58 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
|
|
public interface IPool<T>
|
|
{
|
|
/// <summary>
|
|
/// 回收事件
|
|
/// </summary>
|
|
event Action<T> OnRecycle;
|
|
|
|
/// <summary>
|
|
/// 取出事件
|
|
/// </summary>
|
|
event Action<T> OnGet;
|
|
|
|
/// <summary>
|
|
/// 获取IPoolObject
|
|
/// </summary>
|
|
IPoolObject<T> Get();
|
|
|
|
/// <summary>
|
|
/// 回收IPoolObject
|
|
/// </summary>
|
|
/// <param name="_pool_object"></param>
|
|
void Recycle(IPoolObject<T> _pool_object);
|
|
|
|
/// <summary>
|
|
/// 销毁IPoolObject
|
|
/// </summary>
|
|
/// <param name="_pool_object"></param>
|
|
void Dispose(IPoolObject<T> _pool_object);
|
|
}
|
|
|
|
|
|
public interface IPoolObject<T>
|
|
{
|
|
/// <summary>
|
|
/// 对象池的引用
|
|
/// </summary>
|
|
IPool<T> Pool { get; set; }
|
|
|
|
/// <summary>
|
|
/// 内容
|
|
/// </summary>
|
|
T Content { get; set; }
|
|
|
|
/// <summary>
|
|
/// 回收自己
|
|
/// </summary>
|
|
void Recycle();
|
|
|
|
/// <summary>
|
|
/// 销毁自己IPoolObject
|
|
/// </summary>
|
|
void Dispose();
|
|
} |