Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Attack.js
Show First 20 Lines • Show All 477 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. | |||||||||||||||
*/ | */ | |||||||||||||||
▲ Show 20 Lines • Show All 245 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) | ||||||||||||||||
{ | ||||||||||||||||
let [target, iid] = [this.target, this.callerIID]; | ||||||||||||||||
this.StopAttacking(); | ||||||||||||||||
this.StartAttacking(target, this.lastAttackedType, iid); | ||||||||||||||||
} | ||||||||||||||||
FreagarachAuthorUnsubmitted Done Inline Actions
Freagarach: | ||||||||||||||||
let cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI); | let cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI); | |||||||||||||||
if (!cmpUnitAI) | if (!cmpUnitAI) | |||||||||||||||
return; | return; | |||||||||||||||
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(); | |||||||||||||||
}; | }; | |||||||||||||||
Show All 20 Lines |
Wildfire Games · Phabricator