fromJSON method

  1. @override
Trigger fromJSON(
  1. Map<String, dynamic> json
)
override

Restores this instance from the given JSON object.

Implementation

@override
Trigger fromJSON(Map<String,dynamic> json ) {
	super.fromJSON( json );

	final Map<String,dynamic> regionJSON = json['region'];
	String type = regionJSON['type'];

	switch ( type ) {
		case 'TriggerRegion':
			region = TriggerRegion().fromJSON( regionJSON );
			break;
		case 'RectangularTriggerRegion':
			region = RectangularTriggerRegion().fromJSON( regionJSON );
			break;
		case 'SphericalTriggerRegion':
			region = SphericalTriggerRegion().fromJSON( regionJSON );
			break;
		default:
			// handle custom type
			final ctor = _typesMap[type];
			if ( ctor != null ) {
				region = ctor().fromJSON( regionJSON );
			}
        else {
				yukaConsole.warning( 'YUKA.Trigger: Unsupported trigger region type:${regionJSON[type]}',  );
			}
	}

	return this;
}