1
0
forked from mirrors/0ad
Files
0ad/binaries/data/mods/public/simulation/helpers/ValueModification.js
T
leper f8ff206169 Recreate some tech modified values upon deserialization. Fixes #3055.
Also check for some possible null pointers.

This was SVN commit r16364.
2015-02-21 01:41:24 +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);