public override NodeResult Execute() { AITargeter aiSource = source as AITargeter; if (FactionUnits.NoEnemies((source as AITargeter).stats)) { return(NodeResult.Failure); } targeter = FactionUnits.FindClosestEnemy(source as AITargeter); if (Vector3.Distance(targeter.transform.position, aiSource.transform.position) < range) { return(NodeResult.Success); } return(NodeResult.Failure); }
public override NodeResult Execute() { if (FactionUnits.NoEnemies((source as AITargeter).stats)) { return(NodeResult.Failure); } if (!(source as AITargeter).moving.IsIdle) { return(NodeResult.Failure); } targeter = FactionUnits.FindClosestEnemy(source as AITargeter); (source as AITargeter).moving.Attach(mode, GenerateDirPathToTarget(mode, (source as AITargeter), targeter)); return(NodeResult.Success); }