Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Promotion.js
Show All 40 Lines | Promotion.prototype.Promote = function(promotedTemplateName) | ||||
// Copy parameters from current entity to promoted one | // Copy parameters from current entity to promoted one | ||||
var cmpCurrentUnitPosition = Engine.QueryInterface(this.entity, IID_Position); | var cmpCurrentUnitPosition = Engine.QueryInterface(this.entity, IID_Position); | ||||
var cmpPromotedUnitPosition = Engine.QueryInterface(promotedUnitEntity, IID_Position); | var cmpPromotedUnitPosition = Engine.QueryInterface(promotedUnitEntity, IID_Position); | ||||
if (cmpCurrentUnitPosition.IsInWorld()) | if (cmpCurrentUnitPosition.IsInWorld()) | ||||
{ | { | ||||
var pos = cmpCurrentUnitPosition.GetPosition2D(); | var pos = cmpCurrentUnitPosition.GetPosition2D(); | ||||
cmpPromotedUnitPosition.JumpTo(pos.x, pos.y); | cmpPromotedUnitPosition.JumpTo(pos.x, pos.y); | ||||
} | } | ||||
var rot = cmpCurrentUnitPosition.GetRotation(); | let rot = cmpCurrentUnitPosition.GetRotation(); | ||||
// For turrets, the y rotation should be relative to the turret one. | |||||
let turretParent = cmpCurrentUnitPosition.GetTurretParent(); | |||||
if (turretParent != INVALID_ENTITY && Engine.QueryInterface(turretParent, IID_Position)) | |||||
rot.y -= Engine.QueryInterface(turretParent, IID_Position).GetRotation().y; | |||||
cmpPromotedUnitPosition.SetYRotation(rot.y); | cmpPromotedUnitPosition.SetYRotation(rot.y); | ||||
cmpPromotedUnitPosition.SetXZRotation(rot.x, rot.z); | cmpPromotedUnitPosition.SetXZRotation(rot.x, rot.z); | ||||
var heightOffset = cmpCurrentUnitPosition.GetHeightOffset(); | var heightOffset = cmpCurrentUnitPosition.GetHeightOffset(); | ||||
cmpPromotedUnitPosition.SetHeightOffset(heightOffset); | cmpPromotedUnitPosition.SetHeightOffset(heightOffset); | ||||
var cmpCurrentUnitOwnership = Engine.QueryInterface(this.entity, IID_Ownership); | var cmpCurrentUnitOwnership = Engine.QueryInterface(this.entity, IID_Ownership); | ||||
var cmpPromotedUnitOwnership = Engine.QueryInterface(promotedUnitEntity, IID_Ownership); | var cmpPromotedUnitOwnership = Engine.QueryInterface(promotedUnitEntity, IID_Ownership); | ||||
cmpPromotedUnitOwnership.SetOwner(cmpCurrentUnitOwnership.GetOwner()); | cmpPromotedUnitOwnership.SetOwner(cmpCurrentUnitOwnership.GetOwner()); | ||||
▲ Show 20 Lines • Show All 120 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator