local models = {}
local master = dwarf_characters


--animations and textures are expected to work the same on all models
--this is bad for modularity but this mod is currently only intended to
--work with a masculine and a feminine version of the same model



--we set this as metatable for all animations so we can call
--them as functions even when they're tables.
--This allows us to use actual functions as animations which we can use
--to pick random animations
local animation_table_meta =
{
	__call = function(self)
		return self
	end
}
local animations =
{
	stand     = {x = 31,   y = 31},
	die       = {x = 81, y = 130},
	walk      = {x = 0, y = 30},
	mine      = {x = 71, y = 80},
	walk_mine = {x = 40, y = 69},
	sit       = {x = 32,  y = 32},
}
for _, v in pairs(animations)
do
	if(type(v) == "table")
	then
		setmetatable(v, animation_table_meta)
	end
end
master.intramodcom.animations = animations






function master.register_model(name, description, sex)
	assert(not models[name], "There is already a model registered with name "..name)

	models[name] = {description = description, sex  = sex}
end

function master.get_models()
	local i = 0
	local ret = {}
	for k, v in pairs(models)
	do
		i = i + 1
		ret[i] = {name = k,  description = v.description, sex = v.sex}
	end
	return ret
end
