public DoWhenNamedActivity(string customActivityName, IUseWhenPredicate useWhenPredicate, OrderNodeCollection nodes, bool isMovementStopRequired) : base(CreateActivityIdentifier(customActivityName), useWhenPredicate, isMovementStopRequired) { Contract.Requires(!string.IsNullOrEmpty(customActivityName), context => "!string.IsNullOrEmpty(customActivityName)"); Contract.Requires(nodes != null && nodes.GetNodes().Any(), context => "nodes != null && Nodes.GetNodes().Any()"); Nodes = nodes; }
public DoWhen(Dictionary <string, string> args) : base(args) { try { // NB: Core attributes are parsed by QuestBehaviorBase parent (e.g., QuestId, NonCompeteDistance, etc) // Behavior-specific attributes... // NB: We must parse the Command first, as this helps determine whether certain attributes are // mandator or optional. Command = GetAttributeAsNullable <CommandType>("Command", false, null, null) ?? CommandType.Update; // Primary attributes... ActivityKey_ItemId = GetAttributeAsNullable <int>("ItemId", false, ConstrainAs.ItemId, null) ?? 0; ActivityKey_SpellId = GetAttributeAsNullable <int>("SpellId", false, ConstrainAs.SpellId, null) ?? 0; ActivityKey_Name = GetAttributeAs <string>("ActivityName", false, ConstrainAs.StringNonEmpty, null) ?? ""; var useAtInterval = GetAttributeAsNullable <int>("UseAtInterval", false, ConstrainAs.Milliseconds, null) ?? 0; UseAtInterval = TimeSpan.FromMilliseconds(useAtInterval); // Go ahead and compile the "UseWhen" expression to look for problems... // Doing this in the constructor allows us to catch 'blind change'problems when ProfileDebuggingMode is turned on. // If there is a problem, an exception will be thrown (and handled here). var useWhenExpression = GetAttributeAs <string>("UseWhen", false, ConstrainAs.StringNonEmpty, null) ?? "false"; UseWhen = DelayCompiledExpression.Condition(useWhenExpression); // Tunables... AllowUseDuringCombat = GetAttributeAsNullable <bool>("AllowUseDuringCombat", false, null, null) ?? false; AllowUseInVehicle = GetAttributeAsNullable <bool>("AllowUseInVehicle", false, null, null) ?? false; AllowUseWhileFlying = GetAttributeAsNullable <bool>("AllowUseWhileFlying", false, null, null) ?? false; AllowUseWhileMounted = GetAttributeAsNullable <bool>("AllowUseWhileMounted", false, null, null) ?? false; AllowExecutionWhileNotAlive = GetAttributeAsNullable <bool>("AllowExecutionWhileNotAlive", false, null, null) ?? false; LogExecution = GetAttributeAsNullable <bool>("LogExecution", false, null, null) ?? true; StopMovingToConductActivity = GetAttributeAsNullable <bool>("StopMovingToConductActivity", false, null, null) ?? false; TreeHookName = GetAttributeAs <string>("TreeHookName", false, ConstrainAs.StringNonEmpty, null) ?? "Questbot_Main"; Nodes = OrderNodeCollection.FromXml(Element); CfbContextForHook = this; } catch (Exception except) { // Maintenance problems occur for a number of reasons. The primary two are... // * Changes were made to the behavior, and boundary conditions weren't properly tested. // * The Honorbuddy core was changed, and the behavior wasn't adjusted for the new changes. // In any case, we pinpoint the source of the problem area here, and hopefully it can be quickly // resolved. QBCLog.Exception(except); IsAttributeProblem = true; } }