local g="\078\101\120\117\115\069\110\117\109"local A=(require(script.Parent.Parent.Parent:WaitForChild("\078\101\120\117\115\080\108\117\103\105\110\070\114\097\109\101\119\111\114\107\080\114\111\106\101\099\116"))):GetContext(script)local I=A:GetResource("\066\097\115\101\046\079\118\101\114\114\105\100\097\098\108\101\073\110\100\101\120\073\110\115\116\097\110\099\101")local O=I:Extend()O:SetClassName(g)A:SetContextResource(O)function O.__new(A,g)A:InitializeSuper()A.Name=g A.CustomEnums={}end function O.__getindex(I,g,A)if g=="\067\117\115\116\111\109\069\110\117\109\115"then return A end local Y=I.CustomEnums if Y then local A=Y[g]if A then return A,true end end return O.super.__getindex(I,g,A)end function O.__tostring(g)local A=""if g.ParentEnum~=nil then A=tostring(g.ParentEnum).."\046"end return A..g.Name end function O.GetEnum(A,g)return A.CustomEnums[g]end function O.GetEnumItems(g)local A={}for g,I in pairs(g.CustomEnums)do table.insert(A,I)end return A end function O.AddEnum(A,g)A.CustomEnums[g.Name]=g g.ParentEnum=A end function O.CreateEnum(g,...)local A={...}local I=g for g,A in pairs(A)do if not I:GetEnum(A)then local g=O.new(A)I:AddEnum(g)end I=I:GetEnum(A)end return I end function O.Equals(A,g)return A==g or A.Name==g or tostring(A)==tostring(g)end return O
--[[
TheNexusAvenger

Custom enum that contains a set of items, including Enums.
--]]

local CLASS_NAME = "NexusEnum"



local NexusPluginFramework = require(script.Parent.Parent.Parent:WaitForChild("NexusPluginFrameworkProject")):GetContext(script)
local OverridableIndexInstance = NexusPluginFramework:GetResource("Base.OverridableIndexInstance")

local NexusEnum = OverridableIndexInstance:Extend()
NexusEnum:SetClassName(CLASS_NAME)
NexusPluginFramework:SetContextResource(NexusEnum)



--[[
Creates an NexusEnum object.
--]]
function NexusEnum:__new(Name)
	self:InitializeSuper()
	
	self.Name = Name
	self.CustomEnums = {}
end

--[[
Returns the value for a custom index. If the second
value returned is true, it will force return the
returned value, even if it is nil. If not, regular
indexing will be used.
--]]
function NexusEnum:__getindex(IndexName,OriginalReturn)
	--Return the base case for CustomEnums.
	if IndexName == "CustomEnums" then
		return OriginalReturn
	end
	
	--Return an enum item.
	local CustomEnums = self.CustomEnums
	if CustomEnums then
		local CustomEnum = CustomEnums[IndexName]
		if CustomEnum then
			return CustomEnum,true
		end
	end
	
	--Return the super.
	return NexusEnum.super.__getindex(self,IndexName,OriginalReturn)
end

--[[
Returns the Enum as a string.
--]]
function NexusEnum:__tostring()
	--Create the base.
	local Base = ""
	if self.ParentEnum ~= nil then
		Base = tostring(self.ParentEnum).."."
	end
	
	--Return the string.
	return Base..self.Name
end

--[[
Returns an enum for the name.
--]]
function NexusEnum:GetEnum(EnumName)
	return self.CustomEnums[EnumName]
end

--[[
Returns a list of the sub-enums.
--]]
function NexusEnum:GetEnumItems()
	--Clone the enum items.
	local ClonedSubEnums = {}
	for _,SubEnum in pairs(self.CustomEnums) do
		table.insert(ClonedSubEnums,SubEnum)
	end
	
	--Return the enum items.
	return ClonedSubEnums
end

--[[
Adds an Enum.
--]]
function NexusEnum:AddEnum(EnumInstance)
	self.CustomEnums[EnumInstance.Name] = EnumInstance
	EnumInstance.ParentEnum = self
end

--[[
Creates an Enum.
--]]
function NexusEnum:CreateEnum(...)
	local Names = {...}
	
	--Add or create the enum.
	local CurrentEnum = self
	for _,Name in pairs(Names) do
		--Create a new enum.
		if not CurrentEnum:GetEnum(Name) then
			local NewEnum = NexusEnum.new(Name)
			CurrentEnum:AddEnum(NewEnum)
		end
		
		--Move the current enum.
		CurrentEnum = CurrentEnum:GetEnum(Name)
	end
	
	--Return the enum.
	return CurrentEnum
end

--[[
Returns if another enum item is equal.
--]]
function NexusEnum:Equals(OtherEnum)
	return self == OtherEnum or self.Name == OtherEnum or tostring(self) == tostring(OtherEnum)
end



return NexusEnum