local InterpolatedSystem = inherited("InterpolatedSystem", SystemMap)

function InterpolatedSystem:new()
	local ms = instance(self)
	return ms
end

function InterpolatedSystem:wants(ent)
	return ent.aspects.interpolated
end

function InterpolatedSystem:ent_added(ent)
	ent.rx = ent.x
	ent.ry = ent.y
	ent.rz = ent.z
end

function InterpolatedSystem:ent_removed(ent)
end

function InterpolatedSystem:interpolate(prg)	
	local iprg = 1-prg
	for ent, _ in pairs(self.ents) do
		local rx = ent.x *iprg + ent.nx *prg
		local ry = ent.y *iprg + ent.ny *prg
		local rz = ent.z *iprg + ent.nz *prg
		ent.rx = rx
		ent.ry = ry
		ent.rz = rz
	end
end

return InterpolatedSystem