local nameList = {
	'armaak',
	'armaap',
	'armaas',
	'armaca',
	'armack',
	'armacsub',
	'armacv',
	'armadvsol',
	'armafus',
	'armageo',
	'armah',
	'armalab',
	'armamb',
	'armamd',
	'armamex',
	'armamph',
	'armamsub',
	'armanac',
	'armanni',
	'armap',
	'armarad',
	'armart',
	'armaser',
	'armason',
	'armasp',
	'armasy',
	'armatl',
	'armatlas',
	'armavp',
	'armawac',
	'armbanth',
	'armbats',
	'armbeamer',
	'armbeaver',
	'armblade',
	'armbrawl',
	'armbrtha',
	'armbull',
	'armca',
	'armcarry',
	'armch',
	'armcir',
	'armck',
	'armckfus',
	'armclaw',
	'armcom',
	'armconsul',
	'armcroc',
	'armcrus',
	'armcs',
	'armcsa',
	'armcv',
	'armdecade',
	'armdecom',
	'armdf',
	'armdfly',
	'armdl',
	'armdrag',
	'armemp',
	'armepoch',
	'armestor',
	'armeyes',
	'armfark',
	'armfast',
	'armfatf',
	'armfav',
	'armfboy',
	'armfdrag',
	'armfflak',
	'armfgate',
	'armfhlt',
	'armfhp',
	'armfido',
	'armfig',
	'armflak',
	'armflash',
	'armflea',
	'armfmine3',
	'armfmkr',
	'armfort',
	'armfrad',
	'armfrock',
	'armfrt',
	'armfus',
	'armgate',
	'armgeo',
	'armgmm',
	'armgplat',
	'armguard',
	'armham',
	'armhawk',
	'armhlt',
	'armhp',
	'armjam',
	'armjamt',
	'armjanus',
	'armjeth',
	'armjuno',
	'armkam',
	'armlab',
	'armlance',
	'armlatnk',
	'armliche',
	'armllt',
	'armlun',
	'armmakr',
	'armmanni',
	'armmar',
	'armmark',
	'armmart',
	'armmav',
	'armmercury',
	'armmerl',
	'armmex',
	'armmh',
	'armmine1',
	'armmine2',
	'armmine3',
	'armmls',
	'armmlv',
	'armmmkr',
	'armmoho',
	'armmship',
	'armmstor',
	'armnanotc',
	'armnanotcplat',
	'armpacko',
	'armpb',
	'armpeep',
	'armpincer',
	'armplat',
	'armpnix',
	'armpship',
	'armpt',
	'armptl',
	'armpw',
	'armrad',
	'armraz',
	'armrecl',
	'armrectr',
	'armrl',
	'armrock',
	'armroy',
	'armsaber',
	'armsam',
	'armsb',
	'armscab',
	'armsd',
	'armseap',
	'armseer',
	'armsehak',
	'armserp',
	'armsfig',
	'armsh',
	'armshltx',
	'armshltxuw',
	'armsilo',
	'armsjam',
	'armsnipe',
	'armsolar',
	'armsonar',
	'armspid',
	'armsptk',
	'armspy',
	'armst',
	'armstil',
	'armstone',
	'armstump',
	'armsub',
	'armsubk',
	'armsy',
	'armtarg',
	'armthovr',
	'armthund',
	'armtide',
	'armtl',
	'armtship',
	'armuwadves',
	'armuwadvms',
	'armuwes',
	'armuwfus',
	'armuwmex',
	'armuwmme',
	'armuwmmm',
	'armuwms',
	'armvader',
	'armvang',
	'armveil',
	'armvp',
	'armvulc',
	'armwar',
	'armwin',
	'armyork',
	'armzeus',

	'coraak',
	'coraap',
	'coraca',
	'corack',
	'coracsub',
	'coracv',
	'coradvsol',
	'corafus',
	'corageo',
	'corah',
	'corak',
	'coralab',
	'coramph',
	'coramsub',
	'corap',
	'corape',
	'corarad',
	'corarch',
	'corason',
	'corasp',
	'corasy',
	'coratl',
	'coravp',
	'corawac',
	'corban',
	'corbats',
	'corbhmth',
	'corblackhy',
	'corbuzz',
	'corbw',
	'corca',
	'corcan',
	'corcarry',
	'corcat',
	'corch',
	'corck',
	'corcom',
	'corcrash',
	'corcrus',
	'corcrw',
	'corcs',
	'corcsa',
	'corcut',
	'corcv',
	'cordecom',
	'cordl',
	'cordoom',
	'cordrag',
	'corenaa',
	'corerad',
	'corestor',
	'coresupp',
	'coreter',
	'corexp',
	'coreyes',
	'corfast',
	'corfatf',
	'corfav',
	'corfdrag',
	'corfgate',
	'corfhlt',
	'corfhp',
	'corfink',
	'corflak',
	'corfmd',
	'corfmine3',
	'corfmkr',
	'corfort',
	'corfrad',
	'corfrock',
	'corfrt',
	'corfus',
	'corgant',
	'corgantuw',
	'corgarp',
	'corgate',
	'corgator',
	'corgeo',
	'corgol',
	'corgplat',
	'corhal',
	'corhllt',
	'corhlt',
	'corhp',
	'corhrk',
	'corhunt',
	'corhurc',
	'corint',
	'corintr',
	'corjamt',
	'corjugg',
	'corjuno',
	'corkarg',
	'corkrog',
	'corlab',
	'corlevlr',
	'corllt',
	'cormabm',
	'cormadsam',
	'cormakr',
	'cormando',
	'cormart',
	'cormaw',
	'cormex',
	'cormexp',
	'cormh',
	'cormine1',
	'cormine2',
	'cormine3',
	'cormine4',
	'cormist',
	'cormls',
	'cormlv',
	'cormmkr',
	'cormoho',
	'cormort',
	'cormship',
	'cormstor',
	'cormuskrat',
	'cornanotc',
	'cornanotcplat',
	'cornecro',
	'corparrow',
	'corplat',
	'corpship',
	'corpt',
	'corptl',
	'corpun',
	'corpyro',
	'corrad',
	'corraid',
	'correap',
	'correcl',
	'corrl',
	'corroach',
	'corroy',
	'corsb',
	'corscreamer',
	'corsd',
	'corseah',
	'corseal',
	'corseap',
	'corsent',
	'corsfig',
	'corsh',
	'corshad',
	'corshark',
	'corshiva',
	'corshroud',
	'corsilo',
	'corsjam',
	'corsktl',
	'corsnap',
	'corsok',
	'corsolar',
	'corsonar',
	'corspec',
	'corspy',
	'corssub',
	'corstone',
	'corstorm',
	'corsub',
	'corsumo',
	'corsy',
	'cortarg',
	'cortermite',
	'corthovr',
	'corthud',
	'cortide',
	'cortitan',
	'cortl',
	'cortoast',
	'cortrem',
	'cortron',
	'cortship',
	'coruwadves',
	'coruwadvms',
	'coruwes',
	'coruwfus',
	'coruwmex',
	'coruwmme',
	'coruwmmm',
	'coruwms',
	'corvalk',
	'corvamp',
	'corveng',
	'corvipe',
	'corvoyr',
	'corvp',
	'corvrad',
	'corvroc',
	'corwin',
	'corwolv',

	--'freefusion',
	--'mission_command_tower',

	--'chicken1',
	--'chicken1b',
	--'chicken1c',
	--'chicken1d',
	--'chicken1x',
	--'chicken1y',
	--'chicken1z',
	--'chicken2',
	--'chicken2b',
	--'chicken_dodo1',
	--'chicken_dodo2',
	--'chickena1',
	--'chickena1b',
	--'chickena1c',
	--'chickena2',
	--'chickena2b',
	--'chickenc1',
	--'chickenc2',
	--'chickenc3',
	--'chickenc3b',
	--'chickenc3c',
	--'chickend1',
	--'chickenf1',
	--'chickenf1b',
	--'chickenf2',
	--'chickenh1',
	--'chickenh1b',
	--'chickenh2',
	--'chickenh3',
	--'chickenh4',
	--'chickenh5',
	--'chickenp1',
	--'chickenr1',
	--'chickenr2',
	--'chickenr3',
	--'chickens1',
	--'chickens2',
	--'chickens3',
	--'chickenw1',
	--'chickenw1b',
	--'chickenw1c',
	--'chickenw1d',
	--'chickenw2',
	--'e_chickenq',
	--'n_chickenq',
	--'epic_chickenq',
	--'h_chickenq',
	--'ve_chickenq',
	--'vh_chickenq',
	--'roost',
	--'meteor',

	--'critter_ant',
	--'critter_duck',
	--'critter_goldfish',
	--'critter_gull',
	--'critter_penguin',
	--'critter_penguinbro',
	--'critter_penguinking',
}

