fromJSON method
Restores this instance from the given JSON object.
Implementation
SteeringManager fromJSON(Map<String,dynamic> json ) {
clear();
final behaviorsJSON = json['behaviors'];
for ( int i = 0, l = behaviorsJSON.length; i < l; i ++ ) {
final behaviorJSON = behaviorsJSON[ i ];
final type = behaviorJSON.type;
dynamic behavior;
switch ( type ) {
case 'SteeringBehavior':
behavior = SteeringBehavior().fromJSON( behaviorJSON );
break;
case 'AlignmentBehavior':
behavior = AlignmentBehavior().fromJSON( behaviorJSON );
break;
case 'ArriveBehavior':
behavior = ArriveBehavior().fromJSON( behaviorJSON );
break;
case 'CohesionBehavior':
behavior = CohesionBehavior().fromJSON( behaviorJSON );
break;
case 'EvadeBehavior':
behavior = EvadeBehavior().fromJSON( behaviorJSON );
break;
case 'FleeBehavior':
behavior = FleeBehavior().fromJSON( behaviorJSON );
break;
case 'FollowPathBehavior':
behavior = FollowPathBehavior().fromJSON( behaviorJSON );
break;
case 'InterposeBehavior':
behavior = InterposeBehavior().fromJSON( behaviorJSON );
break;
case 'ObstacleAvoidanceBehavior':
behavior = ObstacleAvoidanceBehavior().fromJSON( behaviorJSON );
break;
case 'OffsetPursuitBehavior':
behavior = OffsetPursuitBehavior().fromJSON( behaviorJSON );
break;
case 'PursuitBehavior':
behavior = PursuitBehavior().fromJSON( behaviorJSON );
break;
case 'SeekBehavior':
behavior = SeekBehavior().fromJSON( behaviorJSON );
break;
case 'SeparationBehavior':
behavior = SeparationBehavior().fromJSON( behaviorJSON );
break;
case 'WanderBehavior':
behavior = WanderBehavior().fromJSON( behaviorJSON );
break;
default:
// handle custom type
final ctor = _typesMap[type];
if ( ctor != null ) {
behavior = ctor().fromJSON( behaviorJSON );
}
else {
yukaConsole.warning( 'YUKA.SteeringManager: Unsupported steering behavior type: $type' );
continue;
}
}
add( behavior );
}
return this;
}