2012-04-20 19:21:04 +02:00
|
|
|
function TechnologyManager() {}
|
|
|
|
|
|
|
|
TechnologyManager.prototype.Schema =
|
|
|
|
"<a:component type='system'/><empty/>";
|
2012-05-05 23:21:36 +02:00
|
|
|
|
|
|
|
TechnologyManager.prototype.Serialize = function()
|
|
|
|
{
|
|
|
|
// The modifications cache will be affected by property reads from the GUI and other places so we shouldn't
|
|
|
|
// serialize it.
|
|
|
|
|
|
|
|
var ret = {};
|
2012-05-05 23:29:36 +02:00
|
|
|
for (var i in this)
|
2012-05-05 23:21:36 +02:00
|
|
|
{
|
|
|
|
if (this.hasOwnProperty(i))
|
|
|
|
ret[i] = this[i];
|
|
|
|
}
|
|
|
|
ret.modificationCache = {};
|
|
|
|
return ret;
|
|
|
|
};
|
2012-04-20 19:21:04 +02:00
|
|
|
|
|
|
|
TechnologyManager.prototype.Init = function ()
|
|
|
|
{
|
|
|
|
var cmpTechTempMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager);
|
|
|
|
this.allTechs = cmpTechTempMan.GetAllTechs();
|
|
|
|
this.researchedTechs = {}; // technologies which have been researched
|
2012-07-31 04:03:25 +02:00
|
|
|
this.researchQueued = {}; // technologies which are queued for research
|
|
|
|
this.researchStarted = {}; // technologies which are being researched currently (non-queued)
|
2012-04-20 19:21:04 +02:00
|
|
|
|
|
|
|
// This stores the modifications to unit stats from researched technologies
|
|
|
|
// Example data: {"ResourceGatherer/Rates/food.grain": [
|
2013-11-03 15:09:32 +01:00
|
|
|
// {"multiply": 1.15, "affects": ["Female", "Infantry Swordsman"]},
|
2012-04-20 19:21:04 +02:00
|
|
|
// {"add": 2}
|
|
|
|
// ]}
|
|
|
|
this.modifications = {};
|
2012-04-21 18:37:35 +02:00
|
|
|
this.modificationCache = {}; // Caches the values after technologies have been applied
|
2013-11-17 19:24:04 +01:00
|
|
|
// e.g. { "Attack/Melee/Hack" : {5: {"origValue": 8, "newValue": 10}, 7: {"origValue": 9, "newValue": 12}, ...}, ...}
|
2012-04-21 18:37:35 +02:00
|
|
|
// where 5 and 7 are entity id's
|
2012-04-20 19:21:04 +02:00
|
|
|
|
|
|
|
this.typeCounts = {}; // stores the number of entities of each type
|
|
|
|
this.classCounts = {}; // stores the number of entities of each Class
|
|
|
|
this.typeCountsByClass = {}; // stores the number of entities of each type for each class i.e.
|
|
|
|
// {"someClass": {"unit/spearman": 2, "unit/cav": 5} "someOtherClass":...}
|
|
|
|
|
|
|
|
// Some technologies are automatically researched when their conditions are met. They have no cost and are
|
|
|
|
// researched instantly. This allows civ bonuses and more complicated technologies.
|
|
|
|
this.autoResearchTech = {};
|
|
|
|
for (var key in this.allTechs)
|
|
|
|
{
|
2012-04-21 23:40:07 +02:00
|
|
|
if (this.allTechs[key].autoResearch || this.allTechs[key].top)
|
2012-04-20 19:21:04 +02:00
|
|
|
this.autoResearchTech[key] = this.allTechs[key];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-10-07 22:34:37 +02:00
|
|
|
TechnologyManager.prototype.OnUpdate = function ()
|
|
|
|
{
|
|
|
|
this.UpdateAutoResearch();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-20 19:21:04 +02:00
|
|
|
// This function checks if the requirements of any autoresearch techs are met and if they are it researches them
|
|
|
|
TechnologyManager.prototype.UpdateAutoResearch = function ()
|
|
|
|
{
|
|
|
|
for (var key in this.autoResearchTech)
|
|
|
|
{
|
2012-04-21 23:40:07 +02:00
|
|
|
if ((this.allTechs[key].autoResearch && this.CanResearch(key))
|
|
|
|
|| (this.allTechs[key].top && (this.IsTechnologyResearched(this.allTechs[key].top) || this.IsTechnologyResearched(this.allTechs[key].bottom))))
|
2012-04-20 19:21:04 +02:00
|
|
|
{
|
|
|
|
delete this.autoResearchTech[key];
|
|
|
|
this.ResearchTechnology(key);
|
|
|
|
return; // We will have recursively handled any knock-on effects so can just return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TechnologyManager.prototype.GetTechnologyTemplate = function (tech)
|
|
|
|
{
|
2014-01-31 16:30:16 +01:00
|
|
|
if (!(tech in this.allTechs))
|
|
|
|
return undefined;
|
|
|
|
|
2012-04-20 19:21:04 +02:00
|
|
|
return this.allTechs[tech];
|
|
|
|
};
|
|
|
|
|
|
|
|
// Checks an entity template to see if its technology requirements have been met
|
|
|
|
TechnologyManager.prototype.CanProduce = function (templateName)
|
|
|
|
{
|
|
|
|
var cmpTempManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
|
|
|
|
var template = cmpTempManager.GetTemplate(templateName);
|
|
|
|
|
|
|
|
if (template.Identity && template.Identity.RequiredTechnology)
|
|
|
|
return this.IsTechnologyResearched(template.Identity.RequiredTechnology);
|
|
|
|
else
|
|
|
|
return true; // If there is no required technology then this entity can be produced
|
|
|
|
};
|
|
|
|
|
|
|
|
TechnologyManager.prototype.IsTechnologyResearched = function (tech)
|
|
|
|
{
|
|
|
|
return (this.researchedTechs[tech] !== undefined);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Checks the requirements for a technology to see if it can be researched at the current time
|
|
|
|
TechnologyManager.prototype.CanResearch = function (tech)
|
|
|
|
{
|
|
|
|
var template = this.GetTechnologyTemplate(tech);
|
|
|
|
if (!template)
|
|
|
|
{
|
|
|
|
warn("Technology \"" + tech + "\" does not exist");
|
|
|
|
return false;
|
|
|
|
}
|
2012-04-21 23:40:07 +02:00
|
|
|
|
2012-04-20 19:21:04 +02:00
|
|
|
// The technology which this technology supersedes is required
|
|
|
|
if (template.supersedes && !this.IsTechnologyResearched(template.supersedes))
|
|
|
|
return false;
|
|
|
|
|
2013-05-05 15:54:00 +02:00
|
|
|
if (template.top && this.IsInProgress(template.top) ||
|
|
|
|
template.bottom && this.IsInProgress(template.bottom))
|
|
|
|
return false;
|
|
|
|
|
2012-04-21 23:40:07 +02:00
|
|
|
if (template.pair && !this.CanResearch(template.pair))
|
|
|
|
return false;
|
2013-05-05 15:54:00 +02:00
|
|
|
|
2012-09-24 22:20:14 +02:00
|
|
|
if (this.IsInProgress(tech))
|
|
|
|
return false;
|
2012-04-21 23:40:07 +02:00
|
|
|
|
2014-03-29 12:03:00 +01:00
|
|
|
return this.CheckTechnologyRequirements(template.requirements || null);
|
2012-04-20 19:21:04 +02:00
|
|
|
};
|
|
|
|
|
2012-04-21 23:40:07 +02:00
|
|
|
// Private function for checking a set of requirements is met
|
2012-04-20 19:21:04 +02:00
|
|
|
TechnologyManager.prototype.CheckTechnologyRequirements = function (reqs)
|
|
|
|
{
|
|
|
|
// If there are no requirements then all requirements are met
|
|
|
|
if (!reqs)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (reqs.tech)
|
|
|
|
{
|
|
|
|
return this.IsTechnologyResearched(reqs.tech);
|
|
|
|
}
|
|
|
|
else if (reqs.all)
|
|
|
|
{
|
|
|
|
for (var i = 0; i < reqs.all.length; i++)
|
|
|
|
{
|
|
|
|
if (!this.CheckTechnologyRequirements(reqs.all[i]))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (reqs.any)
|
|
|
|
{
|
|
|
|
for (var i = 0; i < reqs.any.length; i++)
|
|
|
|
{
|
|
|
|
if (this.CheckTechnologyRequirements(reqs.any[i]))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (reqs.class)
|
|
|
|
{
|
2012-05-02 22:31:25 +02:00
|
|
|
if (reqs.numberOfTypes)
|
|
|
|
{
|
|
|
|
if (this.typeCountsByClass[reqs.class])
|
|
|
|
return (reqs.numberOfTypes <= Object.keys(this.typeCountsByClass[reqs.class]).length);
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (reqs.number)
|
|
|
|
{
|
|
|
|
if (this.classCounts[reqs.class])
|
|
|
|
return (reqs.number <= this.classCounts[reqs.class]);
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
2012-10-07 22:34:37 +02:00
|
|
|
}
|
|
|
|
else if (reqs.civ)
|
|
|
|
{
|
|
|
|
var cmpPlayer = Engine.QueryInterface(this.entity, IID_Player);
|
|
|
|
if (cmpPlayer && cmpPlayer.GetCiv() == reqs.civ)
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
2012-04-20 19:21:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// The technologies requirements are not a recognised format
|
|
|
|
error("Bad requirements " + uneval(reqs));
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
TechnologyManager.prototype.OnGlobalOwnershipChanged = function (msg)
|
|
|
|
{
|
|
|
|
// This automatically updates typeCounts, classCounts and typeCountsByClass
|
|
|
|
var playerID = (Engine.QueryInterface(this.entity, IID_Player)).GetPlayerID();
|
|
|
|
if (msg.to == playerID)
|
|
|
|
{
|
|
|
|
var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
|
|
|
|
var template = cmpTemplateManager.GetCurrentTemplateName(msg.entity);
|
|
|
|
|
|
|
|
this.typeCounts[template] = this.typeCounts[template] || 0;
|
|
|
|
this.typeCounts[template] += 1;
|
|
|
|
|
|
|
|
var cmpIdentity = Engine.QueryInterface(msg.entity, IID_Identity);
|
2012-09-23 21:19:57 +02:00
|
|
|
if (!cmpIdentity)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var classes = cmpIdentity.GetClassesList();
|
2012-12-08 20:17:48 +01:00
|
|
|
// don't use foundations for the class counts but check if techs apply (e.g. health increase)
|
|
|
|
if (!Engine.QueryInterface(msg.entity, IID_Foundation))
|
2012-04-20 19:21:04 +02:00
|
|
|
{
|
2012-12-08 20:17:48 +01:00
|
|
|
for (var i in classes)
|
|
|
|
{
|
|
|
|
this.classCounts[classes[i]] = this.classCounts[classes[i]] || 0;
|
|
|
|
this.classCounts[classes[i]] += 1;
|
2012-09-23 21:19:57 +02:00
|
|
|
|
2012-12-08 20:17:48 +01:00
|
|
|
this.typeCountsByClass[classes[i]] = this.typeCountsByClass[classes[i]] || {};
|
|
|
|
this.typeCountsByClass[classes[i]][template] = this.typeCountsByClass[classes[i]][template] || 0;
|
|
|
|
this.typeCountsByClass[classes[i]][template] += 1;
|
|
|
|
}
|
2012-09-23 21:19:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Newly created entity, check if any researched techs might apply
|
|
|
|
// (only do this for new entities because even if an entity is converted or captured,
|
|
|
|
// we want it to maintain whatever technologies previously applied)
|
|
|
|
if (msg.from == -1)
|
|
|
|
{
|
|
|
|
var modifiedComponents = {};
|
|
|
|
for (var name in this.modifications)
|
2012-04-20 19:21:04 +02:00
|
|
|
{
|
2012-09-23 21:19:57 +02:00
|
|
|
// We only need to find one one tech per component for a match
|
|
|
|
var modifications = this.modifications[name];
|
|
|
|
var component = name.split("/")[0];
|
|
|
|
for (var i in modifications)
|
2014-01-16 21:32:44 +01:00
|
|
|
if (DoesModificationApply(modifications[i], classes))
|
|
|
|
{
|
|
|
|
if (!modifiedComponents[component])
|
|
|
|
modifiedComponents[component] = [];
|
|
|
|
modifiedComponents[component].push(name);
|
|
|
|
}
|
2012-04-20 19:21:04 +02:00
|
|
|
}
|
2012-09-23 21:19:57 +02:00
|
|
|
|
|
|
|
// Send mesage(s) to the entity so it knows about researched techs
|
|
|
|
for (var component in modifiedComponents)
|
2014-01-16 21:32:44 +01:00
|
|
|
Engine.PostMessage(msg.entity, MT_ValueModification, { "entities": [msg.entity], "component": component, "valueNames": modifiedComponents[component] });
|
2012-04-20 19:21:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (msg.from == playerID)
|
|
|
|
{
|
|
|
|
var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
|
|
|
|
var template = cmpTemplateManager.GetCurrentTemplateName(msg.entity);
|
|
|
|
|
|
|
|
this.typeCounts[template] -= 1;
|
|
|
|
if (this.typeCounts[template] <= 0)
|
|
|
|
delete this.typeCounts[template];
|
|
|
|
|
|
|
|
// don't use foundations for the class counts
|
2012-12-08 20:17:48 +01:00
|
|
|
if (!Engine.QueryInterface(msg.entity, IID_Foundation))
|
2012-04-20 19:21:04 +02:00
|
|
|
{
|
2012-12-08 20:17:48 +01:00
|
|
|
var cmpIdentity = Engine.QueryInterface(msg.entity, IID_Identity);
|
|
|
|
if (cmpIdentity)
|
2012-04-20 19:21:04 +02:00
|
|
|
{
|
2012-12-08 20:17:48 +01:00
|
|
|
var classes = cmpIdentity.GetClassesList();
|
|
|
|
for (var i in classes)
|
|
|
|
{
|
|
|
|
this.classCounts[classes[i]] -= 1;
|
|
|
|
if (this.classCounts[classes[i]] <= 0)
|
|
|
|
delete this.classCounts[classes[i]];
|
2012-04-20 19:21:04 +02:00
|
|
|
|
2012-12-08 20:17:48 +01:00
|
|
|
this.typeCountsByClass[classes[i]][template] -= 1;
|
|
|
|
if (this.typeCountsByClass[classes[i]][template] <= 0)
|
|
|
|
delete this.typeCountsByClass[classes[i]][template];
|
|
|
|
}
|
2012-04-20 19:21:04 +02:00
|
|
|
}
|
|
|
|
}
|
2012-04-21 18:37:35 +02:00
|
|
|
|
|
|
|
this.clearModificationCache(msg.entity);
|
2012-04-20 19:21:04 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Marks a technology as researched. Note that this does not verify that the requirements are met.
|
|
|
|
TechnologyManager.prototype.ResearchTechnology = function (tech)
|
|
|
|
{
|
|
|
|
this.StoppedResearch(tech); // The tech is no longer being currently researched
|
|
|
|
|
|
|
|
var template = this.GetTechnologyTemplate(tech);
|
|
|
|
|
|
|
|
if (!template)
|
|
|
|
{
|
|
|
|
error("Tried to research invalid techonology: " + uneval(tech));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var modifiedComponents = {};
|
|
|
|
this.researchedTechs[tech] = template;
|
|
|
|
// store the modifications in an easy to access structure
|
|
|
|
if (template.modifications)
|
|
|
|
{
|
|
|
|
var affects = [];
|
|
|
|
if (template.affects && template.affects.length > 0)
|
|
|
|
{
|
|
|
|
for (var i in template.affects)
|
|
|
|
{
|
|
|
|
// Put the list of classes into an array for convenient access
|
|
|
|
affects.push(template.affects[i].split(/\s+/));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
affects.push([]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// We add an item to this.modifications for every modification in the template.modifications array
|
|
|
|
for (var i in template.modifications)
|
|
|
|
{
|
|
|
|
var modification = template.modifications[i];
|
|
|
|
if (!this.modifications[modification.value])
|
|
|
|
this.modifications[modification.value] = [];
|
|
|
|
|
2014-04-14 18:33:00 +02:00
|
|
|
var modAffects = affects.slice();
|
2012-04-21 18:37:35 +02:00
|
|
|
if (modification.affects)
|
|
|
|
{
|
2014-04-14 18:33:00 +02:00
|
|
|
var extraAffects = modification.affects.split(/\s+/);
|
|
|
|
for (var a in modAffects)
|
|
|
|
modAffects[a] = modAffects[a].concat(extraAffects);
|
2012-04-21 18:37:35 +02:00
|
|
|
}
|
|
|
|
|
2014-04-14 18:33:00 +02:00
|
|
|
var mod = {"affects": modAffects};
|
2012-04-21 18:37:35 +02:00
|
|
|
|
2012-04-20 19:21:04 +02:00
|
|
|
// copy the modification data into our new data structure
|
|
|
|
for (var j in modification)
|
2012-04-21 18:37:35 +02:00
|
|
|
if (j !== "value" && j !== "affects")
|
2012-04-20 19:21:04 +02:00
|
|
|
mod[j] = modification[j];
|
|
|
|
|
|
|
|
this.modifications[modification.value].push(mod);
|
2014-01-16 21:32:44 +01:00
|
|
|
var component = modification.value.split("/")[0];
|
|
|
|
if (!modifiedComponents[component])
|
|
|
|
modifiedComponents[component] = [];
|
|
|
|
modifiedComponents[component].push(modification.value);
|
2012-04-21 18:37:35 +02:00
|
|
|
this.modificationCache[modification.value] = {};
|
2012-04-20 19:21:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-09 23:32:21 +02:00
|
|
|
this.UpdateAutoResearch();
|
|
|
|
|
2014-01-16 21:32:44 +01:00
|
|
|
var cmpPlayer = Engine.QueryInterface(this.entity, IID_Player);
|
2014-01-18 21:26:52 +01:00
|
|
|
if (!cmpPlayer || cmpPlayer.GetPlayerID() === undefined)
|
2014-01-16 21:32:44 +01:00
|
|
|
return;
|
|
|
|
var playerID = cmpPlayer.GetPlayerID();
|
|
|
|
var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
|
|
|
var ents = cmpRangeManager.GetEntitiesByPlayer(playerID);
|
2014-01-18 21:26:52 +01:00
|
|
|
|
2013-10-15 12:05:08 +02:00
|
|
|
for (var component in modifiedComponents)
|
2014-01-16 21:32:44 +01:00
|
|
|
{
|
|
|
|
Engine.PostMessage(SYSTEM_ENTITY, MT_TemplateModification, { "player": playerID, "component": component, "valueNames": modifiedComponents[component]});
|
|
|
|
Engine.BroadcastMessage(MT_ValueModification, { "entities": ents, "component": component, "valueNames": modifiedComponents[component]});
|
|
|
|
}
|
2012-04-20 19:21:04 +02:00
|
|
|
};
|
|
|
|
|
2012-04-21 18:37:35 +02:00
|
|
|
// Clears the cached data for an entity from the modifications cache
|
|
|
|
TechnologyManager.prototype.clearModificationCache = function(ent)
|
|
|
|
{
|
|
|
|
for (var valueName in this.modificationCache)
|
|
|
|
delete this.modificationCache[valueName][ent];
|
|
|
|
};
|
|
|
|
|
|
|
|
// Caching layer in front of ApplyModificationsWorker
|
2012-04-28 01:06:40 +02:00
|
|
|
// Note: be careful with the type of curValue, if it should be a numerical
|
|
|
|
// value and is derived from template data, you must convert the string
|
|
|
|
// from the template to a number using the + operator, before calling
|
|
|
|
// this function!
|
2012-04-20 19:21:04 +02:00
|
|
|
TechnologyManager.prototype.ApplyModifications = function(valueName, curValue, ent)
|
2012-04-21 18:37:35 +02:00
|
|
|
{
|
|
|
|
if (!this.modificationCache[valueName])
|
|
|
|
this.modificationCache[valueName] = {};
|
|
|
|
|
2013-11-17 19:24:04 +01:00
|
|
|
if (!this.modificationCache[valueName][ent] || this.modificationCache[valueName][ent].origValue != curValue)
|
2012-04-20 19:21:04 +02:00
|
|
|
{
|
2013-11-17 19:24:04 +01:00
|
|
|
this.modificationCache[valueName][ent] = {"origValue": curValue};
|
2012-07-03 04:16:45 +02:00
|
|
|
var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
|
|
|
|
var templateName = cmpTemplateManager.GetCurrentTemplateName(ent);
|
2014-04-14 17:00:49 +02:00
|
|
|
// Ensure that preview or construction entites have the same properties as the final building
|
|
|
|
if (templateName.indexOf("preview|") > -1 || templateName.indexOf("construction|") > -1 )
|
|
|
|
templateName = templateName.slice(templateName.indexOf("|") + 1);
|
2013-11-17 19:24:04 +01:00
|
|
|
this.modificationCache[valueName][ent].newValue = GetTechModifiedProperty(this.modifications, cmpTemplateManager.GetTemplate(templateName), valueName, curValue);
|
2012-04-20 19:21:04 +02:00
|
|
|
}
|
|
|
|
|
2013-11-17 19:24:04 +01:00
|
|
|
return this.modificationCache[valueName][ent].newValue;
|
2012-07-20 03:54:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Alternative version of ApplyModifications, applies to templates instead of entities
|
|
|
|
TechnologyManager.prototype.ApplyModificationsTemplate = function(valueName, curValue, template)
|
|
|
|
{
|
|
|
|
return GetTechModifiedProperty(this.modifications, template, valueName, curValue);
|
|
|
|
};
|
2012-04-20 19:21:04 +02:00
|
|
|
|
2012-07-31 04:03:25 +02:00
|
|
|
// Marks a technology as being queued for research
|
|
|
|
TechnologyManager.prototype.QueuedResearch = function (tech, researcher)
|
|
|
|
{
|
|
|
|
this.researchQueued[tech] = researcher;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Marks a technology as actively being researched
|
2012-04-20 19:21:04 +02:00
|
|
|
TechnologyManager.prototype.StartedResearch = function (tech)
|
|
|
|
{
|
2012-07-31 04:03:25 +02:00
|
|
|
this.researchStarted[tech] = true;
|
2012-04-20 19:21:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Marks a technology as not being currently researched
|
|
|
|
TechnologyManager.prototype.StoppedResearch = function (tech)
|
|
|
|
{
|
2012-07-31 04:03:25 +02:00
|
|
|
delete this.researchQueued[tech];
|
|
|
|
delete this.researchStarted[tech];
|
2012-04-20 19:21:04 +02:00
|
|
|
};
|
|
|
|
|
2012-07-31 04:03:25 +02:00
|
|
|
// Checks whether a technology is set to be researched
|
2012-04-20 19:21:04 +02:00
|
|
|
TechnologyManager.prototype.IsInProgress = function(tech)
|
|
|
|
{
|
2012-07-31 04:03:25 +02:00
|
|
|
if (this.researchQueued[tech])
|
2012-04-20 19:21:04 +02:00
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2012-07-31 04:03:25 +02:00
|
|
|
// Get all techs that are currently being researched
|
|
|
|
TechnologyManager.prototype.GetTechsStarted = function()
|
|
|
|
{
|
|
|
|
return this.researchStarted;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Gets the entity currently researching a technology
|
|
|
|
TechnologyManager.prototype.GetResearcher = function(tech)
|
|
|
|
{
|
|
|
|
if (this.researchQueued[tech])
|
|
|
|
return this.researchQueued[tech];
|
|
|
|
return undefined;
|
|
|
|
};
|
|
|
|
|
2012-07-03 04:16:45 +02:00
|
|
|
// Get helper data for tech modifications
|
|
|
|
TechnologyManager.prototype.GetTechModifications = function()
|
|
|
|
{
|
|
|
|
return this.modifications;
|
|
|
|
};
|
|
|
|
|
2013-03-05 23:52:48 +01:00
|
|
|
// called by GUIInterface for PlayerData. AI use.
|
|
|
|
TechnologyManager.prototype.GetQueuedResearch = function()
|
|
|
|
{
|
|
|
|
return this.researchQueued;
|
|
|
|
};
|
|
|
|
TechnologyManager.prototype.GetStartedResearch = function()
|
|
|
|
{
|
|
|
|
return this.researchStarted;
|
|
|
|
};
|
|
|
|
TechnologyManager.prototype.GetResearchedTechs = function()
|
|
|
|
{
|
|
|
|
return this.researchedTechs;
|
|
|
|
};
|
|
|
|
TechnologyManager.prototype.GetClassCounts = function()
|
|
|
|
{
|
|
|
|
return this.classCounts;
|
|
|
|
};
|
|
|
|
TechnologyManager.prototype.GetTypeCountsByClass = function()
|
|
|
|
{
|
|
|
|
return this.typeCountsByClass;
|
|
|
|
};
|
|
|
|
|
2012-04-20 19:21:04 +02:00
|
|
|
Engine.RegisterComponentType(IID_TechnologyManager, "TechnologyManager", TechnologyManager);
|