Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/maps/scenarios/units_demo.js
/** | /** | ||||
* Whether to also place all actors. | * Whether to also place all actors. | ||||
*/ | */ | ||||
let actors = false; | let actors = false; | ||||
/** | /** | ||||
* Coordinates of the first entity. | * Coordinates of the first entity. | ||||
*/ | */ | ||||
let startX = 20; | let startX = 50; | ||||
Lint: prefer-const: 'startX' is never reassigned. Use 'const' instead. | |||||
let startZ = 20; | let startZ = 65; | ||||
Lint: prefer-const 'startZ' is never reassigned. Use 'const' instead. Lint: prefer-const: 'startZ' is never reassigned. Use 'const' instead. | |||||
/** | /** | ||||
* Horizontal coordinate of the last entity in the current row. | * Horizontal coordinate of the last entity in the current row. | ||||
*/ | */ | ||||
let stopX = 1580; | let stopX = 1870; | ||||
Lint: prefer-const 'stopX' is never reassigned. Use 'const' instead. Lint: prefer-const: 'stopX' is never reassigned. Use 'const' instead. | |||||
/** | /** | ||||
* Coordinates of the current entity. | * Coordinates of the current entity. | ||||
*/ | */ | ||||
let x = startX; | let x = startX; | ||||
let z = startZ; | let z = startZ; | ||||
/** | /** | ||||
* Recall the greatest length in the current row to prevent overlapping. | * Recall the greatest length in the current row to prevent overlapping. | ||||
*/ | */ | ||||
let maxh = 0; | let maxh = 0; | ||||
/** | /** | ||||
* Space between entities. | * Space between entities. | ||||
*/ | */ | ||||
let gap = 14; | let gap = 20; | ||||
Lint: prefer-const 'gap' is never reassigned. Use 'const' instead. Lint: prefer-const: 'gap' is never reassigned. Use 'const' instead. | |||||
let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); | let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); | ||||
for (let template of cmpTemplateManager.FindAllTemplates(actors)) | for (let template of cmpTemplateManager.FindAllTemplates(actors)) | ||||
{ | { | ||||
print(template + "...\n"); | print(template + "...\n"); | ||||
let ent = Engine.AddEntity(template); | let ent = Engine.AddEntity(template); | ||||
if (!ent) | if (!ent) | ||||
Show All 27 Lines | for (let template of cmpTemplateManager.FindAllTemplates(actors)) | ||||
let cmpPosition = Engine.QueryInterface(ent, IID_Position); | let cmpPosition = Engine.QueryInterface(ent, IID_Position); | ||||
if (!cmpPosition) | if (!cmpPosition) | ||||
{ | { | ||||
warn(template + " has no position\n"); | warn(template + " has no position\n"); | ||||
Engine.DestroyEntity(ent); | Engine.DestroyEntity(ent); | ||||
continue; | continue; | ||||
} | } | ||||
cmpPosition.MoveTo(x + w / 2, z); | cmpPosition.MoveTo(x + w / 2, z); | ||||
SilierUnsubmitted Not Done Inline Actionsjust mental note: this should jumpTo not moveTo Silier: just mental note: this should jumpTo not moveTo | |||||
cmpPosition.SetYRotation(Math.PI * 3 / 4); | cmpPosition.SetYRotation(Math.PI * 3 / 4); | ||||
let cmpOwnership = Engine.QueryInterface(ent, IID_Ownership); | let cmpOwnership = Engine.QueryInterface(ent, IID_Ownership); | ||||
if (cmpOwnership) | if (cmpOwnership) | ||||
cmpOwnership.SetOwner(1); | cmpOwnership.SetOwner(1); | ||||
x += w + gap; | x += w + gap; | ||||
maxh = Math.max(maxh, h); | maxh = Math.max(maxh, h); | ||||
} | } |
Wildfire Games · Phabricator
'startX' is never reassigned. Use 'const' instead.