local w={}w.__index=w function w.GetInstance(I,w)if I.InstancePoolsByClass[w]==nil then I.InstancePoolsByClass[w]={}end local y=#I.InstancePoolsByClass[w]if y>0 then local p=I.InstancePoolsByClass[w][y]table.remove(I.InstancePoolsByClass[w])return p end return Instance.new(w)end function w.ReturnInstance(I,w)if I.InstancePoolsByClass[w.ClassName]==nil then I.InstancePoolsByClass[w.ClassName]={}end if#I.InstancePoolsByClass[w.ClassName]<I.PoolSizePerType then table.insert(I.InstancePoolsByClass[w.ClassName],w)else w:Destroy()end end
--////////////////////////////// Methods
--//////////////////////////////////////
local methods = {}
methods.__index = methods

function methods:GetInstance(className)
	if self.InstancePoolsByClass[className] == nil then
		self.InstancePoolsByClass[className] = {}
	end
	local availableInstances = #self.InstancePoolsByClass[className]
	if availableInstances > 0 then
		local instance = self.InstancePoolsByClass[className][availableInstances]
		table.remove(self.InstancePoolsByClass[className])
		return instance
	end
	return Instance.new(className)
end

function methods:ReturnInstance(instance)
	if self.InstancePoolsByClass[instance.ClassName] == nil then
		self.InstancePoolsByClass[instance.ClassName] = {}
	end
	if #self.InstancePoolsByClass[instance.ClassName] < self.PoolSizePerType then
		table.insert(self.InstancePoolsByClass[instance.ClassName], instance)
	else
		instance:Destroy()
	end
end
