Skip to content

Instantly share code, notes, and snippets.

@vrobel
Last active December 12, 2015 01:28
Show Gist options
  • Save vrobel/4691374 to your computer and use it in GitHub Desktop.
Save vrobel/4691374 to your computer and use it in GitHub Desktop.
ActionList based on Ash EntityStateMachine
package com.blackmoondev.ashes.fsm
{
import ash.fsm.EntityStateMachine;
public class ActionList implements IActionList
{
public function ActionList( fsm : EntityStateMachine, states : Vector.<String> ) {
this.fsm = fsm;
this.states = states || new Vector.<String>();
}
private var fsm : EntityStateMachine;
private var states : Vector.<String>;
public function next() : void {
fsm.changeState( states.shift() );
}
public function hasNext() : Boolean {
return states.length > 0;
}
public function append( statesToAppend : Vector.<String>, removeAfterState : String = null ) : void {
states.length = states.indexOf( removeAfterState );
states = states.concat( statesToAppend );
}
}
}
package com.blackmoondev.ashes.fsm
{
public interface IActionList
{
function next() : void;
function hasNext() : Boolean;
function append( statesToAppend : Vector.<String>, removeAfterState : String = null ) : void;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment