2015-05-06 12:17:08 -05:00
from direct . distributed . DistributedObjectGlobal import DistributedObjectGlobal
from otp . speedchat import SpeedChatGlobals
from direct . directnotify . DirectNotifyGlobal import directNotify
# Portable Hole settings
Hood2Details = {
2015-06-10 09:16:05 -05:00
# hood : [speedchatIndex, destination]
2514 : [ 109 , 2514 ] # TTC, Hello?
2015-05-06 12:17:08 -05:00
}
Interior2Messages = {
2015-05-06 14:48:32 -05:00
2514 : [ " Banker Bob: I have a very important message for you. Do not forget it. " , " Banker Bob: Li0uLiAuLSAuLS0gLS4uLiAtLS0gLSAuLi4gLyAuLS4uIC0tLSAuLi4gLg== " ]
2015-05-06 12:17:08 -05:00
}
class ARGManager ( DistributedObjectGlobal ) :
"""
This is a client - view of the manager that handles everything to do
with the portable hole ARG event .
"""
notify = directNotify . newCategory ( ' ARGManager ' )
def __init__ ( self , cr ) :
DistributedObjectGlobal . __init__ ( self , cr )
self . setupPortableHoleEvent ( )
def disable ( self ) :
self . cleanupPortableHoleEvent ( )
DistributedObjectGlobal . disable ( self )
def delete ( self ) :
self . cleanupPortableHoleEvent ( )
DistributedObjectGlobal . delete ( self )
def setupPortableHoleEvent ( self ) :
def phraseSaid ( phraseId ) :
2015-05-25 01:38:20 -05:00
if not hasattr ( base . cr . playGame , ' place ' ) or not base . cr . playGame . getPlace ( ) :
2015-05-16 04:40:45 -05:00
return
2015-06-10 09:16:05 -05:00
speedchatIndex , destination = Hood2Details . get ( base . cr . playGame . getPlace ( ) . getZoneId ( ) , [ None , None ] )
if not speedchatIndex or not destination :
2015-05-06 12:17:08 -05:00
return
if speedchatIndex != phraseId :
return
msgBefore , msgAfter = Interior2Messages . get ( destination , [ None , None ] )
if not msgBefore :
self . notify . warning ( " Interior %d has no message definitions! " % destination )
return
taskMgr . doMethodLater ( 2 , base . localAvatar . setSystemMessage , self . uniqueName ( " arg-before-msg " ) , extraArgs = [ 0 , msgBefore ] )
taskMgr . doMethodLater ( 7 , base . localAvatar . setSystemMessage , self . uniqueName ( " arg-after-msg " ) , extraArgs = [ 0 , msgAfter ] )
self . accept ( SpeedChatGlobals . SCStaticTextMsgEvent , phraseSaid )
def cleanupPortableHoleEvent ( self ) :
self . ignore ( SpeedChatGlobals . SCStaticTextMsgEvent )