Differential D3280 Diff 16223 ps/trunk/binaries/data/mods/public/simulation/components/TurretHolder.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/TurretHolder.js
Show First 20 Lines • Show All 232 Lines • ▼ Show 20 Lines | SetInitEntity(turretName, entity) | ||||
if (this.initTurrets.has(turretName)) | if (this.initTurrets.has(turretName)) | ||||
warn("The turret position " + turretName + " of entity " + | warn("The turret position " + turretName + " of entity " + | ||||
this.entity + " is already set! Overwriting."); | this.entity + " is already set! Overwriting."); | ||||
this.initTurrets.set(turretName, entity); | this.initTurrets.set(turretName, entity); | ||||
} | } | ||||
/** | /** | ||||
* We process EntityRenamed here because we need to be sure that we receive | |||||
* it after it is processed by GarrisonHolder.js. | |||||
* ToDo: Make this not needed by fully separating TurretHolder from GarrisonHolder. | |||||
* That means an entity with TurretHolder should not need a GarrisonHolder | |||||
* for e.g. the garrisoning logic. | |||||
* | |||||
* @param {number} from - The entity to substitute. | * @param {number} from - The entity to substitute. | ||||
* @param {number} to - The entity to subtitute with. | * @param {number} to - The entity to subtitute with. | ||||
*/ | */ | ||||
SwapEntities(from, to) | SwapEntities(from, to) | ||||
{ | { | ||||
let turretPoint = this.GetOccupiedTurret(from); | let turretPoint = this.GetOccupiedTurret(from); | ||||
if (turretPoint) | if (turretPoint) | ||||
{ | |||||
this.LeaveTurret(from, turretPoint); | this.LeaveTurret(from, turretPoint); | ||||
let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder); | |||||
if (cmpGarrisonHolder && cmpGarrisonHolder.IsGarrisoned(to)) | |||||
this.OccupyTurret(to, turretPoint); | this.OccupyTurret(to, turretPoint); | ||||
} | } | ||||
OnGarrisonedUnitsChanged(msg) | |||||
{ | |||||
// Ignore renaming for that is handled seperately | |||||
// (i.e. called directly from GarrisonHolder.js). | |||||
if (msg.renamed) | |||||
return; | |||||
for (let entity of msg.removed) | |||||
this.LeaveTurret(entity); | |||||
for (let entity of msg.added) | |||||
this.OccupyTurret(entity); | |||||
} | } | ||||
/** | /** | ||||
* Initialise the turreted units. | * Initialise the turreted units. | ||||
* Really ugly, but because GarrisonHolder is processed earlier, and also turrets | * Really ugly, but because GarrisonHolder is processed earlier, and also turrets | ||||
* entities on init, we can find an entity that already is present. | * entities on init, we can find an entity that already is present. | ||||
* In that case we reject and occupy. | * In that case we reject and occupy. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator