Add AI engine function for template loading
Partial commit of https://code.wildfiregames.com/D639, taken from Sandarac patch
Reviewed by mimo