Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/helpers/ValueModification.js
// Little helper functions to make applying technology and auras more convenient | // Little helper functions to make applying technology and auras more convenient | ||||
function ApplyValueModificationsToEntity(tech_type, current_value, entity) | function ApplyValueModificationsToEntity(tech_type, current_value, entity) | ||||
{ | { | ||||
let value = current_value; | let value = current_value; | ||||
let cmpTechnologyManager = QueryOwnerInterface(entity, IID_TechnologyManager); | let cmpModManager = QueryOwnerInterface(entity, IID_ModifiersManager); | ||||
if (cmpTechnologyManager) | if (cmpModManager) | ||||
value = cmpTechnologyManager.ApplyModifications(tech_type, current_value, entity); | value = cmpModManager.ApplyModifications(tech_type, current_value, entity); | ||||
let cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager); | let cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager); | ||||
if (!cmpAuraManager) | if (!cmpAuraManager) | ||||
return value; | return value; | ||||
return cmpAuraManager.ApplyModifications(tech_type, value, entity); | return cmpAuraManager.ApplyModifications(tech_type, value, entity); | ||||
} | } | ||||
function ApplyValueModificationsToPlayer(tech_type, current_value, playerEntity, playerID) | function ApplyValueModificationsToPlayer(tech_type, current_value, playerEntity, playerID) | ||||
{ | { | ||||
let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); | let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); | ||||
let entityTemplateName = cmpTemplateManager.GetCurrentTemplateName(playerEntity); | let entityTemplateName = cmpTemplateManager.GetCurrentTemplateName(playerEntity); | ||||
let entityTemplate = cmpTemplateManager.GetTemplate(entityTemplateName); | let entityTemplate = cmpTemplateManager.GetTemplate(entityTemplateName); | ||||
return ApplyValueModificationsToTemplate(tech_type, current_value, playerID, entityTemplate); | return ApplyValueModificationsToTemplate(tech_type, current_value, playerID, entityTemplate); | ||||
} | } | ||||
function ApplyValueModificationsToTemplate(tech_type, current_value, playerID, template) | function ApplyValueModificationsToTemplate(tech_type, current_value, playerID, template) | ||||
{ | { | ||||
let value = current_value; | let value = current_value; | ||||
let cmpTechnologyManager = QueryPlayerIDInterface(playerID, IID_TechnologyManager); | let cmpModManager = QueryPlayerIDInterface(playerID, IID_ModifiersManager); | ||||
if (cmpTechnologyManager) | if (cmpModManager) | ||||
value = cmpTechnologyManager.ApplyModificationsTemplate(tech_type, current_value, template); | value = cmpModManager.ApplyModificationsTemplate(tech_type, current_value, template); | ||||
let cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager); | let cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager); | ||||
if (!cmpAuraManager) | if (!cmpAuraManager) | ||||
return value; | return value; | ||||
return cmpAuraManager.ApplyTemplateModifications(tech_type, value, playerID, template); | return cmpAuraManager.ApplyTemplateModifications(tech_type, value, playerID, template); | ||||
} | } | ||||
Engine.RegisterGlobal("ApplyValueModificationsToEntity", ApplyValueModificationsToEntity); | Engine.RegisterGlobal("ApplyValueModificationsToEntity", ApplyValueModificationsToEntity); | ||||
Engine.RegisterGlobal("ApplyValueModificationsToPlayer", ApplyValueModificationsToPlayer); | Engine.RegisterGlobal("ApplyValueModificationsToPlayer", ApplyValueModificationsToPlayer); | ||||
Engine.RegisterGlobal("ApplyValueModificationsToTemplate", ApplyValueModificationsToTemplate); | Engine.RegisterGlobal("ApplyValueModificationsToTemplate", ApplyValueModificationsToTemplate); |
Wildfire Games · Phabricator