-
Notifications
You must be signed in to change notification settings - Fork 8
Building Guide : Rules
Blecki edited this page Oct 1, 2014
·
1 revision
Rules control how commands interact with objects. Commands that are governed by rules have a cosponsoring rules interface to control them. Rule interfaces follow a standard pattern. Each rule has two methods.
-
CheckRule Check(Actor Actor)- Determine if the Actor can perform the action. The rules must returnCheckRule.Allow()if the action should be allowed, orCheckRule.Disallow(Reason)otherwise. Reason is not optional, and will be displayed to the player. -
HandleRuleFollowUp Handle(Actor Actor)- Perform any special behavior when the action happens. Return HandleRuleFollowUp.Stop to suppress the default behavior of the command, otherwise HandleRuleFollowUp.Continue to allow the command to perform the default behavior.
Not every rule interface will follow this pattern exactly. For example, LockableRules accepts a second parameter to Check and Handle - the key. Open and Close are combined into a single rule interface, so the methods follow the naming pattern of CheckOpen, CheckClose, etc.