Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/GarrisonHolder.js
Show First 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | GarrisonHolder.prototype.PerformGarrison = function(entity) | ||||
// 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(); | ||||
let cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI); | |||||
if (cmpUnitAI) | |||||
Stan: Not sure if that's in the scope of the patch, but there are quite a few calls to check whether… | |||||
FreagarachAuthorUnsubmitted Done Inline ActionsFreagarach: The position check is moved in D2367, the extraCount should be moved in D2056.
Is that what you… | |||||
StanUnsubmitted Done Inline ActionsYeah I actually thought this function was in another file ^^ Stan: Yeah I actually thought this function was in another file ^^ | |||||
cmpUnitAI.SetGarrisoned(true); | |||||
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); | ||||
Engine.PostMessage(this.entity, MT_GarrisonedUnitsChanged, { "added": [entity], "removed": [] }); | Engine.PostMessage(this.entity, MT_GarrisonedUnitsChanged, { "added": [entity], "removed": [] }); | ||||
return true; | return true; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | if (cmpEntUnitMotion) | ||||
cmpEntUnitMotion.SetFacePointAfterMove(true); | cmpEntUnitMotion.SetFacePointAfterMove(true); | ||||
if (cmpEntUnitAI) | if (cmpEntUnitAI) | ||||
cmpEntUnitAI.ResetTurretStance(); | cmpEntUnitAI.ResetTurretStance(); | ||||
vgp.entity = null; | vgp.entity = null; | ||||
break; | break; | ||||
} | } | ||||
if (cmpEntUnitAI) | if (cmpEntUnitAI) | ||||
{ | |||||
cmpEntUnitAI.Ungarrison(); | cmpEntUnitAI.Ungarrison(); | ||||
cmpEntUnitAI.SetGarrisoned(false); | |||||
Done Inline Actions
But moving SetGarrisoned out of Ungarrisoned allows to forget calling SetGarrisoned after calling unitAI.Ungarrison, no? (Disclaimer: I don't know what I'm talking about.) elexis: > so that it cannot be forgotten when introducing new code or moving existing code
But moving… | |||||
Done Inline ActionsUnitAI.Ungarrison() Does nothing but resetting orders (I plan to either remove that or make it useful, preferably the latter) if one would call ungarrison without calling the the garrisonHolder-code to perform the eject, the entity would still be garrisoned visually (or non-visibly) but won't have the garrison order anymore and, formerly, would be able to receive moving-orders. Freagarach: `UnitAI.Ungarrison()` Does nothing but resetting orders (I plan to either remove that or make… | |||||
} | |||||
let cmpEntProductionQueue = Engine.QueryInterface(entity, IID_ProductionQueue); | let cmpEntProductionQueue = Engine.QueryInterface(entity, IID_ProductionQueue); | ||||
if (cmpEntProductionQueue) | if (cmpEntProductionQueue) | ||||
cmpEntProductionQueue.UnpauseProduction(); | cmpEntProductionQueue.UnpauseProduction(); | ||||
let cmpEntAura = Engine.QueryInterface(entity, IID_Auras); | let cmpEntAura = Engine.QueryInterface(entity, IID_Auras); | ||||
if (cmpEntAura && cmpEntAura.HasGarrisonAura()) | if (cmpEntAura && cmpEntAura.HasGarrisonAura()) | ||||
cmpEntAura.RemoveGarrisonAura(this.entity); | cmpEntAura.RemoveGarrisonAura(this.entity); | ||||
▲ Show 20 Lines • Show All 390 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Not sure if that's in the scope of the patch, but there are quite a few calls to check whether one can garrison.
It seems weird to me that this.GetGarrisonedEntitiesCount() + extraCount >= this.GetCapacity() is not checked in the IsAllowedToGarrison function call.