<s> """<STR_LIT>""" <EOL> import sys , sylphis , math <EOL> from string import * <EOL> from CMiscModel import * <EOL> from sylphis import CVector3 <EOL> from util import manage <EOL> CLOSE = <NUM_LIT:0> <EOL> OPEN = <NUM_LIT:1> <EOL> OPENING = <NUM_LIT:2> <EOL> CLOSING = <NUM_LIT:3> <EOL> class CSlideDoor ( CMiscModel ) : <EOL> __classname__ = '<STR_LIT>' <EOL> __desc__ = '<STR_LIT>' <EOL> __actortype__ = '<STR_LIT:b>' <EOL> __specs__ = [ <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : { <NUM_LIT:1> : '<STR_LIT>' , <NUM_LIT:0> : '<STR_LIT>' } , '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : { OPEN : '<STR_LIT>' , CLOSE : '<STR_LIT>' } , '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : { OPEN : '<STR_LIT>' , CLOSE : '<STR_LIT>' } , '<STR_LIT>' : '<STR_LIT>' } <EOL> ] <EOL> speed = <NUM_LIT> <EOL> wait = <NUM_LIT> <EOL> useportal = <NUM_LIT:1> <EOL> initstate = CLOSE <EOL> reststate = CLOSE <EOL> movesize = <NUM_LIT> <EOL> movedir = sylphis . CVector3 ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> state = CLOSE <EOL> def handleEvent ( self , * args ) : <EOL> if args [ <NUM_LIT:0> ] == <NUM_LIT:11> : <EOL> other = args [ <NUM_LIT:1> ] <EOL> if ( other . getContents ( ) & sylphis . CONTENTS_BODY ) : <EOL> self . Action_toggle ( other ) <EOL> def join ( self , ent ) : <EOL> self . rigidbody = <NUM_LIT:1> <EOL> self . rigidflags = <NUM_LIT:1> <EOL> CMiscModel . join ( self , ent ) <EOL> self . openPos = self . origin + self . movedir * self . movesize <EOL> self . closePos = self . origin <EOL> self . vel = self . movedir * self . speed <EOL> if self . useportal : <EOL> self . portalId = self . mScene . getAreaPortal ( self . origin ) <EOL> self . node . setPassClosedPortals ( True ) <EOL> self . state = self . initstate <EOL> if self . state == OPEN : <EOL> self . body . setPosition ( self . openPos ) <EOL> self . setPortalOpen ( True ) <EOL> elif self . state == CLOSE : <EOL> self . body . setPosition ( self . closePos ) <EOL> self . setPortalOpen ( False ) <EOL> else : <EOL> raise "<STR_LIT>" <EOL> def Action_open ( self , other ) : <EOL> self . killSignalThreads ( '<STR_LIT>' ) <EOL> self . state = OPENING <EOL> self . setPortalOpen ( True ) <EOL> self . body . setVelocity ( self . vel ) <EOL> time = self . calcMoveTime ( self . openPos ) <EOL> self . sleep ( time ) <EOL> self . body . setVelocity ( CVector3 . ZERO ) <EOL> self . body . setPosition ( self . openPos ) <EOL> self . Action_openFinish ( ) <EOL> def Action_close ( self , other ) : <EOL> self . killSignalThreads ( '<STR_LIT>' ) <EOL> self . state = CLOSING <EOL> self . body . setVelocity ( - self . vel ) <EOL> time = self . calcMoveTime ( self . closePos ) <EOL> self . sleep ( time ) <EOL> self . body . setVelocity ( CVector3 . ZERO ) <EOL> self . body . setPosition ( self . closePos ) <EOL> self . setPortalOpen ( False ) <EOL> self . Action_closeFinish ( ) <EOL> def Action_openFinish ( self , other ) : <EOL> if other != None : <EOL> return <EOL> if self . reststate == OPEN : <EOL> return <EOL> self . sleep ( self . wait ) <EOL> self . Action_close ( ) <EOL> def Action_closeFinish ( self , other ) : <EOL> if other != None : <EOL> return <EOL> if self . reststate == CLOSE : <EOL> return <EOL> self . sleep ( self . wait ) <EOL> self . Action_open ( ) <EOL> def Action_toggle ( self , other ) : <EOL> if self . state in ( OPENING , OPEN ) : self . Action_close ( other ) <EOL> elif self . state in ( CLOSING , CLOSE ) : self . Action_open ( other ) <EOL> def calcMoveTime ( self , targetPos ) : <EOL> """<STR_LIT>""" <EOL> return ( self . body . getPosition ( ) - targetPos ) . length ( ) / self . speed <EOL> def setPortalOpen ( self , t ) : <EOL> if self . useportal : <EOL> self . mScene . setAreaPortalOpen ( self . portalId , t ) </s>
