Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/helpers/Transform.js
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | function ChangeEntityTemplate(oldEnt, newTemplate) | ||||
var cmpNewUnitAI = Engine.QueryInterface(newEnt, IID_UnitAI); | var cmpNewUnitAI = Engine.QueryInterface(newEnt, IID_UnitAI); | ||||
if (cmpUnitAI && cmpNewUnitAI) | if (cmpUnitAI && cmpNewUnitAI) | ||||
{ | { | ||||
let pos = cmpUnitAI.GetHeldPosition(); | let pos = cmpUnitAI.GetHeldPosition(); | ||||
if (pos) | if (pos) | ||||
cmpNewUnitAI.SetHeldPosition(pos.x, pos.z); | cmpNewUnitAI.SetHeldPosition(pos.x, pos.z); | ||||
if (cmpUnitAI.GetStanceName()) | if (cmpUnitAI.GetStanceName()) | ||||
cmpNewUnitAI.SwitchToStance(cmpUnitAI.GetStanceName()); | cmpNewUnitAI.SwitchToStance(cmpUnitAI.GetStanceName()); | ||||
if (cmpUnitAI.IsGarrisoned()) | if (cmpUnitAI.GetGarrisonHolder() != INVALID_ENTITY) | ||||
cmpNewUnitAI.SetGarrisoned(); | cmpNewUnitAI.SetGarrisoned(); | ||||
cmpNewUnitAI.AddOrders(cmpUnitAI.GetOrders()); | cmpNewUnitAI.AddOrders(cmpUnitAI.GetOrders()); | ||||
if (cmpUnitAI.IsGuardOf()) | if (cmpUnitAI.IsGuardOf()) | ||||
{ | { | ||||
let guarded = cmpUnitAI.IsGuardOf(); | let guarded = cmpUnitAI.IsGuardOf(); | ||||
let cmpGuard = Engine.QueryInterface(guarded, IID_Guard); | let cmpGuard = Engine.QueryInterface(guarded, IID_Guard); | ||||
if (cmpGuard) | if (cmpGuard) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 130 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 20 Lines • Show All 41 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
'ent' is already declared in the upper scope.