Last active
December 12, 2015 01:28
-
-
Save vrobel/4691374 to your computer and use it in GitHub Desktop.
ActionList based on Ash EntityStateMachine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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