Index: binaries/data/mods/public/simulation/components/Promotion.js =================================================================== --- binaries/data/mods/public/simulation/components/Promotion.js +++ binaries/data/mods/public/simulation/components/Promotion.js @@ -166,6 +166,8 @@ } this.Promote(promotedTemplateName); } + + Engine.PostMessage(this.entity, MT_ExperienceChanged, {}); }; Promotion.prototype.OnValueModification = function(msg) Index: binaries/data/mods/public/simulation/components/StatusBars.js =================================================================== --- binaries/data/mods/public/simulation/components/StatusBars.js +++ binaries/data/mods/public/simulation/components/StatusBars.js @@ -25,6 +25,7 @@ "ResourceSupplyBar", "CaptureBar", "HealthBar", + "XpBar", "AuraIcons", "RankIcon" ]; @@ -107,6 +108,12 @@ this.RegenerateSprites(); }; +StatusBars.prototype.OnExperienceChanged = function() +{ + if (this.enabled) + this.RegenerateSprites(); +}; + StatusBars.prototype.UpdateColor = function() { if (this.usedPlayerColors) @@ -127,11 +134,11 @@ /** * Generic piece of code to add a bar. */ -StatusBars.prototype.AddBar = function(cmpOverlayRenderer, yoffset, type, amount) +StatusBars.prototype.AddBar = function(cmpOverlayRenderer, yoffset, type, amount, heightMultiplier = 1) { // Size of health bar (in world-space units) let width = +this.template.BarWidth; - let height = +this.template.BarHeight; + let height = +this.template.BarHeight * heightMultiplier; // World-space offset from the unit's position let offset = { "x": 0, "y": +this.template.HeightOffset, "z": 0 }; @@ -157,6 +164,18 @@ return height * 1.2; }; +StatusBars.prototype.AddXpBar = function(cmpOverlayRenderer, yoffset) +{ + if (!this.enabled) + return 0; + + let cmpPromotion = Engine.QueryInterface(this.entity, IID_Promotion); + if (!cmpPromotion || !cmpPromotion.GetCurrentXp() || !cmpPromotion.GetRequiredXp()) + return 0; + + return this.AddBar(cmpOverlayRenderer, yoffset, "pack", cmpPromotion.GetCurrentXp() / cmpPromotion.GetRequiredXp(), 2/3); +}; + StatusBars.prototype.AddPackBar = function(cmpOverlayRenderer, yoffset) { if (!this.enabled) Index: binaries/data/mods/public/simulation/components/interfaces/Promotion.js =================================================================== --- binaries/data/mods/public/simulation/components/interfaces/Promotion.js +++ binaries/data/mods/public/simulation/components/interfaces/Promotion.js @@ -1 +1,7 @@ Engine.RegisterInterface("Promotion"); + +/** + * Message of the form {} + * sent from Promotion component whenever the experience changes. + */ +Engine.RegisterMessageType("ExperienceChanged");