local categories = {
	--cloak = {
	--	name = "Cloakbots",
	--	order = 1,
	--},
	--shield = {
	--	name = "Shieldbots",
	--	order = 2,
	--},
	--veh = {
	--	name = "Rovers",
	--	order = 3,
	--},
	--tank = {
	--	name = "Tanks",
	--	order = 4,
	--},
	--hover = {
	--	name = "Hovercraft",
	--	order = 5,
	--},
	--amph = {
	--	name = "Amphbots",
	--	order = 6,
	--},
	--jump = {
	--	name = "Jumpbots",
	--	order = 7,
	--},
	--spider = {
	--	name = "Spiders",
	--	order = 8,
	--},
	--gunship = {
	--	name = "Gunships",
	--	order = 9,
	--},
	--plane = {
	--	name = "Planes",
	--	order = 10,
	--},
	--ship = {
	--	name = "Ships",
	--	order = 11,
	--},
	--strider = {
	--	name = "Striders",
	--	order = 12,
	--},
	--econ = {
	--	name = "Economy",
	--	order = 13,
	--},
	--defence = {
	--	name = "Defence",
	--	order = 14,
	--},
	--special = {
	--	name = "Special",
	--	order = 15,
	--},
	--missilesilo = {
	--	name = "Missile Silo",
	--	order = 16,
	--},
	--drone = {
	--	name = "Drones",
	--	order = 17,
	--},
}

