BGC Tools
Public Member Functions | Protected Member Functions | Protected Attributes | Properties | Private Attributes
BGC.StateMachine.State Class Referenceabstract

This class is implemented by states that are use din game. It comes with access to state machine related functions once it has been added to the machine. Users must implement OnEnter and OnExit. Users can override Update if they have a function they want to call on a frame by frame basis. More...

Inheritance diagram for BGC.StateMachine.State:
Inheritance graph
[legend]
Collaboration diagram for BGC.StateMachine.State:
Collaboration graph
[legend]

Public Member Functions

 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

abstract void OnStateEnter ()
 Called when the state is entered More...
 
virtual void OnStateExit ()
 Called when the state is exited before the next state is entered More...
 

Protected Attributes

virtual string DefaultName => "State"
 

Properties

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...
 

Private Attributes

bool verbose = false
 

Detailed Description

This class is implemented by states that are use din game. It comes with access to state machine related functions once it has been added to the machine. Users must implement OnEnter and OnExit. Users can override Update if they have a function they want to call on a frame by frame basis.

Definition at line 13 of file State.cs.

Constructor & Destructor Documentation

◆ State() [1/2]

BGC.StateMachine.State.State ( )
inline

Create a state with the default name

Definition at line 28 of file State.cs.

29  {
30  Debug.Assert(!string.IsNullOrEmpty(DefaultName));
31  Name = DefaultName;
32  }
virtual string DefaultName
Definition: State.cs:15
string Name
Name of the state. This will either be user defined or the default state name depending on the constr...
Definition: State.cs:23

◆ State() [2/2]

BGC.StateMachine.State.State ( string  name)
inline

Create a state with a custom name rather than the default

Definition at line 37 of file State.cs.

38  {
39  Debug.Assert(!string.IsNullOrEmpty(name));
40  Name = name;
41  }
string Name
Name of the state. This will either be user defined or the default state name depending on the constr...
Definition: State.cs:23

Member Function Documentation

◆ OnEnter()

void BGC.StateMachine.State.OnEnter ( )
inline

Called when the state is entered

Definition at line 46 of file State.cs.

Referenced by BGC.StateMachine.StateMachine< TBoolEnum, TTriggerEnum >.ExecuteTransitions(), and BGC.StateMachine.StateMachine< TBoolEnum, TTriggerEnum >.Update().

47  {
48  if (verbose)
49  {
50  Debug.Log($"{Name} entered.");
51  }
52 
53  OnStateEnter();
54  }
abstract void OnStateEnter()
Called when the state is entered
Here is the caller graph for this function:

◆ OnExit()

void BGC.StateMachine.State.OnExit ( )
inline

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

Definition at line 59 of file State.cs.

60  {
61  if (verbose)
62  {
63  Debug.Log($"{Name} left.");
64  }
65 
66  OnStateExit();
67  }
virtual void OnStateExit()
Called when the state is exited before the next state is entered
Definition: State.cs:77

◆ OnStateEnter()

abstract void BGC.StateMachine.State.OnStateEnter ( )
protectedpure virtual

◆ OnStateExit()

virtual void BGC.StateMachine.State.OnStateExit ( )
inlineprotectedvirtual

◆ SetVerbose()

void BGC.StateMachine.State.SetVerbose ( bool  isVerbose)
inline

Set whether the state machine is verbose or not

Parameters
isVerbose

Definition at line 90 of file State.cs.

Referenced by BGC.StateMachine.StateMachine< TBoolEnum, TTriggerEnum >.AddState().

91  {
92  verbose = isVerbose;
93  }
Here is the caller graph for this function:

◆ Update()

virtual void BGC.StateMachine.State.Update ( )
inlinevirtual

This can be called every frame or whenever for complex states that have behavior on a frame by X basis.

Reimplemented in BGC.StateMachine.TriggeringUpdatingLambdaState< TTriggerEnum >, and BGC.StateMachine.UpdatingLambdaState< TBoolEnum, TTriggerEnum >.

Definition at line 83 of file State.cs.

83 { }

Field Documentation

◆ DefaultName

virtual string BGC.StateMachine.State.DefaultName => "State"
protected

Definition at line 15 of file State.cs.

◆ verbose

bool BGC.StateMachine.State.verbose = false
private

Definition at line 16 of file State.cs.

Property Documentation

◆ Name

string BGC.StateMachine.State.Name
getprivate set

Name of the state. This will either be user defined or the default state name depending on the constructor used

Definition at line 23 of file State.cs.


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