Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/GarrisonHolder.js
Show First 20 Lines • Show All 254 Lines • ▼ Show 20 Lines | GarrisonHolder.prototype.PerformGarrison = function(entity) | ||||
{ | { | ||||
let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | ||||
this.timer = cmpTimer.SetTimeout(this.entity, IID_GarrisonHolder, "HealTimeout", 1000, {}); | this.timer = cmpTimer.SetTimeout(this.entity, IID_GarrisonHolder, "HealTimeout", 1000, {}); | ||||
} | } | ||||
// Actual garrisoning happens here | // Actual garrisoning happens here | ||||
this.entities.push(entity); | this.entities.push(entity); | ||||
this.UpdateGarrisonFlag(); | this.UpdateGarrisonFlag(); | ||||
let cmpProductionQueue = Engine.QueryInterface(entity, IID_ProductionQueue); | let cmpProductionQueue = Engine.QueryInterface(entity, IID_ProductionQueue); | ||||
if (cmpProductionQueue) | if (cmpProductionQueue) | ||||
cmpProductionQueue.PauseProduction(); | cmpProductionQueue.PauseProduction(); | ||||
Freagarach: This can be moved to `cmpGarrisonable` in a separate diff. | |||||
Done Inline ActionsThis kind of stuff looks like it should go in Garrisonable.Garrison. wraitii: This kind of stuff looks like it should go in Garrisonable.Garrison. | |||||
Done Inline ActionsFreagarach: D3223. | |||||
let cmpAura = Engine.QueryInterface(entity, IID_Auras); | let cmpAura = Engine.QueryInterface(entity, IID_Auras); | ||||
if (cmpAura && cmpAura.HasGarrisonAura()) | if (cmpAura && cmpAura.HasGarrisonAura()) | ||||
cmpAura.ApplyGarrisonAura(this.entity); | cmpAura.ApplyGarrisonAura(this.entity); | ||||
let cmpGarrisonable = Engine.QueryInterface(entity, IID_Garrisonable); | |||||
if (cmpGarrisonable) | |||||
cmpGarrisonable.Garrison(this.entity); | |||||
Engine.PostMessage(this.entity, MT_GarrisonedUnitsChanged, { "added": [entity], "removed": [] }); | Engine.PostMessage(this.entity, MT_GarrisonedUnitsChanged, { "added": [entity], "removed": [] }); | ||||
return true; | return true; | ||||
}; | }; | ||||
/** | /** | ||||
* Simply eject the unit from the garrisoning entity without moving it | * Simply eject the unit from the garrisoning entity without moving it | ||||
* @param {number} entity - Id of the entity to be ejected. | * @param {number} entity - Id of the entity to be ejected. | ||||
* @param {boolean} forced - Whether eject is forced (i.e. if building is destroyed). | * @param {boolean} forced - Whether eject is forced (i.e. if building is destroyed). | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | GarrisonHolder.prototype.Eject = function(entity, forced) | ||||
cmpEntPosition.JumpTo(pos.x, pos.z); | cmpEntPosition.JumpTo(pos.x, pos.z); | ||||
cmpEntPosition.SetHeightOffset(0); | cmpEntPosition.SetHeightOffset(0); | ||||
let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); | let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); | ||||
if (cmpPosition) | if (cmpPosition) | ||||
cmpEntPosition.SetYRotation(cmpPosition.GetPosition().horizAngleTo(pos)); | cmpEntPosition.SetYRotation(cmpPosition.GetPosition().horizAngleTo(pos)); | ||||
let cmpGarrisonable = Engine.QueryInterface(entity, IID_Garrisonable); | |||||
if (cmpGarrisonable) | |||||
cmpGarrisonable.UnGarrison(); | |||||
Engine.PostMessage(this.entity, MT_GarrisonedUnitsChanged, { "added": [], "removed": [entity] }); | Engine.PostMessage(this.entity, MT_GarrisonedUnitsChanged, { "added": [], "removed": [entity] }); | ||||
return true; | return true; | ||||
}; | }; | ||||
/** | /** | ||||
* Ejects units and orders them to move to the rally point. If an ejection | * Ejects units and orders them to move to the rally point. If an ejection | ||||
* with a given obstruction radius has failed, we won't try anymore to eject | * with a given obstruction radius has failed, we won't try anymore to eject | ||||
▲ Show 20 Lines • Show All 374 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
This can be moved to cmpGarrisonable in a separate diff.