BGC Tools
Public Member Functions | Protected Member Functions | Private Attributes
BGC.StateMachine.OrConjunction< TBoolEnum, TTriggerEnum > Class Template Reference

An or conjunction is a set of transitions conditions where they are tested together with the logical or operator. If one transition condition returns true, then this entire conjunction will also return true. More...

Inheritance diagram for BGC.StateMachine.OrConjunction< TBoolEnum, TTriggerEnum >:
Inheritance graph
[legend]
Collaboration diagram for BGC.StateMachine.OrConjunction< TBoolEnum, TTriggerEnum >:
Collaboration graph
[legend]

Public Member Functions

 OrConjunction (params TransitionCondition< TBoolEnum, TTriggerEnum >[] conditions)
 Construct an or conjuction which operates as a set of boolean results with an or between each. This function sets the conditions and does error checking for null values. More...
 
override void OnTransition ()
 On Transition, all conditions are notified of the transition. More...
 
override bool ShouldTransition ()
 Returns true as long as one state returns that a transition should happen More...
 
- Public Member Functions inherited from BGC.StateMachine.TransitionCondition< TBoolEnum, TTriggerEnum >
void SetStateMachineFunctions (ITransitionDataRetriever< TBoolEnum, TTriggerEnum > stateMachine)
 Sets the required functions for the transition that it has received from the state machine. More...
 

Protected Member Functions

override void StateMachineFunctionsSet ()
 Calls this function on every state to give them their required functionality. More...
 

Private Attributes

readonly TransitionCondition< TBoolEnum, TTriggerEnum > [] conditions
 Set of required conditions for a transition to be called More...
 

Additional Inherited Members

- Protected Attributes inherited from BGC.StateMachine.TransitionCondition< TBoolEnum, TTriggerEnum >
ITransitionDataRetriever< TBoolEnum, TTriggerEnum > stateMachine
 

Detailed Description

An or conjunction is a set of transitions conditions where they are tested together with the logical or operator. If one transition condition returns true, then this entire conjunction will also return true.

Type Constraints
TBoolEnum :Enum 
TTriggerEnum :Enum 

Definition at line 11 of file OrConjunction.cs.

Constructor & Destructor Documentation

◆ OrConjunction()

BGC.StateMachine.OrConjunction< TBoolEnum, TTriggerEnum >.OrConjunction ( params TransitionCondition< TBoolEnum, TTriggerEnum > []  conditions)
inline

Construct an or conjuction which operates as a set of boolean results with an or between each. This function sets the conditions and does error checking for null values.

Definition at line 25 of file OrConjunction.cs.

26  {
27  if (conditions == null)
28  {
29  throw new ArgumentNullException(nameof(conditions),
30  message: "OrConjunction conditions canot be null.");
31  }
32 
33  for (int i = 0; i < conditions.Length; ++i)
34  {
35  if (conditions[i] == null)
36  {
37  throw new ArgumentNullException(nameof(conditions),
38  message: $"OrConjunction conditions element {i} is null and should not be.");
39  }
40  }
41 
42  this.conditions = conditions;
43  }
readonly TransitionCondition< TBoolEnum, TTriggerEnum > [] conditions
Set of required conditions for a transition to be called

Member Function Documentation

◆ OnTransition()

override void BGC.StateMachine.OrConjunction< TBoolEnum, TTriggerEnum >.OnTransition ( )
inlinevirtual

On Transition, all conditions are notified of the transition.

Implements BGC.StateMachine.TransitionCondition< TBoolEnum, TTriggerEnum >.

Definition at line 48 of file OrConjunction.cs.

49  {
50  for (int i = 0; i < conditions.Length; ++i)
51  {
53  {
54  conditions[i].OnTransition();
55  break;
56  }
57  }
58  }
readonly TransitionCondition< TBoolEnum, TTriggerEnum > [] conditions
Set of required conditions for a transition to be called
override bool ShouldTransition()
Returns true as long as one state returns that a transition should happen

◆ ShouldTransition()

override bool BGC.StateMachine.OrConjunction< TBoolEnum, TTriggerEnum >.ShouldTransition ( )
inlinevirtual

Returns true as long as one state returns that a transition should happen

Implements BGC.StateMachine.TransitionCondition< TBoolEnum, TTriggerEnum >.

Definition at line 64 of file OrConjunction.cs.

65  {
66  bool shouldTransition = false;
67  for (int i = 0; i < conditions.Length; ++i)
68  {
70  {
71  shouldTransition = true;
72  break;
73  }
74  }
75 
76  return conditions.Length == 0 ? true : shouldTransition;
77  }
readonly TransitionCondition< TBoolEnum, TTriggerEnum > [] conditions
Set of required conditions for a transition to be called
override bool ShouldTransition()
Returns true as long as one state returns that a transition should happen

◆ StateMachineFunctionsSet()

override void BGC.StateMachine.OrConjunction< TBoolEnum, TTriggerEnum >.StateMachineFunctionsSet ( )
inlineprotectedvirtual

Calls this function on every state to give them their required functionality.

Implements BGC.StateMachine.TransitionCondition< TBoolEnum, TTriggerEnum >.

Definition at line 83 of file OrConjunction.cs.

84  {
85  for (int i = 0; i < conditions.Length; ++i)
86  {
87  conditions[i].SetStateMachineFunctions(stateMachine);
88  }
89  }
readonly TransitionCondition< TBoolEnum, TTriggerEnum > [] conditions
Set of required conditions for a transition to be called
ITransitionDataRetriever< TBoolEnum, TTriggerEnum > stateMachine

Field Documentation

◆ conditions

readonly TransitionCondition<TBoolEnum, TTriggerEnum> [] BGC.StateMachine.OrConjunction< TBoolEnum, TTriggerEnum >.conditions
private

Set of required conditions for a transition to be called

Definition at line 18 of file OrConjunction.cs.


The documentation for this class was generated from the following file: