Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/helpers/Transform.js
Show First 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | if (newTemplate.Obstruction.Obstructions || | ||||
newTemplate.Obstruction.Unit && template.Obstruction.Static && | newTemplate.Obstruction.Unit && template.Obstruction.Static && | ||||
(newTemplate.Obstruction.Unit["@radius"] > template.Obstruction.Static["@width"] || | (newTemplate.Obstruction.Unit["@radius"] > template.Obstruction.Static["@width"] || | ||||
newTemplate.Obstruction.Unit["@radius"] > template.Obstruction.Static["@depth"])) | newTemplate.Obstruction.Unit["@radius"] > template.Obstruction.Static["@depth"])) | ||||
{ | { | ||||
var cmpNewObstruction = Engine.QueryInterface(previewEntity, IID_Obstruction); | var cmpNewObstruction = Engine.QueryInterface(previewEntity, IID_Obstruction); | ||||
if (cmpNewObstruction && cmpNewObstruction.GetBlockMovementFlag()) | if (cmpNewObstruction && cmpNewObstruction.GetBlockMovementFlag()) | ||||
{ | { | ||||
// Remove all obstructions at the new entity, especially animal corpses | // Remove all obstructions at the new entity, especially animal corpses | ||||
for (let ent of cmpNewObstruction.GetEntitiesDeletedUponConstruction()) | for (let ent of cmpNewObstruction.GetEntitiesDeletedUponConstruction()) | ||||
Lint: ESLintBear (no-shadow): `'ent' is already declared in the upper scope.` | |||||
Engine.DestroyEntity(ent); | Engine.DestroyEntity(ent); | ||||
let collisions = cmpNewObstruction.GetEntitiesBlockingConstruction(); | let collisions = cmpNewObstruction.GetEntitiesBlockingConstruction(); | ||||
if (collisions.length) | if (collisions.length) | ||||
return DeleteEntityAndReturn(previewEntity, cmpPosition, pos, angle, cmpNewPosition, true); | return DeleteEntityAndReturn(previewEntity, cmpPosition, pos, angle, cmpNewPosition, true); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
Show All 21 Lines | function TransferGarrisonedUnits(oldEnt, newEnt) | ||||
let cmpOldGarrison = Engine.QueryInterface(oldEnt, IID_GarrisonHolder); | let cmpOldGarrison = Engine.QueryInterface(oldEnt, IID_GarrisonHolder); | ||||
if (!cmpOldGarrison || !cmpOldGarrison.GetEntities().length) | if (!cmpOldGarrison || !cmpOldGarrison.GetEntities().length) | ||||
return; | return; | ||||
let cmpNewGarrison = Engine.QueryInterface(newEnt, IID_GarrisonHolder); | let cmpNewGarrison = Engine.QueryInterface(newEnt, IID_GarrisonHolder); | ||||
let entities = cmpOldGarrison.GetEntities().slice(); | let entities = cmpOldGarrison.GetEntities().slice(); | ||||
for (let ent of entities) | for (let ent of entities) | ||||
{ | { | ||||
cmpOldGarrison.Eject(ent); | cmpOldGarrison.Unload(ent); | ||||
if (!cmpNewGarrison) | if (!cmpNewGarrison) | ||||
continue; | continue; | ||||
let cmpGarrisonable = Engine.QueryInterface(ent, IID_Garrisonable); | let cmpGarrisonable = Engine.QueryInterface(ent, IID_Garrisonable); | ||||
if (!cmpGarrisonable) | if (!cmpGarrisonable) | ||||
continue; | continue; | ||||
cmpGarrisonable.Autogarrison(newEnt); | cmpGarrisonable.Autogarrison(newEnt); | ||||
} | } | ||||
} | } | ||||
Engine.RegisterGlobal("ChangeEntityTemplate", ChangeEntityTemplate); | Engine.RegisterGlobal("ChangeEntityTemplate", ChangeEntityTemplate); | ||||
Engine.RegisterGlobal("ObstructionsBlockingTemplateChange", ObstructionsBlockingTemplateChange); | Engine.RegisterGlobal("ObstructionsBlockingTemplateChange", ObstructionsBlockingTemplateChange); |
Wildfire Games · Phabricator
'ent' is already declared in the upper scope.