local X={}function X.Class(G,F)G=G or{}local c={__metatable=X.DeepCopy(F),__index=X.DeepCopy(F)}return setmetatable(G,c)end function X.MakeClass(...)local G={...}assert(#G>0,"\069\082\082\079\082\058 \099\108\097\115\115 \110\101\101\100\115 \049 \097\114\103\117\109\101\110\116 \111\114 \109\111\114\101")local F=G[1]for X=2,#G,1 do if type(G[X])=="\116\097\098\108\101"then for X,G in pairs(G[X])do if not F[X]then F[X]=G end end end end local function c(G)return X.Class(G or{},F)end local function T(X,...)local F=X:New(unpack(G))for X,G in pairs(X)do F[X]=G end return F end F.New=c F.Copy=T return mt end function X.DeepCopy(G)local F=type(G)local c if F=="\116\097\098\108\101"then c={}for G,F in next,G,nil do c[X.DeepCopy(G)]=X.DeepCopy(F)end setmetatable(c,X.DeepCopy(getmetatable(G)))else c=G end return c end function X.Instantiate(X)return function(G)local F=Instance.new(X)for X,G in pairs(G)do if type(X)=="\110\117\109\098\101\114"then G.Parent=F else F[X]=G end end return F end end function X.RetroRegister(X,...)X()for G,F in ipairs({...})do F:connect(X)end end
------------------------
--[[UTIL Functions]]
--
------------------------
--Global functions used by all classes are wrapped in UTIL
--deal with it.
local UTIL = {}

function UTIL.Class(tableIn, template)
	tableIn = tableIn or {}
	local mt = {
		__metatable = UTIL.DeepCopy(template),
		__index = UTIL.DeepCopy(template),
	}
	return setmetatable(tableIn, mt)
end
function UTIL.MakeClass(...)
	local arg = { ... }
	assert(#arg > 0, "ERROR: class needs 1 argument or more")
	local members = arg[1]
	for i = 2, #arg, 1 do
		if type(arg[i]) == "table" then
			for key, val in pairs(arg[i]) do
				if not members[key] then
					members[key] = val
				end
			end
		end
	end
	local function New(init)
		return UTIL.Class(init or {}, members)
	end
	local function Copy(obj, ...)
		local newobj = obj:New(unpack(arg))
		for n, v in pairs(obj) do
			newobj[n] = v
		end
		return newobj
	end
	members.New = New
	members.Copy = Copy
	return mt
end

function UTIL.DeepCopy(orig)
	local orig_type = type(orig)
	local copy
	if orig_type == "table" then
		copy = {}
		for orig_key, orig_value in next, orig, nil do
			copy[UTIL.DeepCopy(orig_key)] = UTIL.DeepCopy(orig_value)
		end
		setmetatable(copy, UTIL.DeepCopy(getmetatable(orig)))
	else -- number, string, boolean, etc
		copy = orig
	end
	return copy
end

function UTIL.Instantiate(guiType)
	return function(data)
		local obj = Instance.new(guiType)
		for k, v in pairs(data) do
			if type(k) == "number" then
				v.Parent = obj
			else
				obj[k] = v
			end
		end
		return obj
	end
end

function UTIL.RetroRegister(func, ...)
	func()
	for _, i in ipairs({ ... }) do
		i:connect(func)
	end
end
