0ad/binaries/data/mods/public/simulation/helpers/ValueModification.js
Ralph Sennhauser 5a9968f88d Fix eslint rule 'prefer-const' in simulation/helpers
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
    binaries/data/mods/public/simulation/helpers

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-11 08:50:27 +02:00

24 lines
993 B
JavaScript

// Little helper functions to make applying technology and auras more convenient
function ApplyValueModificationsToEntity(tech_type, current_value, entity)
{
let value = current_value;
// entity can be an owned entity or a player entity.
const cmpModifiersManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ModifiersManager);
if (cmpModifiersManager)
value = cmpModifiersManager.ApplyModifiers(tech_type, current_value, entity);
return value;
}
function ApplyValueModificationsToTemplate(tech_type, current_value, playerID, template)
{
let value = current_value;
const cmpModifiersManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ModifiersManager);
if (cmpModifiersManager)
value = cmpModifiersManager.ApplyTemplateModifiers(tech_type, current_value, template, playerID);
return value;
}
Engine.RegisterGlobal("ApplyValueModificationsToEntity", ApplyValueModificationsToEntity);
Engine.RegisterGlobal("ApplyValueModificationsToTemplate", ApplyValueModificationsToTemplate);