Skip to content

Latest commit

 

History

History
81 lines (67 loc) · 3.52 KB

README.md

File metadata and controls

81 lines (67 loc) · 3.52 KB

Documentation

Classes

All of the class are located in res://addons/imjp94.yafsm/src but you can just preload res://addons/imjp94.yafsm/YAFSM.gd to import all class available:

const YAFSM = preload("res://addons/imjp94.yafsm/YAFSM.gd")
const StackPlayer = YAFSM.StackPlayer
const StateMachinePlayer = YAFSM.StateMachinePlayer
const StateMachine = YAFSM.StateMachine
const State = YAFSM.State

Node

  • StackPlayer StackPlayer icon

    Manage stack of item, use push/pop function to set current item on top of stack

    • current # Current item on top of stack
    • stack
    • signals:
      • pushed(to) # When item pushed to stack
      • popped(from) # When item popped from stack
  • StateMachinePlayer(extends StackPlayer) StateMachinePlayer icon

    Manage state based on StateMachine and parameters inputted

    • state_machine # StateMachine being played
    • active # Activeness of player
    • autostart # Automatically enter Entry state on ready if true
    • process_mode # ProcessMode of player
    • signals:
      • transited(from, to) # Transition of state
      • entered(to) # Entry of state machine(including nested), empty string equals to root
      • exited(from) # Exit of state machine(including nested, empty string equals to root
      • updated(state, delta) # Time to update(based on process_mode), up to user to handle any logic, for example, update movement of KinematicBody

Control

Reference

  • StateDirectory

    Convert state path to directory object for traversal, mainly used for nested state

Resource

Relationship between all Resources can be best represented as below:

var state_machine = state_machine_player.state_machine
var state = state_machine.states[state_name] # keyed by state name
var transition = state_machine.transitions[from][to] # keyed by state name transition from/to
var condition = transition.conditions[condition_name] # keyed by condition name

For normal usage, you really don't have to access any Resource during runtime as they only store static data that describe the state machine, accessing StackPlayer/StateMachinePlayer alone should be sufficient.

  • State

    Resource that represent a state

    • name
  • StateMachine(extends State) StateMachine icon

    StateMachine is also a State, but mainly used as container of States and Transitionss

    • states
    • transitions
  • Transition

    Describing connection from one state to another, all conditions must be fulfilled to transit to next state

    • from
    • to
    • conditions
  • Condition

    Empty condition with just a name, treated as trigger

    • name
  • ValueCondition(extends Condition)

    Condition with value, fulfilled by comparing values based on comparation

    • comparation
    • value
  • BooleanCondition(extends ValueCondition)
  • IntegerCondition(extends ValueCondition)
  • FloatCondition(extends ValueCondition)
  • StringCondition(extends ValueCondition)