using FishNet.Managing;
using FishNet.Object;
using System;
using UnityEngine;
namespace FishNet.Utility.Performance
{
public abstract class ObjectPool : MonoBehaviour
{
///
/// NetworkManager this ObjectPool belongs to.
///
protected NetworkManager NetworkManager {get; private set;}
///
/// Initializes this script for use.
///
public virtual void InitializeOnce(NetworkManager nm)
{
NetworkManager = nm;
}
///
/// Returns an object that has been stored using collectioNid of 0. A new object will be created if no stored objects are available.
///
/// PrefabId of the object to return.
/// True if being called on the server side.
///
public abstract NetworkObject RetrieveObject(int prefabId, bool asServer);
///
/// Returns an object that has been stored. A new object will be created if no stored objects are available.
///
/// PrefabId of the object to return.
/// True if being called on the server side.
///
public virtual NetworkObject RetrieveObject(int prefabId, ushort collectionId, bool asServer) => null;
///
/// Stores an object into the pool.
///
/// Object to store.
/// True if being called on the server side.
///
public abstract void StoreObject(NetworkObject instantiated, bool asServer);
}
}