Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/helpers/Commands.js
Show First 20 Lines • Show All 1,459 Lines • ▼ Show 20 Lines | else | ||||
RemoveFromFormation([ent]); | RemoveFromFormation([ent]); | ||||
nonformedUnitAIs.push(cmpUnitAI); | nonformedUnitAIs.push(cmpUnitAI); | ||||
} | } | ||||
} | } | ||||
if (formedEnts.length == 0) | if (formedEnts.length == 0) | ||||
{ | { | ||||
// No units support the foundation - return all the others | // No units support the formation - return all the others | ||||
return nonformedUnitAIs; | return nonformedUnitAIs; | ||||
} | } | ||||
// Find what formations the formationable selected entities are currently in | // Find what formations the formationable selected entities are currently in | ||||
var formation = ExtractFormations(formedEnts); | var formation = ExtractFormations(formedEnts); | ||||
var formationUnitAIs = []; | var formationUnitAIs = []; | ||||
if (formation.ids.length == 1) | if (formation.ids.length == 1) | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | for (let cluster of clusters) | ||||
if (lastFormationTemplate && CanMoveEntsIntoFormation(cluster, lastFormationTemplate)) | if (lastFormationTemplate && CanMoveEntsIntoFormation(cluster, lastFormationTemplate)) | ||||
formationTemplate = lastFormationTemplate; | formationTemplate = lastFormationTemplate; | ||||
else | else | ||||
formationTemplate = "special/formations/null"; | formationTemplate = "special/formations/null"; | ||||
} | } | ||||
RemoveFromFormation(cluster); | RemoveFromFormation(cluster); | ||||
if (formationTemplate == "special/formations/null") | |||||
{ | |||||
for (let ent of cluster) | |||||
nonformedUnitAIs.push(Engine.QueryInterface(ent, IID_UnitAI)); | |||||
continue; | |||||
} | |||||
// Create the new controller | // Create the new controller | ||||
var formationEnt = Engine.AddEntity(formationTemplate); | var formationEnt = Engine.AddEntity(formationTemplate); | ||||
var cmpFormation = Engine.QueryInterface(formationEnt, IID_Formation); | var cmpFormation = Engine.QueryInterface(formationEnt, IID_Formation); | ||||
formationUnitAIs.push(Engine.QueryInterface(formationEnt, IID_UnitAI)); | formationUnitAIs.push(Engine.QueryInterface(formationEnt, IID_UnitAI)); | ||||
cmpFormation.SetFormationSeparation(formationSeparation); | cmpFormation.SetFormationSeparation(formationSeparation); | ||||
cmpFormation.SetMembers(cluster); | cmpFormation.SetMembers(cluster); | ||||
for (let ent of formationEnts) | for (let ent of formationEnts) | ||||
▲ Show 20 Lines • Show All 180 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator