Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/TurretHolder.js
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | AllowedToOccupyTurret(entity, turretPoint) | ||||
let cmpIdentity = Engine.QueryInterface(entity, IID_Identity); | let cmpIdentity = Engine.QueryInterface(entity, IID_Identity); | ||||
return cmpIdentity && MatchesClassList(cmpIdentity.GetClassesList(), turretPoint.allowedClasses._string); | return cmpIdentity && MatchesClassList(cmpIdentity.GetClassesList(), turretPoint.allowedClasses._string); | ||||
} | } | ||||
/** | /** | ||||
* Occupy a turret point with the given entity. | * Occupy a turret point with the given entity. | ||||
* @param {number} entity - The entity to use. | * @param {number} entity - The entity to use. | ||||
* @param {Object} turretPoint - Optionally the specific turret point to occupy. | * @param {Object} requestedTurretPoint - Optionally the specific turret point to occupy. | ||||
* | * | ||||
* @return {boolean} - Whether the occupation was successful. | * @return {boolean} - Whether the occupation was successful. | ||||
*/ | */ | ||||
OccupyTurret(entity, requestedTurretPoint) | OccupyTurret(entity, requestedTurretPoint) | ||||
{ | { | ||||
let cmpPositionOccupant = Engine.QueryInterface(entity, IID_Position); | let cmpPositionOccupant = Engine.QueryInterface(entity, IID_Position); | ||||
if (!cmpPositionOccupant) | if (!cmpPositionOccupant) | ||||
return false; | return false; | ||||
Show All 34 Lines | OccupyTurret(entity, requestedTurretPoint) | ||||
let cmpUnitMotion = Engine.QueryInterface(entity, IID_UnitMotion); | let cmpUnitMotion = Engine.QueryInterface(entity, IID_UnitMotion); | ||||
if (cmpUnitMotion) | if (cmpUnitMotion) | ||||
cmpUnitMotion.SetFacePointAfterMove(false); | cmpUnitMotion.SetFacePointAfterMove(false); | ||||
let cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI); | let cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI); | ||||
if (cmpUnitAI) | if (cmpUnitAI) | ||||
cmpUnitAI.SetTurretStance(); | cmpUnitAI.SetTurretStance(); | ||||
// Remove the unit's obstruction to avoid interfering with pathing. | |||||
let cmpObstruction = Engine.QueryInterface(entity, IID_Obstruction); | |||||
if (cmpObstruction) | |||||
cmpObstruction.SetActive(false); | |||||
Engine.PostMessage(this.entity, MT_TurretsChanged, { | Engine.PostMessage(this.entity, MT_TurretsChanged, { | ||||
"added": [entity], | "added": [entity], | ||||
"removed": [] | "removed": [] | ||||
}); | }); | ||||
return true; | return true; | ||||
} | } | ||||
Show All 26 Lines | if (cmpUnitMotionEntity) | ||||
cmpUnitMotionEntity.SetFacePointAfterMove(true); | cmpUnitMotionEntity.SetFacePointAfterMove(true); | ||||
let cmpUnitAIEntity = Engine.QueryInterface(entity, IID_UnitAI); | let cmpUnitAIEntity = Engine.QueryInterface(entity, IID_UnitAI); | ||||
if (cmpUnitAIEntity) | if (cmpUnitAIEntity) | ||||
cmpUnitAIEntity.ResetTurretStance(); | cmpUnitAIEntity.ResetTurretStance(); | ||||
turretPoint.entity = null; | turretPoint.entity = null; | ||||
// Reset the obstruction flags to template defaults. | |||||
let cmpObstruction = Engine.QueryInterface(entity, IID_Obstruction); | |||||
if (cmpObstruction) | |||||
cmpObstruction.SetActive(true); | |||||
Engine.PostMessage(this.entity, MT_TurretsChanged, { | Engine.PostMessage(this.entity, MT_TurretsChanged, { | ||||
"added": [], | "added": [], | ||||
"removed": [entity] | "removed": [entity] | ||||
}); | }); | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator