0ad/binaries/data/mods/public/simulation/helpers/ValueModification.js
Itms 04343a8407 Fix a comment written too quickly
This was SVN commit r16005.
2014-11-23 21:47:15 +00:00

42 lines
1.7 KiB
JavaScript

// Little helper functions to make applying technology more convenient
function ApplyValueModificationsToEntity(tech_type, current_value, entity)
{
let value = current_value;
let cmpTechnologyManager = QueryOwnerInterface(entity, IID_TechnologyManager);
if (cmpTechnologyManager)
value = cmpTechnologyManager.ApplyModifications(tech_type, current_value, entity);
let cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager);
if (!cmpAuraManager)
return value;
return cmpAuraManager.ApplyModifications(tech_type, value, entity);
}
function ApplyValueModificationsToPlayer(tech_type, current_value, player_entity)
{
let cmpTechnologyManager = Engine.QueryInterface(player_entity, IID_TechnologyManager);
if (!cmpTechnologyManager)
return current_value;
return cmpTechnologyManager.ApplyModifications(tech_type, current_value, player_entity);
}
function ApplyValueModificationsToTemplate(tech_type, current_value, playerID, template)
{
let value = current_value;
let cmpTechnologyManager = QueryPlayerIDInterface(playerID, IID_TechnologyManager);
if (cmpTechnologyManager)
value = cmpTechnologyManager.ApplyModificationsTemplate(tech_type, current_value, template);
let cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager);
if (!cmpAuraManager)
return value;
return cmpAuraManager.ApplyTemplateModifications(tech_type, value, playerID, template);
}
Engine.RegisterGlobal("ApplyValueModificationsToEntity", ApplyValueModificationsToEntity);
Engine.RegisterGlobal("ApplyValueModificationsToPlayer", ApplyValueModificationsToPlayer);
Engine.RegisterGlobal("ApplyValueModificationsToTemplate", ApplyValueModificationsToTemplate);