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

Simple State with optional lambda arguments for OnStateEnter and OnStateExit. The lambdas return strings which, if not null, are fired off as Triggers More...

Inheritance diagram for BGC.StateMachine.TriggeringLambdaState< TTriggerEnum >:
Inheritance graph
[legend]
Collaboration diagram for BGC.StateMachine.TriggeringLambdaState< TTriggerEnum >:
Collaboration graph
[legend]

Public Member Functions

 TriggeringLambdaState (string name, Func< TTriggerEnum?> onStateEnter=null, Func< TTriggerEnum?> onStateExit=null)
 
- Public Member Functions inherited from BGC.StateMachine.TriggeringState< TTriggerEnum >
 TriggeringState ()
 Create a coordinating state with the default name More...
 
 TriggeringState (string name)
 Create a coordinate state with a custom name rather than the default More...
 
void SetStateMachineFunctions (IStateTrigger< TTriggerEnum > triggers)
 Receive state machine related functions that give states required behaviour More...
 
- Public Member Functions inherited from BGC.StateMachine.State
 State ()
 Create a state with the default name More...
 
 State (string name)
 Create a state with a custom name rather than the default More...
 
void OnEnter ()
 Called when the state is entered More...
 
void OnExit ()
 Called when the state is exited, before the next state is entered More...
 
virtual void Update ()
 This can be called every frame or whenever for complex states that have behavior on a frame by X basis. More...
 
void SetVerbose (bool isVerbose)
 Set whether the state machine is verbose or not More...
 

Protected Member Functions

override void OnStateEnter ()
 Called when the state is entered More...
 
override void OnStateExit ()
 Called when the state is exited before the next state is entered More...
 
- Protected Member Functions inherited from BGC.StateMachine.TriggeringState< TTriggerEnum >
void ActivateTrigger (TTriggerEnum key)
 Activate a trigger in the state machine this state is a part of More...
 

Private Attributes

readonly Func< TTriggerEnum?> onStateEnter
 
readonly Func< TTriggerEnum?> onStateExit
 

Additional Inherited Members

- Protected Attributes inherited from BGC.StateMachine.State
virtual string DefaultName => "State"
 
- Properties inherited from BGC.StateMachine.State
string Name [get, private set]
 Name of the state. This will either be user defined or the default state name depending on the constructor used More...
 

Detailed Description

Simple State with optional lambda arguments for OnStateEnter and OnStateExit. The lambdas return strings which, if not null, are fired off as Triggers

Type Constraints
TTriggerEnum :struct 
TTriggerEnum :Enum 

Definition at line 9 of file TriggeringLambdaState.cs.

Constructor & Destructor Documentation

◆ TriggeringLambdaState()

BGC.StateMachine.TriggeringLambdaState< TTriggerEnum >.TriggeringLambdaState ( string  name,
Func< TTriggerEnum?>  onStateEnter = null,
Func< TTriggerEnum?>  onStateExit = null 
)
inline

Definition at line 15 of file TriggeringLambdaState.cs.

19  : base(name)
20  {
22  this.onStateExit = onStateExit;
23  }
readonly Func< TTriggerEnum?> onStateEnter
readonly Func< TTriggerEnum?> onStateExit

Member Function Documentation

◆ OnStateEnter()

override void BGC.StateMachine.TriggeringLambdaState< TTriggerEnum >.OnStateEnter ( )
inlineprotectedvirtual

Called when the state is entered

Implements BGC.StateMachine.State.

Definition at line 25 of file TriggeringLambdaState.cs.

26  {
27  TTriggerEnum? trigger = onStateEnter?.Invoke();
28 
29  if (trigger.HasValue)
30  {
31  ActivateTrigger(trigger.Value);
32  }
33  }
readonly Func< TTriggerEnum?> onStateEnter
void ActivateTrigger(TTriggerEnum key)
Activate a trigger in the state machine this state is a part of

◆ OnStateExit()

override void BGC.StateMachine.TriggeringLambdaState< TTriggerEnum >.OnStateExit ( )
inlineprotectedvirtual

Called when the state is exited before the next state is entered

Reimplemented from BGC.StateMachine.State.

Definition at line 35 of file TriggeringLambdaState.cs.

36  {
37  TTriggerEnum? trigger = onStateExit?.Invoke();
38 
39  if (trigger.HasValue)
40  {
41  ActivateTrigger(trigger.Value);
42  }
43  }
readonly Func< TTriggerEnum?> onStateExit
void ActivateTrigger(TTriggerEnum key)
Activate a trigger in the state machine this state is a part of

Field Documentation

◆ onStateEnter

readonly Func<TTriggerEnum?> BGC.StateMachine.TriggeringLambdaState< TTriggerEnum >.onStateEnter
private

Definition at line 12 of file TriggeringLambdaState.cs.

◆ onStateExit

readonly Func<TTriggerEnum?> BGC.StateMachine.TriggeringLambdaState< TTriggerEnum >.onStateExit
private

Definition at line 13 of file TriggeringLambdaState.cs.


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