Well, your current version does not appear to be context-friendly, since you're handling all of your targeting via static functions in a static class. I'm going to break down Apoc's example to the best of my ability (right now I can't test it to "validate" this, so he might have to come in and correct me).
Before I go on, though, let me specify that when I say 'iteration', I'm talking about a distinct walk of the BT. ie, when the PrioritySelector finds a successful child, its iteration is over. When the PrioritySelector is called/walked again, it is a new iteration. I do not use iteration in context with calling the same function multiple times during the same walk (which you shouldn't do, unless the parameters are different).
Code:
ctx => TankManager.Instance.FirstUnit ?? StyxWoW.Me.CurrentTarget,
This is the first argument to the PrioritySelector. Notice that it's not a boolean. The context is set to an instance of the WoWUnit class, either the TankManager instance's FirstUnit, or, if null, the current target.
Code:
ret => ((WoWUnit)ret).HasAura("Lacerate", 3)
This is the use of his context (called ret here). ret is the inherited context of the parent PrioritySelector (although, as you can see from the necessary cast, the child does not appear to know the exact type of the parent context).
Anyway, the point is that the context needs an instantiated object / collection to pass to its children. However, you appear to hold the collection within your TargetManager static class as a static member.
If you wanted to use a context, I would do something like the following. NOTE that this is just an EXAMPLE of how you could write it. However, this code is pretty "scrappy" IMO. I wouldn't recommend using it like this.
Code:
new Decorator(ret => AltarboySettings.Instance.EnableTargeting,
new PrioritySelector(ctx => TargetManager.AquireTargets(),
// Returns an instance of TargetManager w/ the list of your enemies in 40 yds
new Decorator(ret => ((TargetManager)ret).FocusTarget != null
&& TargetManager.SetTarget((TargetManager)ret).FocusTarget),
// Succeeds if the instantiated TargetManager.FocusTarget is not null and TargetManager.SetTarget succeeded in setting
// ret.FocusTarget as the target. FocusTarget property might include its own logic that only returns a WoWUnit if
// a focus exists and it's a valid target for your purposes.
...
What I would recommend instead, in your case, is to have a method that returns the first valid unit from your PrioritySelector (instead of having it as a Selector / BehaviorTree) as a WoWUnit, and using THAT as your context instead. It's worth noting that you don't necessarily have to be targeting something in order to cast a spell at it. You might be able to save yourself some time by not forcing the toon to change targets until its primary target dies, or else has to change for some other reason.
BUT take all that with a grain of salt. I've yet to start studying Apoc's CCs, which I would actually recommend / will start using as an official point of reference. While I feel that my current cc is functioning successfully, I can in no way claim any real knowledge or even comfortable understanding of the HB API. I think it can use a lot more documentation (although, of course, I understand completely why a concurrent one does not exist, as documentation of an API takes a LOT of time to write and flesh out properly).
As an afterthought, perhaps we CC/plugin coders should take it upon ourselves to help update the wiki with the parts of the API that we know or at least of which we feel we have a thorough understanding. I don't know what the rules are for updating the wiki, but I think an organized, concentrated effort should be made to have an up-to-date reference to these kinds of questions. Forums are nice, but they can be hard to sort through.