fromJSON method

StateMachine fromJSON(
  1. Map<String, dynamic> json
)

Restores this instance from the given JSON object.

Implementation

StateMachine fromJSON(Map<String,dynamic> json ) {
	owner = json['owner'];
	final statesJSON = json['states'];

	for (int i = 0, l = statesJSON.length; i < l; i ++ ) {
		final stateJSON = statesJSON[ i ];
		final type = stateJSON['type'];

		final ctor = _typesMap[type];

		if ( ctor != null ) {
			final id = stateJSON.id;
			final state = ctor().fromJSON( stateJSON.state );

			add( id, state );
		}
      else {
			yukaConsole.warning( 'YUKA.StateMachine: Unsupported state type: $type' );
			continue;
		}
	}

	//
	currentState = json['currentState'];// != null ) ? ( this[json.currentState] ?? null ) : null;
	previousState = json['previousState'];// != null ) ? ( this[json.previousState] ?? null ) : null;
	globalState = json['globalState'];// != null ) ? ( this[json.globalState] ?? null ) : null;

	return this;
}