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 @@ -27,6 +27,7 @@ "CaptureBar", "HealthBar", "AuraIcons", + "RankIcon", ]; StatusBars.prototype.Init = function() @@ -40,7 +41,7 @@ */ StatusBars.prototype.Serialize = function() { - return {"auraSources": this.auraSources}; + return { "auraSources": this.auraSources }; }; StatusBars.prototype.Deserialize = function(data) @@ -108,7 +109,7 @@ let yoffset = 0; for (let sprite of this.Sprites) - yoffset += this["Add"+sprite](cmpOverlayRenderer, yoffset); + yoffset += this["Add" + sprite](cmpOverlayRenderer, yoffset); }; // Internal helper functions @@ -126,18 +127,18 @@ // background cmpOverlayRenderer.AddSprite( - "art/textures/ui/session/icons/"+type+"_bg.png", - { "x": -width/2, "y": yoffset }, - { "x": width/2, "y": height + yoffset}, + "art/textures/ui/session/icons/" + type + "_bg.png", + { "x": -width / 2, "y": yoffset }, + { "x": width / 2, "y": height + yoffset }, offset, NATURAL_COLOR ); // foreground cmpOverlayRenderer.AddSprite( - "art/textures/ui/session/icons/"+type+"_fg.png", - { "x": -width/2, "y": yoffset}, - { "x": width*(amount - 0.5), "y": height + yoffset}, + "art/textures/ui/session/icons/" + type + "_fg.png", + { "x": -width / 2, "y": yoffset }, + { "x": width * (amount - 0.5), "y": height + yoffset }, offset, NATURAL_COLOR ); @@ -163,7 +164,7 @@ return 0; let cmpHealth = QueryMiragedInterface(this.entity, IID_Health); - if (!cmpHealth || !cmpHealth.GetHitpoints() > 0) + if (!cmpHealth || cmpHealth.GetHitpoints() <= 0) return 0; return this.AddBar(cmpOverlayRenderer, yoffset, "health", cmpHealth.GetHitpoints() / cmpHealth.GetMaxHitpoints()); @@ -215,7 +216,7 @@ cmpOverlayRenderer.AddSprite( "art/textures/ui/session/icons/capture_bar.png", { "x": startSize, "y": yoffset }, - { "x": startSize + size, "y": height + yoffset}, + { "x": startSize + size, "y": height + yoffset }, offset, strColor ); @@ -259,8 +260,8 @@ { cmpOverlayRenderer.AddSprite( icon, - { "x": xoffset - iconSize/2, "y": yoffset }, - { "x": xoffset + iconSize/2, "y": iconSize + yoffset }, + { "x": xoffset - iconSize / 2, "y": yoffset }, + { "x": xoffset + iconSize / 2, "y": iconSize + yoffset }, offset, NATURAL_COLOR ); @@ -270,6 +271,37 @@ return iconSize + this.template.BarHeight / 2; }; +StatusBars.prototype.AddRankIcon = function(cmpOverlayRenderer, yoffset) +{ + if (!this.enabled) + return 0; + + let cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); + if (!cmpIdentity || !cmpIdentity.GetRank()) + return 0; + + let icon = { + "Basic": "art/textures/ui/session/icons/rank1.png", + "Advanced": "art/textures/ui/session/icons/rank2.png", + "Elite": "art/textures/ui/session/icons/rank3.png" + }[cmpIdentity.GetRank()]; + + if (!icon) + return 0; + + // World-space offset from the unit's position + let offset = { "x": 0, "y": +this.template.HeightOffset + 0.1, "z": 0 }; + let iconSize = +this.template.BarWidth / 2; + cmpOverlayRenderer.AddSprite( + icon, + { "x": -iconSize / 2, "y": yoffset }, + { "x": iconSize / 2, "y": iconSize + yoffset }, + offset, + NATURAL_COLOR + ); + + return iconSize + this.template.BarHeight / 2; +}; Engine.RegisterComponentType(IID_StatusBars, "StatusBars", StatusBars);