local humanNames = {

	-- Soldiders
	--euf_barracks = {
	--	category = "veh",
	--	order = 1,
	--	description = "Produces Light Soliders",
	--	humanName = "Imperial Barracks",
	--},
	--
	---- Tank
	--factorytank = {
	--	category = "tank",
	--	order = 1,
	--	description = "Produces Vehicles",
	--	humanName = "War Factory",
	--},
	--
	---- Plane
	--euf_airport = {
	--	category = "plane",
	--	order = 1,
	--	description = "Produces VTOLs",
	--	humanName = "Airplane Plant",
	--},
	--
	---- Econ
	--euf_metalextractor_lvl1 = {
	--	category = "econ",
	--	order = 1,
	--	description = "Produces Metal",
	--	humanName = "Metal Extractor",
	--},
	--euf_metalextractor_lvl2 = {
	--	category = "econ",
	--	order = 2,
	--	description = "Produces More Metal",
	--	humanName = "Advanced Metal Extractor",
	--},
	--euf_solar = {
	--	category = "econ",
	--	order = 3,
	--	description = "Small Powerplant",
	--	humanName = "Solar Collector",
	--},
	--euf_powerplant = {
	--	category = "econ",
	--	order = 4,
	--	description = "Medium Powerplant",
	--	humanName = "Fusion Reactor",
	--},
	--euf_storage = {
	--	category = "econ",
	--	order = 5,
	--	description = "Stores Metal and Energy",
	--	humanName = "Storage",
	--},
--
	---- Defence
	--euf_plasmatower = {
	--	category = "defence",
	--	order = 1,
	--	description = "Light Defense Tower",
	--	humanName = "Plasma Tower",
	--},
	--euf_aatower = {
	--	category = "defence",
	--	order = 2,
	--	description = "Anti-Air Missile Tower",
	--	humanName = "Missile Tower",
	--},
	--euf_lasertower = {
	--	category = "defence",
	--	order = 3,
	--	description = "Heavy Defense Tower",
	--	humanName = "Laser Tower",
	--},
	--euf_artytower = {
	--	category = "defence",
	--	order = 4,
	--	description = "Log-Range Defense Tower",
	--	humanName = "Artillery Tower",
	--},
	--euf_techcenter_shield = {
	--	category = "defence",
	--	order = 5,
	--	description = "Area Shield",
	--	humanName = "Shielded Technology Center",
	--},
	--
	---- Special
	--euf_radar_lvl1 = {
	--	category = "special",
	--	order = 1,
	--	description = "Early Warning System",
	--	humanName = "Radar Tower",
	--},
	--euf_radar_lvl2 = {
	--	category = "special",
	--	order = 2,
	--	description = "Long-Range Radar",
	--	humanName = "Advanced Radar",
	--},
	--
	---- Missile Silo
	--euf_techcenter_nuke = {
	--	category = "missilesilo",
	--	order = 1,
	--	description = "Produces Tactical Nukes",
	--	humanName = "Nuclear Missile Silo",
	--},

}

