Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/TechnologyManager.js
function TechnologyManager() {} | function TechnologyManager() {} | ||||
TechnologyManager.prototype.Schema = | TechnologyManager.prototype.Schema = | ||||
"<empty/>"; | "<empty/>"; | ||||
TechnologyManager.prototype.Update = function() { | |||||
warn("TechnologyManager.Update: not implemented"); | |||||
} | |||||
/** | /** | ||||
* This object represents a technology under research. | * This object represents a technology under research. | ||||
* @param {string} templateName - The name of the template to research. | * @param {string} templateName - The name of the template to research. | ||||
* @param {number} player - The player ID researching. | * @param {number} player - The player ID researching. | ||||
* @param {number} researcher - The entity ID researching. | * @param {number} researcher - The entity ID researching. | ||||
*/ | */ | ||||
TechnologyManager.prototype.Technology = function(templateName, player, researcher) | TechnologyManager.prototype.Technology = function(templateName, player, researcher) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 404 Lines • ▼ Show 20 Lines | if (!Engine.QueryInterface(msg.entity, IID_Foundation)) | ||||
if (this.typeCountsByClass[cls][template] <= 0) | if (this.typeCountsByClass[cls][template] <= 0) | ||||
delete this.typeCountsByClass[cls][template]; | delete this.typeCountsByClass[cls][template]; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
TechnologyManager.prototype.OnGlobalIdentityClassesChanged = function(msg) | |||||
{ | |||||
warn("TODO: fix this"); | |||||
var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); | |||||
var template = cmpTemplateManager.GetCurrentTemplateName(msg.entity); | |||||
var cmpIdentity = Engine.QueryInterface(msg.entity, IID_Identity); | |||||
if (!cmpIdentity) | |||||
return; | |||||
var classes = cmpIdentity.GetClassesList(); | |||||
// don't use foundations for the class counts but check if techs apply (e.g. health increase) | |||||
if (!Engine.QueryInterface(msg.entity, IID_Foundation)) | |||||
{ | |||||
for (let cls of classes) | |||||
{ | |||||
this.classCounts[cls] = this.classCounts[cls] || 0; | |||||
this.classCounts[cls] += 1; | |||||
this.typeCountsByClass[cls] = this.typeCountsByClass[cls] || {}; | |||||
this.typeCountsByClass[cls][template] = this.typeCountsByClass[cls][template] || 0; | |||||
this.typeCountsByClass[cls][template] += 1; | |||||
} | |||||
} | |||||
}; | |||||
/** | /** | ||||
* This does neither apply effects nor verify requirements. | * This does neither apply effects nor verify requirements. | ||||
* @param {string} tech - The name of the technology to mark as researched. | * @param {string} tech - The name of the technology to mark as researched. | ||||
*/ | */ | ||||
TechnologyManager.prototype.MarkTechnologyAsResearched = function(tech) | TechnologyManager.prototype.MarkTechnologyAsResearched = function(tech) | ||||
{ | { | ||||
this.researchedTechs.add(tech); | this.researchedTechs.add(tech); | ||||
this.UpdateAutoResearch(); | this.UpdateAutoResearch(); | ||||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator