Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/StatusBars.js
Show First 20 Lines • Show All 238 Lines • ▼ Show 20 Lines | StatusBars.prototype.AddResourceSupplyBar = function(cmpOverlayRenderer, yoffset) | ||||
return this.AddBar(cmpOverlayRenderer, yoffset, "supply", value); | return this.AddBar(cmpOverlayRenderer, yoffset, "supply", value); | ||||
}; | }; | ||||
StatusBars.prototype.AddCaptureBar = function(cmpOverlayRenderer, yoffset) | StatusBars.prototype.AddCaptureBar = function(cmpOverlayRenderer, yoffset) | ||||
{ | { | ||||
if (!this.enabled) | if (!this.enabled) | ||||
return 0; | return 0; | ||||
let cmpCapturable = QueryMiragedInterface(this.entity, IID_Capturable); | const cmpCapturable = QueryMiragedInterface(this.entity, IID_Capturable); | ||||
if (!cmpCapturable) | if (!cmpCapturable) | ||||
return 0; | return 0; | ||||
let cmpOwnership = QueryMiragedInterface(this.entity, IID_Ownership); | const cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); | ||||
wraitii: this is a bug btw | |||||
StanUnsubmitted Not Done Inline ActionsWhy? Can't it have been captured in the meantime? Stan: Why? Can't it have been captured in the meantime? | |||||
wraitiiAuthorUnsubmitted Done Inline ActionsI mean the earlier version using QueryMiragedInterface. IID_Ownership isn't miraged, so this returned null. wraitii: I mean the earlier version using QueryMiragedInterface. IID_Ownership isn't miraged, so this… | |||||
if (!cmpOwnership) | if (!cmpOwnership) | ||||
return 0; | return 0; | ||||
let owner = cmpOwnership.GetOwner(); | const owner = cmpOwnership.GetOwner(); | ||||
if (owner == INVALID_PLAYER) | if (owner == INVALID_PLAYER) | ||||
return 0; | return 0; | ||||
this.usedPlayerColors = true; | this.usedPlayerColors = true; | ||||
let capturePoints = cmpCapturable.GetCapturePoints(); | const capturePoints = cmpCapturable.GetCapturePoints(); | ||||
// Size of health bar (in world-space units) | // Size of health bar (in world-space units) | ||||
let width = +this.template.BarWidth; | const width = +this.template.BarWidth; | ||||
let height = +this.template.BarHeight; | const height = +this.template.BarHeight; | ||||
// World-space offset from the unit's position | // World-space offset from the unit's position | ||||
let offset = { "x": 0, "y": +this.template.HeightOffset, "z": 0 }; | const offset = { "x": 0, "y": +this.template.HeightOffset, "z": 0 }; | ||||
let setCaptureBarPart = function(playerID, startSize) | const setCaptureBarPart = function(playerID, startSize) | ||||
{ | { | ||||
let c = QueryPlayerIDInterface(playerID).GetDisplayedColor(); | const c = QueryPlayerIDInterface(playerID).GetDisplayedColor(); | ||||
let strColor = (c.r * 255) + " " + (c.g * 255) + " " + (c.b * 255) + " 255"; | const strColor = (c.r * 255) + " " + (c.g * 255) + " " + (c.b * 255) + " 255"; | ||||
let size = width * capturePoints[playerID] / cmpCapturable.GetMaxCapturePoints(); | const size = width * capturePoints[playerID] / cmpCapturable.GetMaxCapturePoints(); | ||||
cmpOverlayRenderer.AddSprite( | cmpOverlayRenderer.AddSprite( | ||||
"art/textures/ui/session/icons/capture_bar.png", | "art/textures/ui/session/icons/capture_bar.png", | ||||
{ "x": startSize, "y": yoffset }, | { "x": startSize, "y": yoffset }, | ||||
{ "x": startSize + size, "y": height + yoffset }, | { "x": startSize + size, "y": height + yoffset }, | ||||
offset, | offset, | ||||
strColor | strColor | ||||
); | ); | ||||
return size + startSize; | return size + startSize; | ||||
}; | }; | ||||
// First handle the owner's points, to keep those points on the left for clarity | // First handle the owner's points, to keep those points on the left for clarity | ||||
let size = setCaptureBarPart(owner, -width / 2); | let size = setCaptureBarPart(owner, -width / 2); | ||||
for (let i in capturePoints) | for (const i in capturePoints) | ||||
if (i != owner && capturePoints[i] > 0) | if (i != owner && capturePoints[i] > 0) | ||||
size = setCaptureBarPart(i, size); | size = setCaptureBarPart(i, size); | ||||
return height * 1.2; | return height * 1.2; | ||||
}; | }; | ||||
StatusBars.prototype.AddAuraIcons = function(cmpOverlayRenderer, yoffset) | StatusBars.prototype.AddAuraIcons = function(cmpOverlayRenderer, yoffset) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
this is a bug btw