--------- To Generate ------------
--[[
local inNameList = {}
local nameList = {}
local carrierDefs = VFS.Include("LuaRules/Configs/drone_defs.lua")
local function AddUnit(unitName)
	if inNameList[unitName] then
		return
	end
	inNameList[unitName] = true
	nameList[#nameList + 1] = unitName

	local ud = UnitDefNames[unitName]
	if ud.buildOptions then
		for i = 1, #ud.buildOptions do
			AddUnit(UnitDefs[ud.buildOptions[i] ].name)
		end
	end

	if ud.customParams.morphto then
		AddUnit(ud.customParams.morphto)
	end

	if ud.weapons then
		for i = 1, #ud.weapons do
			local wd = WeaponDefs[ud.weapons[i].weaponDef]
			if wd and wd.customParams and wd.customParams.spawns_name then
				AddUnit(wd.customParams.spawns_name)
			end
		end
	end

	if carrierDefs[ud.id] then
		local data = carrierDefs[ud.id]
		for i = 1, #data do
			local droneUnitDefID = data[i].drone
			if droneUnitDefID and UnitDefs[droneUnitDefID] then
				AddUnit(UnitDefs[droneUnitDefID].name)
			end
		end
	end
end

local function GenerateLists()
	AddUnit("cloakcon")
	local humanNames = {}
	for i = 1, #nameList do
		humanNames[nameList[i] ] = {
			humanName = UnitDefNames[nameList[i] ].humanName,
			description = UnitDefNames[nameList[i] ].tooltip,
		}
	end
	Spring.Echo(Spring.Utilities.TableToString(nameList, "nameList"))
	Spring.Echo(Spring.Utilities.TableToString(humanNames, "humanNames"))
end

GenerateLists()
--]]

local function UnitOrder(name1, name2)
	local data1 = name1 and humanNames[name1]
	local data2 = name1 and humanNames[name2]
	if not data1 then
		return (data2 and true)
	end
	if not data2 then
		return true
	end

	local category1 = categories[data1.category].order
	local category2 = categories[data2.category].order
	return category1 < category2 or (category1 == category2 and data1.order < data2.order)
end

return {
	nameList = nameList,
	humanNames = humanNames,
	categories = categories,
	UnitOrder = UnitOrder,
}