Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/UnitAI.js
Show First 20 Lines • Show All 4,989 Lines • ▼ Show 20 Lines | |||||
if (!ents.length) | if (!ents.length) | ||||
return false; | return false; | ||||
let cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); | let cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); | ||||
if (!cmpAttack) | if (!cmpAttack) | ||||
return false; | return false; | ||||
let attackfilter = function(e) { | let attackfilter = function(e) { | ||||
if (!cmpAttack.CanAttack(e)) | if (!cmpAttack.CanAttack(e)) | ||||
return false; | return false; | ||||
bb: I don't like this being an identity class. I think we rather should have an AmbushHolder… | |||||
let cmpAmbush = Engine.QueryInterface(e, IID_Ambush); | |||||
Lint: prefer-const 'cmpAmbush' is never reassigned. Use 'const' instead. Lint: prefer-const: 'cmpAmbush' is never reassigned. Use 'const' instead. | |||||
Done Inline Actionsplease merge conditions into one if Silier: please merge conditions into one if | |||||
if (cmpAmbush && cmpAmbush.IsEntityHidden(e)) | |||||
Done Inline Actions(e) -> () Silier: (e) -> () | |||||
return false; | |||||
let cmpOwnership = Engine.QueryInterface(e, IID_Ownership); | let cmpOwnership = Engine.QueryInterface(e, IID_Ownership); | ||||
if (cmpOwnership && cmpOwnership.GetOwner() > 0) | if (cmpOwnership && cmpOwnership.GetOwner() > 0) | ||||
return true; | return true; | ||||
let cmpUnitAI = Engine.QueryInterface(e, IID_UnitAI); | let cmpUnitAI = Engine.QueryInterface(e, IID_UnitAI); | ||||
return cmpUnitAI && (!cmpUnitAI.IsAnimal() || cmpUnitAI.IsDangerousAnimal()); | return cmpUnitAI && (!cmpUnitAI.IsAnimal() || cmpUnitAI.IsDangerousAnimal()); | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
I don't like this being an identity class. I think we rather should have an AmbushHolder component which a unit can have if it can be used like this.