2012-04-20 19:21:04 +02:00
|
|
|
/**
|
|
|
|
* System component which loads the technology data files
|
|
|
|
*/
|
|
|
|
function TechnologyTemplateManager() {}
|
|
|
|
|
|
|
|
TechnologyTemplateManager.prototype.Schema =
|
|
|
|
"<a:component type='system'/><empty/>";
|
|
|
|
|
|
|
|
TechnologyTemplateManager.prototype.Init = function()
|
|
|
|
{
|
|
|
|
this.allTechs = {};
|
2013-10-14 17:51:21 +02:00
|
|
|
this.allAuras = {};
|
2012-04-20 19:21:04 +02:00
|
|
|
var techNames = this.ListAllTechs();
|
2013-05-13 00:28:02 +02:00
|
|
|
for (var i in techNames)
|
2012-04-20 19:21:04 +02:00
|
|
|
this.GetTemplate(techNames[i]);
|
|
|
|
};
|
|
|
|
|
|
|
|
TechnologyTemplateManager.prototype.GetTemplate = function(template)
|
|
|
|
{
|
|
|
|
if (!this.allTechs[template])
|
|
|
|
{
|
|
|
|
this.allTechs[template] = Engine.ReadJSONFile("technologies/" + template + ".json");
|
|
|
|
if (! this.allTechs[template])
|
|
|
|
error("Failed to load technology \"" + template + "\"");
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.allTechs[template];
|
|
|
|
};
|
|
|
|
|
2013-10-14 17:51:21 +02:00
|
|
|
TechnologyTemplateManager.prototype.GetAuraTemplate = function(template)
|
|
|
|
{
|
|
|
|
if (!this.allAuras[template])
|
|
|
|
{
|
|
|
|
this.allAuras[template] = Engine.ReadJSONFile("auras/" + template + ".json");
|
|
|
|
if (! this.allAuras[template])
|
|
|
|
error("Failed to load aura \"" + template + "\"");
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.allAuras[template];
|
|
|
|
};
|
|
|
|
|
2012-04-20 19:21:04 +02:00
|
|
|
TechnologyTemplateManager.prototype.ListAllTechs = function()
|
|
|
|
{
|
2012-08-16 00:25:25 +02:00
|
|
|
return Engine.FindJSONFiles("technologies", true);
|
2012-04-20 19:21:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TechnologyTemplateManager.prototype.GetAllTechs = function()
|
|
|
|
{
|
|
|
|
return this.allTechs;
|
|
|
|
}
|
|
|
|
|
|
|
|
Engine.RegisterComponentType(IID_TechnologyTemplateManager, "TechnologyTemplateManager", TechnologyTemplateManager);
|