Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Promotion.js
Show All 34 Lines | Promotion.prototype.Promote = function(promotedTemplateName) | ||||
if (cmpHealth && cmpHealth.GetHitpoints() == 0) | if (cmpHealth && cmpHealth.GetHitpoints() == 0) | ||||
{ | { | ||||
this.promotedUnitEntity = INVALID_ENTITY; | this.promotedUnitEntity = INVALID_ENTITY; | ||||
return; | return; | ||||
} | } | ||||
// Save the entity id. | // Save the entity id. | ||||
this.promotedUnitEntity = ChangeEntityTemplate(this.entity, promotedTemplateName); | this.promotedUnitEntity = ChangeEntityTemplate(this.entity, promotedTemplateName); | ||||
let cmpPosition = Engine.QueryInterface(this.promotedUnitEntity, IID_Position); | |||||
let cmpUnitAI = Engine.QueryInterface(this.promotedUnitEntity, IID_UnitAI); | |||||
if (cmpPosition && cmpPosition.IsInWorld() && cmpUnitAI) | |||||
cmpUnitAI.Cheer(); | |||||
}; | }; | ||||
Promotion.prototype.IncreaseXp = function(amount) | Promotion.prototype.IncreaseXp = function(amount) | ||||
{ | { | ||||
// if the unit was already promoted, but is waiting for the engine to be destroyed | // if the unit was already promoted, but is waiting for the engine to be destroyed | ||||
// transfer the gained xp to the promoted unit if applicable | // transfer the gained xp to the promoted unit if applicable | ||||
if (this.promotedUnitEntity) | if (this.promotedUnitEntity) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator