Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Attack.js
Show First 20 Lines • Show All 481 Lines • ▼ Show 20 Lines | if (cmpVisual) | |||||||||||||||
cmpVisual.SetAnimationSyncRepeat(timings.repeat); | cmpVisual.SetAnimationSyncRepeat(timings.repeat); | |||||||||||||||
cmpVisual.SetAnimationSyncOffset(prepare); | cmpVisual.SetAnimationSyncOffset(prepare); | |||||||||||||||
} | } | |||||||||||||||
// If using a non-default prepare time, re-sync the animation when the timer runs. | // If using a non-default prepare time, re-sync the animation when the timer runs. | |||||||||||||||
this.resyncAnimation = prepare != timings.prepare; | this.resyncAnimation = prepare != timings.prepare; | |||||||||||||||
this.target = target; | this.target = target; | |||||||||||||||
this.callerIID = callerIID; | this.callerIID = callerIID; | |||||||||||||||
this.lastAttackedType = type; | ||||||||||||||||
this.timer = cmpTimer.SetInterval(this.entity, IID_Attack, "Attack", prepare, timings.repeat, type); | this.timer = cmpTimer.SetInterval(this.entity, IID_Attack, "Attack", prepare, timings.repeat, type); | |||||||||||||||
return true; | return true; | |||||||||||||||
}; | }; | |||||||||||||||
/** | /** | |||||||||||||||
* @param {string} reason - The reason why we stopped attacking. | * @param {string} reason - The reason why we stopped attacking. | |||||||||||||||
*/ | */ | |||||||||||||||
Attack.prototype.StopAttacking = function(reason) | Attack.prototype.StopAttacking = function(reason) | |||||||||||||||
{ | { | |||||||||||||||
if (!this.target) | if (!this.target) | |||||||||||||||
return; | return; | |||||||||||||||
let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | |||||||||||||||
cmpTimer.CancelTimer(this.timer); | cmpTimer.CancelTimer(this.timer); | |||||||||||||||
delete this.timer; | delete this.timer; | |||||||||||||||
let cmpResistance = Engine.QueryInterface(this.target, IID_Resistance); | let cmpResistance = Engine.QueryInterface(this.target, IID_Resistance); | |||||||||||||||
if (cmpResistance) | if (cmpResistance) | |||||||||||||||
cmpResistance.RemoveAttacker(this.entity); | cmpResistance.RemoveAttacker(this.entity); | |||||||||||||||
delete this.target; | delete this.target; | |||||||||||||||
delete this.lastAttackedType; | ||||||||||||||||
let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); | let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); | |||||||||||||||
if (cmpVisual) | if (cmpVisual) | |||||||||||||||
cmpVisual.SelectAnimation("idle", false, 1.0); | cmpVisual.SelectAnimation("idle", false, 1.0); | |||||||||||||||
// The callerIID component may start again, | // The callerIID component may start again, | |||||||||||||||
// replacing the callerIID, hence save that. | // replacing the callerIID, hence save that. | |||||||||||||||
let callerIID = this.callerIID; | let callerIID = this.callerIID; | |||||||||||||||
▲ Show 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | Attack.prototype.IsTargetInRange = function(target, type) | |||||||||||||||
return cmpObstructionManager.IsInTargetRange(this.entity, target, range.min, range.max, false); | return cmpObstructionManager.IsInTargetRange(this.entity, target, range.min, range.max, false); | |||||||||||||||
}; | }; | |||||||||||||||
Attack.prototype.OnValueModification = function(msg) | Attack.prototype.OnValueModification = function(msg) | |||||||||||||||
{ | { | |||||||||||||||
if (msg.component != "Attack") | if (msg.component != "Attack") | |||||||||||||||
return; | return; | |||||||||||||||
if (this.target) | ||||||||||||||||
this.StartAttacking(this.target, this.lastAttackedType, this.callerIID); | ||||||||||||||||
let cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI); | let cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI); | |||||||||||||||
if (!cmpUnitAI) | if (!cmpUnitAI) | |||||||||||||||
return; | return; | |||||||||||||||
FreagarachAuthorUnsubmitted Done Inline Actions
Freagarach: | ||||||||||||||||
if (this.GetAttackTypes().some(type => | if (this.GetAttackTypes().some(type => | |||||||||||||||
msg.valueNames.indexOf("Attack/" + type + "/MaxRange") != -1)) | msg.valueNames.indexOf("Attack/" + type + "/MaxRange") != -1)) | |||||||||||||||
cmpUnitAI.UpdateRangeQueries(); | cmpUnitAI.UpdateRangeQueries(); | |||||||||||||||
}; | }; | |||||||||||||||
Attack.prototype.GetRangeOverlays = function(type = "Ranged") | Attack.prototype.GetRangeOverlays = function(type = "Ranged") | |||||||||||||||
{ | { | |||||||||||||||
Show All 17 Lines |
Wildfire Games · Phabricator