<s> """<STR_LIT>""" <EOL> from __future__ import division , print_function , unicode_literals <EOL> __docformat__ = '<STR_LIT>' <EOL> from cocos . grid import Grid3D , TiledGrid3D <EOL> from cocos . director import director <EOL> from cocos . euclid import * <EOL> from . base_actions import * <EOL> __all__ = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , ] <EOL> class GridException ( Exception ) : <EOL> pass <EOL> class GridBaseAction ( IntervalAction ) : <EOL> """<STR_LIT>""" <EOL> def init ( self , grid = ( <NUM_LIT:4> , <NUM_LIT:4> ) , duration = <NUM_LIT:5> ) : <EOL> """<STR_LIT>""" <EOL> self . duration = duration <EOL> if not isinstance ( grid , Point2 ) : <EOL> grid = Point2 ( * grid ) <EOL> self . grid = grid <EOL> def start ( self ) : <EOL> new_grid = self . get_grid ( ) <EOL> if self . target . grid and self . target . grid . reuse_grid > <NUM_LIT:0> : <EOL> if self . target . grid . active and self . grid == self . target . grid . grid and type ( new_grid ) == type ( self . target . grid ) : <EOL> self . target . grid . vertex_points = self . target . grid . vertex_list . vertices [ : ] <EOL> self . target . grid . reuse_grid -= <NUM_LIT:1> <EOL> self . target . grid . reuse_grid = max ( <NUM_LIT:0> , self . target . grid . reuse_grid ) <EOL> else : <EOL> raise GridException ( "<STR_LIT>" <EOL> % ( str ( self . grid ) , str ( self . target . grid . grid ) , <EOL> type ( new_grid ) , type ( self . target . grid ) ) ) <EOL> else : <EOL> if self . target . grid and self . target . grid . active : <EOL> self . target . grid . active = False <EOL> self . target . grid = new_grid <EOL> self . target . grid . init ( self . grid ) <EOL> self . target . grid . active = True <EOL> x , y = director . get_window_size ( ) <EOL> self . size_x = x // self . grid . x <EOL> self . size_y = y // self . grid . y <EOL> def __reversed__ ( self ) : <EOL> return _ReverseTime ( self ) <EOL> class Grid3DAction ( GridBaseAction ) : <EOL> """<STR_LIT>""" <EOL> def get_grid ( self ) : <EOL> return Grid3D ( ) <EOL> def get_vertex ( self , x , y ) : <EOL> """<STR_LIT>""" <EOL> return self . target . grid . get_vertex ( x , y ) <EOL> def get_original_vertex ( self , x , y ) : <EOL> """<STR_LIT>""" <EOL> return self . target . grid . get_original_vertex ( x , y ) <EOL> def set_vertex ( self , x , y , v ) : <EOL> """<STR_LIT>""" <EOL> return self . target . grid . set_vertex ( x , y , v ) <EOL> class TiledGrid3DAction ( GridBaseAction ) : <EOL> """<STR_LIT>""" <EOL> def get_grid ( self ) : <EOL> return TiledGrid3D ( ) <EOL> def set_tile ( self , x , y , coords ) : <EOL> """<STR_LIT>""" <EOL> return self . target . grid . set_tile ( x , y , coords ) <EOL> def get_original_tile ( self , x , y ) : <EOL> """<STR_LIT>""" <EOL> return self . target . grid . get_original_tile ( x , y ) <EOL> def get_tile ( self , x , y ) : <EOL> """<STR_LIT>""" <EOL> return self . target . grid . get_tile ( x , y ) <EOL> class AccelDeccelAmplitude ( IntervalAction ) : <EOL> """<STR_LIT>""" <EOL> def init ( self , other , rate = <NUM_LIT:1.0> ) : <EOL> """<STR_LIT>""" <EOL> if not hasattr ( other , '<STR_LIT>' ) : <EOL> raise GridException ( "<STR_LIT>" ) <EOL> self . other = other <EOL> self . rate = rate <EOL> self . duration = other . duration <EOL> def start ( self ) : <EOL> self . other . target = self . target <EOL> self . other . start ( ) <EOL> def update ( self , t ) : <EOL> f = t * <NUM_LIT:2> <EOL> if f > <NUM_LIT:1> : <EOL> f -= <NUM_LIT:1> <EOL> f = <NUM_LIT:1> - f <EOL> self . other . amplitude_rate = f ** self . rate <EOL> self . other . update ( t ) <EOL> def __reversed__ ( self ) : <EOL> return AccelDeccelAmplitude ( Reverse ( self . other ) ) <EOL> class AccelAmplitude ( IntervalAction ) : <EOL> """<STR_LIT>""" <EOL> def init ( self , other , rate = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> if not hasattr ( other , '<STR_LIT>' ) : <EOL> raise GridException ( "<STR_LIT>" ) <EOL> self . other = other <EOL> self . duration = other . duration <EOL> self . rate = rate <EOL> def start ( self ) : <EOL> self . other . target = self . target <EOL> self . other . start ( ) <EOL> def update ( self , t ) : <EOL> self . other . amplitude_rate = ( t ** self . rate ) <EOL> self . other . update ( t ) <EOL> def __reversed__ ( self ) : <EOL> return DeccelAmplitude ( Reverse ( self . other ) , rate = self . rate ) <EOL> class DeccelAmplitude ( AccelAmplitude ) : <EOL> """<STR_LIT>""" <EOL> def update ( self , t ) : <EOL> self . other . amplitude_rate = ( ( <NUM_LIT:1> - t ) ** self . rate ) <EOL> self . other . update ( t ) <EOL> def __reversed__ ( self ) : <EOL> return AccelAmplitude ( Reverse ( self . other ) , rate = self . rate ) <EOL> class StopGrid ( InstantAction ) : <EOL> """<STR_LIT>""" <EOL> def start ( self ) : <EOL> if self . target . grid and self . target . grid . active : <EOL> self . target . grid . active = False <EOL> class ReuseGrid ( InstantAction ) : <EOL> """<STR_LIT>""" <EOL> def init ( self , reuse_times = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> self . reuse_times = reuse_times <EOL> def start ( self ) : <EOL> if self . target . grid and self . target . grid . active : <EOL> self . target . grid . reuse_grid += self . reuse_times <EOL> else : <EOL> raise GridException ( "<STR_LIT>" ) </s>
