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; | ||||
// entity can be an owned entity or a player entity. | // entity can be an owned entity or a player entity. | ||||
let cmpTechnologyManager = Engine.QueryInterface(entity, IID_Player) ? | let cmpModificationsManager = Engine.QueryInterface(entity, IID_Player) ? | ||||
Engine.QueryInterface(entity, IID_TechnologyManager) : QueryOwnerInterface(entity, IID_TechnologyManager); | Engine.QueryInterface(entity, IID_ModificationsManager) : QueryOwnerInterface(entity, IID_ModificationsManager); | ||||
if (cmpTechnologyManager) | if (cmpModificationsManager) | ||||
value = cmpTechnologyManager.ApplyModifications(tech_type, current_value, entity); | value = cmpModificationsManager.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 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 cmpModificationsManager = QueryPlayerIDInterface(playerID, IID_ModificationsManager); | ||||
if (cmpTechnologyManager) | if (cmpModificationsManager) | ||||
value = cmpTechnologyManager.ApplyModificationsTemplate(tech_type, current_value, template); | value = cmpModificationsManager.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("ApplyValueModificationsToTemplate", ApplyValueModificationsToTemplate); | Engine.RegisterGlobal("ApplyValueModificationsToTemplate", ApplyValueModificationsToTemplate); |
Wildfire Games · Phabricator