public MyBehaviorConstructor(Dictionary<string, string> args)
{
// Report anything the profile writer provided that we aren't interested in --
// This can be problems with case, spelling, or outright confusion as to what
// attributes should be provided to this behavior.
CheckForUnrecognizedAttributes(args, s_recognizedAttributeNames);
// Check all the parameters before returning --
// We don't want to "nickel and dime" the profile writer with error messages. This
// pattern reports all failed entry criteria before returning.
_isAttributesOkay = true;
_isAttributesOkay = _isAttributesOkay && GetAttributeAsString(args, "Macro", true, "", out _macro);
_isAttributesOkay = _isAttributesOkay && GetAttributeAsInteger(args, "NumOfTimes", false, "1", 1, 100, out _numOfTimes);
_isAttributesOkay = _isAttributesOkay && GetAttributeAsInteger(args, "WaitTime", false, "1500", 0, int.MaxValue, out _waitTime);
}
public override void OnStart()
{
// If the profile writer didn't provide our full entry criteria for attributes --
// Stop the profile here with a message.
if (!_isAttributesOkay)
{
Logging.Write(Color.Red, "Stopping Honorbuddy. Please repair the profile!");
TreeRoot.Stop();
}
else
{
// Real behavior work goes here --
// ...
}
}
private bool _isAttributesOkay;
private bool _isBehaviorDone;
private string _macro;
private int _numOfTimes;
private int _waitTime;
private static Dictionary<String, Object> s_recognizedAttributeNames = new Dictionary<String, Object>()
{
{ "Macro", null },
{ "NumOfTimes", null },
{ "WaitTime", null },
};